test: firmware notYetStarted: getBlobIds
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ia5593ae141d184314390faae3980a8331d2c3d7d
diff --git a/test/Makefile.am b/test/Makefile.am
index a85d13d..049a002 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -33,7 +33,7 @@
firmware_sessionstat_unittest \
firmware_commit_unittest \
file_handler_unittest \
- firmware_state_notyetstarted
+ firmware_state_notyetstarted_unittest
if BUILD_HOST_TOOL
check_PROGRAMS += \
@@ -80,8 +80,8 @@
file_handler_unittest_SOURCES = file_handler_unittest.cpp
file_handler_unittest_LDADD = $(top_builddir)/libfirmwareblob_common.la -lstdc++fs
-firmware_state_notyetstarted_SOURCES = firmware_state_notyetstarted.cpp
-firmware_state_notyetstarted_LDADD = $(top_builddir)/libfirmwareblob_common.la
+firmware_state_notyetstarted_unittest_SOURCES = firmware_state_notyetstarted_unittest.cpp
+firmware_state_notyetstarted_unittest_LDADD = $(top_builddir)/libfirmwareblob_common.la
if BUILD_HOST_TOOL
tools_bt_unittest_SOURCES = tools_bt_unittest.cpp
diff --git a/test/firmware_state_notyetstarted.cpp b/test/firmware_state_notyetstarted.cpp
deleted file mode 100644
index 7e10c8a..0000000
--- a/test/firmware_state_notyetstarted.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * The goal of these tests is to verify the behavior of all blob commands given
- * the current state is notYetStarted. The initial state.
- */
-#include "firmware_handler.hpp"
-#include "firmware_unittest.hpp"
-
-#include <gtest/gtest.h>
-
-namespace ipmi_flash
-{
-namespace
-{
-
-class FirmwareHandlerNotYetStartedTest : public FakeLpcFirmwareTest
-{
-};
-
-} // namespace
-} // namespace ipmi_flash
diff --git a/test/firmware_state_notyetstarted_unittest.cpp b/test/firmware_state_notyetstarted_unittest.cpp
new file mode 100644
index 0000000..56833f0
--- /dev/null
+++ b/test/firmware_state_notyetstarted_unittest.cpp
@@ -0,0 +1,52 @@
+/**
+ * The goal of these tests is to verify the behavior of all blob commands given
+ * the current state is notYetStarted. The initial state.
+ */
+#include "firmware_handler.hpp"
+#include "firmware_unittest.hpp"
+
+#include <gtest/gtest.h>
+
+namespace ipmi_flash
+{
+namespace
+{
+
+using ::testing::UnorderedElementsAreArray;
+
+class FirmwareHandlerNotYetStartedTest : public IpmiOnlyFirmwareStaticTest
+{
+};
+
+/*
+ * There are the following calls (parameters may vary):
+ * Note: you cannot have a session yet, so only commands that don't take a
+ * session parameter are valid. Once you open() from this state, we will vary
+ * you transition out of this state (ensuring the above is true). Technically
+ * the firmware handler receives the session number with open(), but the blob
+ * manager is providing this normally.
+ *
+ * canHandleBlob
+ * getBlobIds
+ * deleteBlob
+ * stat
+ * open
+ *
+ * canHandleBlob is just a count check (or something similar) against what is
+ * returned by getBlobIds. It is tested in firmware_canhandle_unittest
+ */
+
+TEST_F(FirmwareHandlerNotYetStartedTest, GetBlobListValidateListContents)
+{
+ /* TODO: Presently /flash/verify is present from the beginning, however,
+ * this is going to change to simplify handling of open().
+ */
+ std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId,
+ verifyBlobId};
+
+ EXPECT_THAT(handler->getBlobIds(),
+ UnorderedElementsAreArray(expectedBlobs));
+}
+
+} // namespace
+} // namespace ipmi_flash
diff --git a/test/firmware_unittest.hpp b/test/firmware_unittest.hpp
index 748b212..1f1ae86 100644
--- a/test/firmware_unittest.hpp
+++ b/test/firmware_unittest.hpp
@@ -15,6 +15,26 @@
namespace ipmi_flash
{
+class IpmiOnlyFirmwareStaticTest : public ::testing::Test
+{
+ protected:
+ ImageHandlerMock imageMock;
+ std::vector<HandlerPack> blobs;
+ std::vector<DataHandlerPack> data = {
+ {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}};
+ std::unique_ptr<blobs::GenericBlobInterface> handler;
+
+ void SetUp() override
+ {
+ blobs = {
+ {hashBlobId, &imageMock},
+ {staticLayoutBlobId, &imageMock},
+ };
+ handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+ blobs, data, CreateVerifyMock(), CreateUpdateMock());
+ }
+};
+
class IpmiOnlyFirmwareTest : public ::testing::Test
{
protected: