blob: c8db942890ea538b2c15f53c0aa0dd78811d1f03 [file] [log] [blame]
Patrick Venture8d9f7322018-08-03 10:39:13 -07001#include "flash-ipmi.hpp"
2#include "ipmi.hpp"
3
4#include "updater_mock.hpp"
5
6#include <cstring>
7#include <gtest/gtest.h>
8
9using ::testing::Return;
10using ::testing::StrictMock;
11
12// ipmid.hpp isn't installed where we can grab it and this value is per BMC
13// SoC.
14#define MAX_IPMI_BUFFER 64
15#define HASH_SIZE 512
16
17TEST(IpmiStartHashTest, ValidBoringCaseReturnsSuccess)
18{
19 // This is also mostly a pass-thru command such that the real validation is
20 // done elsewhere.
21
22 StrictMock<UpdaterMock> updater;
23
24 size_t dataLen;
25 uint8_t request[MAX_IPMI_BUFFER] = {0};
26 uint8_t reply[MAX_IPMI_BUFFER] = {0};
27
28 struct StartTx tx;
29 tx.cmd = FlashSubCmds::flashStartHash;
30 tx.length = HASH_SIZE;
31 std::memcpy(request, &tx, sizeof(tx));
32
33 dataLen = sizeof(tx);
34
35 EXPECT_CALL(updater, startHash(HASH_SIZE)).WillOnce(Return(true));
36
37 EXPECT_EQ(IPMI_CC_OK, startHash(&updater, request, reply, &dataLen));
38 EXPECT_EQ(sizeof(uint8_t), dataLen);
39 EXPECT_EQ(0, reply[0]);
40}