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 | 7dad86f | 2019-05-17 08:52:20 -0700 | [diff] [blame] | 5 | #include "util.hpp" |
Patrick Venture | 3ecb350 | 2019-05-17 11:03:51 -0700 | [diff] [blame] | 6 | #include "verification_mock.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 | |
| 13 | namespace blobs |
| 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 | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 27 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, "asdf")); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 28 | |
| 29 | std::vector<std::uint8_t> bytes = {0xaa, 0x55}; |
| 30 | |
| 31 | EXPECT_FALSE(handler->writeMeta(0, 0, bytes)); |
| 32 | } |
| 33 | |
Patrick Venture | ad7c73d | 2019-05-17 18:50:27 -0700 | [diff] [blame] | 34 | TEST_F(FirmwareHandlerWriteMetaTest, WriteConfigParametersPassedThrough) |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 35 | { |
Patrick Venture | 6e307a7 | 2018-11-09 18:21:17 -0800 | [diff] [blame] | 36 | EXPECT_CALL(dataMock, open()).WillOnce(Return(true)); |
Patrick Venture | 1361a12 | 2019-05-20 07:36:05 -0700 | [diff] [blame] | 37 | EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true)); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 38 | |
| 39 | EXPECT_TRUE(handler->open( |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 40 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::lpc, "asdf")); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 41 | |
| 42 | std::vector<std::uint8_t> bytes = {0x01, 0x02, 0x03, 0x04}; |
| 43 | |
Patrick Venture | 7430464 | 2019-01-17 09:31:04 -0800 | [diff] [blame] | 44 | EXPECT_CALL(dataMock, writeMeta(Eq(bytes))).WillOnce(Return(true)); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 45 | EXPECT_TRUE(handler->writeMeta(0, 0, bytes)); |
| 46 | } |
| 47 | |
| 48 | } // namespace blobs |