Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
7ef94fef
Commit
7ef94fef
authored
Aug 31, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor launch process of sub-unit tests
parent
4e2e66cc
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
132 additions
and
112 deletions
+132
-112
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+1
-1
libcaf_core/caf/detail/run_sub_unit_test.hpp
libcaf_core/caf/detail/run_sub_unit_test.hpp
+11
-12
libcaf_core/caf/uniform_type_info.hpp
libcaf_core/caf/uniform_type_info.hpp
+0
-3
libcaf_core/src/run_sub_unit_test.cpp
libcaf_core/src/run_sub_unit_test.cpp
+23
-10
libcaf_core/test/announce_actor_type.cpp
libcaf_core/test/announce_actor_type.cpp
+1
-1
libcaf_core/test/aout.cpp
libcaf_core/test/aout.cpp
+1
-1
libcaf_core/test/atom.cpp
libcaf_core/test/atom.cpp
+1
-1
libcaf_core/test/dynamic_spawn.cpp
libcaf_core/test/dynamic_spawn.cpp
+3
-3
libcaf_core/test/extract.cpp
libcaf_core/test/extract.cpp
+9
-4
libcaf_core/test/message.cpp
libcaf_core/test/message.cpp
+1
-2
libcaf_core/test/metaprogramming.cpp
libcaf_core/test/metaprogramming.cpp
+1
-2
libcaf_core/test/profiled_coordinator.cpp
libcaf_core/test/profiled_coordinator.cpp
+1
-3
libcaf_core/test/serialization.cpp
libcaf_core/test/serialization.cpp
+1
-1
libcaf_core/test/sync_send.cpp
libcaf_core/test/sync_send.cpp
+2
-2
libcaf_core/test/work_sharing.cpp
libcaf_core/test/work_sharing.cpp
+1
-4
libcaf_io/test/automatic_connection.cpp
libcaf_io/test/automatic_connection.cpp
+11
-10
libcaf_io/test/dynamic_broker.cpp
libcaf_io/test/dynamic_broker.cpp
+11
-9
libcaf_io/test/http_broker.cpp
libcaf_io/test/http_broker.cpp
+2
-2
libcaf_io/test/remote_actor.cpp
libcaf_io/test/remote_actor.cpp
+17
-13
libcaf_io/test/remote_spawn.cpp
libcaf_io/test/remote_spawn.cpp
+11
-9
libcaf_io/test/typed_broker.cpp
libcaf_io/test/typed_broker.cpp
+11
-9
libcaf_io/test/typed_remote_actor.cpp
libcaf_io/test/typed_remote_actor.cpp
+10
-8
libcaf_io/test/unpublish.cpp
libcaf_io/test/unpublish.cpp
+2
-2
No files found.
libcaf_core/CMakeLists.txt
View file @
7ef94fef
...
...
@@ -66,7 +66,7 @@ set (LIBCAF_CORE_SRCS
src/replies_to.cpp
src/resumable.cpp
src/ripemd_160.cpp
src/run_
program
.cpp
src/run_
sub_unit_test
.cpp
src/scoped_actor.cpp
src/set_scheduler.cpp
src/serializer.cpp
...
...
libcaf_core/caf/detail/run_
program
.hpp
→
libcaf_core/caf/detail/run_
sub_unit_test
.hpp
View file @
7ef94fef
...
...
@@ -20,25 +20,24 @@
#ifndef 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 <vector>
#include <string>
#include <initializer_list>
#include "caf/send.hpp"
#include "caf/actor.hpp"
#include "caf/message.hpp"
namespace
caf
{
namespace
detail
{
std
::
thread
run_program_impl
(
caf
::
actor
,
const
char
*
,
std
::
vector
<
std
::
string
>
);
template
<
class
...
Ts
>
std
::
thread
run_program
(
caf
::
actor
listener
,
const
char
*
path
,
Ts
&&
...
args
)
{
std
::
vector
<
std
::
string
>
vec
{
convert_to_str
(
std
::
forward
<
Ts
>
(
args
))...};
return
run_program_impl
(
listener
,
path
,
std
::
move
(
vec
));
}
std
::
thread
run_sub_unit_test
(
caf
::
actor
listener
,
const
char
*
path
,
int
max_runtime
,
const
char
*
suite_name
,
bool
set_asio_option
,
std
::
initializer_list
<
std
::
string
>
args
);
}
// namespace detail
}
// namespace caf
...
...
libcaf_core/caf/uniform_type_info.hpp
View file @
7ef94fef
...
...
@@ -104,9 +104,6 @@ uniform_value make_uniform_value(const uniform_type_info* uti, Ts&&... xs) {
/// runtime.
///
/// ~~~
/// #include "caf/all.hpp"
/// using namespace caf;
///
/// struct foo { int a; int b; };
///
/// int main() {
...
...
libcaf_core/src/run_
program
.cpp
→
libcaf_core/src/run_
sub_unit_test
.cpp
View file @
7ef94fef
...
...
@@ -17,13 +17,15 @@
* 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 <iostream>
#include "caf/config.hpp"
#include "caf/string_algorithms.hpp"
#ifdef CAF_MSVC
# include <windows.h>
#endif
...
...
@@ -32,16 +34,23 @@ namespace caf {
namespace
detail
{
#ifndef CAF_WINDOWS
std
::
thread
run_program_impl
(
actor
rc
,
const
char
*
cpath
,
std
::
vector
<
std
::
string
>
args
)
{
std
::
thread
run_sub_unit_test
(
actor
rc
,
const
char
*
cpath
,
int
max_runtime
,
const
char
*
suite_name
,
bool
set_asio_option
,
std
::
initializer_list
<
std
::
string
>
args
)
{
using
namespace
std
;
string
path
=
cpath
;
replace_all
(
path
,
"'"
,
"
\\
'"
);
ostringstream
oss
;
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
;
}
if
(
set_asio_option
)
oss
<<
" --use-asio"
;
oss
<<
" 2>&1"
;
string
cmdstr
=
oss
.
str
();
return
std
::
thread
{
[
cmdstr
,
rc
]
{
...
...
@@ -67,15 +76,19 @@ std::thread run_program_impl(actor rc, const char* cpath,
}};
}
#else
std
::
thread
run_
program_impl
(
actor
rc
,
const
char
*
cpath
,
std
::
vector
<
std
::
string
>
args
)
{
std
::
thread
run_
sub_unit_test
(
actor
rc
,
const
char
*
cpath
,
std
::
vector
<
std
::
string
>
args
)
{
std
::
string
path
=
cpath
;
replace_all
(
path
,
"'"
,
"
\\
'"
);
std
::
ostringstream
oss
;
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
;
}
if
(
set_asio_option
)
oss
<<
" --use-asio"
;
return
std
::
thread
([
rc
](
std
::
string
cmdstr
)
{
STARTUPINFO
si
;
PROCESS_INFORMATION
pi
;
...
...
libcaf_core/test/announce_actor_type.cpp
View file @
7ef94fef
...
...
@@ -54,7 +54,7 @@ struct fixture {
if
(
expect_fail
)
{
self
->
sync_send
(
spawner
,
get_atom
::
value
,
"test_actor"
,
std
::
move
(
args
)).
await
(
[
&
](
error_atom
,
const
std
::
string
&
)
{
CAF_
TEST_VERBOS
E
(
"received error_atom (expected)"
);
CAF_
MESSAG
E
(
"received error_atom (expected)"
);
}
);
}
else
{
...
...
libcaf_core/test/aout.cpp
View file @
7ef94fef
...
...
@@ -57,7 +57,7 @@ void chattier_actor(event_based_actor* self, const std::string& fn) {
CAF_TEST_FIXTURE_SCOPE
(
aout_tests
,
fixture
)
CAF_TEST
(
global_redirect
)
{
CAF_TEST
(
redirect_aout_globally
)
{
scoped_actor
self
;
self
->
join
(
group
::
get
(
"local"
,
global_redirect
));
actor_ostream
::
redirect_all
(
global_redirect
);
...
...
libcaf_core/test/atom.cpp
View file @
7ef94fef
...
...
@@ -110,7 +110,7 @@ CAF_TEST(receive_atoms) {
);
atom_value
x
=
atom
(
"abc"
);
atom_value
y
=
abc_atom
::
value
;
CAF_CHECK
_EQUAL
(
x
,
y
);
CAF_CHECK
(
x
==
y
);
auto
msg
=
make_message
(
atom
(
"abc"
));
self
->
send
(
self
,
msg
);
self
->
receive
(
...
...
libcaf_core/test/dynamic_spawn.cpp
View file @
7ef94fef
...
...
@@ -499,7 +499,7 @@ CAF_TEST(send_to_self) {
self
->
receive
(
on
()
>>
[]
{});
}
CAF_TEST
(
echo_actor
)
{
CAF_TEST
(
echo_actor
_messaging
)
{
scoped_actor
self
;
auto
mecho
=
spawn
<
echo_actor
>
();
self
->
send
(
mecho
,
"hello echo"
);
...
...
@@ -531,7 +531,7 @@ CAF_TEST(delayed_spawn) {
spawn
<
testee1
>
();
}
CAF_TEST
(
spawn_event_testee2
)
{
CAF_TEST
(
spawn_event_testee2
_test
)
{
scoped_actor
self
;
spawn_event_testee2
(
self
);
self
->
receive
(
...
...
@@ -631,7 +631,7 @@ CAF_TEST(sync_sends) {
self
->
receive
(
[
&
](
const
down_msg
&
dm
)
{
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
();
...
...
libcaf_core/test/extract.cpp
View file @
7ef94fef
...
...
@@ -25,10 +25,15 @@
#include <string>
#include <vector>
#include "caf/on.hpp"
#include "caf/message.hpp"
#include "caf/message_builder.hpp"
#include "caf/message_handler.hpp"
#include "caf/all.hpp"
namespace
caf
{
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
message
&
msg
)
{
return
out
<<
to_string
(
msg
);
}
}
// namespace caf
using
namespace
caf
;
...
...
libcaf_core/test/message.cpp
View file @
7ef94fef
...
...
@@ -22,8 +22,7 @@
#define CAF_SUITE message
#include "caf/test/unit_test.hpp"
#include "caf/message.hpp"
#include "caf/message_builder.hpp"
#include "caf/all.hpp"
using
namespace
caf
;
...
...
libcaf_core/test/metaprogramming.cpp
View file @
7ef94fef
...
...
@@ -27,8 +27,7 @@
#include <typeinfo>
#include <type_traits>
#include "caf/shutdown.hpp"
#include "caf/uniform_type_info.hpp"
#include "caf/all.hpp"
#include "caf/detail/ctm.hpp"
#include "caf/detail/int_list.hpp"
...
...
libcaf_core/test/profiled_coordinator.cpp
View file @
7ef94fef
...
...
@@ -25,10 +25,8 @@
#define CAF_SUITE profiled_coordinator
#include "caf/test/unit_test.hpp"
#include "caf/config.hpp"
#include "caf/shutdown.hpp"
#include "caf/all.hpp"
#include "caf/set_scheduler.hpp"
#include "caf/scheduler/profiled_coordinator.hpp"
using
namespace
caf
;
...
...
libcaf_core/test/serialization.cpp
View file @
7ef94fef
...
...
@@ -238,7 +238,7 @@ CAF_TEST(test_int32_t) {
CAF_CHECK_EQUAL
(
i32
,
x
);
}
CAF_TEST
(
test_enum
)
{
CAF_TEST
(
test_enum
_serialization
)
{
auto
buf
=
binary_util
::
serialize
(
te
);
test_enum
x
;
binary_util
::
deserialize
(
buf
,
&
x
);
...
...
libcaf_core/test/sync_send.cpp
View file @
7ef94fef
...
...
@@ -471,7 +471,7 @@ CAF_TEST(sync_send) {
s
->
sync_send
(
serv
,
request_atom
::
value
).
await
(
[
=
](
response_atom
)
{
CAF_MESSAGE
(
"received `response_atom`"
);
CAF_CHECK
_EQUAL
(
s
->
current_sender
(),
work
);
CAF_CHECK
(
s
->
current_sender
()
==
work
);
},
others
>>
[
&
]
{
CAF_TEST_ERROR
(
"Unexpected message: "
...
...
@@ -483,7 +483,7 @@ CAF_TEST(sync_send) {
send_as
(
work
,
serv
,
idle_atom
::
value
,
work
);
handle
.
await
(
[
=
](
response_atom
)
{
CAF_CHECK
_EQUAL
(
s
->
current_sender
(),
work
);
CAF_CHECK
(
s
->
current_sender
()
==
work
);
},
others
>>
[
&
]
{
CAF_TEST_ERROR
(
"Unexpected message: "
...
...
libcaf_core/test/work_sharing.cpp
View file @
7ef94fef
...
...
@@ -22,10 +22,7 @@
#define CAF_SUITE work_sharing
#include "caf/test/unit_test.hpp"
#include "caf/config.hpp"
#include "caf/shutdown.hpp"
#include "caf/set_scheduler.hpp"
#include "caf/all.hpp"
#include "caf/policy/work_sharing.hpp"
...
...
libcaf_io/test/automatic_connection.cpp
View file @
7ef94fef
...
...
@@ -34,7 +34,7 @@
#include "caf/io/network/interfaces.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
#include "caf/io/network/asio_multiplexer.hpp"
...
...
@@ -76,11 +76,12 @@ using pong_atom = atom_constant<atom("pong")>;
*/
std
::
thread
run_prog
(
const
char
*
arg
,
uint16_t
port
,
bool
use_asio
)
{
return
detail
::
run_program
(
invalid_actor
,
test
::
engine
::
path
(),
"-n"
,
"-s"
,
CAF_XSTR
(
CAF_SUITE
),
"-r"
,
test
::
engine
::
max_runtime
(),
"--"
,
arg
,
"-p"
,
port
,
(
use_asio
?
"--use-asio"
:
""
));
return
detail
::
run_sub_unit_test
(
invalid_actor
,
test
::
engine
::
path
(),
test
::
engine
::
max_runtime
(),
CAF_XSTR
(
CAF_SUITE
),
use_asio
,
{
"--port="
+
std
::
to_string
(
port
),
arg
});
}
// 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) {
mars_process
.
join
();
self
->
receive
(
[
&
](
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"
);
...
...
@@ -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
};
CAF_CHECK
_EQUAL
(
found
,
expected
);
CAF_CHECK
(
found
==
expected
);
CAF_MESSAGE
(
"shutdown Jupiter"
);
anon_send_exit
(
jupiter_addr
,
exit_reason
::
kill
);
if
(
jupiter_process
.
joinable
())
...
...
@@ -247,8 +248,8 @@ void run_jupiter(uint16_t port_to_mars) {
CAF_TEST
(
triangle_setup
)
{
uint16_t
port
=
0
;
uint16_t
publish_port
=
0
;
auto
argv
=
caf
::
test
::
engine
::
argv
();
auto
argc
=
caf
::
test
::
engine
::
argc
();
auto
argv
=
test
::
engine
::
argv
();
auto
argc
=
test
::
engine
::
argc
();
auto
r
=
message_builder
(
argv
,
argv
+
argc
).
extract_opts
({
{
"port,p"
,
"port of remote side (when running mars or jupiter)"
,
port
},
{
"mars"
,
"run mars"
},
...
...
libcaf_io/test/dynamic_broker.cpp
View file @
7ef94fef
...
...
@@ -30,7 +30,7 @@
#include "caf/string_algorithms.hpp"
#include "caf/detail/run_
program
.hpp"
#include "caf/detail/run_
sub_unit_test
.hpp"
#ifdef CAF_USE_ASIO
#include "caf/io/network/asio_multiplexer.hpp"
...
...
@@ -186,11 +186,13 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) {
[
&
](
uint16_t
port
)
{
CAF_MESSAGE
(
"server is running on port "
<<
port
);
if
(
spawn_client
)
{
auto
child
=
detail
::
run_program
(
self
,
bin_path
,
"-n"
,
"-s"
,
CAF_XSTR
(
CAF_SUITE
),
"-r"
,
test
::
engine
::
max_runtime
(),
"--"
,
"-c"
,
port
,
(
use_asio
?
"--use-asio"
:
""
));
auto
child
=
detail
::
run_sub_unit_test
(
self
,
bin_path
,
test
::
engine
::
max_runtime
(),
CAF_XSTR
(
CAF_SUITE
),
use_asio
,
{
"--client-port="
+
std
::
to_string
(
port
)});
CAF_MESSAGE
(
"block till child process has finished"
);
child
.
join
();
}
...
...
@@ -208,8 +210,8 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) {
}
// namespace <anonymous>
CAF_TEST
(
test_broker
)
{
auto
argv
=
caf
::
test
::
engine
::
argv
();
auto
argc
=
caf
::
test
::
engine
::
argc
();
auto
argv
=
test
::
engine
::
argv
();
auto
argc
=
test
::
engine
::
argc
();
uint16_t
port
=
0
;
auto
r
=
message_builder
(
argv
,
argv
+
argc
).
extract_opts
({
{
"client-port,c"
,
"set port for IO client"
,
port
},
...
...
@@ -238,7 +240,7 @@ CAF_TEST(test_broker) {
// run in server mode
run_server
(
false
,
argv
[
0
],
use_asio
);
}
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`"
);
await_all_actors_done
();
...
...
libcaf_io/test/http_broker.cpp
View file @
7ef94fef
...
...
@@ -220,8 +220,8 @@ public:
CAF_REQUIRE
((
buf
.
size
()
>=
x
.
size
()));
CAF_REQUIRE
((
std
::
equal
(
buf
.
begin
(),
buf
.
begin
()
+
static_cast
<
ptrdiff_t
>
(
x
.
size
()),
x
.
begin
()));
buf
.
erase
(
buf
.
begin
(),
buf
.
begin
()
+
static_cast
<
ptrdiff_t
>
(
x
.
size
()))
)
;
x
.
begin
()))
)
;
buf
.
erase
(
buf
.
begin
(),
buf
.
begin
()
+
static_cast
<
ptrdiff_t
>
(
x
.
size
()));
return
*
this
;
}
...
...
libcaf_io/test/remote_actor.cpp
View file @
7ef94fef
...
...
@@ -34,7 +34,7 @@
#include "caf/detail/logging.hpp"
#include "caf/detail/singletons.hpp"
#include "caf/detail/run_
program
.hpp"
#include "caf/detail/run_
sub_unit_test
.hpp"
#ifdef CAF_USE_ASIO
#include "caf/io/network/asio_multiplexer.hpp"
...
...
@@ -70,10 +70,10 @@ behavior ping_behavior(local_actor* self, size_t ping_msgs) {
if
(
!
self
->
current_sender
())
{
CAF_TEST_ERROR
(
"current_sender() invalid!"
);
}
CAF_
TEST_INFO
(
"received {'pong', "
<<
value
<<
"}"
);
CAF_
MESSAGE
(
"received {'pong', "
<<
value
<<
"}"
);
// cout << to_string(self->current_message()) << endl;
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"
);
self
->
send_exit
(
self
->
current_sender
(),
exit_reason
::
user_shutdown
);
...
...
@@ -480,17 +480,21 @@ void test_remote_actor(const char* path, bool run_remote, bool use_asio) {
CAF_CHECK
(
serv
==
serv2
);
thread
child
;
if
(
run_remote
)
{
child
=
detail
::
run_program
(
self
,
path
,
"-n"
,
"-s"
,
CAF_XSTR
(
CAF_SUITE
),
"-r"
,
test
::
engine
::
max_runtime
(),
"--"
,
"-c"
,
port2
,
"-c"
,
port1
,
"-g"
,
gport
,
(
use_asio
?
"--use-asio"
:
""
));
child
=
detail
::
run_sub_unit_test
(
self
,
path
,
test
::
engine
::
max_runtime
(),
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
{
CAF_MESSAGE
(
"please run client with: "
<<
"-c "
<<
port2
<<
" -c "
<<
port1
<<
" -g "
<<
gport
);
}
self
->
receive
(
[
&
](
const
down_msg
&
dm
)
{
CAF_CHECK
_EQUAL
(
dm
.
source
,
serv
);
CAF_CHECK
(
dm
.
source
==
serv
);
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) {
}
// namespace <anonymous>
CAF_TEST
(
test_remote_actor
)
{
auto
argv
=
caf
::
test
::
engine
::
argv
();
auto
argc
=
caf
::
test
::
engine
::
argc
();
CAF_TEST
(
remote_actors
)
{
auto
argv
=
test
::
engine
::
argv
();
auto
argc
=
test
::
engine
::
argc
();
announce
<
actor_vector
>
(
"actor_vector"
);
cout
<<
"this node is: "
<<
to_string
(
caf
::
detail
::
singletons
::
get_node_id
())
<<
endl
;
...
...
@@ -557,7 +561,7 @@ CAF_TEST(test_remote_actor) {
auto
c
=
self
->
spawn
<
client
,
monitored
>
(
serv
);
self
->
receive
(
[
&
](
const
down_msg
&
dm
)
{
CAF_CHECK
_EQUAL
(
dm
.
source
,
c
);
CAF_CHECK
(
dm
.
source
==
c
);
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
normal
);
}
);
...
...
@@ -565,7 +569,7 @@ CAF_TEST(test_remote_actor) {
}
else
{
for
(
int
i
=
0
;
i
<
100
;
++
i
)
spawn
([]{});
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
();
shutdown
();
...
...
libcaf_io/test/remote_spawn.cpp
View file @
7ef94fef
...
...
@@ -32,7 +32,7 @@
#include "caf/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"
...
...
@@ -109,8 +109,8 @@ behavior server(stateful_actor<server_state>* self) {
CAF_TEST
(
remote_spawn
)
{
announce_actor_type
(
"mirror"
,
mirror
);
auto
argv
=
caf
::
test
::
engine
::
argv
();
auto
argc
=
caf
::
test
::
engine
::
argc
();
auto
argv
=
test
::
engine
::
argv
();
auto
argc
=
test
::
engine
::
argc
();
uint16_t
port
=
0
;
auto
r
=
message_builder
(
argv
,
argv
+
argc
).
extract_opts
({
{
"server,s"
,
"run as server (don't run client"
},
...
...
@@ -137,14 +137,16 @@ CAF_TEST(remote_spawn) {
}
auto
serv
=
spawn
(
server
);
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
)
{
CAF_MESSAGE
(
"run client program"
);
auto
child
=
detail
::
run_program
(
invalid_actor
,
caf
::
test
::
engine
::
path
(),
"-n"
,
"-s"
,
CAF_XSTR
(
CAF_SUITE
),
"-r"
,
test
::
engine
::
max_runtime
(),
"--"
,
"-c"
,
port
,
(
use_asio
?
"--use-asio"
:
""
));
auto
child
=
detail
::
run_sub_unit_test
(
invalid_actor
,
test
::
engine
::
path
(),
test
::
engine
::
max_runtime
(),
CAF_XSTR
(
CAF_SUITE
),
use_asio
,
{
"--client="
+
std
::
to_string
(
port
)});
child
.
join
();
}
await_all_actors_done
();
...
...
libcaf_io/test/typed_broker.cpp
View file @
7ef94fef
...
...
@@ -32,7 +32,7 @@
#include "caf/string_algorithms.hpp"
#include "caf/detail/run_
program
.hpp"
#include "caf/detail/run_
sub_unit_test
.hpp"
#ifdef CAF_USE_ASIO
#include "caf/io/network/asio_multiplexer.hpp"
...
...
@@ -191,11 +191,13 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) {
[
&
](
uint16_t
port
)
{
CAF_MESSAGE
(
"server is running on port "
<<
port
);
if
(
spawn_client
)
{
auto
child
=
detail
::
run_program
(
self
,
bin_path
,
"-n"
,
"-s"
,
CAF_XSTR
(
CAF_SUITE
),
"-r"
,
test
::
engine
::
max_runtime
(),
"--"
,
"-c"
,
port
,
(
use_asio
?
"--use-asio"
:
""
));
auto
child
=
detail
::
run_sub_unit_test
(
self
,
bin_path
,
test
::
engine
::
max_runtime
(),
CAF_XSTR
(
CAF_SUITE
),
use_asio
,
{
"--client-port="
+
std
::
to_string
(
port
)});
CAF_MESSAGE
(
"block till child process has finished"
);
child
.
join
();
}
...
...
@@ -213,8 +215,8 @@ void run_server(bool spawn_client, const char* bin_path, bool use_asio) {
}
// namespace <anonymous>
CAF_TEST
(
test_typed_broker
)
{
auto
argv
=
caf
::
test
::
engine
::
argv
();
auto
argc
=
caf
::
test
::
engine
::
argc
();
auto
argv
=
test
::
engine
::
argv
();
auto
argc
=
test
::
engine
::
argc
();
uint16_t
port
=
0
;
auto
r
=
message_builder
(
argv
,
argv
+
argc
).
extract_opts
({
{
"client-port,c"
,
"set port for IO client"
,
port
},
...
...
@@ -243,7 +245,7 @@ CAF_TEST(test_typed_broker) {
// run in server mode
run_server
(
false
,
argv
[
0
],
use_asio
);
}
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`"
);
await_all_actors_done
();
...
...
libcaf_io/test/typed_remote_actor.cpp
View file @
7ef94fef
...
...
@@ -32,7 +32,7 @@
#include "caf/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
#include "caf/io/network/asio_multiplexer.hpp"
...
...
@@ -101,8 +101,8 @@ uint16_t run_server() {
}
CAF_TEST
(
test_typed_remote_actor
)
{
auto
argv
=
caf
::
test
::
engine
::
argv
();
auto
argc
=
caf
::
test
::
engine
::
argc
();
auto
argv
=
test
::
engine
::
argv
();
auto
argc
=
test
::
engine
::
argc
();
announce
<
ping
>
(
"ping"
,
&
ping
::
value
);
announce
<
pong
>
(
"pong"
,
&
pong
::
value
);
uint16_t
port
=
0
;
...
...
@@ -133,11 +133,13 @@ CAF_TEST(test_typed_remote_actor) {
// execute client_part() in a separate process,
// connected via localhost socket
scoped_actor
self
;
auto
child
=
detail
::
run_program
(
self
,
test
::
engine
::
path
(),
"-n"
,
"-s"
,
CAF_XSTR
(
CAF_SUITE
),
"-r"
,
test
::
engine
::
max_runtime
(),
"--"
,
"-c"
,
port
,
(
use_asio
?
"--use-asio"
:
""
));
auto
child
=
detail
::
run_sub_unit_test
(
self
,
test
::
engine
::
path
(),
test
::
engine
::
max_runtime
(),
CAF_XSTR
(
CAF_SUITE
),
use_asio
,
{
"--client-port="
+
std
::
to_string
(
port
)});
CAF_MESSAGE
(
"block till child process has finished"
);
child
.
join
();
self
->
await_all_other_actors_done
();
...
...
libcaf_io/test/unpublish.cpp
View file @
7ef94fef
...
...
@@ -62,8 +62,8 @@ void test_invalid_unpublish(const actor& published, uint16_t port) {
}
CAF_TEST
(
unpublishing
)
{
auto
argv
=
caf
::
test
::
engine
::
argv
();
auto
argc
=
caf
::
test
::
engine
::
argc
();
auto
argv
=
test
::
engine
::
argv
();
auto
argc
=
test
::
engine
::
argc
();
if
(
argc
==
1
&&
strcmp
(
argv
[
0
],
"--use-asio"
)
==
0
)
{
# ifdef CAF_USE_ASIO
CAF_MESSAGE
(
"enable ASIO backend"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment