sysd_monitor: Handle default for errors to monitor

If default is input, replace it with the three default errors to monitor
for

Tested:
- Relied on unit test

Change-Id: Ife92e74242d72b322f46f7f08d5a47068b31977d
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/test/systemd_parser.cpp b/test/systemd_parser.cpp
index 7ca94b9..cb3a609 100644
--- a/test/systemd_parser.cpp
+++ b/test/systemd_parser.cpp
@@ -63,6 +63,9 @@
     EXPECT_EQ(tgt.errorToLog,
               "xyz.openbmc_project.State.Chassis.Error.PowerOnTargetFailure");
     EXPECT_EQ(tgt.errorsToMonitor.size(), 2);
+    // Check a target with "default" for errorsToMonitor, should have 3 defaults
+    tgt = targetData["obmc-host-start@0.target"];
+    EXPECT_EQ(tgt.errorsToMonitor.size(), 3);
 
     std::remove("/tmp/good_file1.json");
     std::remove("/tmp/good_file2.json");
@@ -107,3 +110,28 @@
                  nlohmann::detail::parse_error);
     std::remove("/tmp/invalid_json_file.json");
 }
+
+TEST(TargetJsonParser, NotJustDefault)
+{
+    auto notJustDefault = R"(
+        {
+            "targets" : {
+                "obmc-chassis-poweron@0.target" : {
+                    "errorsToMonitor": ["timeout", "default"],
+                    "errorToLog": "xyz.openbmc_project.State.Chassis.Error.PowerOnTargetFailure"}
+                }
+        }
+    )"_json;
+
+    std::FILE* tmpf = fopen("/tmp/not_just_default_file.json", "w");
+    std::fputs(notJustDefault.dump().c_str(), tmpf);
+    std::fclose(tmpf);
+
+    std::vector<std::string> filePaths;
+    filePaths.push_back("/tmp/not_just_default_file.json");
+
+    // Verify exception thrown on invalid errorsToMonitor
+    EXPECT_THROW(TargetErrorData targetData = parseFiles(filePaths),
+                 std::invalid_argument);
+    std::remove("/tmp/not_just_default_file.json");
+}