blob: 006525d25e4d9af4a537fc5695c7698f209477a1 [file] [log] [blame]
#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
TEST(IpmiHashFinish, CallPassedOn)
{
// The data finish command does no validation as the input is empty, and
// simply relies on the flash manager to do work.
StrictMock<UpdaterMock> updater;
size_t dataLen;
uint8_t request[MAX_IPMI_BUFFER] = {0};
uint8_t reply[MAX_IPMI_BUFFER] = {0};
dataLen = 1; // request is only the command.
request[0] = FlashSubCmds::flashHashFinish;
EXPECT_CALL(updater, hashFinish()).WillOnce(Return(true));
EXPECT_EQ(IPMI_CC_OK, hashFinish(&updater, request, reply, &dataLen));
EXPECT_EQ(sizeof(uint8_t), dataLen);
EXPECT_EQ(0, reply[0]);
}