bmc: config: add skip action
If you specify the action for one of the three fields as "skip" it'll
create a handler object for that action that always returns success and
has no effect. This action therefore "skips" the step, moving the state
machine forward as though it was a successful real action.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ib4c1091745eb96b8381a332bbeb0562625d3bfbe
diff --git a/bmc/test/firmware_json_unittest.cpp b/bmc/test/firmware_json_unittest.cpp
index d56a20a..8f3ea30 100644
--- a/bmc/test/firmware_json_unittest.cpp
+++ b/bmc/test/firmware_json_unittest.cpp
@@ -1,5 +1,6 @@
#include "buildjson.hpp"
#include "general_systemd.hpp"
+#include "skip_action.hpp"
#include <nlohmann/json.hpp>
@@ -581,5 +582,39 @@
EXPECT_THAT(updater->getMode(), "replace-fake");
}
+TEST(FirmwareJsonTest, VerifySkipFields)
+{
+ // In this configuration, nothing happens because all actions are set to
+ // skip.
+ auto j2 = R"(
+ [{
+ "blob" : "/flash/image",
+ "handler" : {
+ "type" : "file",
+ "path" : "/run/initramfs/bmc-image"
+ },
+ "actions" : {
+ "preparation" : {
+ "type" : "skip"
+ },
+ "verification" : {
+ "type" : "skip"
+ },
+ "update" : {
+ "type" : "skip"
+ }
+ }
+ }]
+ )"_json;
+
+ auto h = buildHandlerFromJson(j2);
+ EXPECT_EQ(h[0].blobId, "/flash/image");
+ EXPECT_FALSE(h[0].handler == nullptr);
+ EXPECT_FALSE(h[0].actions == nullptr);
+ EXPECT_FALSE(h[0].actions->preparation == nullptr);
+ EXPECT_FALSE(h[0].actions->verification == nullptr);
+ EXPECT_FALSE(h[0].actions->update == nullptr);
+}
+
} // namespace
} // namespace ipmi_flash