diff options
| author | Patrick Venture <venture@google.com> | 2019-08-05 12:23:59 -0700 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2019-08-05 13:22:18 -0700 |
| commit | 984d94d6cd4aa3e671156d00cfd7fa6b29229532 (patch) | |
| tree | beec85fb39cd0f855f958b89a2d5f527b32cb30d | |
| parent | ee614ec1d1b10bceb0b4a68ca2413377c518e29d (diff) | |
| download | phosphor-ipmi-flash-984d94d6cd4aa3e671156d00cfd7fa6b29229532.tar.gz phosphor-ipmi-flash-984d94d6cd4aa3e671156d00cfd7fa6b29229532.zip | |
bmc: add mode json option for verification systemd
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ibe5764c4e2ad7dd938177c813c8c6706886258a2
| -rw-r--r-- | bmc/buildjson.cpp | 12 | ||||
| -rw-r--r-- | bmc/test/firmware_json_unittest.cpp | 8 |
2 files changed, 16 insertions, 4 deletions
diff --git a/bmc/buildjson.cpp b/bmc/buildjson.cpp index 60575db..0be61be 100644 --- a/bmc/buildjson.cpp +++ b/bmc/buildjson.cpp @@ -91,9 +91,17 @@ std::vector<HandlerConfig> buildHandlerFromJson(const nlohmann::json& data) { const auto& path = verify.at("path"); const auto& unit = verify.at("unit"); - const std::string mode = "replace"; + + /* the mode parameter is optional. */ + std::string systemdMode = "replace"; + const auto& mode = verify.find("mode"); + if (mode != verify.end()) + { + systemdMode = verify.at("mode").get<std::string>(); + } + pack->verification = SystemdVerification::CreateVerification( - sdbusplus::bus::new_default(), path, unit, mode); + sdbusplus::bus::new_default(), path, unit, systemdMode); } else { diff --git a/bmc/test/firmware_json_unittest.cpp b/bmc/test/firmware_json_unittest.cpp index 8b4f130..70676bf 100644 --- a/bmc/test/firmware_json_unittest.cpp +++ b/bmc/test/firmware_json_unittest.cpp @@ -433,7 +433,7 @@ TEST(FirmwareJsonTest, VerifyValidSingleNonReboot) EXPECT_THAT(updater->getMode(), "replace"); } -TEST(FirmwareJsonTest, VerifyValidUpdateWithMode) +TEST(FirmwareJsonTest, VerifyValidWithModes) { auto j2 = R"( [{ @@ -450,7 +450,8 @@ TEST(FirmwareJsonTest, VerifyValidUpdateWithMode) "verification" : { "type" : "fileSystemdVerify", "unit" : "phosphor-ipmi-flash-bmc-verify.target", - "path" : "/tmp/bmc.verify" + "path" : "/tmp/bmc.verify", + "mode" : "replace-nope" }, "update" : { "type" : "systemd", @@ -467,6 +468,9 @@ TEST(FirmwareJsonTest, VerifyValidUpdateWithMode) EXPECT_FALSE(h[0].actions == nullptr); EXPECT_FALSE(h[0].actions->preparation == nullptr); EXPECT_FALSE(h[0].actions->verification == nullptr); + auto verifier = reinterpret_cast<SystemdVerification*>( + h[0].actions->verification.get()); + EXPECT_THAT(verifier->getMode(), "replace-nope"); EXPECT_FALSE(h[0].actions->update == nullptr); auto updater = reinterpret_cast<SystemdUpdateMechanism*>(h[0].actions->update.get()); |

