firmware: add sdbusplus for use by verification

The verification process starts a systemd service implemented outside
the scope of this codebase.  Therefore, add sdbusplus to the build and
inject into the object.

Change-Id: Icaacb5d60334da78f6363682f3b97714eb482dcf
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/firmware_open_unittest.cpp b/test/firmware_open_unittest.cpp
index 81a1977..c56d5d5 100644
--- a/test/firmware_open_unittest.cpp
+++ b/test/firmware_open_unittest.cpp
@@ -2,6 +2,7 @@
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
 
+#include <sdbusplus/test/sdbus_mock.hpp>
 #include <vector>
 
 #include <gmock/gmock.h>
@@ -28,7 +29,11 @@
         {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true));
 
@@ -55,7 +60,11 @@
         {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID)))
         .WillOnce(Return(true));
@@ -88,7 +97,11 @@
         {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(dataMock, open()).WillOnce(Return(true));
     EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID)))
@@ -120,7 +133,11 @@
         {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(dataMock, open()).WillOnce(Return(false));
 
@@ -148,7 +165,11 @@
         {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(imageMock2, open("asdf")).WillOnce(Return(true));
 
@@ -193,7 +214,11 @@
         {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true));
 
@@ -231,7 +256,11 @@
         {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(false));
 
@@ -257,7 +286,11 @@
         {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_FALSE(
         handler->open(0, FirmwareBlobHandler::UpdateFlags::ipmi, "asdf"));
@@ -277,7 +310,11 @@
         {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_FALSE(
         handler->open(0, FirmwareBlobHandler::UpdateFlags::lpc, "asdf"));
@@ -297,7 +334,11 @@
         {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
     };
 
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    sdbusplus::SdBusMock sdbus_mock;
+    auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
+
+    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
+        std::move(bus_mock), blobs, data);
 
     EXPECT_FALSE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, "bcdf"));