// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #include #include "../framework.hpp" // TODO: TransportFlags needs operator<< for EXPECT_EQ to work // Using ASSERT_TRUE with manual comparisons as workaround class LocalCommunicatorTest : public ::mscclpp::test::TestCase { protected: void SetUp() override { bootstrap = std::make_shared(0, 1); bootstrap->initialize(bootstrap->createUniqueId()); comm = std::make_shared(bootstrap); } std::shared_ptr bootstrap; std::shared_ptr comm; }; TEST(LocalCommunicatorTest, RegisterMemory) { int dummy[42]; auto memory = comm->registerMemory(&dummy, sizeof(dummy), mscclpp::NoTransports); EXPECT_EQ(memory.data(), &dummy); EXPECT_EQ(memory.size(), sizeof(dummy)); ASSERT_TRUE(memory.transports() == mscclpp::NoTransports); } TEST(LocalCommunicatorTest, SendMemoryToSelf) { int dummy[42]; auto memory = comm->registerMemory(&dummy, sizeof(dummy), mscclpp::NoTransports); comm->sendMemory(memory, 0); auto memoryFuture = comm->recvMemory(0); auto sameMemory = memoryFuture.get(); EXPECT_EQ(sameMemory.data(), memory.data()); EXPECT_EQ(sameMemory.size(), memory.size()); ASSERT_TRUE(sameMemory.transports() == memory.transports()); }