26 #include "gtest/gtest.h" 27 #include <boost/property_tree/ptree.hpp> 28 #include <zmqpp/zmqpp.hpp> 41 template <
typename ModuleType>
43 const boost::property_tree::ptree &cfg)
47 nullptr,
nullptr, std::make_shared<ConfigChecker>(),
false);
48 ModuleType module(*ctx, pipe, cfg, u);
50 pipe->send(zmqpp::signal::ok);
64 template <
typename... Content>
65 bool bus_read_extract(zmqpp::message *m,
const char *first_arg, Content... content);
72 template <
typename T,
typename... Content>
73 typename std::enable_if<!std::is_same<const char *, T>::value,
bool>::type
78 if (value != first_arg)
87 template <
typename... Content>
93 if (strcmp(value.c_str(), first_arg) != 0)
102 template <
typename... Content>
103 bool bus_read(zmqpp::socket &sub, Content... content)
107 if (!sub.receive(msg))
124 virtual bool run_module(zmqpp::socket *pipe) = 0;
134 bus_sub_.connect(
"inproc://zmq-bus-pub");
135 bus_push_.connect(
"inproc://zmq-bus-pull");
148 module_actor_ = std::unique_ptr<zmqpp::actor>(
new zmqpp::actor(
This is the header file for a generated source file, GitSHA1.cpp.
virtual bool run_module(zmqpp::socket *pipe)=0
Called in the module's actor's thread.
Base class for test fixtures, it defines a ZMQ context, a BUS and a sub socket connect to the bus...
std::unique_ptr< zmqpp::actor > module_actor_
An actor, to run the module code the same way it would be run by the core.
zmqpp::socket bus_push_
A PUSH socket to write on the bus.
zmqpp::socket bus_sub_
A SUB socket connected to the previous bus.
bool bus_read_extract(zmqpp::message *)
Part of the bus_read() stuff.
virtual void SetUp() override final
We need this 2-step initialization to prevent calling virtual method (run_module) in constructor...
zmqpp::context ctx_
A context for the test case.
bool test_run_module(zmqpp::context *ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg)
Helper function that create an object of type ModuleType (using conventional parameter) and run it...
Implements a message bus (running in its own thread) that use 2 sockets.
bool bus_read(zmqpp::socket &sub, Content... content)
Make a blocking read on the bus, return true if content match the message.
std::shared_ptr< CoreUtils > CoreUtilsPtr
MessageBus bus_
A BUS identical to the one spawned by core.