test: firmware verificationCompleted: stat(session)
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I02938bc8f9aa07ae2822e9d766683f6517a7a5ef
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 6ebc559..57fd24d 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -212,9 +212,14 @@
{
value = VerifyCheckResponses::other;
}
+ else if (state == UpdateState::verificationCompleted)
+ {
+ value = lastVerificationResponse;
+ }
else
{
value = verification->checkVerificationState();
+ lastVerificationResponse = value;
}
meta->metadata.push_back(static_cast<std::uint8_t>(value));
diff --git a/firmware_handler.hpp b/firmware_handler.hpp
index 0b58876..bfae529 100644
--- a/firmware_handler.hpp
+++ b/firmware_handler.hpp
@@ -230,6 +230,8 @@
/** Temporary variable to track whether a blob is open. */
bool fileOpen = false;
+
+ VerifyCheckResponses lastVerificationResponse = VerifyCheckResponses::other;
};
} // namespace ipmi_flash
diff --git a/test/firmware_state_verificationcompleted_unittest.cpp b/test/firmware_state_verificationcompleted_unittest.cpp
index 1bef136..c162c5b 100644
--- a/test/firmware_state_verificationcompleted_unittest.cpp
+++ b/test/firmware_state_verificationcompleted_unittest.cpp
@@ -175,6 +175,42 @@
* stat(session) - the verify blobid is open in this state, so stat on that once
* completed should have no effect.
*/
+TEST_F(FirmwareHandlerVerificationCompletedTest,
+ SessionStatOnVerifyAfterSuccessDoesNothing)
+{
+ /* Every time you stat() once it's triggered, it checks the state again
+ * until it's completed.
+ */
+ getToVerificationCompleted(VerifyCheckResponses::success);
+ EXPECT_CALL(*verifyMockPtr, checkVerificationState()).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));
+
+ EXPECT_TRUE(handler->stat(session, &meta));
+ EXPECT_EQ(expectedMeta, meta);
+ expectedState(FirmwareBlobHandler::UpdateState::verificationCompleted);
+}
+
+TEST_F(FirmwareHandlerVerificationCompletedTest,
+ SessionStatOnVerifyAfterFailureDoesNothing)
+{
+ getToVerificationCompleted(VerifyCheckResponses::failed);
+ EXPECT_CALL(*verifyMockPtr, checkVerificationState()).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));
+
+ EXPECT_TRUE(handler->stat(session, &meta));
+ EXPECT_EQ(expectedMeta, meta);
+ expectedState(FirmwareBlobHandler::UpdateState::verificationCompleted);
+}
/*
* open(blob) - all open should fail