ipmi: start implementing flashStartHash

Change-Id: I5465bd672eac510be30d50cac8cf34b86a24ca40
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/ipmi_starthash_unittest.cpp b/test/ipmi_starthash_unittest.cpp
new file mode 100644
index 0000000..c8db942
--- /dev/null
+++ b/test/ipmi_starthash_unittest.cpp
@@ -0,0 +1,40 @@
+#include "flash-ipmi.hpp"
+#include "ipmi.hpp"
+
+#include "updater_mock.hpp"
+
+#include <cstring>
+#include <gtest/gtest.h>
+
+using ::testing::Return;
+using ::testing::StrictMock;
+
+// ipmid.hpp isn't installed where we can grab it and this value is per BMC
+// SoC.
+#define MAX_IPMI_BUFFER 64
+#define HASH_SIZE 512
+
+TEST(IpmiStartHashTest, ValidBoringCaseReturnsSuccess)
+{
+    // This is also mostly a pass-thru command such that the real validation is
+    // done elsewhere.
+
+    StrictMock<UpdaterMock> updater;
+
+    size_t dataLen;
+    uint8_t request[MAX_IPMI_BUFFER] = {0};
+    uint8_t reply[MAX_IPMI_BUFFER] = {0};
+
+    struct StartTx tx;
+    tx.cmd = FlashSubCmds::flashStartHash;
+    tx.length = HASH_SIZE;
+    std::memcpy(request, &tx, sizeof(tx));
+
+    dataLen = sizeof(tx);
+
+    EXPECT_CALL(updater, startHash(HASH_SIZE)).WillOnce(Return(true));
+
+    EXPECT_EQ(IPMI_CC_OK, startHash(&updater, request, reply, &dataLen));
+    EXPECT_EQ(sizeof(uint8_t), dataLen);
+    EXPECT_EQ(0, reply[0]);
+}