mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Add test for shm transport options
This commit is contained in:
parent
beb7766fca
commit
3eca8e9def
|
@ -95,14 +95,14 @@ class Manager
|
|||
|
||||
LOG(debug) << "created/opened shared memory segment '" << "fmq_" << fShmId << "_main" << "' of " << fSegment.get_size() << " bytes. Available are " << fSegment.get_free_memory() << " bytes.";
|
||||
if (mlockSegment) {
|
||||
LOG(debug) << "Locking the memory pages behind the managed segment...";
|
||||
LOG(debug) << "Locking the managed segment memory pages...";
|
||||
mlock(fSegment.get_address(), fSegment.get_size());
|
||||
LOG(debug) << "Successfully locked the memory pages.";
|
||||
LOG(debug) << "Successfully locked the managed segment memory pages.";
|
||||
}
|
||||
if (zeroSegment) {
|
||||
LOG(debug) << "Zeroing the free memory of the managed segment...";
|
||||
LOG(debug) << "Zeroing the managed segment free memory...";
|
||||
fSegment.zero_free_memory();
|
||||
LOG(debug) << "Successfully zeroed the free memory of the managed segment";
|
||||
LOG(debug) << "Successfully zeroed the managed segment free memory.";
|
||||
}
|
||||
|
||||
fRegionInfos = fManagementSegment.find_or_construct<Uint64RegionInfoMap>(unique_instance)(fShmVoidAlloc);
|
||||
|
|
|
@ -66,6 +66,24 @@ void RunOptionsTest(const string& transport)
|
|||
ASSERT_EQ(channel.GetSocket().GetRcvKernelSize(), 8000);
|
||||
}
|
||||
|
||||
void ZeroingAndMlock(const string& transport)
|
||||
{
|
||||
size_t session{fair::mq::tools::UuidHash()};
|
||||
|
||||
fair::mq::ProgOptions config;
|
||||
config.SetProperty<string>("session", to_string(session));
|
||||
config.SetProperty<size_t>("shm-segment-size", 16384);
|
||||
config.SetProperty<bool>("shm-zero-segment", true);
|
||||
config.SetProperty<bool>("shm-mlock-segment", true);
|
||||
|
||||
auto factory = FairMQTransportFactory::CreateTransportFactory(transport, fair::mq::tools::Uuid(), &config);
|
||||
|
||||
FairMQMessagePtr outMsg(factory->CreateMessage(10000));
|
||||
char test[10000];
|
||||
memset(test, 0, sizeof(test));
|
||||
ASSERT_EQ(memcmp(test, outMsg->GetData(), outMsg->GetSize()), 0);
|
||||
}
|
||||
|
||||
TEST(Options, zeromq)
|
||||
{
|
||||
RunOptionsTest("zeromq");
|
||||
|
@ -76,4 +94,9 @@ TEST(Options, shmem)
|
|||
RunOptionsTest("shmem");
|
||||
}
|
||||
|
||||
TEST(ZeroingAndMlock, shmem)
|
||||
{
|
||||
ZeroingAndMlock("shmem");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue
Block a user