firmware: implement stat command
Implement the BmcBlobStat command for the generic blob_ids, versus the
active ones.
Also, reduce the size of our transport bits to match the use-case state.
Change-Id: I9e2b28134026e8abfa18952dc80c526f0325308f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/Makefile.am b/test/Makefile.am
index d3a971d..9afb25a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -10,10 +10,14 @@
# Run all 'check' test programs
check_PROGRAMS = \
- firmware_handler
+ firmware_handler \
+ firmware_stat
TESTS = $(check_PROGRAMS)
firmware_handler_SOURCES = firmware_handler_unittest.cpp
firmware_handler_LDADD = $(top_builddir)/firmware_handler.o
+firmware_stat_SOURCES = firmware_stat_unittest.cpp
+firmware_stat_LDADD = $(top_builddir)/firmware_handler.o
+
diff --git a/test/firmware_stat_unittest.cpp b/test/firmware_stat_unittest.cpp
new file mode 100644
index 0000000..b872b16
--- /dev/null
+++ b/test/firmware_stat_unittest.cpp
@@ -0,0 +1,25 @@
+#include "firmware_handler.hpp"
+
+#include <memory>
+
+#include <gtest/gtest.h>
+
+namespace blobs
+{
+TEST(FirmwareHandlerStatTest, StatOnInactiveBlobIDReturnsTransport)
+{
+ /* Test that the metadata information returned matches expectations for this
+ * case.
+ *
+ * canHandle has already been called at this point, so we don't need to test
+ * the input for this function.
+ */
+
+ auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+ {"asdf"}, static_cast<uint16_t>(FirmwareUpdateFlags::bt));
+ struct BlobMeta meta;
+ EXPECT_TRUE(handler->stat("asdf", &meta));
+ EXPECT_EQ(static_cast<uint16_t>(FirmwareUpdateFlags::bt), meta.blobState);
+}
+
+} // namespace blobs