bmc: updatePending: deleteBlob(blob)
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I111448fd777cb14ef9748f15dd2a791a237ee1e2
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index e519ccb..e6f0fee 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -126,12 +126,12 @@
abortProcess();
return true;
case UpdateState::updatePending:
- break;
+ abortProcess();
+ return true;
default:
break;
}
- /* TODO: implement. */
return false;
}
diff --git a/test/firmware_state_updatepending_unittest.cpp b/test/firmware_state_updatepending_unittest.cpp
index 31c88e9..884852c 100644
--- a/test/firmware_state_updatepending_unittest.cpp
+++ b/test/firmware_state_updatepending_unittest.cpp
@@ -235,8 +235,70 @@
}
/*
- * TODO: deleteBlob(blob)
+ * deleteBlob(blob)
*/
+TEST_F(FirmwareHandlerUpdatePendingTest, DeleteUpdateAbortsProcess)
+{
+ /* It doesn't matter what blob id is used to delete in the design, so just
+ * delete the update blob id
+ */
+ getToUpdatePending();
+
+ EXPECT_CALL(*updateMockPtr, abort()).Times(0);
+
+ ASSERT_TRUE(handler->canHandleBlob(updateBlobId));
+ EXPECT_TRUE(handler->deleteBlob(updateBlobId));
+
+ std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(expectedBlobs));
+ expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
+}
+
+TEST_F(FirmwareHandlerUpdatePendingTest, DeleteActiveImageAbortsProcess)
+{
+ getToUpdatePending();
+
+ EXPECT_CALL(*updateMockPtr, abort()).Times(0);
+
+ ASSERT_TRUE(handler->canHandleBlob(activeImageBlobId));
+ EXPECT_TRUE(handler->deleteBlob(activeImageBlobId));
+
+ std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(expectedBlobs));
+ expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
+}
+
+TEST_F(FirmwareHandlerUpdatePendingTest, DeleteStaticLayoutAbortsProcess)
+{
+ getToUpdatePending();
+
+ EXPECT_CALL(*updateMockPtr, abort()).Times(0);
+
+ ASSERT_TRUE(handler->canHandleBlob(staticLayoutBlobId));
+ EXPECT_TRUE(handler->deleteBlob(staticLayoutBlobId));
+
+ std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(expectedBlobs));
+ expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
+}
+
+TEST_F(FirmwareHandlerUpdatePendingTest, DeleteHashAbortsProcess)
+{
+ getToUpdatePending();
+
+ EXPECT_CALL(*updateMockPtr, abort()).Times(0);
+
+ ASSERT_TRUE(handler->canHandleBlob(hashBlobId));
+ EXPECT_TRUE(handler->deleteBlob(hashBlobId));
+
+ std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(expectedBlobs));
+ expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
+}
} // namespace
} // namespace ipmi_flash