mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Add additional test for running device with plugins without DeviceRunner
This commit is contained in:
committed by
Dennis Klein
parent
4281d7b27e
commit
5271d4236e
@@ -7,6 +7,7 @@
|
||||
********************************************************************************/
|
||||
|
||||
#include <FairMQDevice.h>
|
||||
#include <fairmq/DeviceRunner.h>
|
||||
#include <fairmq/ProgOptions.h>
|
||||
|
||||
#include <fairmq/Tools.h>
|
||||
@@ -125,6 +126,46 @@ class Config : public ::testing::Test
|
||||
return device.GetTransportName();
|
||||
}
|
||||
|
||||
string TestDeviceSetConfigWithPlugins(const string& transport)
|
||||
{
|
||||
fair::mq::ProgOptions config;
|
||||
|
||||
vector<string> emptyArgs = {"dummy", "--id", "test", "--color", "false"};
|
||||
|
||||
config.SetProperty("transport", transport);
|
||||
|
||||
FairMQDevice device;
|
||||
fair::mq::PluginManager mgr;
|
||||
mgr.LoadPlugin("s:config");
|
||||
mgr.ForEachPluginProgOptions([&](boost::program_options::options_description options) {
|
||||
config.AddToCmdLineOptions(options);
|
||||
});
|
||||
mgr.EmplacePluginServices(config, device);
|
||||
mgr.InstantiatePlugins();
|
||||
|
||||
config.ParseAll(emptyArgs, true);
|
||||
fair::mq::DeviceRunner::HandleGeneralOptions(config);
|
||||
device.SetConfig(config);
|
||||
|
||||
FairMQChannel channel;
|
||||
channel.UpdateType("pub");
|
||||
channel.UpdateMethod("connect");
|
||||
channel.UpdateAddress("tcp://localhost:5558");
|
||||
device.AddChannel("data", std::move(channel));
|
||||
|
||||
thread t(control, ref(device));
|
||||
|
||||
device.RunStateMachine();
|
||||
|
||||
config.PrintOptions();
|
||||
|
||||
if (t.joinable()) {
|
||||
t.join();
|
||||
}
|
||||
|
||||
return device.GetTransportName();
|
||||
}
|
||||
|
||||
string TestDeviceControlInConstructor(const string& transport)
|
||||
{
|
||||
TestDevice device(transport);
|
||||
@@ -163,6 +204,14 @@ TEST_F(Config, SetConfig)
|
||||
EXPECT_EQ(transport, returnedTransport);
|
||||
}
|
||||
|
||||
TEST_F(Config, SetConfigWithPlugins)
|
||||
{
|
||||
string transport = "zeromq";
|
||||
string returnedTransport = TestDeviceSetConfigWithPlugins(transport);
|
||||
|
||||
EXPECT_EQ(transport, returnedTransport);
|
||||
}
|
||||
|
||||
TEST_F(Config, SetTransport)
|
||||
{
|
||||
string transport = "zeromq";
|
||||
|
Reference in New Issue
Block a user