diff options
author | Patrick Venture <venture@google.com> | 2019-06-03 11:11:24 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2019-06-03 11:24:59 -0700 |
commit | da66fd84209f93d9f9c11ea45d45819b92a4a98f (patch) | |
tree | d076a0c3958f3466ddf67501cd78529c4584b24f | |
parent | a2d8239473ea9c441e157481c83195c5dcffe5bc (diff) | |
download | phosphor-ipmi-flash-da66fd84209f93d9f9c11ea45d45819b92a4a98f.tar.gz phosphor-ipmi-flash-da66fd84209f93d9f9c11ea45d45819b92a4a98f.zip |
merge Verification and Update statuses
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ibb9c1c9f9cb7e9cda18f4e8dddb31d57a12f0d90
-rw-r--r-- | firmware_handler.cpp | 57 | ||||
-rw-r--r-- | firmware_handler.hpp | 8 | ||||
-rw-r--r-- | status.hpp | 12 | ||||
-rw-r--r-- | test/bmc_update_mock.hpp | 2 | ||||
-rw-r--r-- | test/firmware_state_updatecompleted_unittest.cpp | 10 | ||||
-rw-r--r-- | test/firmware_state_updatepending_unittest.cpp | 2 | ||||
-rw-r--r-- | test/firmware_state_updatestarted_unittest.cpp | 18 | ||||
-rw-r--r-- | test/firmware_state_verificationcompleted_unittest.cpp | 38 | ||||
-rw-r--r-- | test/firmware_state_verificationpending_unittest.cpp | 2 | ||||
-rw-r--r-- | test/firmware_state_verificationstarted_unittest.cpp | 16 | ||||
-rw-r--r-- | test/firmware_unittest.hpp | 6 | ||||
-rw-r--r-- | test/tools_updater_unittest.cpp | 2 | ||||
-rw-r--r-- | test/verification_mock.hpp | 2 | ||||
-rw-r--r-- | tools/updater.cpp | 16 | ||||
-rw-r--r-- | update.hpp | 2 | ||||
-rw-r--r-- | update_systemd.cpp | 4 | ||||
-rw-r--r-- | update_systemd.hpp | 2 | ||||
-rw-r--r-- | verify.hpp | 2 | ||||
-rw-r--r-- | verify_systemd.cpp | 10 | ||||
-rw-r--r-- | verify_systemd.hpp | 2 |
20 files changed, 89 insertions, 124 deletions
diff --git a/firmware_handler.cpp b/firmware_handler.cpp index 9cb78fb..26893e3 100644 --- a/firmware_handler.cpp +++ b/firmware_handler.cpp @@ -175,37 +175,24 @@ bool FirmwareBlobHandler::stat(const std::string& path, return true; } -VerifyCheckResponses FirmwareBlobHandler::getVerifyStatus() +ActionStatus FirmwareBlobHandler::getActionStatus() { - VerifyCheckResponses value = VerifyCheckResponses::other; + ActionStatus value = ActionStatus::unknown; switch (state) { case UpdateState::verificationPending: - value = VerifyCheckResponses::other; + value = ActionStatus::unknown; break; case UpdateState::verificationStarted: value = verification->status(); - lastVerificationResponse = value; + lastVerificationStatus = value; break; case UpdateState::verificationCompleted: - value = lastVerificationResponse; + value = lastVerificationStatus; break; - default: - break; - } - - return value; -} - -UpdateStatus FirmwareBlobHandler::getUpdateStatus() -{ - UpdateStatus value = UpdateStatus::unknown; - - switch (state) - { case UpdateState::updatePending: - value = UpdateStatus::unknown; + value = ActionStatus::unknown; break; case UpdateState::updateStarted: value = update->status(); @@ -241,43 +228,31 @@ bool FirmwareBlobHandler::stat(uint16_t session, struct blobs::BlobMeta* meta) meta->metadata.clear(); - if (item->second->activePath == verifyBlobId) + if (item->second->activePath == verifyBlobId || + item->second->activePath == updateBlobId) { - VerifyCheckResponses value = getVerifyStatus(); + ActionStatus value = getActionStatus(); meta->metadata.push_back(static_cast<std::uint8_t>(value)); /* Change the firmware handler's state and the blob's stat value * depending. */ - if (value == VerifyCheckResponses::success || - value == VerifyCheckResponses::failed) + if (value == ActionStatus::success || value == ActionStatus::failed) { - state = UpdateState::verificationCompleted; - item->second->flags &= ~blobs::StateFlags::committing; - - if (value == VerifyCheckResponses::success) + if (item->second->activePath == verifyBlobId) { - item->second->flags |= blobs::StateFlags::committed; + state = UpdateState::verificationCompleted; } else { - item->second->flags |= blobs::StateFlags::commit_error; + /* item->second->activePath == updateBlobId */ + state = UpdateState::updateCompleted; } - } - } - else if (item->second->activePath == updateBlobId) - { - UpdateStatus value = getUpdateStatus(); - meta->metadata.push_back(static_cast<std::uint8_t>(value)); - - if (value == UpdateStatus::success || value == UpdateStatus::failed) - { - state = UpdateState::updateCompleted; item->second->flags &= ~blobs::StateFlags::committing; - if (value == UpdateStatus::success) + if (value == ActionStatus::success) { item->second->flags |= blobs::StateFlags::committed; } @@ -669,7 +644,7 @@ bool FirmwareBlobHandler::close(uint16_t session) */ return false; case UpdateState::verificationCompleted: - if (lastVerificationResponse == VerifyCheckResponses::success) + if (lastVerificationStatus == ActionStatus::success) { state = UpdateState::updatePending; addBlobId(updateBlobId); diff --git a/firmware_handler.hpp b/firmware_handler.hpp index e08cb66..649b059 100644 --- a/firmware_handler.hpp +++ b/firmware_handler.hpp @@ -195,8 +195,8 @@ class FirmwareBlobHandler : public blobs::GenericBlobInterface blobIDs.end()); } - VerifyCheckResponses getVerifyStatus(); - UpdateStatus getUpdateStatus(); + ActionStatus getVerifyStatus(); + ActionStatus getActionStatus(); /** List of handlers by type. */ std::vector<HandlerPack> handlers; @@ -235,9 +235,9 @@ class FirmwareBlobHandler : public blobs::GenericBlobInterface /** Temporary variable to track whether a blob is open. */ bool fileOpen = false; - VerifyCheckResponses lastVerificationResponse = VerifyCheckResponses::other; + ActionStatus lastVerificationStatus = ActionStatus::unknown; - UpdateStatus lastUpdateStatus = UpdateStatus::unknown; + ActionStatus lastUpdateStatus = ActionStatus::unknown; }; } // namespace ipmi_flash @@ -5,16 +5,8 @@ namespace ipmi_flash { -enum class VerifyCheckResponses : std::uint8_t -{ - running = 0, - success = 1, - failed = 2, - other = 3, -}; - -/** The status of the update mechanism. */ -enum class UpdateStatus : std::uint8_t +/** The status of the update mechanism or the verification mechanism */ +enum class ActionStatus : std::uint8_t { running = 0, success = 1, diff --git a/test/bmc_update_mock.hpp b/test/bmc_update_mock.hpp index 3db9221..296b513 100644 --- a/test/bmc_update_mock.hpp +++ b/test/bmc_update_mock.hpp @@ -16,7 +16,7 @@ class UpdateMock : public UpdateInterface public: MOCK_METHOD0(triggerUpdate, bool()); MOCK_METHOD0(abortUpdate, void()); - MOCK_METHOD0(status, UpdateStatus()); + MOCK_METHOD0(status, ActionStatus()); }; std::unique_ptr<UpdateInterface> CreateUpdateMock() diff --git a/test/firmware_state_updatecompleted_unittest.cpp b/test/firmware_state_updatecompleted_unittest.cpp index 95e0a32..7c26688 100644 --- a/test/firmware_state_updatecompleted_unittest.cpp +++ b/test/firmware_state_updatecompleted_unittest.cpp @@ -46,7 +46,7 @@ TEST_F(FirmwareHandlerUpdateCompletedTest, AttemptToOpenFilesReturnsFailureAfterSuccess) { /* In state updateCompleted a file is open, which means no others can be. */ - getToUpdateCompleted(UpdateStatus::success); + getToUpdateCompleted(ActionStatus::success); auto blobsToOpen = handler->getBlobIds(); for (const auto& blob : blobsToOpen) @@ -61,14 +61,14 @@ TEST_F(FirmwareHandlerUpdateCompletedTest, TEST_F(FirmwareHandlerUpdateCompletedTest, CallingStatSessionAfterCompletedSuccessReturnsStateWithoutRechecking) { - getToUpdateCompleted(UpdateStatus::success); + getToUpdateCompleted(ActionStatus::success); EXPECT_CALL(*updateMockPtr, status()).Times(0); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::committed; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(UpdateStatus::success)); + static_cast<std::uint8_t>(ActionStatus::success)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); @@ -78,14 +78,14 @@ TEST_F(FirmwareHandlerUpdateCompletedTest, TEST_F(FirmwareHandlerUpdateCompletedTest, CallingStatSessionAfterCompletedFailureReturnsStateWithoutRechecking) { - getToUpdateCompleted(UpdateStatus::failed); + getToUpdateCompleted(ActionStatus::failed); EXPECT_CALL(*updateMockPtr, status()).Times(0); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::commit_error; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(UpdateStatus::failed)); + static_cast<std::uint8_t>(ActionStatus::failed)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); diff --git a/test/firmware_state_updatepending_unittest.cpp b/test/firmware_state_updatepending_unittest.cpp index 87df67d..00bdc2a 100644 --- a/test/firmware_state_updatepending_unittest.cpp +++ b/test/firmware_state_updatepending_unittest.cpp @@ -195,7 +195,7 @@ TEST_F(FirmwareHandlerUpdatePendingTest, expectedMeta.size = 0; expectedMeta.blobState = flags; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(UpdateStatus::unknown)); + static_cast<std::uint8_t>(ActionStatus::unknown)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); diff --git a/test/firmware_state_updatestarted_unittest.cpp b/test/firmware_state_updatestarted_unittest.cpp index e2348e4..6b55b4e 100644 --- a/test/firmware_state_updatestarted_unittest.cpp +++ b/test/firmware_state_updatestarted_unittest.cpp @@ -158,17 +158,17 @@ TEST_F(FirmwareHandlerUpdateStartedTest, * stat(session) - this will trigger a check, and the state may change. */ TEST_F(FirmwareHandlerUpdateStartedTest, - CallStatChecksUpdateStatusReturnsRunningDoesNotChangeState) + CallStatChecksActionStatusReturnsRunningDoesNotChangeState) { getToUpdateStarted(); EXPECT_CALL(*updateMockPtr, status()) - .WillOnce(Return(UpdateStatus::running)); + .WillOnce(Return(ActionStatus::running)); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::committing; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(UpdateStatus::running)); + static_cast<std::uint8_t>(ActionStatus::running)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); @@ -176,17 +176,17 @@ TEST_F(FirmwareHandlerUpdateStartedTest, } TEST_F(FirmwareHandlerUpdateStartedTest, - CallStatChecksUpdateStatusReturnsFailedChangesStateToCompleted) + CallStatChecksActionStatusReturnsFailedChangesStateToCompleted) { getToUpdateStarted(); EXPECT_CALL(*updateMockPtr, status()) - .WillOnce(Return(UpdateStatus::failed)); + .WillOnce(Return(ActionStatus::failed)); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::commit_error; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(UpdateStatus::failed)); + static_cast<std::uint8_t>(ActionStatus::failed)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); @@ -194,17 +194,17 @@ TEST_F(FirmwareHandlerUpdateStartedTest, } TEST_F(FirmwareHandlerUpdateStartedTest, - CallStatChecksUpdateStatusReturnsSuccessChangesStateToCompleted) + CallStatChecksActionStatusReturnsSuccessChangesStateToCompleted) { getToUpdateStarted(); EXPECT_CALL(*updateMockPtr, status()) - .WillOnce(Return(UpdateStatus::success)); + .WillOnce(Return(ActionStatus::success)); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::committed; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(UpdateStatus::success)); + static_cast<std::uint8_t>(ActionStatus::success)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); diff --git a/test/firmware_state_verificationcompleted_unittest.cpp b/test/firmware_state_verificationcompleted_unittest.cpp index 3c9f34d..90338f0 100644 --- a/test/firmware_state_verificationcompleted_unittest.cpp +++ b/test/firmware_state_verificationcompleted_unittest.cpp @@ -59,14 +59,14 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, * consistent behavior with verifyBlobId only added when closing the image * or hash. */ - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); EXPECT_FALSE(handler->canHandleBlob(updateBlobId)); } TEST_F(FirmwareHandlerVerificationCompletedTest, OnVerificationCompleteFailureUpdateBlobIdNotPresent) { - getToVerificationCompleted(VerifyCheckResponses::failed); + getToVerificationCompleted(ActionStatus::failed); EXPECT_FALSE(handler->canHandleBlob(updateBlobId)); } @@ -75,7 +75,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, */ TEST_F(FirmwareHandlerVerificationCompletedTest, GetBlobIdsReturnsExpectedList) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); std::vector<std::string> expected = {verifyBlobId, hashBlobId, activeImageBlobId, staticLayoutBlobId}; EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected)); @@ -87,7 +87,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, GetBlobIdsReturnsExpectedList) TEST_F(FirmwareHandlerVerificationCompletedTest, StatOnActiveImageReturnsFailure) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); ASSERT_TRUE(handler->canHandleBlob(activeImageBlobId)); blobs::BlobMeta meta; @@ -100,7 +100,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, /* The path taken to get to this state never opened the hash blob Id, which * is fine. But let's verify it behaved as intended. */ - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); EXPECT_FALSE(handler->canHandleBlob(activeHashBlobId)); } @@ -113,7 +113,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, TEST_F(FirmwareHandlerVerificationCompletedTest, StatOnVerifyBlobReturnsFailure) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); ASSERT_TRUE(handler->canHandleBlob(verifyBlobId)); blobs::BlobMeta meta; @@ -123,7 +123,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, StatOnVerifyBlobReturnsFailure) TEST_F(FirmwareHandlerVerificationCompletedTest, StatOnNormalBlobsReturnsSuccess) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); blobs::BlobMeta expected; expected.blobState = FirmwareBlobHandler::UpdateFlags::ipmi; @@ -150,14 +150,14 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, /* Every time you stat() once it's triggered, it checks the state again * until it's completed. */ - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); EXPECT_CALL(*verifyMockPtr, status()).Times(0); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::committed; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(VerifyCheckResponses::success)); + static_cast<std::uint8_t>(ActionStatus::success)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); @@ -167,14 +167,14 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, TEST_F(FirmwareHandlerVerificationCompletedTest, SessionStatOnVerifyAfterFailureDoesNothing) { - getToVerificationCompleted(VerifyCheckResponses::failed); + getToVerificationCompleted(ActionStatus::failed); EXPECT_CALL(*verifyMockPtr, status()).Times(0); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::commit_error; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(VerifyCheckResponses::failed)); + static_cast<std::uint8_t>(ActionStatus::failed)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); @@ -187,7 +187,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, TEST_F(FirmwareHandlerVerificationCompletedTest, OpeningAnyBlobAvailableFailsAfterSuccess) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); auto blobs = handler->getBlobIds(); for (const auto& blob : blobs) @@ -199,7 +199,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, TEST_F(FirmwareHandlerVerificationCompletedTest, OpeningAnyBlobAvailableFailsAfterFailure) { - getToVerificationCompleted(VerifyCheckResponses::failed); + getToVerificationCompleted(ActionStatus::failed); auto blobs = handler->getBlobIds(); for (const auto& blob : blobs) @@ -214,7 +214,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, TEST_F(FirmwareHandlerVerificationCompletedTest, WriteMetaToVerifyBlobReturnsFailure) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); std::vector<std::uint8_t> bytes = {0x01, 0x02}; EXPECT_FALSE(handler->writeMeta(session, 0, bytes)); @@ -226,7 +226,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, TEST_F(FirmwareHandlerVerificationCompletedTest, WriteToVerifyBlobReturnsFailure) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); std::vector<std::uint8_t> bytes = {0x01, 0x02}; EXPECT_FALSE(handler->write(session, 0, bytes)); @@ -237,7 +237,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, */ TEST_F(FirmwareHandlerVerificationCompletedTest, ReadOfVerifyBlobReturnsEmpty) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); EXPECT_THAT(handler->read(session, 0, 1), IsEmpty()); } @@ -250,7 +250,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, /* If you've started this'll return success, but if it's finished, it won't * let you try-again. */ - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); EXPECT_CALL(*verifyMockPtr, triggerVerification()).Times(0); EXPECT_FALSE(handler->commit(session, {})); @@ -259,7 +259,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, TEST_F(FirmwareHandlerVerificationCompletedTest, CommitOnVerifyBlobAfterFailureReturnsFailure) { - getToVerificationCompleted(VerifyCheckResponses::failed); + getToVerificationCompleted(ActionStatus::failed); EXPECT_CALL(*verifyMockPtr, triggerVerification()).Times(0); EXPECT_FALSE(handler->commit(session, {})); @@ -272,7 +272,7 @@ TEST_F(FirmwareHandlerVerificationCompletedTest, TEST_F(FirmwareHandlerVerificationCompletedTest, CloseAfterSuccessChangesStateAddsUpdateBlob) { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); ASSERT_FALSE(handler->canHandleBlob(updateBlobId)); handler->close(session); diff --git a/test/firmware_state_verificationpending_unittest.cpp b/test/firmware_state_verificationpending_unittest.cpp index b96ecb3..d22b887 100644 --- a/test/firmware_state_verificationpending_unittest.cpp +++ b/test/firmware_state_verificationpending_unittest.cpp @@ -216,7 +216,7 @@ TEST_F(FirmwareHandlerVerificationPendingTest, StatOnVerifyBlobIdReturnsState) expectedMeta.size = 0; expectedMeta.blobState = flags; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(VerifyCheckResponses::other)); + static_cast<std::uint8_t>(ActionStatus::unknown)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); diff --git a/test/firmware_state_verificationstarted_unittest.cpp b/test/firmware_state_verificationstarted_unittest.cpp index e031fe3..03ceb99 100644 --- a/test/firmware_state_verificationstarted_unittest.cpp +++ b/test/firmware_state_verificationstarted_unittest.cpp @@ -71,13 +71,13 @@ TEST_F(FirmwareHandlerVerificationStartedTest, { getToVerificationStarted(staticLayoutBlobId); EXPECT_CALL(*verifyMockPtr, status()) - .WillOnce(Return(VerifyCheckResponses::running)); + .WillOnce(Return(ActionStatus::running)); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::committing; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(VerifyCheckResponses::running)); + static_cast<std::uint8_t>(ActionStatus::running)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); @@ -88,13 +88,13 @@ TEST_F(FirmwareHandlerVerificationStartedTest, { getToVerificationStarted(staticLayoutBlobId); EXPECT_CALL(*verifyMockPtr, status()) - .WillOnce(Return(VerifyCheckResponses::other)); + .WillOnce(Return(ActionStatus::unknown)); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::committing; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(VerifyCheckResponses::other)); + static_cast<std::uint8_t>(ActionStatus::unknown)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); @@ -108,13 +108,13 @@ TEST_F(FirmwareHandlerVerificationStartedTest, */ getToVerificationStarted(staticLayoutBlobId); EXPECT_CALL(*verifyMockPtr, status()) - .WillOnce(Return(VerifyCheckResponses::failed)); + .WillOnce(Return(ActionStatus::failed)); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::commit_error; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(VerifyCheckResponses::failed)); + static_cast<std::uint8_t>(ActionStatus::failed)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); @@ -129,13 +129,13 @@ TEST_F(FirmwareHandlerVerificationStartedTest, */ getToVerificationStarted(staticLayoutBlobId); EXPECT_CALL(*verifyMockPtr, status()) - .WillOnce(Return(VerifyCheckResponses::success)); + .WillOnce(Return(ActionStatus::success)); blobs::BlobMeta meta, expectedMeta = {}; expectedMeta.size = 0; expectedMeta.blobState = flags | blobs::StateFlags::committed; expectedMeta.metadata.push_back( - static_cast<std::uint8_t>(VerifyCheckResponses::success)); + static_cast<std::uint8_t>(ActionStatus::success)); EXPECT_TRUE(handler->stat(session, &meta)); EXPECT_EQ(expectedMeta, meta); diff --git a/test/firmware_unittest.hpp b/test/firmware_unittest.hpp index 947c2ba..11d49bf 100644 --- a/test/firmware_unittest.hpp +++ b/test/firmware_unittest.hpp @@ -75,7 +75,7 @@ class IpmiOnlyFirmwareStaticTest : public ::testing::Test expectedState(FirmwareBlobHandler::UpdateState::verificationStarted); } - void getToVerificationCompleted(VerifyCheckResponses checkResponse) + void getToVerificationCompleted(ActionStatus checkResponse) { getToVerificationStarted(staticLayoutBlobId); @@ -87,7 +87,7 @@ class IpmiOnlyFirmwareStaticTest : public ::testing::Test void getToUpdatePending() { - getToVerificationCompleted(VerifyCheckResponses::success); + getToVerificationCompleted(ActionStatus::success); handler->close(session); expectedState(FirmwareBlobHandler::UpdateState::updatePending); @@ -103,7 +103,7 @@ class IpmiOnlyFirmwareStaticTest : public ::testing::Test expectedState(FirmwareBlobHandler::UpdateState::updateStarted); } - void getToUpdateCompleted(UpdateStatus result) + void getToUpdateCompleted(ActionStatus result) { getToUpdateStarted(); EXPECT_CALL(*updateMockPtr, status()).WillOnce(Return(result)); diff --git a/test/tools_updater_unittest.cpp b/test/tools_updater_unittest.cpp index 95a5abc..cacf2b0 100644 --- a/test/tools_updater_unittest.cpp +++ b/test/tools_updater_unittest.cpp @@ -130,7 +130,7 @@ TEST(UpdaterTest, NormalWalkthroughAllHappy) verificationResponse.blob_state = supported | blobs::StateFlags::committing; verificationResponse.size = 0; verificationResponse.metadata.push_back(static_cast<std::uint8_t>( - ipmi_flash::FirmwareBlobHandler::VerifyCheckResponses::success)); + ipmi_flash::FirmwareBlobHandler::ActionStatus::success)); EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session))) .WillOnce(Return(verificationResponse)); diff --git a/test/verification_mock.hpp b/test/verification_mock.hpp index b3071ef..728411b 100644 --- a/test/verification_mock.hpp +++ b/test/verification_mock.hpp @@ -16,7 +16,7 @@ class VerificationMock : public VerificationInterface public: MOCK_METHOD0(triggerVerification, bool()); MOCK_METHOD0(abortVerification, void()); - MOCK_METHOD0(status, VerifyCheckResponses()); + MOCK_METHOD0(status, ActionStatus()); }; std::unique_ptr<VerificationInterface> CreateVerifyMock() diff --git a/tools/updater.cpp b/tools/updater.cpp index 0819c80..98ef86e 100644 --- a/tools/updater.cpp +++ b/tools/updater.cpp @@ -114,8 +114,7 @@ bool pollVerificationStatus(std::uint16_t session, using namespace std::chrono_literals; static constexpr auto verificationSleep = 5s; - ipmi_flash::VerifyCheckResponses result = - ipmi_flash::VerifyCheckResponses::other; + ipmi_flash::ActionStatus result = ipmi_flash::ActionStatus::unknown; try { @@ -138,22 +137,21 @@ bool pollVerificationStatus(std::uint16_t session, std::fprintf(stderr, "Received invalid metadata response!!!\n"); } - result = - static_cast<ipmi_flash::VerifyCheckResponses>(resp.metadata[0]); + result = static_cast<ipmi_flash::ActionStatus>(resp.metadata[0]); switch (result) { - case ipmi_flash::VerifyCheckResponses::failed: + case ipmi_flash::ActionStatus::failed: std::fprintf(stderr, "failed\n"); exitLoop = true; break; - case ipmi_flash::VerifyCheckResponses::other: + case ipmi_flash::ActionStatus::unknown: std::fprintf(stderr, "other\n"); break; - case ipmi_flash::VerifyCheckResponses::running: + case ipmi_flash::ActionStatus::running: std::fprintf(stderr, "running\n"); break; - case ipmi_flash::VerifyCheckResponses::success: + case ipmi_flash::ActionStatus::success: std::fprintf(stderr, "success\n"); exitLoop = true; break; @@ -183,7 +181,7 @@ bool pollVerificationStatus(std::uint16_t session, * which exceptions from the lower layers allow one to try and delete the * blobs to rollback the state and progress. */ - return (result == ipmi_flash::VerifyCheckResponses::success); + return (result == ipmi_flash::ActionStatus::success); } bool UpdateHandler::verifyFile(const std::string& target) @@ -21,7 +21,7 @@ class UpdateInterface virtual void abortUpdate() = 0; /** Check the current state of the update process. */ - virtual UpdateStatus status() = 0; + virtual ActionStatus status() = 0; }; } // namespace ipmi_flash diff --git a/update_systemd.cpp b/update_systemd.cpp index 0802f43..e81b2bc 100644 --- a/update_systemd.cpp +++ b/update_systemd.cpp @@ -68,10 +68,10 @@ void SystemdUpdateMechanism::abortUpdate() return; } -UpdateStatus SystemdUpdateMechanism::status() +ActionStatus SystemdUpdateMechanism::status() { /* For now, don't check if the target failed. */ - return UpdateStatus::running; + return ActionStatus::running; } } // namespace ipmi_flash diff --git a/update_systemd.hpp b/update_systemd.hpp index 47c8d67..693beb4 100644 --- a/update_systemd.hpp +++ b/update_systemd.hpp @@ -35,7 +35,7 @@ class SystemdUpdateMechanism : public UpdateInterface bool triggerUpdate() override; void abortUpdate() override; - UpdateStatus status() override; + ActionStatus status() override; private: sdbusplus::bus::bus bus; @@ -24,7 +24,7 @@ class VerificationInterface virtual void abortVerification() = 0; /** Check the current state of the verification process. */ - virtual VerifyCheckResponses status() = 0; + virtual ActionStatus status() = 0; }; } // namespace ipmi_flash diff --git a/verify_systemd.cpp b/verify_systemd.cpp index 11386e0..73d9f24 100644 --- a/verify_systemd.cpp +++ b/verify_systemd.cpp @@ -67,9 +67,9 @@ void SystemdVerification::abortVerification() /* TODO: Implement this. */ } -VerifyCheckResponses SystemdVerification::status() +ActionStatus SystemdVerification::status() { - VerifyCheckResponses result = VerifyCheckResponses::other; + ActionStatus result = ActionStatus::unknown; std::ifstream ifs; ifs.open(checkPath); @@ -83,15 +83,15 @@ VerifyCheckResponses SystemdVerification::status() ifs >> status; if (status == "running") { - result = VerifyCheckResponses::running; + result = ActionStatus::running; } else if (status == "success") { - result = VerifyCheckResponses::success; + result = ActionStatus::success; } else if (status == "failed") { - result = VerifyCheckResponses::failed; + result = ActionStatus::failed; } } diff --git a/verify_systemd.hpp b/verify_systemd.hpp index 5e63e63..9b2cbab 100644 --- a/verify_systemd.hpp +++ b/verify_systemd.hpp @@ -47,7 +47,7 @@ class SystemdVerification : public VerificationInterface bool triggerVerification() override; void abortVerification() override; - VerifyCheckResponses status() override; + ActionStatus status() override; private: sdbusplus::bus::bus bus; |