diff --git a/examples/1-1/Sampler.cxx b/examples/1-1/Sampler.cxx index 03a406db..664a1ba4 100644 --- a/examples/1-1/Sampler.cxx +++ b/examples/1-1/Sampler.cxx @@ -1,16 +1,10 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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" * ********************************************************************************/ -/** - * Sampler.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ #include // this_thread::sleep_for #include diff --git a/fairmq/Tools.h b/fairmq/Tools.h index 319a2cda..d2ad6d34 100644 --- a/fairmq/Tools.h +++ b/fairmq/Tools.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2017-2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * diff --git a/fairmq/devices/FairMQBenchmarkSampler.cxx b/fairmq/devices/FairMQBenchmarkSampler.cxx index 0e0d6c40..badfd076 100644 --- a/fairmq/devices/FairMQBenchmarkSampler.cxx +++ b/fairmq/devices/FairMQBenchmarkSampler.cxx @@ -1,16 +1,10 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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" * ********************************************************************************/ -/** - * FairMQBenchmarkSampler.cpp - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ #include "FairMQBenchmarkSampler.h" diff --git a/fairmq/devices/FairMQBenchmarkSampler.h b/fairmq/devices/FairMQBenchmarkSampler.h index 313e67cf..f173c79f 100644 --- a/fairmq/devices/FairMQBenchmarkSampler.h +++ b/fairmq/devices/FairMQBenchmarkSampler.h @@ -1,16 +1,10 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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" * ********************************************************************************/ -/** - * FairMQBenchmarkSampler.h - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ #ifndef FAIRMQBENCHMARKSAMPLER_H_ #define FAIRMQBENCHMARKSAMPLER_H_ diff --git a/fairmq/options/FairMQParser.cxx b/fairmq/options/FairMQParser.cxx index f4b2a86c..abf277d9 100644 --- a/fairmq/options/FairMQParser.cxx +++ b/fairmq/options/FairMQParser.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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, * diff --git a/fairmq/options/FairMQProgOptions.cxx b/fairmq/options/FairMQProgOptions.cxx index 3b8472f1..3b1f8e67 100644 --- a/fairmq/options/FairMQProgOptions.cxx +++ b/fairmq/options/FairMQProgOptions.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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, * diff --git a/fairmq/options/FairMQProgOptions.h b/fairmq/options/FairMQProgOptions.h index 85de740a..9eebf4e0 100644 --- a/fairmq/options/FairMQProgOptions.h +++ b/fairmq/options/FairMQProgOptions.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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, * diff --git a/fairmq/run/runBenchmarkSampler.cxx b/fairmq/run/runBenchmarkSampler.cxx index 5f7d7fe6..7f509968 100644 --- a/fairmq/run/runBenchmarkSampler.cxx +++ b/fairmq/run/runBenchmarkSampler.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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, * diff --git a/fairmq/tools/RateLimit.h b/fairmq/tools/RateLimit.h index d04d12d4..ab208b04 100644 --- a/fairmq/tools/RateLimit.h +++ b/fairmq/tools/RateLimit.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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, * diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 63226d1d..841e7c53 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# 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, # @@ -83,10 +83,10 @@ add_testsuite(FairMQ.Device SOURCES device/TestSender.h device/TestReceiver.h - device/TestVersion.h device/runner.cxx device/_multiple_devices.cxx device/_device_version.cxx + device/_device_config.cxx LINKS FairMQ INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/device diff --git a/test/device/TestVersion.h b/test/device/TestVersion.h deleted file mode 100644 index c43b86c1..00000000 --- a/test/device/TestVersion.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2015-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 -#include -#include - -namespace fair -{ -namespace mq -{ -namespace test -{ - -class TestVersion : public FairMQDevice -{ - public: - TestVersion(fair::mq::tools::Version version) - : FairMQDevice(version) - {} -}; - -} // namespace test -} // namespace mq -} // namespace fair diff --git a/test/device/_device_config.cxx b/test/device/_device_config.cxx new file mode 100644 index 00000000..313c6c7e --- /dev/null +++ b/test/device/_device_config.cxx @@ -0,0 +1,122 @@ +/******************************************************************************** + * 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 +#include + +#include + +#include + +#include // std::stringstream +#include + +namespace +{ + +using namespace std; + +void control(FairMQDevice& device) +{ + device.ChangeState("INIT_DEVICE"); + device.WaitForEndOfState("INIT_DEVICE"); + device.ChangeState("INIT_TASK"); + device.WaitForEndOfState("INIT_TASK"); + + device.ChangeState("RUN"); + device.WaitForEndOfState("RUN"); + + device.ChangeState("RESET_TASK"); + device.WaitForEndOfState("RESET_TASK"); + device.ChangeState("RESET_DEVICE"); + device.WaitForEndOfState("RESET_DEVICE"); + + device.ChangeState("END"); +} + +class DeviceConfig : public ::testing::Test +{ + public: + DeviceConfig() + {} + + string TestDeviceSetConfig(const string& transport) + { + FairMQProgOptions config; + + vector emptyArgs = {"dummy", "--id", "test", "--color", "false"}; + + if (config.ParseAll(emptyArgs, true)) + { + return 0; + } + + config.SetValue("transport", transport); + + FairMQDevice device; + device.SetConfig(config); + + FairMQChannel channel; + channel.UpdateType("pub"); + channel.UpdateMethod("connect"); + channel.UpdateAddress("tcp://localhost:5558"); + device.AddChannel("data", channel); + + thread t(control, ref(device)); + + device.RunStateMachine(); + + if (t.joinable()) + { + t.join(); + } + + return device.GetTransportName(); + } + + string TestDeviceSetTransport(const string& transport) + { + FairMQDevice device; + device.SetTransport(transport); + + FairMQChannel channel; + channel.UpdateType("pub"); + channel.UpdateMethod("connect"); + channel.UpdateAddress("tcp://localhost:5558"); + device.AddChannel("data", channel); + + std::thread t(control, std::ref(device)); + + device.RunStateMachine(); + + if (t.joinable()) + { + t.join(); + } + + return device.GetTransportName(); + } +}; + +TEST_F(DeviceConfig, SetConfig) +{ + string transport = "nanomsg"; + string returnedTransport = TestDeviceSetConfig(transport); + + EXPECT_EQ(transport, returnedTransport); +} + +TEST_F(DeviceConfig, SetTransport) +{ + string transport = "nanomsg"; + string returnedTransport = TestDeviceSetTransport(transport); + + EXPECT_EQ(transport, returnedTransport); +} + +} // namespace diff --git a/test/device/_device_version.cxx b/test/device/_device_version.cxx index 1b264c54..540248b1 100644 --- a/test/device/_device_version.cxx +++ b/test/device/_device_version.cxx @@ -1,12 +1,12 @@ /******************************************************************************** - * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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 "TestVersion.h" +#include #include @@ -19,16 +19,24 @@ namespace { using namespace std; -using namespace fair::mq::test; -class DeviceVersion : public ::testing::Test { +class TestVersion : public FairMQDevice +{ + public: + TestVersion(fair::mq::tools::Version version) + : FairMQDevice(version) + {} +}; + +class DeviceVersion : public ::testing::Test +{ public: DeviceVersion() {} fair::mq::tools::Version TestDeviceVersion() { - fair::mq::test::TestVersion versionDevice({1, 2, 3}); + TestVersion versionDevice({1, 2, 3}); versionDevice.ChangeState("END"); return versionDevice.GetVersion(); diff --git a/test/device/_multiple_devices.cxx b/test/device/_multiple_devices.cxx index 43e84b0d..490e58e3 100644 --- a/test/device/_multiple_devices.cxx +++ b/test/device/_multiple_devices.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * 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, * @@ -51,7 +51,7 @@ class MultipleDevices : public ::testing::Test { FairMQChannel channel("push", "connect", "ipc://multiple-devices-test"); channel.UpdateRateLogging(0); - sender.fChannels["data"].push_back(channel); + sender.AddChannel("data", channel); thread t(control, std::ref(sender)); @@ -73,7 +73,7 @@ class MultipleDevices : public ::testing::Test { FairMQChannel channel("pull", "bind", "ipc://multiple-devices-test"); channel.UpdateRateLogging(0); - receiver.fChannels["data"].push_back(channel); + receiver.AddChannel("data", channel); thread t(control, std::ref(receiver));