blob: f28ff56604f41a99bc539cad3049353043db788d [file] [log] [blame]
Patrick Venture2c1205d2018-08-03 10:23:14 -07001#include "flash-ipmi.hpp"
2#include "ipmi.hpp"
Patrick Venture2c1205d2018-08-03 10:23:14 -07003#include "updater_mock.hpp"
4
5#include <cstring>
Patrick Venture1aedab22018-09-10 14:41:45 -07006
Patrick Venture2c1205d2018-08-03 10:23:14 -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(IpmiFlashFinish, 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::flashDataFinish;
29
30 EXPECT_CALL(updater, flashFinish()).WillOnce(Return(true));
31 EXPECT_EQ(IPMI_CC_OK, dataFinish(&updater, request, reply, &dataLen));
32 EXPECT_EQ(sizeof(uint8_t), dataLen);
33 EXPECT_EQ(0, reply[0]);
34}