mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Avoid fixed ports in the test suites
This commit is contained in:
committed by
Dennis Klein
parent
bfd08bb33f
commit
f4d39d224b
@@ -9,7 +9,9 @@
|
||||
#include "runner.h"
|
||||
#include <fairmq/tools/Unique.h>
|
||||
#include <fairmq/tools/Process.h>
|
||||
#include <fairmq/tools/Strings.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdio> // std::remove
|
||||
#include <sstream> // std::stringstream
|
||||
#include <thread>
|
||||
|
||||
@@ -22,21 +24,33 @@ using namespace fair::mq::tools;
|
||||
|
||||
auto RunPushPull(string transport) -> void
|
||||
{
|
||||
size_t session{fair::mq::tools::UuidHash()};
|
||||
size_t session(fair::mq::tools::UuidHash());
|
||||
string ipcFile("/tmp/fmq_" + to_string(session) + "_data_" + transport);
|
||||
string address("ipc://" + ipcFile);
|
||||
|
||||
auto push = execute_result{"", 100};
|
||||
thread push_thread([&]() {
|
||||
stringstream cmd;
|
||||
cmd << runTestDevice << " --id push_" << transport << " --control static "
|
||||
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
|
||||
cmd << runTestDevice
|
||||
<< " --id push_" << transport
|
||||
<< " --control static"
|
||||
<< " --shm-segment-size 100000000"
|
||||
<< " --session " << session
|
||||
<< " --color false"
|
||||
<< " --channel-config name=data,type=push,method=bind,address=" << address;
|
||||
push = execute(cmd.str(), "[PUSH]");
|
||||
});
|
||||
|
||||
auto pull = execute_result{"", 100};
|
||||
thread pull_thread([&]() {
|
||||
stringstream cmd;
|
||||
cmd << runTestDevice << " --id pull_" << transport << " --control static "
|
||||
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
|
||||
cmd << runTestDevice
|
||||
<< " --id pull_" << transport
|
||||
<< " --control static"
|
||||
<< " --shm-segment-size 100000000"
|
||||
<< " --session " << session
|
||||
<< " --color false"
|
||||
<< " --channel-config name=data,type=pull,method=connect,address=" << address;
|
||||
pull = execute(cmd.str(), "[PULL]");
|
||||
});
|
||||
|
||||
@@ -44,15 +58,17 @@ auto RunPushPull(string transport) -> void
|
||||
pull_thread.join();
|
||||
cerr << push.console_out << pull.console_out;
|
||||
|
||||
std::remove(ipcFile.c_str());
|
||||
|
||||
exit(push.exit_code + pull.exit_code);
|
||||
}
|
||||
|
||||
TEST(PushPull, SingleMsg_MP_tcp_zeromq)
|
||||
TEST(PushPull, SingleMsg_MP_ipc_zeromq)
|
||||
{
|
||||
EXPECT_EXIT(RunPushPull("zeromq"), ::testing::ExitedWithCode(0), "PUSH-PULL test successfull");
|
||||
}
|
||||
|
||||
TEST(PushPull, SingleMsg_MP_tcp_shmem)
|
||||
TEST(PushPull, SingleMsg_MP_ipc_shmem)
|
||||
{
|
||||
EXPECT_EXIT(RunPushPull("shmem"), ::testing::ExitedWithCode(0), "PUSH-PULL test successfull");
|
||||
}
|
||||
|
Reference in New Issue
Block a user