Patrick Venture | 8d9f732 | 2018-08-03 10:39:13 -0700 | [diff] [blame] | 1 | #include "flash-ipmi.hpp" |
| 2 | #include "ipmi.hpp" |
Patrick Venture | 8d9f732 | 2018-08-03 10:39:13 -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 | 8d9f732 | 2018-08-03 10:39:13 -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 | #define HASH_SIZE 512 |
| 16 | |
| 17 | TEST(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 | } |