util: create util object for bmc and tool
Create a common util object for the BMC library and host tool. Place in
blobs namespace favoring BMC.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I036fd65d924c65fcfa71aba5cd76275a2941ff14
diff --git a/test/firmware_delete_unittest.cpp b/test/firmware_delete_unittest.cpp
index 10c4227..49809f8 100644
--- a/test/firmware_delete_unittest.cpp
+++ b/test/firmware_delete_unittest.cpp
@@ -1,6 +1,7 @@
#include "data_mock.hpp"
#include "firmware_handler.hpp"
#include "image_mock.hpp"
+#include "util.hpp"
#include <sdbusplus/test/sdbus_mock.hpp>
#include <vector>
@@ -21,7 +22,7 @@
ImageHandlerMock imageMock;
std::vector<HandlerPack> blobs = {
- {FirmwareBlobHandler::hashBlobID, &imageMock},
+ {hashBlobId, &imageMock},
{"asdf", &imageMock},
};
std::vector<DataHandlerPack> data = {
@@ -35,18 +36,17 @@
auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
std::move(bus_mock), blobs, data);
- EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID)))
- .WillOnce(Return(true));
+ EXPECT_CALL(imageMock, open(StrEq(hashBlobId))).WillOnce(Return(true));
EXPECT_TRUE(handler->open(
0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi,
- FirmwareBlobHandler::hashBlobID));
+ hashBlobId));
/* The active hash blob_id was added. */
auto currentBlobs = handler->getBlobIds();
EXPECT_EQ(4, currentBlobs.size());
EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
- FirmwareBlobHandler::activeHashBlobID));
+ activeHashBlobId));
/* Set up close() expectations. */
EXPECT_CALL(imageMock, close());
@@ -55,15 +55,15 @@
currentBlobs = handler->getBlobIds();
EXPECT_EQ(4, currentBlobs.size());
EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
- FirmwareBlobHandler::activeHashBlobID));
+ activeHashBlobId));
/* Delete the blob. */
- EXPECT_TRUE(handler->deleteBlob(FirmwareBlobHandler::activeHashBlobID));
+ EXPECT_TRUE(handler->deleteBlob(activeHashBlobId));
currentBlobs = handler->getBlobIds();
EXPECT_EQ(3, currentBlobs.size());
EXPECT_EQ(0, std::count(currentBlobs.begin(), currentBlobs.end(),
- FirmwareBlobHandler::activeHashBlobID));
+ activeHashBlobId));
}
} // namespace blobs