blob: a0d40b831aff112b7924dfb24c87d855d1ae5274 [file] [log] [blame]
Patrick Venturefbc7d192018-08-03 13:54:21 -07001#include "flash-ipmi.hpp"
2#include "ipmi.hpp"
Patrick Venturefbc7d192018-08-03 13:54:21 -07003#include "updater_mock.hpp"
4
5#include <cstring>
Patrick Venture1aedab22018-09-10 14:41:45 -07006
Patrick Venturefbc7d192018-08-03 13:54:21 -07007#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
16TEST(IpmiHashFinish, CallPassedOn)
17{
18 // The data finish command does no validation as the input is empty, and
19 // simply relies on the flash manager to do work.
20
21 StrictMock<UpdaterMock> updater;
22
23 size_t dataLen;
24 uint8_t request[MAX_IPMI_BUFFER] = {0};
25 uint8_t reply[MAX_IPMI_BUFFER] = {0};
26
27 dataLen = 1; // request is only the command.
28 request[0] = FlashSubCmds::flashHashFinish;
29
30 EXPECT_CALL(updater, hashFinish()).WillOnce(Return(true));
31 EXPECT_EQ(IPMI_CC_OK, hashFinish(&updater, request, reply, &dataLen));
32 EXPECT_EQ(sizeof(uint8_t), dataLen);
33 EXPECT_EQ(0, reply[0]);
34}