test: Add first unit-test to verify factory

Verify the factory does what we expect.

Change-Id: Ied4fbe45b1b46c0cc5726c9d5e437a9cb92e6182
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/Makefile.am b/Makefile.am
index afed099..1b469cc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,3 +8,5 @@
                         -version-info 0:0:0 -shared
 libfirmwareblob_la_CXXFLAGS = $(PHOSPHOR_LOGGING_CFLAGS) \
                          -flto
+
+SUBDIRS = . test
diff --git a/configure.ac b/configure.ac
index 8af2813..da02696 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,5 +76,5 @@
 )
 
 # Create configured output
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile test/Makefile])
 AC_OUTPUT
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 23b0925..1980760 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -9,7 +9,7 @@
 namespace blobs
 {
 
-static std::string hashBlobID = "/flash/hash";
+const std::string FirmwareBlobHandler::hashBlobID = "/flash/hash";
 
 std::unique_ptr<GenericBlobInterface>
     FirmwareBlobHandler::CreateFirmwareBlobHandler(
diff --git a/firmware_handler.hpp b/firmware_handler.hpp
index 3eede31..f5239b4 100644
--- a/firmware_handler.hpp
+++ b/firmware_handler.hpp
@@ -67,6 +67,8 @@
     bool stat(uint16_t session, struct BlobMeta* meta) override;
     bool expire(uint16_t session) override;
 
+    static const std::string hashBlobID;
+
   private:
     std::vector<std::string> blobIDs;
     std::uint32_t transports;
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..d3a971d
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,19 @@
+AM_CPPFLAGS = -I$(top_srcdir)/ \
+	$(GTEST_CFLAGS) \
+	$(GMOCK_CFLAGS)
+AM_CXXFLAGS = \
+	$(GTEST_MAIN_CFLAGS)
+AM_LDFLAGS = \
+	$(GMOCK_LIBS) \
+	$(GTEST_MAIN_LIBS) \
+	$(OESDK_TESTCASE_FLAGS)
+
+# Run all 'check' test programs
+check_PROGRAMS = \
+	firmware_handler
+
+TESTS = $(check_PROGRAMS)
+
+firmware_handler_SOURCES = firmware_handler_unittest.cpp
+firmware_handler_LDADD = $(top_builddir)/firmware_handler.o
+
diff --git a/test/firmware_handler_unittest.cpp b/test/firmware_handler_unittest.cpp
new file mode 100644
index 0000000..97c28f8
--- /dev/null
+++ b/test/firmware_handler_unittest.cpp
@@ -0,0 +1,16 @@
+#include "firmware_handler.hpp"
+
+#include <memory>
+
+#include <gtest/gtest.h>
+
+namespace blobs
+{
+TEST(FirmwareHandlerTest, CreateEmptyListVerifyHasHash)
+{
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler({}, 0);
+    auto result = handler->getBlobIds();
+    EXPECT_EQ(1, result.size());
+    EXPECT_STREQ(result.at(0).c_str(), FirmwareBlobHandler::hashBlobID.c_str());
+}
+} // namespace blobs