fix(test): fail instead of hang when a region callback check fails

- an ASSERT_* in a region callback returned before blocker.Signal(),
  and the test then waited in blocker.Wait() until the ctest timeout
- use EXPECT_* in the callbacks, so that the signal always comes
- wait with a deadline (test::Semaphore) in the region and message
  tests
- in RegionEventSubscriptions, make the semaphore outlive the factory
  that calls the callback

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-03 14:09:47 +00:00
committed by Dennis Klein
parent f8e1b34fb1
commit 5994ea44de
2 changed files with 32 additions and 29 deletions

View File

@@ -8,7 +8,6 @@
#include <fairmq/Channel.h>
#include <fairmq/ProgOptions.h>
#include <fairmq/tools/Semaphore.h>
#include <fairmq/tools/Strings.h>
#include <fairmq/tools/Unique.h>
#include <fairmq/TransportFactory.h>
@@ -16,6 +15,8 @@
#include <fairlogger/Logger.h>
#include <helper/Sync.h>
#include <gtest/gtest.h>
#include <array>
@@ -317,7 +318,7 @@ auto ZeroCopyFromUnmanaged(string const& address, bool expandedShmMetadata, uint
const size_t regionSize{1000000};
RegionConfig cfg;
cfg.rcSegmentSize = rcSegmentSize;
tools::Semaphore blocker;
test::Semaphore blocker;
auto region = factory1->CreateUnmanagedRegion(regionSize, [&blocker](void*, size_t, void*) {
blocker.Signal();
@@ -391,8 +392,8 @@ auto ZeroCopyFromUnmanaged(string const& address, bool expandedShmMetadata, uint
EXPECT_EQ(static_cast<const shmem::Message&>(*msg1).GetRefCount(), 1);
}
blocker.Wait();
blocker.Wait();
ASSERT_TRUE(blocker.Wait());
ASSERT_TRUE(blocker.Wait());
}
TEST(Resize, zeromq) // NOLINT
@@ -523,7 +524,7 @@ auto SideChannelUnmanaged() -> void
auto consumerFactory(TransportFactory::CreateTransportFactory("shmem", tools::Uuid(), &consumerConfig));
const size_t regionSize = 1000000;
tools::Semaphore blocker;
test::Semaphore blocker;
auto region = producerFactory->CreateUnmanagedRegion(regionSize, [&blocker](void*, size_t, void*) {
blocker.Signal();
});
@@ -545,7 +546,7 @@ auto SideChannelUnmanaged() -> void
EXPECT_EQ(ptr[1], 'B');
msg.reset();
blocker.Wait();
ASSERT_TRUE(blocker.Wait());
}
auto ReuseReceivedRegionMessage() -> void