tools: Add ignoreUpdate parameter
Adds ignoreUpdate flag to skip checking the update status and always
return success instead. This is needed for platforms that use the reboot
json and encounters an update failure due to IPMI going down during
shutdown.
Tested: Tried out an update with and without --ignore-update to verify
that the flag ignores the update status and returns success.
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: Ie20774f997229cd5ff8ae9082dc8a747079f9a2c
diff --git a/tools/test/tools_updater_unittest.cpp b/tools/test/tools_updater_unittest.cpp
index 0c9e6b5..706a4c3 100644
--- a/tools/test/tools_updater_unittest.cpp
+++ b/tools/test/tools_updater_unittest.cpp
@@ -87,7 +87,7 @@
.WillOnce(Return(verificationResponse));
EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
- EXPECT_TRUE(updater.verifyFile(ipmi_flash::verifyBlobId));
+ EXPECT_TRUE(updater.verifyFile(ipmi_flash::verifyBlobId, false));
}
class UpdaterTest : public ::testing::Test
@@ -95,6 +95,7 @@
protected:
ipmiblob::BlobInterfaceMock blobMock;
std::uint16_t session = 0xbeef;
+ bool defaultIgnore = false;
};
TEST_F(UpdaterTest, UpdateMainReturnsSuccessIfAllSuccess)
@@ -106,12 +107,30 @@
EXPECT_CALL(handler, checkAvailable(_)).WillOnce(Return(true));
EXPECT_CALL(handler, sendFile(_, image)).WillOnce(Return());
EXPECT_CALL(handler, sendFile(_, signature)).WillOnce(Return());
- EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId))
+ EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
.WillOnce(Return(true));
- EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId))
+ EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, defaultIgnore))
.WillOnce(Return(true));
- updaterMain(&handler, image, signature, "static");
+ updaterMain(&handler, image, signature, "static", defaultIgnore);
+}
+
+TEST_F(UpdaterTest, UpdateMainReturnsSuccessWithIgnoreUpdate)
+{
+ const std::string image = "image.bin";
+ const std::string signature = "signature.bin";
+ UpdateHandlerMock handler;
+ bool updateIgnore = true;
+
+ EXPECT_CALL(handler, checkAvailable(_)).WillOnce(Return(true));
+ EXPECT_CALL(handler, sendFile(_, image)).WillOnce(Return());
+ EXPECT_CALL(handler, sendFile(_, signature)).WillOnce(Return());
+ EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
+ .WillOnce(Return(true));
+ EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, updateIgnore))
+ .WillOnce(Return(true));
+
+ updaterMain(&handler, image, signature, "static", updateIgnore);
}
TEST_F(UpdaterTest, UpdateMainCleansUpOnFailure)
@@ -123,12 +142,13 @@
EXPECT_CALL(handler, checkAvailable(_)).WillOnce(Return(true));
EXPECT_CALL(handler, sendFile(_, image)).WillOnce(Return());
EXPECT_CALL(handler, sendFile(_, signature)).WillOnce(Return());
- EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId))
+ EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
.WillOnce(Return(false));
EXPECT_CALL(handler, cleanArtifacts()).WillOnce(Return());
- EXPECT_THROW(updaterMain(&handler, image, signature, "static"),
- ToolException);
+ EXPECT_THROW(
+ updaterMain(&handler, image, signature, "static", defaultIgnore),
+ ToolException);
}
} // namespace host_tool