2019-03-19 00:21:48 +08:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
2022-01-28 17:38:27 +08:00
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2019-03-19 00:21:48 +08:00
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
// Unittest for the sandbox2::Comms class.
|
|
|
|
|
|
|
|
#include "sandboxed_api/sandbox2/comms.h"
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/socket.h>
|
2023-08-24 21:23:03 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2021-12-03 21:20:13 +08:00
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
#include <cstdint>
|
2019-03-19 00:21:48 +08:00
|
|
|
#include <cstring>
|
2023-08-24 00:03:05 +08:00
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2019-03-19 00:21:48 +08:00
|
|
|
#include <thread> // NOLINT(build/c++11)
|
2023-08-24 00:03:05 +08:00
|
|
|
#include <vector>
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
#include "gmock/gmock.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "absl/container/fixed_array.h"
|
2022-10-20 21:48:06 +08:00
|
|
|
#include "absl/log/check.h"
|
|
|
|
#include "absl/log/log.h"
|
2023-08-24 00:03:05 +08:00
|
|
|
#include "absl/status/status.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
#include "absl/strings/string_view.h"
|
|
|
|
#include "sandboxed_api/sandbox2/comms_test.pb.h"
|
|
|
|
#include "sandboxed_api/util/status_matchers.h"
|
|
|
|
|
|
|
|
using ::sapi::IsOk;
|
|
|
|
using ::sapi::StatusIs;
|
|
|
|
using ::testing::Eq;
|
|
|
|
using ::testing::IsFalse;
|
|
|
|
using ::testing::IsTrue;
|
|
|
|
|
|
|
|
namespace sandbox2 {
|
|
|
|
|
|
|
|
using CommunicationHandler = std::function<void(Comms* comms)>;
|
|
|
|
|
2022-03-29 22:16:05 +08:00
|
|
|
constexpr char kProtoStr[] = "ABCD";
|
2023-03-23 22:33:49 +08:00
|
|
|
static absl::string_view NullTestString() {
|
2019-03-19 00:21:48 +08:00
|
|
|
static constexpr char kHelperStr[] = "test\0\n\r\t\x01\x02";
|
|
|
|
return absl::string_view(kHelperStr, sizeof(kHelperStr) - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper function that handles the communication between the two handler
|
|
|
|
// functions.
|
2023-09-20 14:54:18 +08:00
|
|
|
void HandleCommunication(const CommunicationHandler& a,
|
2019-03-19 00:21:48 +08:00
|
|
|
const CommunicationHandler& b) {
|
2023-09-20 14:54:18 +08:00
|
|
|
int sv[2];
|
|
|
|
CHECK_NE(socketpair(AF_UNIX, SOCK_STREAM, 0, sv), -1);
|
|
|
|
Comms comms(sv[0]);
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
// Start handler a.
|
2023-09-20 14:54:18 +08:00
|
|
|
std::thread remote([sv, &a]() {
|
|
|
|
Comms my_comms(sv[1]);
|
2019-03-19 00:21:48 +08:00
|
|
|
a(&my_comms);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Accept connection and run handler b.
|
|
|
|
b(&comms);
|
|
|
|
remote.join();
|
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecv8) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Send Uint8.
|
|
|
|
ASSERT_THAT(comms->SendUint8(192), IsTrue());
|
|
|
|
|
|
|
|
// Recv Int8.
|
|
|
|
int8_t tmp8;
|
|
|
|
ASSERT_THAT(comms->RecvInt8(&tmp8), IsTrue());
|
|
|
|
EXPECT_THAT(tmp8, Eq(-7));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Recv Uint8.
|
|
|
|
uint8_t tmpu8;
|
|
|
|
ASSERT_THAT(comms->RecvUint8(&tmpu8), IsTrue());
|
|
|
|
EXPECT_THAT(tmpu8, Eq(192));
|
|
|
|
|
|
|
|
// Send Int8.
|
|
|
|
ASSERT_THAT(comms->SendInt8(-7), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecv16) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Send Uint16.
|
|
|
|
ASSERT_THAT(comms->SendUint16(40001), IsTrue());
|
|
|
|
|
|
|
|
// Recv Int16.
|
|
|
|
int16_t tmp16;
|
|
|
|
ASSERT_THAT(comms->RecvInt16(&tmp16), IsTrue());
|
|
|
|
EXPECT_THAT(tmp16, Eq(-22050));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Recv Uint16.
|
|
|
|
uint16_t tmpu16;
|
|
|
|
ASSERT_THAT(comms->RecvUint16(&tmpu16), IsTrue());
|
|
|
|
EXPECT_THAT(tmpu16, Eq(40001));
|
|
|
|
|
|
|
|
// Send Int16.
|
|
|
|
ASSERT_THAT(comms->SendInt16(-22050), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecv32) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// SendUint32.
|
|
|
|
ASSERT_THAT(comms->SendUint32(3221225472UL), IsTrue());
|
|
|
|
|
|
|
|
// Recv Int32.
|
|
|
|
int32_t tmp32;
|
|
|
|
ASSERT_THAT(comms->RecvInt32(&tmp32), IsTrue());
|
|
|
|
EXPECT_THAT(tmp32, Eq(-1073741824));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Recv Uint32.
|
|
|
|
uint32_t tmpu32;
|
|
|
|
ASSERT_THAT(comms->RecvUint32(&tmpu32), IsTrue());
|
|
|
|
EXPECT_THAT(tmpu32, Eq(3221225472UL));
|
|
|
|
|
|
|
|
// Send Int32.
|
|
|
|
ASSERT_THAT(comms->SendInt32(-1073741824), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecv64) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// SendUint64.
|
|
|
|
ASSERT_THAT(comms->SendUint64(1099511627776ULL), IsTrue());
|
|
|
|
|
|
|
|
// Recv Int64.
|
2020-10-01 21:44:57 +08:00
|
|
|
int64_t tmp64;
|
2019-03-19 00:21:48 +08:00
|
|
|
ASSERT_THAT(comms->RecvInt64(&tmp64), IsTrue());
|
|
|
|
EXPECT_THAT(tmp64, Eq(-1099511627776LL));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Recv Uint64.
|
2020-10-01 21:44:57 +08:00
|
|
|
uint64_t tmpu64;
|
2019-03-19 00:21:48 +08:00
|
|
|
ASSERT_THAT(comms->RecvUint64(&tmpu64), IsTrue());
|
|
|
|
EXPECT_THAT(tmpu64, Eq(1099511627776ULL));
|
|
|
|
|
|
|
|
// Send Int64.
|
|
|
|
ASSERT_THAT(comms->SendInt64(-1099511627776LL), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestTypeMismatch) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
uint8_t tmpu8;
|
|
|
|
// Receive Int8 (but Uint8 expected).
|
|
|
|
EXPECT_THAT(comms->RecvUint8(&tmpu8), IsFalse());
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send Int8 (but Uint8 expected).
|
|
|
|
ASSERT_THAT(comms->SendInt8(-93), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvString) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
std::string tmps;
|
|
|
|
ASSERT_THAT(comms->RecvString(&tmps), IsTrue());
|
|
|
|
EXPECT_TRUE(tmps == NullTestString());
|
|
|
|
EXPECT_THAT(tmps.size(), Eq(NullTestString().size()));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
ASSERT_THAT(comms->SendString(std::string(NullTestString())), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvArray) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Receive 1M bytes.
|
|
|
|
std::vector<uint8_t> buffer;
|
|
|
|
ASSERT_THAT(comms->RecvBytes(&buffer), IsTrue());
|
|
|
|
EXPECT_THAT(buffer.size(), Eq(1024 * 1024));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send 1M bytes.
|
|
|
|
std::vector<uint8_t> buffer(1024 * 1024);
|
|
|
|
memset(buffer.data(), 0, buffer.size());
|
|
|
|
ASSERT_THAT(comms->SendBytes(buffer), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvFD) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Receive FD and test it.
|
|
|
|
int fd = -1;
|
|
|
|
ASSERT_THAT(comms->RecvFD(&fd), IsTrue());
|
|
|
|
EXPECT_GE(fd, 0);
|
|
|
|
EXPECT_NE(fcntl(fd, F_GETFD), -1);
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send our STDERR to the thread.
|
|
|
|
ASSERT_THAT(comms->SendFD(STDERR_FILENO), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvEmptyTLV) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Receive TLV without a value.
|
|
|
|
uint32_t tag;
|
|
|
|
std::vector<uint8_t> value;
|
|
|
|
ASSERT_THAT(comms->RecvTLV(&tag, &value), IsTrue()); // NOLINT
|
|
|
|
EXPECT_THAT(tag, Eq(0x00DEADBE));
|
|
|
|
EXPECT_THAT(value.size(), Eq(0));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send TLV without a value.
|
|
|
|
ASSERT_THAT(comms->SendTLV(0x00DEADBE, 0, nullptr), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvEmptyTLV2) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Receive TLV without a value.
|
|
|
|
uint32_t tag;
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
ASSERT_THAT(comms->RecvTLV(&tag, &data), IsTrue());
|
|
|
|
EXPECT_THAT(tag, Eq(0x00DEADBE));
|
|
|
|
EXPECT_THAT(data.size(), Eq(0));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send TLV without a value.
|
|
|
|
ASSERT_THAT(comms->SendTLV(0x00DEADBE, 0, nullptr), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvProto) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Receive a ProtoBuf.
|
|
|
|
std::unique_ptr<CommsTestMsg> comms_msg(new CommsTestMsg());
|
|
|
|
ASSERT_THAT(comms->RecvProtoBuf(comms_msg.get()), IsTrue());
|
2022-03-29 22:16:05 +08:00
|
|
|
ASSERT_THAT(comms_msg->value_size(), Eq(1));
|
|
|
|
EXPECT_THAT(comms_msg->value(0), Eq(kProtoStr));
|
2019-03-19 00:21:48 +08:00
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send a ProtoBuf.
|
|
|
|
std::unique_ptr<CommsTestMsg> comms_msg(new CommsTestMsg());
|
2022-03-29 22:16:05 +08:00
|
|
|
comms_msg->add_value(kProtoStr);
|
|
|
|
ASSERT_THAT(comms_msg->value_size(), Eq(1));
|
2019-03-19 00:21:48 +08:00
|
|
|
ASSERT_THAT(comms->SendProtoBuf(*comms_msg), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvStatusOK) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Receive a good status.
|
2020-02-28 01:23:44 +08:00
|
|
|
absl::Status status;
|
2019-03-19 00:21:48 +08:00
|
|
|
ASSERT_THAT(comms->RecvStatus(&status), IsTrue());
|
|
|
|
EXPECT_THAT(status, IsOk());
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send a good status.
|
2020-02-28 01:23:44 +08:00
|
|
|
ASSERT_THAT(comms->SendStatus(absl::OkStatus()), IsTrue());
|
2019-03-19 00:21:48 +08:00
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvStatusFailing) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Receive a failing status.
|
2020-02-28 01:23:44 +08:00
|
|
|
absl::Status status;
|
2019-03-19 00:21:48 +08:00
|
|
|
ASSERT_THAT(comms->RecvStatus(&status), IsTrue());
|
|
|
|
EXPECT_THAT(status, Not(IsOk()));
|
2020-02-28 01:23:44 +08:00
|
|
|
EXPECT_THAT(status, StatusIs(absl::StatusCode::kInternal, "something odd"));
|
2019-03-19 00:21:48 +08:00
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send a failing status.
|
|
|
|
ASSERT_THAT(comms->SendStatus(
|
2020-02-28 01:23:44 +08:00
|
|
|
absl::Status{absl::StatusCode::kInternal, "something odd"}),
|
2019-03-19 00:21:48 +08:00
|
|
|
IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestUsesDistinctBuffers) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Receive 1M bytes.
|
|
|
|
std::vector<uint8_t> buffer1, buffer2;
|
|
|
|
ASSERT_THAT(comms->RecvBytes(&buffer1), IsTrue()); // NOLINT
|
|
|
|
EXPECT_THAT(buffer1.size(), Eq(1024 * 1024));
|
|
|
|
|
|
|
|
ASSERT_THAT(comms->RecvBytes(&buffer2), IsTrue()); // NOLINT
|
|
|
|
EXPECT_THAT(buffer2.size(), Eq(1024 * 1024));
|
|
|
|
|
|
|
|
// Make sure we can access the buffer (memory was not free'd).
|
|
|
|
// Probably only useful when running with ASAN/MSAN.
|
|
|
|
EXPECT_THAT(buffer1[1024 * 1024 - 1], Eq(buffer1[1024 * 1024 - 1]));
|
|
|
|
EXPECT_THAT(buffer2[1024 * 1024 - 1], Eq(buffer2[1024 * 1024 - 1]));
|
|
|
|
EXPECT_NE(buffer1.data(), buffer2.data());
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send 1M bytes.
|
|
|
|
absl::FixedArray<uint8_t> buf(1024 * 1024);
|
|
|
|
memset(buf.data(), 0, buf.size());
|
|
|
|
ASSERT_THAT(comms->SendBytes(buf.data(), buf.size()), IsTrue());
|
|
|
|
ASSERT_THAT(comms->SendBytes(buf.data(), buf.size()), IsTrue());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvCredentials) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Check credentials.
|
|
|
|
pid_t pid;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
ASSERT_THAT(comms->RecvCreds(&pid, &uid, &gid), IsTrue());
|
|
|
|
EXPECT_THAT(pid, Eq(getpid()));
|
|
|
|
EXPECT_THAT(uid, Eq(getuid()));
|
|
|
|
EXPECT_THAT(gid, Eq(getgid()));
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Nothing to do here.
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendTooMuchData) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
// Nothing to do here.
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
// Send too much data.
|
|
|
|
ASSERT_THAT(comms->SendBytes(nullptr, comms->GetMaxMsgSize() + 1),
|
|
|
|
IsFalse());
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:54:18 +08:00
|
|
|
TEST(CommsTest, TestSendRecvBytes) {
|
2019-03-19 00:21:48 +08:00
|
|
|
auto a = [](Comms* comms) {
|
|
|
|
std::vector<uint8_t> buffer;
|
|
|
|
ASSERT_THAT(comms->RecvBytes(&buffer), IsTrue());
|
|
|
|
ASSERT_THAT(comms->SendBytes(buffer), IsTrue());
|
|
|
|
};
|
|
|
|
auto b = [](Comms* comms) {
|
|
|
|
const std::vector<uint8_t> request = {0, 1, 2, 3, 7};
|
|
|
|
ASSERT_THAT(comms->SendBytes(request), IsTrue());
|
|
|
|
|
|
|
|
std::vector<uint8_t> response;
|
|
|
|
ASSERT_THAT(comms->RecvBytes(&response), IsTrue());
|
|
|
|
EXPECT_THAT(request, Eq(response));
|
|
|
|
};
|
2023-09-20 14:54:18 +08:00
|
|
|
HandleCommunication(a, b);
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-09-21 21:17:00 +08:00
|
|
|
// We cannot test this in the Client or Server tests, as the endpoint needs to
|
|
|
|
// be unconnected.
|
|
|
|
TEST(CommsTest, TestMsgSize) {
|
|
|
|
// There will be no actual connection to this socket.
|
|
|
|
const std::string socket_name = "sandbox2_comms_msg_size_test";
|
|
|
|
Comms c(socket_name);
|
|
|
|
}
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
} // namespace sandbox2
|