diff options
| author | Brandon Kim <brandonkim@google.com> | 2019-09-19 13:31:37 -0700 |
|---|---|---|
| committer | Brandon Kim <brandonkim@google.com> | 2019-09-19 19:39:05 -0700 |
| commit | 6749ba1c93c9b4f65c9ef7791987fc2f98bc15d1 (patch) | |
| tree | 78c5c89b89da73cfcad2f308643f90097b1f300b /tools/test | |
| parent | cec91dd139a026753eedd7af7db546b78462a451 (diff) | |
| download | phosphor-ipmi-flash-6749ba1c93c9b4f65c9ef7791987fc2f98bc15d1.tar.gz phosphor-ipmi-flash-6749ba1c93c9b4f65c9ef7791987fc2f98bc15d1.zip | |
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
Diffstat (limited to 'tools/test')
| -rw-r--r-- | tools/test/tools_updater_unittest.cpp | 34 | ||||
| -rw-r--r-- | tools/test/updater_mock.hpp | 2 |
2 files changed, 28 insertions, 8 deletions
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 @@ TEST_F(UpdateHandlerTest, VerifyFileHandleReturnsTrueOnSuccess) .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 @@ class UpdaterTest : public ::testing::Test protected: ipmiblob::BlobInterfaceMock blobMock; std::uint16_t session = 0xbeef; + bool defaultIgnore = false; }; TEST_F(UpdaterTest, UpdateMainReturnsSuccessIfAllSuccess) @@ -106,12 +107,30 @@ TEST_F(UpdaterTest, UpdateMainReturnsSuccessIfAllSuccess) 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 @@ TEST_F(UpdaterTest, UpdateMainCleansUpOnFailure) 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 diff --git a/tools/test/updater_mock.hpp b/tools/test/updater_mock.hpp index d67991b..9469c62 100644 --- a/tools/test/updater_mock.hpp +++ b/tools/test/updater_mock.hpp @@ -14,7 +14,7 @@ class UpdateHandlerMock : public UpdateHandlerInterface public: MOCK_METHOD1(checkAvailable, bool(const std::string&)); MOCK_METHOD2(sendFile, void(const std::string&, const std::string&)); - MOCK_METHOD1(verifyFile, bool(const std::string&)); + MOCK_METHOD2(verifyFile, bool(const std::string&, bool)); MOCK_METHOD0(cleanArtifacts, void()); }; |

