blob: 1645ea5ed5b81dae30a38d2c96affed02155da5e [file] [log] [blame]
Patrick Venture8e1b2332019-01-17 15:22:45 -08001#include "internal_sys_mock.hpp"
Patrick Venture46bdadc2019-01-18 09:04:16 -08002#include "io_mock.hpp"
Patrick Venture8e1b2332019-01-17 15:22:45 -08003#include "lpc.hpp"
4
5#include <cstring>
Patrick Venture664c5bc2019-03-07 08:09:45 -08006#include <ipmiblob/test/blob_interface_mock.hpp>
Patrick Venture8e1b2332019-01-17 15:22:45 -08007
8#include <gtest/gtest.h>
9
10namespace host_tool
11{
12
13using ::testing::ContainerEq;
14
15TEST(LpcHandleTest, verifySendsFileContents)
16{
Patrick Venture69a9e192019-01-17 16:02:33 -080017 internal::InternalSysMock sysMock;
Patrick Venture664c5bc2019-03-07 08:09:45 -080018 ipmiblob::BlobInterfaceMock blobMock;
Patrick Venture46bdadc2019-01-18 09:04:16 -080019 HostIoInterfaceMock ioMock;
Patrick Venture8e1b2332019-01-17 15:22:45 -080020
Patrick Venture46bdadc2019-01-18 09:04:16 -080021 LpcDataHandler handler(&blobMock, &ioMock, &sysMock);
Patrick Venture8e1b2332019-01-17 15:22:45 -080022 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