Relocate some tests to more apropriate test suits

This commit is contained in:
Alexey Rybalchenko
2018-09-13 17:29:12 +02:00
committed by Dennis Klein
parent 5397cef9d1
commit 957233cf95
4 changed files with 23 additions and 3 deletions

View File

@@ -1,87 +0,0 @@
/********************************************************************************
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "runner.h"
#include <fairmq/Tools.h>
#include <gtest/gtest.h>
#include <sstream> // std::stringstream
#include <thread>
namespace
{
using namespace std;
using namespace fair::mq::test;
using namespace fair::mq::tools;
auto RunPoller(string transport, int pollType) -> void
{
size_t session{fair::mq::tools::UuidHash()};
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 << "\"";
pollout = execute(cmd.str(), "[POLLOUT]");
});
auto pollin = execute_result{"", 0};
thread poll_in_thread([&]() {
stringstream cmd;
cmd << runTestDevice
<< " --id pollin_" << transport
<< " --control static --color false"
<< " --session " << session << " --mq-config \"" << mqConfig << "\" --poll-type " << pollType;
pollin = execute(cmd.str(), "[POLLIN]");
});
poll_out_thread.join();
poll_in_thread.join();
cerr << pollout.console_out << pollin.console_out;
exit(pollout.exit_code + pollin.exit_code);
}
TEST(Poller, ZeroMQ_subchannel)
{
EXPECT_EXIT(RunPoller("zeromq", 0), ::testing::ExitedWithCode(0), "POLL test successfull");
}
#ifdef BUILD_NANOMSG_TRANSPORT
TEST(Poller, Nanomsg_subchannel)
{
EXPECT_EXIT(RunPoller("nanomsg", 0), ::testing::ExitedWithCode(0), "POLL test successfull");
}
#endif /* BUILD_NANOMSG_TRANSPORT */
TEST(Poller, ShMem_subchannel)
{
EXPECT_EXIT(RunPoller("shmem", 0), ::testing::ExitedWithCode(0), "POLL test successfull");
}
TEST(Poller, ZeroMQ_channel)
{
EXPECT_EXIT(RunPoller("zeromq", 1), ::testing::ExitedWithCode(0), "POLL test successfull");
}
#ifdef BUILD_NANOMSG_TRANSPORT
TEST(Poller, Nanomsg_channel)
{
EXPECT_EXIT(RunPoller("nanomsg", 1), ::testing::ExitedWithCode(0), "POLL test successfull");
}
#endif /* BUILD_NANOMSG_TRANSPORT */
TEST(Poller, ShMem_channel)
{
EXPECT_EXIT(RunPoller("shmem", 1), ::testing::ExitedWithCode(0), "POLL test successfull");
}
} // namespace

View File

@@ -1,51 +0,0 @@
/********************************************************************************
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "runner.h"
#include <fairmq/Tools.h>
#include <gtest/gtest.h>
#include <sstream> // std::stringstream
namespace
{
using namespace std;
using namespace fair::mq::test;
using namespace fair::mq::tools;
auto RunTransferTimeout(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
stringstream cmd;
cmd << runTestDevice << " --id transfer_timeout_" << transport << " --control static --transport " << transport
<< " --session " << session << " --color false --mq-config \"" << mqConfig << "\"";
auto res = execute(cmd.str());
cerr << res.console_out;
exit(res.exit_code);
}
TEST(TransferTimeout, ZeroMQ)
{
EXPECT_EXIT(RunTransferTimeout("zeromq"), ::testing::ExitedWithCode(0), "Transfer timeout test successfull");
}
TEST(TransferTimeout, ShMem)
{
EXPECT_EXIT(RunTransferTimeout("shmem"), ::testing::ExitedWithCode(0), "Transfer timeout test successfull");
}
#ifdef BUILD_NANOMSG_TRANSPORT
TEST(TransferTimeout, Nanomsg)
{
EXPECT_EXIT(RunTransferTimeout("nanomsg"), ::testing::ExitedWithCode(0), "Transfer timeout test successfull");
}
#endif /* BUILD_NANOMSG_TRANSPORT */
} // namespace

View File

@@ -1,74 +0,0 @@
/********************************************************************************
* Copyright (C) 2014-2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "runner.h"
#include <gtest/gtest.h>
#include <boost/process.hpp>
#include <sys/types.h>
#include <signal.h>
#include <string>
#include <thread>
#include <chrono>
#include <iostream>
#include <future> // std::async, std::future
namespace
{
using namespace std;
using namespace fair::mq::test;
void RunWaitFor()
{
std::mutex mtx;
std::condition_variable cv;
int pid = 0;
int exit_code = 0;
thread deviceThread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id waitfor_" << " --control static " << " --severity nolog";
boost::process::ipstream stdout;
boost::process::child c(cmd.str(), boost::process::std_out > stdout);
string line;
getline(stdout, line);
{
std::lock_guard<std::mutex> lock(mtx);
pid = c.id();
}
cv.notify_one();
c.wait();
exit_code = c.exit_code();
});
{
std::unique_lock<std::mutex> lock(mtx);
cv.wait(lock, [&pid]{ return pid != 0; });
}
kill(pid, SIGINT);
deviceThread.join();
exit(exit_code);
}
TEST(Device, WaitFor)
{
EXPECT_EXIT(RunWaitFor(), ::testing::ExitedWithCode(0), "");
}
} // namespace