Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 1 | #include "data_mock.hpp" |
| 2 | #include "firmware_handler.hpp" |
Patrick Venture | 1361a12 | 2019-05-20 07:36:05 -0700 | [diff] [blame] | 3 | #include "firmware_unittest.hpp" |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 4 | #include "image_mock.hpp" |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 5 | #include "triggerable_mock.hpp" |
Patrick Venture | 7dad86f | 2019-05-17 08:52:20 -0700 | [diff] [blame] | 6 | #include "util.hpp" |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 7 | |
Patrick Venture | ad7c73d | 2019-05-17 18:50:27 -0700 | [diff] [blame] | 8 | #include <memory> |
| 9 | #include <vector> |
| 10 | |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 11 | #include <gtest/gtest.h> |
| 12 | |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 13 | namespace ipmi_flash |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 14 | { |
Patrick Venture | d4e20de | 2019-07-18 12:48:05 -0700 | [diff] [blame] | 15 | namespace |
| 16 | { |
| 17 | |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 18 | using ::testing::Eq; |
| 19 | using ::testing::Return; |
| 20 | |
Patrick Venture | 1361a12 | 2019-05-20 07:36:05 -0700 | [diff] [blame] | 21 | class FirmwareHandlerWriteMetaTest : public FakeLpcFirmwareTest |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame] | 22 | {}; |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 23 | |
Patrick Venture | ad7c73d | 2019-05-17 18:50:27 -0700 | [diff] [blame] | 24 | TEST_F(FirmwareHandlerWriteMetaTest, WriteConfigParametersFailIfOverIPMI) |
| 25 | { |
Patrick Venture | d4e20de | 2019-07-18 12:48:05 -0700 | [diff] [blame] | 26 | EXPECT_CALL(*imageMock, open("asdf")).WillOnce(Return(true)); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 27 | |
| 28 | EXPECT_TRUE(handler->open( |
Patrick Venture | 84778b8 | 2019-06-26 20:11:09 -0700 | [diff] [blame] | 29 | 0, blobs::OpenFlags::write | FirmwareFlags::UpdateFlags::ipmi, "asdf")); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 30 | |
| 31 | std::vector<std::uint8_t> bytes = {0xaa, 0x55}; |
| 32 | |
| 33 | EXPECT_FALSE(handler->writeMeta(0, 0, bytes)); |
| 34 | } |
| 35 | |
Patrick Venture | ad7c73d | 2019-05-17 18:50:27 -0700 | [diff] [blame] | 36 | TEST_F(FirmwareHandlerWriteMetaTest, WriteConfigParametersPassedThrough) |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 37 | { |
Patrick Venture | 4934daa | 2020-09-22 16:37:44 -0700 | [diff] [blame^] | 38 | EXPECT_CALL(*dataMock, open()).WillOnce(Return(true)); |
Patrick Venture | d4e20de | 2019-07-18 12:48:05 -0700 | [diff] [blame] | 39 | EXPECT_CALL(*imageMock, open("asdf")).WillOnce(Return(true)); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 40 | |
| 41 | EXPECT_TRUE(handler->open( |
Patrick Venture | 84778b8 | 2019-06-26 20:11:09 -0700 | [diff] [blame] | 42 | 0, blobs::OpenFlags::write | FirmwareFlags::UpdateFlags::lpc, "asdf")); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 43 | |
| 44 | std::vector<std::uint8_t> bytes = {0x01, 0x02, 0x03, 0x04}; |
| 45 | |
Patrick Venture | 4934daa | 2020-09-22 16:37:44 -0700 | [diff] [blame^] | 46 | EXPECT_CALL(*dataMock, writeMeta(Eq(bytes))).WillOnce(Return(true)); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 47 | EXPECT_TRUE(handler->writeMeta(0, 0, bytes)); |
| 48 | } |
| 49 | |
Patrick Venture | d4e20de | 2019-07-18 12:48:05 -0700 | [diff] [blame] | 50 | } // namespace |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 51 | } // namespace ipmi_flash |