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
ee336330
Commit
ee336330
authored
Feb 24, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
print unit test log info to stdout as well
parent
600ad249
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
33 deletions
+39
-33
cppa/logging.hpp
cppa/logging.hpp
+3
-2
unit_testing/ping_pong.cpp
unit_testing/ping_pong.cpp
+7
-4
unit_testing/test_broker.cpp
unit_testing/test_broker.cpp
+2
-2
unit_testing/test_remote_actor.cpp
unit_testing/test_remote_actor.cpp
+14
-12
unit_testing/test_spawn.cpp
unit_testing/test_spawn.cpp
+12
-12
unit_testing/test_typed_remote_actor.cpp
unit_testing/test_typed_remote_actor.cpp
+1
-1
No files found.
cppa/logging.hpp
View file @
ee336330
...
...
@@ -171,10 +171,11 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) {
} CPPA_VOID_STMT
#ifndef CPPA_LOG_LEVEL
inline
cppa
::
actor_id
cppa_set_aid_dummy
()
{
return
0
;
}
# define CPPA_LOG_IMPL(lvlname, classname, funname, message) \
CPPA_PRINT_ERROR_IMPL(lvlname, classname, funname, message)
# define CPPA_PUSH_AID(unused)
# define CPPA_SET_AID(unused)
0
# define CPPA_PUSH_AID(unused)
static_cast<void>(0)
# define CPPA_SET_AID(unused)
cppa_set_aid_dummy()
# define CPPA_LOG_LEVEL 1
#else
# define CPPA_LOG_IMPL(lvlname, classname, funname, message) \
...
...
unit_testing/ping_pong.cpp
View file @
ee336330
#include <iostream>
#include "test.hpp"
#include "ping_pong.hpp"
#include "cppa/cppa.hpp"
...
...
@@ -18,11 +19,13 @@ size_t s_pongs = 0;
behavior
ping_behavior
(
local_actor
*
self
,
size_t
num_pings
)
{
return
(
on
(
atom
(
"pong"
),
arg_match
)
>>
[
=
](
int
value
)
->
any_tuple
{
CPPA_LOGF_ERROR_IF
(
!
self
->
last_sender
(),
"last_sender() == nullptr"
);
CPPA_LOGF_INFO
(
"received {'pong', "
<<
value
<<
"}"
);
if
(
!
self
->
last_sender
())
{
CPPA_PRINT
(
"last_sender() invalid!"
);
}
CPPA_PRINT
(
"received {'pong', "
<<
value
<<
"}"
);
//cout << to_string(self->last_dequeued()) << endl;
if
(
++
s_pongs
>=
num_pings
)
{
CPPA_
LOGF_INFO
(
"reached maximum, send {'EXIT', user_defined} "
CPPA_
PRINT
(
"reached maximum, send {'EXIT', user_defined} "
<<
"to last sender and quit with normal reason"
);
self
->
send_exit
(
self
->
last_sender
(),
exit_reason
::
user_shutdown
);
self
->
quit
();
...
...
@@ -40,7 +43,7 @@ behavior ping_behavior(local_actor* self, size_t num_pings) {
behavior
pong_behavior
(
local_actor
*
self
)
{
return
(
on
(
atom
(
"ping"
),
arg_match
)
>>
[](
int
value
)
->
any_tuple
{
CPPA_
LOGF_INFO
(
"received {'ping', "
<<
value
<<
"}"
);
CPPA_
PRINT
(
"received {'ping', "
<<
value
<<
"}"
);
return
make_any_tuple
(
atom
(
"pong"
),
value
+
1
);
},
others
()
>>
[
=
]
{
...
...
unit_testing/test_broker.cpp
View file @
ee336330
...
...
@@ -99,7 +99,7 @@ void peer(io::broker* self, io::connection_handle hdl, const actor& buddy) {
};
self
->
become
(
on
(
atom
(
"IO_closed"
),
arg_match
)
>>
[
=
](
io
::
connection_handle
)
{
CPPA_
LOGF_INFO
(
"received IO_closed"
);
CPPA_
PRINT
(
"received IO_closed"
);
self
->
quit
();
},
on
(
atom
(
"IO_read"
),
arg_match
)
>>
[
=
](
io
::
connection_handle
,
const
util
::
buffer
&
buf
)
{
...
...
@@ -127,7 +127,7 @@ void peer_acceptor(io::broker* self, const actor& buddy) {
self
->
become
(
on
(
atom
(
"IO_accept"
),
arg_match
)
>>
[
=
](
io
::
accept_handle
,
io
::
connection_handle
hdl
)
{
CPPA_CHECKPOINT
();
CPPA_
LOGF_INFO
(
"received IO_accept"
);
CPPA_
PRINT
(
"received IO_accept"
);
self
->
fork
(
peer
,
hdl
,
buddy
);
self
->
quit
();
},
...
...
unit_testing/test_remote_actor.cpp
View file @
ee336330
...
...
@@ -25,7 +25,7 @@ typedef vector<actor> actor_vector;
void
reflector
(
event_based_actor
*
self
)
{
self
->
become
(
others
()
>>
[
=
]
{
CPPA_
LOGF_INFO
(
"reflect and quit"
);
CPPA_
PRINT
(
"reflect and quit"
);
self
->
quit
();
return
self
->
last_dequeued
();
}
...
...
@@ -38,10 +38,10 @@ void spawn5_server_impl(event_based_actor* self, actor client, group grp) {
CPPA_CHECK
(
grp
!=
invalid_group
);
self
->
spawn_in_group
(
grp
,
reflector
);
self
->
spawn_in_group
(
grp
,
reflector
);
CPPA_
LOGF_INFO
(
"send {'Spawn5'} and await {'ok', actor_vector}"
);
CPPA_
PRINT
(
"send {'Spawn5'} and await {'ok', actor_vector}"
);
self
->
sync_send
(
client
,
atom
(
"Spawn5"
),
grp
).
then
(
on
(
atom
(
"ok"
),
arg_match
)
>>
[
=
](
const
actor_vector
&
vec
)
{
CPPA_
LOGF_INFO
(
"received vector with "
<<
vec
.
size
()
<<
" elements"
);
CPPA_
PRINT
(
"received vector with "
<<
vec
.
size
()
<<
" elements"
);
self
->
send
(
grp
,
"Hello reflectors!"
,
5.0
);
if
(
vec
.
size
()
!=
5
)
{
CPPA_PRINTERR
(
"remote client did not spawn five reflectors!"
);
...
...
@@ -107,7 +107,7 @@ void spawn5_server_impl(event_based_actor* self, actor client, group grp) {
void
spawn5_server
(
event_based_actor
*
self
,
actor
client
,
bool
inverted
)
{
if
(
!
inverted
)
spawn5_server_impl
(
self
,
client
,
group
::
get
(
"local"
,
"foobar"
));
else
{
CPPA_
LOGF_INFO
(
"request group"
);
CPPA_
PRINT
(
"request group"
);
self
->
sync_send
(
client
,
atom
(
"GetGroup"
)).
then
(
[
=
](
const
group
&
remote_group
)
{
spawn5_server_impl
(
self
,
client
,
remote_group
);
...
...
@@ -119,11 +119,11 @@ void spawn5_server(event_based_actor* self, actor client, bool inverted) {
void
spawn5_client
(
event_based_actor
*
self
)
{
self
->
become
(
on
(
atom
(
"GetGroup"
))
>>
[]()
->
group
{
CPPA_
LOGF_INFO
(
"received {'GetGroup'}"
);
CPPA_
PRINT
(
"received {'GetGroup'}"
);
return
group
::
get
(
"local"
,
"foobar"
);
},
on
(
atom
(
"Spawn5"
),
arg_match
)
>>
[
=
](
const
group
&
grp
)
->
any_tuple
{
CPPA_
LOGF_INFO
(
"received {'Spawn5'}"
);
CPPA_
PRINT
(
"received {'Spawn5'}"
);
actor_vector
vec
;
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
vec
.
push_back
(
spawn_in_group
(
grp
,
reflector
));
...
...
@@ -131,7 +131,7 @@ void spawn5_client(event_based_actor* self) {
return
make_any_tuple
(
atom
(
"ok"
),
std
::
move
(
vec
));
},
on
(
atom
(
"Spawn5Done"
))
>>
[
=
]
{
CPPA_
LOGF_INFO
(
"received {'Spawn5Done'}"
);
CPPA_
PRINT
(
"received {'Spawn5Done'}"
);
self
->
quit
();
}
);
...
...
@@ -252,10 +252,12 @@ class server : public event_based_actor {
on
(
atom
(
"SpawnPing"
))
>>
[
=
]()
->
any_tuple
{
CPPA_PRINT
(
"received {'SpawnPing'}"
);
auto
client
=
last_sender
();
CPPA_LOGF_ERROR_IF
(
!
client
,
"last_sender() == nullptr"
);
CPPA_LOGF_INFO
(
"spawn event-based ping actor"
);
if
(
!
client
)
{
CPPA_PRINT
(
"last_sender() invalid!"
);
}
CPPA_PRINT
(
"spawn event-based ping actor"
);
auto
pptr
=
spawn
<
monitored
>
(
event_based_ping
,
num_pings
);
CPPA_
LOGF_INFO
(
"wait until spawned ping actor is done"
);
CPPA_
PRINT
(
"wait until spawned ping actor is done"
);
await_down
(
this
,
pptr
,
[
=
]
{
CPPA_CHECK_EQUAL
(
pongs
(),
num_pings
);
await_sync_msg
();
...
...
@@ -331,11 +333,11 @@ int main(int argc, char** argv) {
bool
run_as_server
=
false
;
if
(
argc
>
1
)
{
if
(
strcmp
(
argv
[
1
],
"run_remote_actor=false"
)
==
0
)
{
CPPA_
LOGF_INFO
(
"don't run remote actor"
);
CPPA_
PRINT
(
"don't run remote actor"
);
run_remote_actor
=
false
;
}
else
if
(
strcmp
(
argv
[
1
],
"run_as_server"
)
==
0
)
{
CPPA_
LOGF_INFO
(
"don't run remote actor"
);
CPPA_
PRINT
(
"don't run remote actor"
);
run_remote_actor
=
false
;
run_as_server
=
true
;
}
...
...
unit_testing/test_spawn.cpp
View file @
ee336330
...
...
@@ -275,7 +275,7 @@ behavior echo_actor(event_based_actor* self) {
struct
simple_mirror
:
sb_actor
<
simple_mirror
>
{
behavior
init_state
;
simple_mirror
()
{
init_state
=
(
others
()
>>
[
=
]()
->
any_tuple
{
...
...
@@ -343,7 +343,7 @@ struct slave : event_based_actor {
void
test_serial_reply
()
{
auto
mirror_behavior
=
[
=
](
event_based_actor
*
self
)
{
self
->
become
(
others
()
>>
[
=
]()
->
any_tuple
{
CPPA_
LOGF_INFO
(
"return self->last_dequeued()"
);
CPPA_
PRINT
(
"return self->last_dequeued()"
);
return
self
->
last_dequeued
();
});
};
...
...
@@ -357,22 +357,22 @@ void test_serial_reply() {
auto
c4
=
self
->
spawn
<
linked
>
(
mirror_behavior
);
self
->
become
(
on
(
atom
(
"hi there"
))
>>
[
=
]()
->
continue_helper
{
CPPA_
LOGF_INFO
(
"received 'hi there'"
);
CPPA_
PRINT
(
"received 'hi there'"
);
return
self
->
sync_send
(
c0
,
atom
(
"sub0"
)).
then
(
on
(
atom
(
"sub0"
))
>>
[
=
]()
->
continue_helper
{
CPPA_
LOGF_INFO
(
"received 'sub0'"
);
CPPA_
PRINT
(
"received 'sub0'"
);
return
self
->
sync_send
(
c1
,
atom
(
"sub1"
)).
then
(
on
(
atom
(
"sub1"
))
>>
[
=
]()
->
continue_helper
{
CPPA_
LOGF_INFO
(
"received 'sub1'"
);
CPPA_
PRINT
(
"received 'sub1'"
);
return
self
->
sync_send
(
c2
,
atom
(
"sub2"
)).
then
(
on
(
atom
(
"sub2"
))
>>
[
=
]()
->
continue_helper
{
CPPA_
LOGF_INFO
(
"received 'sub2'"
);
CPPA_
PRINT
(
"received 'sub2'"
);
return
self
->
sync_send
(
c3
,
atom
(
"sub3"
)).
then
(
on
(
atom
(
"sub3"
))
>>
[
=
]()
->
continue_helper
{
CPPA_
LOGF_INFO
(
"received 'sub3'"
);
CPPA_
PRINT
(
"received 'sub3'"
);
return
self
->
sync_send
(
c4
,
atom
(
"sub4"
)).
then
(
on
(
atom
(
"sub4"
))
>>
[
=
]()
->
atom_value
{
CPPA_
LOGF_INFO
(
"received 'sub4'"
);
CPPA_
PRINT
(
"received 'sub4'"
);
return
atom
(
"hiho"
);
}
);
...
...
@@ -426,13 +426,13 @@ void test_or_else() {
self
->
await_all_other_actors_done
();
});
CPPA_
LOGF_INFO
(
"run_testee: handle_a.or_else(handle_b).or_else(handle_c)"
);
CPPA_
PRINT
(
"run_testee: handle_a.or_else(handle_b).or_else(handle_c)"
);
run_testee
(
spawn
([
=
]
{
return
handle_a
.
or_else
(
handle_b
).
or_else
(
handle_c
);
})
);
CPPA_
LOGF_INFO
(
"run_testee: handle_a.or_else(handle_b), on(
\"
c
\"
) ..."
);
CPPA_
PRINT
(
"run_testee: handle_a.or_else(handle_b), on(
\"
c
\"
) ..."
);
run_testee
(
spawn
([
=
]
{
return
(
...
...
@@ -441,7 +441,7 @@ void test_or_else() {
);
})
);
CPPA_
LOGF_INFO
(
"run_testee: on(
\"
a
\"
) ..., handle_b.or_else(handle_c)"
);
CPPA_
PRINT
(
"run_testee: on(
\"
a
\"
) ..., handle_b.or_else(handle_c)"
);
run_testee
(
spawn
([
=
]
{
return
(
...
...
@@ -832,7 +832,7 @@ void test_spawn() {
// create some actors linked to one single actor
// and kill them all through killing the link
auto
legion
=
spawn
([](
event_based_actor
*
self
)
{
CPPA_
LOGF_INFO
(
"spawn 1, 000 actors"
);
CPPA_
PRINT
(
"spawn 1, 000 actors"
);
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
self
->
spawn
<
event_testee
,
linked
>
();
}
...
...
unit_testing/test_typed_remote_actor.cpp
View file @
ee336330
...
...
@@ -86,7 +86,7 @@ int main(int argc, char** argv) {
auto
run_remote_actor
=
true
;
if
(
argc
>
1
)
{
if
(
strcmp
(
argv
[
1
],
"run_remote_actor=false"
)
==
0
)
{
CPPA_
LOGF_INFO
(
"don't run remote actor"
);
CPPA_
PRINT
(
"don't run remote actor"
);
run_remote_actor
=
false
;
}
else
{
...
...
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