Patrick Venture | fbc7d19 | 2018-08-03 13:54:21 -0700 | [diff] [blame] | 1 | #include "flash-ipmi.hpp" |
| 2 | #include "ipmi.hpp" |
Patrick Venture | fbc7d19 | 2018-08-03 13:54:21 -0700 | [diff] [blame] | 3 | #include "updater_mock.hpp" |
| 4 | |
| 5 | #include <cstring> |
Patrick Venture | 1aedab2 | 2018-09-10 14:41:45 -0700 | [diff] [blame^] | 6 | |
Patrick Venture | fbc7d19 | 2018-08-03 13:54:21 -0700 | [diff] [blame] | 7 | #include <gtest/gtest.h> |
| 8 | |
| 9 | using ::testing::Return; |
| 10 | using ::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 | |
| 16 | TEST(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 | } |