Patrick Venture | 8e1b233 | 2019-01-17 15:22:45 -0800 | [diff] [blame] | 1 | #include "internal_sys_mock.hpp" |
Patrick Venture | 46bdadc | 2019-01-18 09:04:16 -0800 | [diff] [blame] | 2 | #include "io_mock.hpp" |
Patrick Venture | 8e1b233 | 2019-01-17 15:22:45 -0800 | [diff] [blame] | 3 | #include "lpc.hpp" |
| 4 | |
| 5 | #include <cstring> |
Patrick Venture | 664c5bc | 2019-03-07 08:09:45 -0800 | [diff] [blame^] | 6 | #include <ipmiblob/test/blob_interface_mock.hpp> |
Patrick Venture | 8e1b233 | 2019-01-17 15:22:45 -0800 | [diff] [blame] | 7 | |
| 8 | #include <gtest/gtest.h> |
| 9 | |
| 10 | namespace host_tool |
| 11 | { |
| 12 | |
| 13 | using ::testing::ContainerEq; |
| 14 | |
| 15 | TEST(LpcHandleTest, verifySendsFileContents) |
| 16 | { |
Patrick Venture | 69a9e19 | 2019-01-17 16:02:33 -0800 | [diff] [blame] | 17 | internal::InternalSysMock sysMock; |
Patrick Venture | 664c5bc | 2019-03-07 08:09:45 -0800 | [diff] [blame^] | 18 | ipmiblob::BlobInterfaceMock blobMock; |
Patrick Venture | 46bdadc | 2019-01-18 09:04:16 -0800 | [diff] [blame] | 19 | HostIoInterfaceMock ioMock; |
Patrick Venture | 8e1b233 | 2019-01-17 15:22:45 -0800 | [diff] [blame] | 20 | |
Patrick Venture | 46bdadc | 2019-01-18 09:04:16 -0800 | [diff] [blame] | 21 | LpcDataHandler handler(&blobMock, &ioMock, &sysMock); |
Patrick Venture | 8e1b233 | 2019-01-17 15:22:45 -0800 | [diff] [blame] | 22 | std::uint16_t session = 0xbeef; |
| 23 | std::string filePath = "/asdf"; |
| 24 | |
| 25 | LpcRegion host_lpc_buf; |
| 26 | host_lpc_buf.address = 0xfedc1000; |
| 27 | host_lpc_buf.length = 0x1000; |
| 28 | |
| 29 | std::vector<std::uint8_t> bytes(sizeof(host_lpc_buf)); |
| 30 | std::memcpy(bytes.data(), &host_lpc_buf, sizeof(host_lpc_buf)); |
| 31 | |
| 32 | EXPECT_CALL(blobMock, writeMeta(session, 0, ContainerEq(bytes))); |
| 33 | |
| 34 | EXPECT_FALSE(handler.sendContents(filePath, session)); |
| 35 | } |
| 36 | |
| 37 | } // namespace host_tool |