mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
fix(test): check the results of Bind, Connect, Send and Receive
- the message, region, channel and transport tests ignored the return values of these calls; a failed bind or a short transfer showed up later as an unrelated failure, or not at all - assert each result where the test uses it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -110,13 +110,13 @@ auto testConnectedPeers(std::string const& transport)
|
||||
|
||||
Channel ch1("ch1", "pair", factory);
|
||||
ASSERT_EQ(ch1.GetNumberOfConnectedPeers(), zero);
|
||||
ch1.Bind(address);
|
||||
ASSERT_TRUE(ch1.Bind(address));
|
||||
ASSERT_EQ(ch1.GetNumberOfConnectedPeers(), zero);
|
||||
|
||||
{
|
||||
Channel ch2("ch2", "pair", factory);
|
||||
ASSERT_EQ(ch2.GetNumberOfConnectedPeers(), zero);
|
||||
ch2.Connect(address);
|
||||
ASSERT_TRUE(ch2.Connect(address));
|
||||
std::this_thread::sleep_for(100ms);
|
||||
ASSERT_EQ(ch1.GetNumberOfConnectedPeers(), one);
|
||||
ASSERT_EQ(ch2.GetNumberOfConnectedPeers(), one);
|
||||
|
||||
@@ -55,8 +55,8 @@ auto RunPushPullWithMsgResize(string const & transport, string const & _address,
|
||||
Channel push{"Push", "push", factory};
|
||||
Channel pull{"Pull", "pull", factory};
|
||||
auto const address(tools::ToString(_address, "_", transport, "_", config.GetProperty<string>("session")));
|
||||
push.Bind(address);
|
||||
pull.Connect(address);
|
||||
ASSERT_TRUE(push.Bind(address));
|
||||
ASSERT_TRUE(pull.Connect(address));
|
||||
|
||||
{
|
||||
size_t const size{6};
|
||||
@@ -158,8 +158,8 @@ auto RunPushPullWithAlignment(string const& transport, string const& _address, b
|
||||
Channel push{"Push", "push", factory};
|
||||
Channel pull{"Pull", "pull", factory};
|
||||
auto const address(tools::ToString(_address, "_", transport, "_", config.GetProperty<string>("session")));
|
||||
push.Bind(address);
|
||||
pull.Connect(address);
|
||||
ASSERT_TRUE(push.Bind(address));
|
||||
ASSERT_TRUE(pull.Connect(address));
|
||||
|
||||
{
|
||||
Alignment const align{64};
|
||||
@@ -216,8 +216,8 @@ auto EmptyMessage(string const& transport, string const& _address, bool expanded
|
||||
Channel push{"Push", "push", factory};
|
||||
Channel pull{"Pull", "pull", factory};
|
||||
auto const address(tools::ToString(_address, "_", transport, "_", config.GetProperty<string>("session")));
|
||||
push.Bind(address);
|
||||
pull.Connect(address);
|
||||
ASSERT_TRUE(push.Bind(address));
|
||||
ASSERT_TRUE(pull.Connect(address));
|
||||
|
||||
{
|
||||
auto outMsg(push.NewMessage());
|
||||
@@ -329,8 +329,8 @@ auto ZeroCopyFromUnmanaged(string const& address, bool expandedShmMetadata, uint
|
||||
Channel push("Push", "push", factory1);
|
||||
Channel pull("Pull", "pull", factory2);
|
||||
|
||||
push.Bind(address + "_" + session);
|
||||
pull.Connect(address + "_" + session);
|
||||
ASSERT_TRUE(push.Bind(address + "_" + session));
|
||||
ASSERT_TRUE(pull.Connect(address + "_" + session));
|
||||
|
||||
const size_t offset = 100;
|
||||
auto msg1(push.NewMessage(region, static_cast<char*>(region->GetData()), msgSize, nullptr));
|
||||
@@ -362,13 +362,13 @@ auto ZeroCopyFromUnmanaged(string const& address, bool expandedShmMetadata, uint
|
||||
ASSERT_EQ(AsStringView(*msg1)[0], 'A');
|
||||
ASSERT_EQ(AsStringView(*msg1)[1], 'B');
|
||||
|
||||
push.Send(copyFromCopy);
|
||||
push.Send(msg2);
|
||||
ASSERT_EQ(push.Send(copyFromCopy), msgSize);
|
||||
ASSERT_EQ(push.Send(msg2), msgSize);
|
||||
|
||||
auto incomingCopiedMsg(pull.NewMessage());
|
||||
auto incomingOriginalMsg(pull.NewMessage());
|
||||
pull.Receive(incomingCopiedMsg);
|
||||
pull.Receive(incomingOriginalMsg);
|
||||
ASSERT_EQ(pull.Receive(incomingCopiedMsg), msgSize);
|
||||
ASSERT_EQ(pull.Receive(incomingOriginalMsg), msgSize);
|
||||
|
||||
EXPECT_EQ(static_cast<const shmem::Message&>(*incomingCopiedMsg).GetRefCount(), 3);
|
||||
EXPECT_EQ(static_cast<const shmem::Message&>(*incomingOriginalMsg).GetRefCount(), 1);
|
||||
@@ -573,8 +573,8 @@ auto ReuseReceivedRegionMessage() -> void
|
||||
Channel push{"Push", "push", factory};
|
||||
Channel pull{"Pull", "pull", factory};
|
||||
auto const address(tools::ToString("ipc://test_reuse_received_region_msg_", config.GetProperty<string>("session")));
|
||||
push.Bind(address);
|
||||
pull.Connect(address);
|
||||
ASSERT_TRUE(push.Bind(address));
|
||||
ASSERT_TRUE(pull.Connect(address));
|
||||
|
||||
// Receive a block of region A and read it. This resolves region A in the message.
|
||||
auto inMsg(pull.NewMessage());
|
||||
|
||||
@@ -110,12 +110,12 @@ void RegionsCache(const string& transport, const string& _address)
|
||||
|
||||
Channel push1("Push1", "push", factory1);
|
||||
Channel pull1("Pull1", "pull", factory1);
|
||||
push1.Bind(address + to_string(1));
|
||||
pull1.Connect(address + to_string(1));
|
||||
ASSERT_TRUE(push1.Bind(address + to_string(1)));
|
||||
ASSERT_TRUE(pull1.Connect(address + to_string(1)));
|
||||
Channel push2("Push2", "push", factory2);
|
||||
Channel pull2("Pull2", "pull", factory2);
|
||||
push2.Bind(address + to_string(2));
|
||||
pull2.Connect(address + to_string(2));
|
||||
ASSERT_TRUE(push2.Bind(address + to_string(2)));
|
||||
ASSERT_TRUE(pull2.Connect(address + to_string(2)));
|
||||
|
||||
{
|
||||
static_cast<char*>(r1ptr)[0] = 97; // a
|
||||
@@ -125,13 +125,13 @@ void RegionsCache(const string& transport, const string& _address)
|
||||
|
||||
MessagePtr m1(push1.NewMessage(region1, r1ptr, 100, nullptr));
|
||||
MessagePtr m2(push1.NewMessage(region1, static_cast<char*>(r1ptr) + 100, 100, nullptr));
|
||||
push1.Send(m1);
|
||||
push1.Send(m2);
|
||||
ASSERT_EQ(push1.Send(m1), 100);
|
||||
ASSERT_EQ(push1.Send(m2), 100);
|
||||
|
||||
MessagePtr m3(push2.NewMessage(region2, r2ptr, 100, nullptr));
|
||||
MessagePtr m4(push2.NewMessage(region2, static_cast<char*>(r2ptr) + 100, 100, nullptr));
|
||||
push2.Send(m3);
|
||||
push2.Send(m4);
|
||||
ASSERT_EQ(push2.Send(m3), 100);
|
||||
ASSERT_EQ(push2.Send(m4), 100);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -287,10 +287,10 @@ void RegionCallbacks(const string& transport, const string& _address)
|
||||
tools::Semaphore blocker;
|
||||
|
||||
Channel push("Push", "push", factory);
|
||||
push.Bind(address);
|
||||
ASSERT_TRUE(push.Bind(address));
|
||||
|
||||
Channel pull("Pull", "pull", factory);
|
||||
pull.Connect(address);
|
||||
ASSERT_TRUE(pull.Connect(address));
|
||||
|
||||
void* ptr1 = nullptr;
|
||||
size_t size1 = 100;
|
||||
@@ -353,9 +353,9 @@ void RegionCallbackCallsTransportDuringDestruction(const string& transport, cons
|
||||
auto factory = TransportFactory::CreateTransportFactory(transport, tools::Uuid(), &config);
|
||||
|
||||
Channel push("Push", "push", factory);
|
||||
push.Bind(address);
|
||||
ASSERT_TRUE(push.Bind(address));
|
||||
Channel pull("Pull", "pull", factory);
|
||||
pull.Connect(address);
|
||||
ASSERT_TRUE(pull.Connect(address));
|
||||
|
||||
atomic<int> numCallbacks(0);
|
||||
auto region = factory->CreateUnmanagedRegion(1000000, [&](void*, size_t, void*) {
|
||||
@@ -393,9 +393,9 @@ void RegionLockOrder(const string& _address)
|
||||
auto factory2 = TransportFactory::CreateTransportFactory("shmem", tools::Uuid(), &config);
|
||||
|
||||
Channel push("Push", "push", factory2);
|
||||
push.Bind(address);
|
||||
ASSERT_TRUE(push.Bind(address));
|
||||
Channel pull("Pull", "pull", factory1);
|
||||
pull.Connect(address);
|
||||
ASSERT_TRUE(pull.Connect(address));
|
||||
|
||||
vector<UnmanagedRegionPtr> peerRegions;
|
||||
for (int i = 0; i < numIterations; ++i) {
|
||||
|
||||
@@ -81,7 +81,7 @@ void InterruptTransfer(const string& transport, const string& _address)
|
||||
auto factory = TransportFactory::CreateTransportFactory(transport, Uuid(), &config);
|
||||
|
||||
Channel pull{"Pull", "pull", factory};
|
||||
pull.Bind(address);
|
||||
ASSERT_TRUE(pull.Bind(address));
|
||||
|
||||
MessagePtr msg(pull.NewMessage());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user