1 #include "data_mock.hpp" 2 #include "firmware_handler.hpp" 3 #include "firmware_unittest.hpp" 4 #include "image_mock.hpp" 5 #include "triggerable_mock.hpp" 6 #include "util.hpp" 7 8 #include <memory> 9 #include <vector> 10 11 #include <gtest/gtest.h> 12 13 namespace ipmi_flash 14 { 15 namespace 16 { 17 18 using ::testing::Eq; 19 using ::testing::Return; 20 21 class FirmwareHandlerWriteMetaTest : public FakeLpcFirmwareTest 22 {}; 23 24 TEST_F(FirmwareHandlerWriteMetaTest, WriteConfigParametersFailIfOverIPMI) 25 { 26 EXPECT_CALL(*imageMock, open("asdf")).WillOnce(Return(true)); 27 28 EXPECT_TRUE(handler->open( 29 0, blobs::OpenFlags::write | FirmwareFlags::UpdateFlags::ipmi, "asdf")); 30 31 std::vector<std::uint8_t> bytes = {0xaa, 0x55}; 32 33 EXPECT_FALSE(handler->writeMeta(0, 0, bytes)); 34 } 35 36 TEST_F(FirmwareHandlerWriteMetaTest, WriteConfigParametersPassedThrough) 37 { 38 EXPECT_CALL(*dataMock, open()).WillOnce(Return(true)); 39 EXPECT_CALL(*imageMock, open("asdf")).WillOnce(Return(true)); 40 41 EXPECT_TRUE(handler->open( 42 0, blobs::OpenFlags::write | FirmwareFlags::UpdateFlags::lpc, "asdf")); 43 44 std::vector<std::uint8_t> bytes = {0x01, 0x02, 0x03, 0x04}; 45 46 EXPECT_CALL(*dataMock, writeMeta(Eq(bytes))).WillOnce(Return(true)); 47 EXPECT_TRUE(handler->writeMeta(0, 0, bytes)); 48 } 49 50 } // namespace 51 } // namespace ipmi_flash 52