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 | { |
| 15 | using ::testing::Eq; |
| 16 | using ::testing::Return; |
| 17 | |
Patrick Venture | 1361a12 | 2019-05-20 07:36:05 -0700 | [diff] [blame] | 18 | class FirmwareHandlerWriteMetaTest : public FakeLpcFirmwareTest |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 19 | { |
Patrick Venture | ad7c73d | 2019-05-17 18:50:27 -0700 | [diff] [blame] | 20 | }; |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 21 | |
Patrick Venture | ad7c73d | 2019-05-17 18:50:27 -0700 | [diff] [blame] | 22 | TEST_F(FirmwareHandlerWriteMetaTest, WriteConfigParametersFailIfOverIPMI) |
| 23 | { |
Patrick Venture | 1361a12 | 2019-05-20 07:36:05 -0700 | [diff] [blame] | 24 | EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true)); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 25 | |
| 26 | EXPECT_TRUE(handler->open( |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 27 | 0, blobs::OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, |
| 28 | "asdf")); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 29 | |
| 30 | std::vector<std::uint8_t> bytes = {0xaa, 0x55}; |
| 31 | |
| 32 | EXPECT_FALSE(handler->writeMeta(0, 0, bytes)); |
| 33 | } |
| 34 | |
Patrick Venture | ad7c73d | 2019-05-17 18:50:27 -0700 | [diff] [blame] | 35 | TEST_F(FirmwareHandlerWriteMetaTest, WriteConfigParametersPassedThrough) |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 36 | { |
Patrick Venture | 6e307a7 | 2018-11-09 18:21:17 -0800 | [diff] [blame] | 37 | EXPECT_CALL(dataMock, open()).WillOnce(Return(true)); |
Patrick Venture | 1361a12 | 2019-05-20 07:36:05 -0700 | [diff] [blame] | 38 | EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true)); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 39 | |
| 40 | EXPECT_TRUE(handler->open( |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 41 | 0, blobs::OpenFlags::write | FirmwareBlobHandler::UpdateFlags::lpc, |
| 42 | "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 | 7430464 | 2019-01-17 09:31:04 -0800 | [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 | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 50 | } // namespace ipmi_flash |