From c78b7e4cfae7c6fc668207a4d8e4b85cc6c9c373 Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Mon, 27 Feb 2017 16:40:07 +0100 Subject: [PATCH] Fix nanomsg tests --- fairmq/test/pub-sub/runTestPub.cxx | 9 ++++++++ fairmq/test/pub-sub/runTestSub.cxx | 12 ++++++++-- fairmq/test/push-pull/runTestPull.cxx | 9 ++++++++ fairmq/test/push-pull/runTestPush.cxx | 9 ++++++++ fairmq/test/req-rep/runTestRep.cxx | 12 ++++++++-- fairmq/test/req-rep/runTestReq.cxx | 12 ++++++++-- fairmq/test/runTransferTimeoutTest.cxx | 31 +++++++++++++++++--------- 7 files changed, 77 insertions(+), 17 deletions(-) diff --git a/fairmq/test/pub-sub/runTestPub.cxx b/fairmq/test/pub-sub/runTestPub.cxx index 4c8deed2..e841267f 100644 --- a/fairmq/test/pub-sub/runTestPub.cxx +++ b/fairmq/test/pub-sub/runTestPub.cxx @@ -15,6 +15,9 @@ #include "FairMQLogger.h" #include "FairMQTestPub.h" +#include +#include + int main(int argc, char** argv) { reinit_logger(false); @@ -67,6 +70,12 @@ int main(int argc, char** argv) testPub.ChangeState("RUN"); testPub.WaitForEndOfState("RUN"); + // nanomsg does not implement the LINGER option. Give the sockets some time before their queues are terminated + if (transport == "nanomsg") + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + testPub.ChangeState("RESET_TASK"); testPub.WaitForEndOfState("RESET_TASK"); diff --git a/fairmq/test/pub-sub/runTestSub.cxx b/fairmq/test/pub-sub/runTestSub.cxx index 3540ccad..d79fd3f6 100644 --- a/fairmq/test/pub-sub/runTestSub.cxx +++ b/fairmq/test/pub-sub/runTestSub.cxx @@ -12,11 +12,13 @@ * @author A. Rybalchenko */ -#include - #include "FairMQLogger.h" #include "FairMQTestSub.h" +#include +#include +#include + int main(int argc, char** argv) { reinit_logger(false); @@ -70,6 +72,12 @@ int main(int argc, char** argv) testSub.ChangeState("RUN"); testSub.WaitForEndOfState("RUN"); + // nanomsg does not implement the LINGER option. Give the sockets some time before their queues are terminated + if (transport == "nanomsg") + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + testSub.ChangeState("RESET_TASK"); testSub.WaitForEndOfState("RESET_TASK"); diff --git a/fairmq/test/push-pull/runTestPull.cxx b/fairmq/test/push-pull/runTestPull.cxx index 52035e22..34377eb6 100644 --- a/fairmq/test/push-pull/runTestPull.cxx +++ b/fairmq/test/push-pull/runTestPull.cxx @@ -15,6 +15,9 @@ #include "FairMQLogger.h" #include "FairMQTestPull.h" +#include +#include + int main(int argc, char** argv) { reinit_logger(false); @@ -59,6 +62,12 @@ int main(int argc, char** argv) testPull.ChangeState("RUN"); testPull.WaitForEndOfState("RUN"); + // nanomsg does not implement the LINGER option. Give the sockets some time before their queues are terminated + if (transport == "nanomsg") + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + testPull.ChangeState("RESET_TASK"); testPull.WaitForEndOfState("RESET_TASK"); diff --git a/fairmq/test/push-pull/runTestPush.cxx b/fairmq/test/push-pull/runTestPush.cxx index 99cf2c4f..8c4ecef8 100644 --- a/fairmq/test/push-pull/runTestPush.cxx +++ b/fairmq/test/push-pull/runTestPush.cxx @@ -15,6 +15,9 @@ #include "FairMQLogger.h" #include "FairMQTestPush.h" +#include +#include + int main(int argc, char** argv) { reinit_logger(false); @@ -60,6 +63,12 @@ int main(int argc, char** argv) testPush.ChangeState("RUN"); testPush.WaitForEndOfState("RUN"); + // nanomsg does not implement the LINGER option. Give the sockets some time before their queues are terminated + if (transport == "nanomsg") + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + testPush.ChangeState("RESET_TASK"); testPush.WaitForEndOfState("RESET_TASK"); diff --git a/fairmq/test/req-rep/runTestRep.cxx b/fairmq/test/req-rep/runTestRep.cxx index 8b9f0c7d..77fa8991 100644 --- a/fairmq/test/req-rep/runTestRep.cxx +++ b/fairmq/test/req-rep/runTestRep.cxx @@ -12,11 +12,13 @@ * @author A. Rybalchenko */ -#include - #include "FairMQLogger.h" #include "FairMQTestRep.h" +#include +#include +#include + int main(int argc, char** argv) { reinit_logger(false); @@ -61,6 +63,12 @@ int main(int argc, char** argv) testRep.ChangeState("RUN"); testRep.WaitForEndOfState("RUN"); + // nanomsg does not implement the LINGER option. Give the sockets some time before their queues are terminated + if (transport == "nanomsg") + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + testRep.ChangeState("RESET_TASK"); testRep.WaitForEndOfState("RESET_TASK"); diff --git a/fairmq/test/req-rep/runTestReq.cxx b/fairmq/test/req-rep/runTestReq.cxx index 5f0e1d3c..925a6bfb 100644 --- a/fairmq/test/req-rep/runTestReq.cxx +++ b/fairmq/test/req-rep/runTestReq.cxx @@ -12,11 +12,13 @@ * @author A. Rybalchenko */ -#include - #include "FairMQLogger.h" #include "FairMQTestReq.h" +#include +#include +#include + int main(int argc, char** argv) { reinit_logger(false); @@ -62,6 +64,12 @@ int main(int argc, char** argv) testReq.ChangeState("RUN"); testReq.WaitForEndOfState("RUN"); + // nanomsg does not implement the LINGER option. Give the sockets some time before their queues are terminated + if (transport == "nanomsg") + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + testReq.ChangeState("RESET_TASK"); testReq.WaitForEndOfState("RESET_TASK"); diff --git a/fairmq/test/runTransferTimeoutTest.cxx b/fairmq/test/runTransferTimeoutTest.cxx index 7005ad2b..21e3f4d5 100644 --- a/fairmq/test/runTransferTimeoutTest.cxx +++ b/fairmq/test/runTransferTimeoutTest.cxx @@ -15,6 +15,9 @@ #include "FairMQLogger.h" #include "FairMQDevice.h" +#include +#include + class TransferTimeoutTester : public FairMQDevice { public: @@ -110,22 +113,28 @@ int main(int argc, char** argv) dataInChannel.UpdateRateLogging(0); timeoutTester.fChannels["data-in"].push_back(dataInChannel); - timeoutTester.ChangeState(TransferTimeoutTester::INIT_DEVICE); - timeoutTester.WaitForEndOfState(TransferTimeoutTester::INIT_DEVICE); + timeoutTester.ChangeState("INIT_DEVICE"); + timeoutTester.WaitForEndOfState("INIT_DEVICE"); - timeoutTester.ChangeState(TransferTimeoutTester::INIT_TASK); - timeoutTester.WaitForEndOfState(TransferTimeoutTester::INIT_TASK); + timeoutTester.ChangeState("INIT_TASK"); + timeoutTester.WaitForEndOfState("INIT_TASK"); - timeoutTester.ChangeState(TransferTimeoutTester::RUN); - timeoutTester.WaitForEndOfState(TransferTimeoutTester::RUN); + timeoutTester.ChangeState("RUN"); + timeoutTester.WaitForEndOfState("RUN"); - timeoutTester.ChangeState(TransferTimeoutTester::RESET_TASK); - timeoutTester.WaitForEndOfState(TransferTimeoutTester::RESET_TASK); + // nanomsg does not implement the LINGER option. Give the sockets some time before their queues are terminated + if (transport == "nanomsg") + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } - timeoutTester.ChangeState(TransferTimeoutTester::RESET_DEVICE); - timeoutTester.WaitForEndOfState(TransferTimeoutTester::RESET_DEVICE); + timeoutTester.ChangeState("RESET_TASK"); + timeoutTester.WaitForEndOfState("RESET_TASK"); - timeoutTester.ChangeState(TransferTimeoutTester::END); + timeoutTester.ChangeState("RESET_DEVICE"); + timeoutTester.WaitForEndOfState("RESET_DEVICE"); + + timeoutTester.ChangeState("END"); return 0; }