blob: 3a9d80eb744d52db6aae63288aa2367c6fc187aa [file] [log] [blame]
Patrick Venture8e1b2332019-01-17 15:22:45 -08001#include "blob_interface_mock.hpp"
2#include "internal_sys_mock.hpp"
Patrick Venture46bdadc2019-01-18 09:04:16 -08003#include "io_mock.hpp"
Patrick Venture8e1b2332019-01-17 15:22:45 -08004#include "lpc.hpp"
5
6#include <cstring>
7
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 Venture8e1b2332019-01-17 15:22:45 -080018 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