firmware: add logging to factory failures
Add logging to factory failures. This is now possible
with injection available for phosphor-logging.
Change-Id: I77ac959d58e44305d7acf918b656bdd21a9c4da8
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/firmware_createhandler_unittest.cpp b/test/firmware_createhandler_unittest.cpp
new file mode 100644
index 0000000..78bde97
--- /dev/null
+++ b/test/firmware_createhandler_unittest.cpp
@@ -0,0 +1,44 @@
+#include "data_mock.hpp"
+#include "firmware_handler.hpp"
+
+#include <phosphor-logging/test/sdjournal_mock.hpp>
+#include <sdbusplus/test/sdbus_mock.hpp>
+
+#include <gtest/gtest.h>
+
+using namespace phosphor::logging;
+
+namespace blobs
+{
+using ::testing::Return;
+using ::testing::StrEq;
+using ::testing::StrictMock;
+
+TEST(FirmwareHandlerBlobTest, VerifyFirmareCounts)
+{
+ /* Verify the firmware count must be greater than zero. */
+
+ DataHandlerMock dataMock;
+ StrictMock<SdJournalMock> journalMock;
+ SwapJouralHandler(&journalMock);
+
+ std::vector<HandlerPack> blobs;
+
+ std::vector<DataHandlerPack> data = {
+ {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
+ {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock},
+ };
+
+ sdbusplus::SdBusMock sdbus_mock;
+ auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+ EXPECT_CALL(journalMock, journal_send_call(StrEq("PRIORITY=%d")))
+ .WillOnce(Return(0));
+
+ auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+ std::move(bus_mock), blobs, data);
+
+ EXPECT_EQ(handler, nullptr);
+}
+
+} // namespace blobs