blob_handler: Have delete return a status
A user of this library would like to know if the delete operation
succeeds or fails.
Change-Id: Ida5890be9dad214854527c8afffd05bffc7e5e2a
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/ipmiblob/blob_handler.cpp b/src/ipmiblob/blob_handler.cpp
index 3d14eff..2076add 100644
--- a/src/ipmiblob/blob_handler.cpp
+++ b/src/ipmiblob/blob_handler.cpp
@@ -357,7 +357,7 @@
}
}
-void BlobHandler::deleteBlob(const std::string& id)
+bool BlobHandler::deleteBlob(const std::string& id)
{
std::vector<std::uint8_t> name;
std::copy(id.begin(), id.end(), std::back_inserter(name));
@@ -366,11 +366,13 @@
try
{
sendIpmiPayload(BlobOEMCommands::bmcBlobDelete, name);
+ return true;
}
catch (const BlobException& b)
{
std::fprintf(stderr, "Received failure on delete: %s\n", b.what());
}
+ return false;
}
std::vector<std::uint8_t> BlobHandler::readBytes(std::uint16_t session,
diff --git a/src/ipmiblob/blob_handler.hpp b/src/ipmiblob/blob_handler.hpp
index 33634fd..a9e6ef4 100644
--- a/src/ipmiblob/blob_handler.hpp
+++ b/src/ipmiblob/blob_handler.hpp
@@ -82,7 +82,7 @@
void closeBlob(std::uint16_t session) override;
- void deleteBlob(const std::string& id) override;
+ bool deleteBlob(const std::string& id) override;
/**
* @throws BlobException.
diff --git a/src/ipmiblob/blob_interface.hpp b/src/ipmiblob/blob_interface.hpp
index ed1de9f..c527fba 100644
--- a/src/ipmiblob/blob_interface.hpp
+++ b/src/ipmiblob/blob_interface.hpp
@@ -127,7 +127,7 @@
*
* @param[in] path - the blobId path.
*/
- virtual void deleteBlob(const std::string& id) = 0;
+ virtual bool deleteBlob(const std::string& id) = 0;
/**
* Read bytes from a blob.
diff --git a/src/ipmiblob/test/blob_interface_mock.hpp b/src/ipmiblob/test/blob_interface_mock.hpp
index b92ba25..968fdd0 100644
--- a/src/ipmiblob/test/blob_interface_mock.hpp
+++ b/src/ipmiblob/test/blob_interface_mock.hpp
@@ -25,7 +25,7 @@
MOCK_METHOD(std::uint16_t, openBlob, (const std::string&, std::uint16_t),
(override));
MOCK_METHOD(void, closeBlob, (std::uint16_t), (override));
- MOCK_METHOD(void, deleteBlob, (const std::string&), (override));
+ MOCK_METHOD(bool, deleteBlob, (const std::string&), (override));
MOCK_METHOD(std::vector<std::uint8_t>, readBytes,
(std::uint16_t, std::uint32_t, std::uint32_t), (override));
};
diff --git a/test/tools_blob_unittest.cpp b/test/tools_blob_unittest.cpp
index a9ec639..4b08854 100644
--- a/test/tools_blob_unittest.cpp
+++ b/test/tools_blob_unittest.cpp
@@ -567,7 +567,7 @@
sendPacket(ipmiOEMNetFn, ipmiOEMBlobCmd, ContainerEq(request)))
.WillOnce(Return(resp));
- blob.deleteBlob("abcd");
+ EXPECT_TRUE(blob.deleteBlob("abcd"));
}
} // namespace ipmiblob