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
@@ -10,7 +10,9 @@
|
||||
|
||||
#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>
|
||||
|
||||
@@ -23,15 +25,22 @@ using namespace fair::mq::tools;
|
||||
|
||||
auto RunPoller(string transport, int pollType) -> void
|
||||
{
|
||||
size_t session{fair::mq::tools::UuidHash()};
|
||||
size_t session{UuidHash()};
|
||||
string data1IpcFile("/tmp/fmq_" + to_string(session) + "_data1_" + transport);
|
||||
string data2IpcFile("/tmp/fmq_" + to_string(session) + "_data2_" + transport);
|
||||
string data1Address("ipc://" + data1IpcFile);
|
||||
string data2Address("ipc://" + data2IpcFile);
|
||||
|
||||
auto pollout = execute_result{"", 0};
|
||||
thread poll_out_thread([&]() {
|
||||
stringstream cmd;
|
||||
cmd << runTestDevice
|
||||
<< " --id pollout_"<< transport
|
||||
<< " --control static --color false"
|
||||
<< " --session " << session << " --mq-config \"" << mqConfig << "\"";
|
||||
<< " --control static"
|
||||
<< " --color false"
|
||||
<< " --session " << session
|
||||
<< " --channel-config name=data1,type=push,method=bind,address=" << data1Address
|
||||
<< " name=data2,type=push,method=bind,address=" << data2Address;
|
||||
pollout = execute(cmd.str(), "[POLLOUT]");
|
||||
});
|
||||
|
||||
@@ -40,8 +49,12 @@ auto RunPoller(string transport, int pollType) -> void
|
||||
stringstream cmd;
|
||||
cmd << runTestDevice
|
||||
<< " --id pollin_" << transport
|
||||
<< " --control static --color false"
|
||||
<< " --session " << session << " --mq-config \"" << mqConfig << "\" --poll-type " << pollType;
|
||||
<< " --control static"
|
||||
<< " --color false"
|
||||
<< " --session " << session
|
||||
<< " --poll-type " << pollType
|
||||
<< " --channel-config name=data1,type=pull,method=connect,address=" << data1Address
|
||||
<< " name=data2,type=pull,method=connect,address=" << data2Address;
|
||||
pollin = execute(cmd.str(), "[POLLIN]");
|
||||
});
|
||||
|
||||
@@ -49,6 +62,9 @@ auto RunPoller(string transport, int pollType) -> void
|
||||
poll_in_thread.join();
|
||||
cerr << pollout.console_out << pollin.console_out;
|
||||
|
||||
std::remove(data1IpcFile.c_str());
|
||||
std::remove(data2IpcFile.c_str());
|
||||
|
||||
exit(pollout.exit_code + pollin.exit_code);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user