tools: implement blob write
Implement blob write bytes.
Change-Id: Ie7c79db67ea58a82d39ac679a8e380934e93ca5a
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/tools_blob_unittest.cpp b/test/tools_blob_unittest.cpp
index 8205d3a..7893e3c 100644
--- a/test/tools_blob_unittest.cpp
+++ b/test/tools_blob_unittest.cpp
@@ -214,4 +214,27 @@
EXPECT_EQ(0xedfe, session);
}
+TEST_F(BlobHandlerTest, writeBytesSucceeds)
+{
+ /* The write bytes succeeds. */
+ IpmiInterfaceMock ipmiMock;
+ BlobHandler blob(&ipmiMock);
+
+ std::vector<std::uint8_t> request = {
+ 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobWrite,
+ 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 'a', 'b', 'c', 'd'};
+
+ std::vector<std::uint8_t> bytes = {'a', 'b', 'c', 'd'};
+ std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00};
+ std::vector<std::uint8_t> reqCrc = {0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 'a', 'b', 'c', 'd'};
+ EXPECT_CALL(crcMock, generateCrc(Eq(reqCrc))).WillOnce(Return(0x00));
+
+ EXPECT_CALL(ipmiMock, sendPacket(Eq(request))).WillOnce(Return(resp));
+
+ blob.writeBytes(0x0001, 0, bytes);
+}
+
} // namespace host_tool