Commit 7ef94fef authored by Dominik Charousset's avatar Dominik Charousset

Refactor launch process of sub-unit tests

parent 4e2e66cc
...@@ -66,7 +66,7 @@ set (LIBCAF_CORE_SRCS ...@@ -66,7 +66,7 @@ set (LIBCAF_CORE_SRCS
src/replies_to.cpp src/replies_to.cpp
src/resumable.cpp src/resumable.cpp
src/ripemd_160.cpp src/ripemd_160.cpp
src/run_program.cpp src/run_sub_unit_test.cpp
src/scoped_actor.cpp src/scoped_actor.cpp
src/set_scheduler.cpp src/set_scheduler.cpp
src/serializer.cpp src/serializer.cpp
......
...@@ -20,25 +20,24 @@ ...@@ -20,25 +20,24 @@
#ifndef CAF_DETAIL_RUN_PROGRAM_HPP #ifndef CAF_DETAIL_RUN_PROGRAM_HPP
#define CAF_DETAIL_RUN_PROGRAM_HPP #define CAF_DETAIL_RUN_PROGRAM_HPP
#include "caf/send.hpp"
#include "caf/actor.hpp"
#include "caf/message.hpp"
#include "caf/string_algorithms.hpp"
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <string> #include <string>
#include <initializer_list>
#include "caf/send.hpp"
#include "caf/actor.hpp"
#include "caf/message.hpp"
namespace caf { namespace caf {
namespace detail { namespace detail {
std::thread run_program_impl(caf::actor, const char*, std::vector<std::string>); std::thread run_sub_unit_test(caf::actor listener,
const char* path,
template <class... Ts> int max_runtime,
std::thread run_program(caf::actor listener, const char* path, Ts&&... args) { const char* suite_name,
std::vector<std::string> vec{convert_to_str(std::forward<Ts>(args))...}; bool set_asio_option,
return run_program_impl(listener, path, std::move(vec)); std::initializer_list<std::string> args);
}
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
......
...@@ -104,9 +104,6 @@ uniform_value make_uniform_value(const uniform_type_info* uti, Ts&&... xs) { ...@@ -104,9 +104,6 @@ uniform_value make_uniform_value(const uniform_type_info* uti, Ts&&... xs) {
/// runtime. /// runtime.
/// ///
/// ~~~ /// ~~~
/// #include "caf/all.hpp"
/// using namespace caf;
///
/// struct foo { int a; int b; }; /// struct foo { int a; int b; };
/// ///
/// int main() { /// int main() {
......
...@@ -17,13 +17,15 @@ ...@@ -17,13 +17,15 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include "caf/detail/run_program.hpp" #include "caf/detail/run_sub_unit_test.hpp"
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/string_algorithms.hpp"
#ifdef CAF_MSVC #ifdef CAF_MSVC
# include <windows.h> # include <windows.h>
#endif #endif
...@@ -32,16 +34,23 @@ namespace caf { ...@@ -32,16 +34,23 @@ namespace caf {
namespace detail { namespace detail {
#ifndef CAF_WINDOWS #ifndef CAF_WINDOWS
std::thread run_program_impl(actor rc, const char* cpath, std::thread run_sub_unit_test(actor rc,
std::vector<std::string> args) { const char* cpath,
int max_runtime,
const char* suite_name,
bool set_asio_option,
std::initializer_list<std::string> args) {
using namespace std; using namespace std;
string path = cpath; string path = cpath;
replace_all(path, "'", "\\'"); replace_all(path, "'", "\\'");
ostringstream oss; ostringstream oss;
oss << "'" << path << "'"; // set path and default options for sub unit tests
for (auto& arg : args) { oss << "'" << path << "' "
<< "-n -s " << suite_name << " -r " << max_runtime << " --";
for (auto& arg : args)
oss << " " << arg; oss << " " << arg;
} if (set_asio_option)
oss << " --use-asio";
oss << " 2>&1"; oss << " 2>&1";
string cmdstr = oss.str(); string cmdstr = oss.str();
return std::thread{ [cmdstr, rc] { return std::thread{ [cmdstr, rc] {
...@@ -67,15 +76,19 @@ std::thread run_program_impl(actor rc, const char* cpath, ...@@ -67,15 +76,19 @@ std::thread run_program_impl(actor rc, const char* cpath,
}}; }};
} }
#else #else
std::thread run_program_impl(actor rc, const char* cpath, std::thread run_sub_unit_test(actor rc, const char* cpath,
std::vector<std::string> args) { std::vector<std::string> args) {
std::string path = cpath; std::string path = cpath;
replace_all(path, "'", "\\'"); replace_all(path, "'", "\\'");
std::ostringstream oss; std::ostringstream oss;
oss << path; oss << path;
for (auto& arg : args) { // set path and default options for sub unit tests
oss << "'" << path << "' "
<< "-n -s " << suite_name << " -r " << max_runtime << " --";
for (auto& arg : args)
oss << " " << arg; oss << " " << arg;
} if (set_asio_option)
oss << " --use-asio";
return std::thread([rc](std::string cmdstr) { return std::thread([rc](std::string cmdstr) {
STARTUPINFO si; STARTUPINFO si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
......
...@@ -54,7 +54,7 @@ struct fixture { ...@@ -54,7 +54,7 @@ struct fixture {
if (expect_fail) { if (expect_fail) {
self->sync_send(spawner, get_atom::value, "test_actor", std::move(args)).await( self->sync_send(spawner, get_atom::value, "test_actor", std::move(args)).await(
[&](error_atom, const std::string&) { [&](error_atom, const std::string&) {
CAF_TEST_VERBOSE("received error_atom (expected)"); CAF_MESSAGE("received error_atom (expected)");
} }
); );
} else { } else {
......
...@@ -57,7 +57,7 @@ void chattier_actor(event_based_actor* self, const std::string& fn) { ...@@ -57,7 +57,7 @@ void chattier_actor(event_based_actor* self, const std::string& fn) {
CAF_TEST_FIXTURE_SCOPE(aout_tests, fixture) CAF_TEST_FIXTURE_SCOPE(aout_tests, fixture)
CAF_TEST(global_redirect) { CAF_TEST(redirect_aout_globally) {
scoped_actor self; scoped_actor self;
self->join(group::get("local", global_redirect)); self->join(group::get("local", global_redirect));
actor_ostream::redirect_all(global_redirect); actor_ostream::redirect_all(global_redirect);
......
...@@ -110,7 +110,7 @@ CAF_TEST(receive_atoms) { ...@@ -110,7 +110,7 @@ CAF_TEST(receive_atoms) {
); );
atom_value x = atom("abc"); atom_value x = atom("abc");
atom_value y = abc_atom::value; atom_value y = abc_atom::value;
CAF_CHECK_EQUAL(x, y); CAF_CHECK(x == y);
auto msg = make_message(atom("abc")); auto msg = make_message(atom("abc"));
self->send(self, msg); self->send(self, msg);
self->receive( self->receive(
......
...@@ -499,7 +499,7 @@ CAF_TEST(send_to_self) { ...@@ -499,7 +499,7 @@ CAF_TEST(send_to_self) {
self->receive(on() >> [] {}); self->receive(on() >> [] {});
} }
CAF_TEST(echo_actor) { CAF_TEST(echo_actor_messaging) {
scoped_actor self; scoped_actor self;
auto mecho = spawn<echo_actor>(); auto mecho = spawn<echo_actor>();
self->send(mecho, "hello echo"); self->send(mecho, "hello echo");
...@@ -531,7 +531,7 @@ CAF_TEST(delayed_spawn) { ...@@ -531,7 +531,7 @@ CAF_TEST(delayed_spawn) {
spawn<testee1>(); spawn<testee1>();
} }
CAF_TEST(spawn_event_testee2) { CAF_TEST(spawn_event_testee2_test) {
scoped_actor self; scoped_actor self;
spawn_event_testee2(self); spawn_event_testee2(self);
self->receive( self->receive(
...@@ -631,7 +631,7 @@ CAF_TEST(sync_sends) { ...@@ -631,7 +631,7 @@ CAF_TEST(sync_sends) {
self->receive ( self->receive (
[&](const down_msg& dm) { [&](const down_msg& dm) {
CAF_CHECK_EQUAL(dm.reason, exit_reason::normal); CAF_CHECK_EQUAL(dm.reason, exit_reason::normal);
CAF_CHECK_EQUAL(dm.source, sync_testee); CAF_CHECK(dm.source == sync_testee);
} }
); );
self->await_all_other_actors_done(); self->await_all_other_actors_done();
......
...@@ -25,10 +25,15 @@ ...@@ -25,10 +25,15 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "caf/on.hpp" #include "caf/all.hpp"
#include "caf/message.hpp"
#include "caf/message_builder.hpp" namespace caf {
#include "caf/message_handler.hpp"
std::ostream& operator<<(std::ostream& out, const message& msg) {
return out << to_string(msg);
}
} // namespace caf
using namespace caf; using namespace caf;
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
#define CAF_SUITE message #define CAF_SUITE message
#include "caf/test/unit_test.hpp" #include "caf/test/unit_test.hpp"
#include "caf/message.hpp" #include "caf/all.hpp"
#include "caf/message_builder.hpp"
using namespace caf; using namespace caf;
......
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
#include <typeinfo> #include <typeinfo>
#include <type_traits> #include <type_traits>
#include "caf/shutdown.hpp" #include "caf/all.hpp"
#include "caf/uniform_type_info.hpp"
#include "caf/detail/ctm.hpp" #include "caf/detail/ctm.hpp"
#include "caf/detail/int_list.hpp" #include "caf/detail/int_list.hpp"
......
...@@ -25,10 +25,8 @@ ...@@ -25,10 +25,8 @@
#define CAF_SUITE profiled_coordinator #define CAF_SUITE profiled_coordinator
#include "caf/test/unit_test.hpp" #include "caf/test/unit_test.hpp"
#include "caf/config.hpp" #include "caf/all.hpp"
#include "caf/shutdown.hpp"
#include "caf/set_scheduler.hpp"
#include "caf/scheduler/profiled_coordinator.hpp" #include "caf/scheduler/profiled_coordinator.hpp"
using namespace caf; using namespace caf;
......
...@@ -238,7 +238,7 @@ CAF_TEST(test_int32_t) { ...@@ -238,7 +238,7 @@ CAF_TEST(test_int32_t) {
CAF_CHECK_EQUAL(i32, x); CAF_CHECK_EQUAL(i32, x);
} }
CAF_TEST(test_enum) { CAF_TEST(test_enum_serialization) {
auto buf = binary_util::serialize(te); auto buf = binary_util::serialize(te);
test_enum x; test_enum x;
binary_util::deserialize(buf, &x); binary_util::deserialize(buf, &x);
......
...@@ -471,7 +471,7 @@ CAF_TEST(sync_send) { ...@@ -471,7 +471,7 @@ CAF_TEST(sync_send) {
s->sync_send(serv, request_atom::value).await( s->sync_send(serv, request_atom::value).await(
[=](response_atom) { [=](response_atom) {
CAF_MESSAGE("received `response_atom`"); CAF_MESSAGE("received `response_atom`");
CAF_CHECK_EQUAL(s->current_sender(), work); CAF_CHECK(s->current_sender() == work);
}, },
others >> [&] { others >> [&] {
CAF_TEST_ERROR("Unexpected message: " CAF_TEST_ERROR("Unexpected message: "
...@@ -483,7 +483,7 @@ CAF_TEST(sync_send) { ...@@ -483,7 +483,7 @@ CAF_TEST(sync_send) {
send_as(work, serv, idle_atom::value, work); send_as(work, serv, idle_atom::value, work);
handle.await( handle.await(
[=](response_atom) { [=](response_atom) {
CAF_CHECK_EQUAL(s->current_sender(), work); CAF_CHECK(s->current_sender() == work);
}, },
others >> [&] { others >> [&] {
CAF_TEST_ERROR("Unexpected message: " CAF_TEST_ERROR("Unexpected message: "
......
...@@ -22,10 +22,7 @@ ...@@ -22,10 +22,7 @@
#define CAF_SUITE work_sharing #define CAF_SUITE work_sharing
#include "caf/test/unit_test.hpp" #include "caf/test/unit_test.hpp"
#include "caf/config.hpp" #include "caf/all.hpp"
#include "caf/shutdown.hpp"
#include "caf/set_scheduler.hpp"
#include "caf/policy/work_sharing.hpp" #include "caf/policy/work_sharing.hpp"
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "caf/io/network/interfaces.hpp" #include "caf/io/network/interfaces.hpp"
#include "caf/io/network/test_multiplexer.hpp" #include "caf/io/network/test_multiplexer.hpp"
#include "caf/detail/run_program.hpp" #include "caf/detail/run_sub_unit_test.hpp"
#ifdef CAF_USE_ASIO #ifdef CAF_USE_ASIO
#include "caf/io/network/asio_multiplexer.hpp" #include "caf/io/network/asio_multiplexer.hpp"
...@@ -76,11 +76,12 @@ using pong_atom = atom_constant<atom("pong")>; ...@@ -76,11 +76,12 @@ using pong_atom = atom_constant<atom("pong")>;
*/ */
std::thread run_prog(const char* arg, uint16_t port, bool use_asio) { std::thread run_prog(const char* arg, uint16_t port, bool use_asio) {
return detail::run_program(invalid_actor, test::engine::path(), "-n", return detail::run_sub_unit_test(invalid_actor,
"-s", CAF_XSTR(CAF_SUITE), test::engine::path(),
"-r", test::engine::max_runtime(), "--", test::engine::max_runtime(),
arg, "-p", port, CAF_XSTR(CAF_SUITE),
(use_asio ? "--use-asio" : "")); use_asio,
{"--port=" + std::to_string(port), arg});
} }
// we run the same code on all three nodes, a simple ping-pong client // we run the same code on all three nodes, a simple ping-pong client
...@@ -208,7 +209,7 @@ void run_earth(bool use_asio, bool as_server, uint16_t pub_port) { ...@@ -208,7 +209,7 @@ void run_earth(bool use_asio, bool as_server, uint16_t pub_port) {
mars_process.join(); mars_process.join();
self->receive( self->receive(
[&](delete_atom, const node_id& nid) { [&](delete_atom, const node_id& nid) {
CAF_CHECK_EQUAL(nid, mars); CAF_CHECK(nid == mars);
} }
); );
CAF_MESSAGE("check whether we still can talk to Jupiter"); CAF_MESSAGE("check whether we still can talk to Jupiter");
...@@ -221,7 +222,7 @@ void run_earth(bool use_asio, bool as_server, uint16_t pub_port) { ...@@ -221,7 +222,7 @@ void run_earth(bool use_asio, bool as_server, uint16_t pub_port) {
} }
); );
std::set<actor_addr> expected{aut.address(), jupiter_addr}; std::set<actor_addr> expected{aut.address(), jupiter_addr};
CAF_CHECK_EQUAL(found, expected); CAF_CHECK(found == expected);
CAF_MESSAGE("shutdown Jupiter"); CAF_MESSAGE("shutdown Jupiter");
anon_send_exit(jupiter_addr, exit_reason::kill); anon_send_exit(jupiter_addr, exit_reason::kill);
if (jupiter_process.joinable()) if (jupiter_process.joinable())
...@@ -247,8 +248,8 @@ void run_jupiter(uint16_t port_to_mars) { ...@@ -247,8 +248,8 @@ void run_jupiter(uint16_t port_to_mars) {
CAF_TEST(triangle_setup) { CAF_TEST(triangle_setup) {
uint16_t port = 0; uint16_t port = 0;
uint16_t publish_port = 0; uint16_t publish_port = 0;
auto argv = caf::test::engine::argv(); auto argv = test::engine::argv();
auto argc = caf::test::engine::argc(); auto argc = test::engine::argc();
auto r = message_builder(argv, argv + argc).extract_opts({ auto r = message_builder(argv, argv + argc).extract_opts({
{"port,p", "port of remote side (when running mars or jupiter)", port}, {"port,p", "port of remote side (when running mars or jupiter)", port},
{"mars", "run mars"}, {"mars", "run mars"},
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
#include "caf/detail/run_program.hpp" #include "caf/detail/run_sub_unit_test.hpp"
#ifdef CAF_USE_ASIO #ifdef CAF_USE_ASIO
#include "caf/io/network/asio_multiplexer.hpp" #include "caf/io/network/asio_multiplexer.hpp"
...@@ -186,11 +186,13 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) { ...@@ -186,11 +186,13 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) {
[&](uint16_t port) { [&](uint16_t port) {
CAF_MESSAGE("server is running on port " << port); CAF_MESSAGE("server is running on port " << port);
if (spawn_client) { if (spawn_client) {
auto child = detail::run_program(self, bin_path, "-n", auto child = detail::run_sub_unit_test(self,
"-s", CAF_XSTR(CAF_SUITE), bin_path,
"-r", test::engine::max_runtime(), test::engine::max_runtime(),
"--", "-c", port, CAF_XSTR(CAF_SUITE),
(use_asio ? "--use-asio" : "")); use_asio,
{"--client-port="
+ std::to_string(port)});
CAF_MESSAGE("block till child process has finished"); CAF_MESSAGE("block till child process has finished");
child.join(); child.join();
} }
...@@ -208,8 +210,8 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) { ...@@ -208,8 +210,8 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) {
} // namespace <anonymous> } // namespace <anonymous>
CAF_TEST(test_broker) { CAF_TEST(test_broker) {
auto argv = caf::test::engine::argv(); auto argv = test::engine::argv();
auto argc = caf::test::engine::argc(); auto argc = test::engine::argc();
uint16_t port = 0; uint16_t port = 0;
auto r = message_builder(argv, argv + argc).extract_opts({ auto r = message_builder(argv, argv + argc).extract_opts({
{"client-port,c", "set port for IO client", port}, {"client-port,c", "set port for IO client", port},
...@@ -238,7 +240,7 @@ CAF_TEST(test_broker) { ...@@ -238,7 +240,7 @@ CAF_TEST(test_broker) {
// run in server mode // run in server mode
run_server(false, argv[0], use_asio); run_server(false, argv[0], use_asio);
} else { } else {
run_server(true, caf::test::engine::path(), use_asio); run_server(true, test::engine::path(), use_asio);
} }
CAF_MESSAGE("block on `await_all_actors_done`"); CAF_MESSAGE("block on `await_all_actors_done`");
await_all_actors_done(); await_all_actors_done();
......
...@@ -220,8 +220,8 @@ public: ...@@ -220,8 +220,8 @@ public:
CAF_REQUIRE((buf.size() >= x.size())); CAF_REQUIRE((buf.size() >= x.size()));
CAF_REQUIRE((std::equal(buf.begin(), CAF_REQUIRE((std::equal(buf.begin(),
buf.begin() + static_cast<ptrdiff_t>(x.size()), buf.begin() + static_cast<ptrdiff_t>(x.size()),
x.begin())); x.begin())));
buf.erase(buf.begin(), buf.begin() + static_cast<ptrdiff_t>(x.size()))); buf.erase(buf.begin(), buf.begin() + static_cast<ptrdiff_t>(x.size()));
return *this; return *this;
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "caf/detail/logging.hpp" #include "caf/detail/logging.hpp"
#include "caf/detail/singletons.hpp" #include "caf/detail/singletons.hpp"
#include "caf/detail/run_program.hpp" #include "caf/detail/run_sub_unit_test.hpp"
#ifdef CAF_USE_ASIO #ifdef CAF_USE_ASIO
#include "caf/io/network/asio_multiplexer.hpp" #include "caf/io/network/asio_multiplexer.hpp"
...@@ -70,10 +70,10 @@ behavior ping_behavior(local_actor* self, size_t ping_msgs) { ...@@ -70,10 +70,10 @@ behavior ping_behavior(local_actor* self, size_t ping_msgs) {
if (! self->current_sender()) { if (! self->current_sender()) {
CAF_TEST_ERROR("current_sender() invalid!"); CAF_TEST_ERROR("current_sender() invalid!");
} }
CAF_TEST_INFO("received {'pong', " << value << "}"); CAF_MESSAGE("received {'pong', " << value << "}");
// cout << to_string(self->current_message()) << endl; // cout << to_string(self->current_message()) << endl;
if (++s_pongs >= ping_msgs) { if (++s_pongs >= ping_msgs) {
CAF_TEST_INFO("reached maximum, send {'EXIT', user_defined} " CAF_MESSAGE("reached maximum, send {'EXIT', user_defined} "
<< "to last sender and quit with normal reason"); << "to last sender and quit with normal reason");
self->send_exit(self->current_sender(), self->send_exit(self->current_sender(),
exit_reason::user_shutdown); exit_reason::user_shutdown);
...@@ -480,17 +480,21 @@ void test_remote_actor(const char* path, bool run_remote, bool use_asio) { ...@@ -480,17 +480,21 @@ void test_remote_actor(const char* path, bool run_remote, bool use_asio) {
CAF_CHECK(serv == serv2); CAF_CHECK(serv == serv2);
thread child; thread child;
if (run_remote) { if (run_remote) {
child = detail::run_program(self, path, "-n", "-s", CAF_XSTR(CAF_SUITE), child = detail::run_sub_unit_test(self,
"-r", test::engine::max_runtime(), "--", path,
"-c", port2, "-c", port1, "-g", gport, test::engine::max_runtime(),
(use_asio ? "--use-asio" : "")); CAF_XSTR(CAF_SUITE),
use_asio,
{"--client-port=" + std::to_string(port2),
"--client-port=" + std::to_string(port1),
"--group-port=" + std::to_string(gport)});
} else { } else {
CAF_MESSAGE("please run client with: " CAF_MESSAGE("please run client with: "
<< "-c " << port2 << " -c " << port1 << " -g " << gport); << "-c " << port2 << " -c " << port1 << " -g " << gport);
} }
self->receive( self->receive(
[&](const down_msg& dm) { [&](const down_msg& dm) {
CAF_CHECK_EQUAL(dm.source, serv); CAF_CHECK(dm.source == serv);
CAF_CHECK_EQUAL(dm.reason, exit_reason::normal); CAF_CHECK_EQUAL(dm.reason, exit_reason::normal);
} }
); );
...@@ -509,9 +513,9 @@ void test_remote_actor(const char* path, bool run_remote, bool use_asio) { ...@@ -509,9 +513,9 @@ void test_remote_actor(const char* path, bool run_remote, bool use_asio) {
} // namespace <anonymous> } // namespace <anonymous>
CAF_TEST(test_remote_actor) { CAF_TEST(remote_actors) {
auto argv = caf::test::engine::argv(); auto argv = test::engine::argv();
auto argc = caf::test::engine::argc(); auto argc = test::engine::argc();
announce<actor_vector>("actor_vector"); announce<actor_vector>("actor_vector");
cout << "this node is: " << to_string(caf::detail::singletons::get_node_id()) cout << "this node is: " << to_string(caf::detail::singletons::get_node_id())
<< endl; << endl;
...@@ -557,7 +561,7 @@ CAF_TEST(test_remote_actor) { ...@@ -557,7 +561,7 @@ CAF_TEST(test_remote_actor) {
auto c = self->spawn<client, monitored>(serv); auto c = self->spawn<client, monitored>(serv);
self->receive( self->receive(
[&](const down_msg& dm) { [&](const down_msg& dm) {
CAF_CHECK_EQUAL(dm.source, c); CAF_CHECK(dm.source == c);
CAF_CHECK_EQUAL(dm.reason, exit_reason::normal); CAF_CHECK_EQUAL(dm.reason, exit_reason::normal);
} }
); );
...@@ -565,7 +569,7 @@ CAF_TEST(test_remote_actor) { ...@@ -565,7 +569,7 @@ CAF_TEST(test_remote_actor) {
} else { } else {
for (int i = 0; i < 100; ++i) spawn([]{}); for (int i = 0; i < 100; ++i) spawn([]{});
await_all_actors_done(); await_all_actors_done();
test_remote_actor(caf::test::engine::path(), true, use_asio); test_remote_actor(test::engine::path(), true, use_asio);
} }
await_all_actors_done(); await_all_actors_done();
shutdown(); shutdown();
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/io/all.hpp" #include "caf/io/all.hpp"
#include "caf/detail/run_program.hpp" #include "caf/detail/run_sub_unit_test.hpp"
#include "caf/experimental/announce_actor_type.hpp" #include "caf/experimental/announce_actor_type.hpp"
...@@ -109,8 +109,8 @@ behavior server(stateful_actor<server_state>* self) { ...@@ -109,8 +109,8 @@ behavior server(stateful_actor<server_state>* self) {
CAF_TEST(remote_spawn) { CAF_TEST(remote_spawn) {
announce_actor_type("mirror", mirror); announce_actor_type("mirror", mirror);
auto argv = caf::test::engine::argv(); auto argv = test::engine::argv();
auto argc = caf::test::engine::argc(); auto argc = test::engine::argc();
uint16_t port = 0; uint16_t port = 0;
auto r = message_builder(argv, argv + argc).extract_opts({ auto r = message_builder(argv, argv + argc).extract_opts({
{"server,s", "run as server (don't run client"}, {"server,s", "run as server (don't run client"},
...@@ -137,14 +137,16 @@ CAF_TEST(remote_spawn) { ...@@ -137,14 +137,16 @@ CAF_TEST(remote_spawn) {
} }
auto serv = spawn(server); auto serv = spawn(server);
port = io::publish(serv, port); port = io::publish(serv, port);
CAF_TEST_INFO("published server at port " << port); CAF_MESSAGE("published server at port " << port);
if (r.opts.count("server") == 0) { if (r.opts.count("server") == 0) {
CAF_MESSAGE("run client program"); CAF_MESSAGE("run client program");
auto child = detail::run_program(invalid_actor, caf::test::engine::path(), auto child = detail::run_sub_unit_test(invalid_actor,
"-n", "-s", CAF_XSTR(CAF_SUITE), test::engine::path(),
"-r", test::engine::max_runtime(), "--", test::engine::max_runtime(),
"-c", port, CAF_XSTR(CAF_SUITE),
(use_asio ? "--use-asio" : "")); use_asio,
{"--client="
+ std::to_string(port)});
child.join(); child.join();
} }
await_all_actors_done(); await_all_actors_done();
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
#include "caf/detail/run_program.hpp" #include "caf/detail/run_sub_unit_test.hpp"
#ifdef CAF_USE_ASIO #ifdef CAF_USE_ASIO
#include "caf/io/network/asio_multiplexer.hpp" #include "caf/io/network/asio_multiplexer.hpp"
...@@ -191,11 +191,13 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) { ...@@ -191,11 +191,13 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) {
[&](uint16_t port) { [&](uint16_t port) {
CAF_MESSAGE("server is running on port " << port); CAF_MESSAGE("server is running on port " << port);
if (spawn_client) { if (spawn_client) {
auto child = detail::run_program(self, bin_path, "-n", auto child = detail::run_sub_unit_test(self,
"-s", CAF_XSTR(CAF_SUITE), bin_path,
"-r", test::engine::max_runtime(), test::engine::max_runtime(),
"--", "-c", port, CAF_XSTR(CAF_SUITE),
(use_asio ? "--use-asio" : "")); use_asio,
{"--client-port="
+ std::to_string(port)});
CAF_MESSAGE("block till child process has finished"); CAF_MESSAGE("block till child process has finished");
child.join(); child.join();
} }
...@@ -213,8 +215,8 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) { ...@@ -213,8 +215,8 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) {
} // namespace <anonymous> } // namespace <anonymous>
CAF_TEST(test_typed_broker) { CAF_TEST(test_typed_broker) {
auto argv = caf::test::engine::argv(); auto argv = test::engine::argv();
auto argc = caf::test::engine::argc(); auto argc = test::engine::argc();
uint16_t port = 0; uint16_t port = 0;
auto r = message_builder(argv, argv + argc).extract_opts({ auto r = message_builder(argv, argv + argc).extract_opts({
{"client-port,c", "set port for IO client", port}, {"client-port,c", "set port for IO client", port},
...@@ -243,7 +245,7 @@ CAF_TEST(test_typed_broker) { ...@@ -243,7 +245,7 @@ CAF_TEST(test_typed_broker) {
// run in server mode // run in server mode
run_server(false, argv[0], use_asio); run_server(false, argv[0], use_asio);
} else { } else {
run_server(true, caf::test::engine::path(), use_asio); run_server(true, test::engine::path(), use_asio);
} }
CAF_MESSAGE("block on `await_all_actors_done`"); CAF_MESSAGE("block on `await_all_actors_done`");
await_all_actors_done(); await_all_actors_done();
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/io/all.hpp" #include "caf/io/all.hpp"
#include "caf/detail/run_program.hpp" #include "caf/detail/run_sub_unit_test.hpp"
#ifdef CAF_USE_ASIO #ifdef CAF_USE_ASIO
#include "caf/io/network/asio_multiplexer.hpp" #include "caf/io/network/asio_multiplexer.hpp"
...@@ -101,8 +101,8 @@ uint16_t run_server() { ...@@ -101,8 +101,8 @@ uint16_t run_server() {
} }
CAF_TEST(test_typed_remote_actor) { CAF_TEST(test_typed_remote_actor) {
auto argv = caf::test::engine::argv(); auto argv = test::engine::argv();
auto argc = caf::test::engine::argc(); auto argc = test::engine::argc();
announce<ping>("ping", &ping::value); announce<ping>("ping", &ping::value);
announce<pong>("pong", &pong::value); announce<pong>("pong", &pong::value);
uint16_t port = 0; uint16_t port = 0;
...@@ -133,11 +133,13 @@ CAF_TEST(test_typed_remote_actor) { ...@@ -133,11 +133,13 @@ CAF_TEST(test_typed_remote_actor) {
// execute client_part() in a separate process, // execute client_part() in a separate process,
// connected via localhost socket // connected via localhost socket
scoped_actor self; scoped_actor self;
auto child = detail::run_program(self, test::engine::path(), "-n", auto child = detail::run_sub_unit_test(self,
"-s", CAF_XSTR(CAF_SUITE), test::engine::path(),
"-r", test::engine::max_runtime(), "--", test::engine::max_runtime(),
"-c", port, CAF_XSTR(CAF_SUITE),
(use_asio ? "--use-asio" : "")); use_asio,
{"--client-port="
+ std::to_string(port)});
CAF_MESSAGE("block till child process has finished"); CAF_MESSAGE("block till child process has finished");
child.join(); child.join();
self->await_all_other_actors_done(); self->await_all_other_actors_done();
......
...@@ -62,8 +62,8 @@ void test_invalid_unpublish(const actor& published, uint16_t port) { ...@@ -62,8 +62,8 @@ void test_invalid_unpublish(const actor& published, uint16_t port) {
} }
CAF_TEST(unpublishing) { CAF_TEST(unpublishing) {
auto argv = caf::test::engine::argv(); auto argv = test::engine::argv();
auto argc = caf::test::engine::argc(); auto argc = test::engine::argc();
if (argc == 1 && strcmp(argv[0], "--use-asio") == 0) { if (argc == 1 && strcmp(argv[0], "--use-asio") == 0) {
# ifdef CAF_USE_ASIO # ifdef CAF_USE_ASIO
CAF_MESSAGE("enable ASIO backend"); CAF_MESSAGE("enable ASIO backend");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment