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
05df7bfe
Commit
05df7bfe
authored
Apr 29, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Leave cleanup in unit tests to ref counting
parent
765b76a8
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
98 additions
and
238 deletions
+98
-238
libcaf_core/test/custom_exception_handler.cpp
libcaf_core/test/custom_exception_handler.cpp
+28
-31
libcaf_core/test/dynamic_spawn.cpp
libcaf_core/test/dynamic_spawn.cpp
+1
-2
libcaf_core/test/local_group.cpp
libcaf_core/test/local_group.cpp
+5
-5
libcaf_core/test/request_response.cpp
libcaf_core/test/request_response.cpp
+5
-7
libcaf_core/test/request_timeout.cpp
libcaf_core/test/request_timeout.cpp
+12
-9
libcaf_core/test/sequencer.cpp
libcaf_core/test/sequencer.cpp
+0
-15
libcaf_core/test/serial_reply.cpp
libcaf_core/test/serial_reply.cpp
+0
-1
libcaf_core/test/shutdown.cpp
libcaf_core/test/shutdown.cpp
+0
-52
libcaf_core/test/simple_reply_response.cpp
libcaf_core/test/simple_reply_response.cpp
+0
-46
libcaf_core/test/splitter.cpp
libcaf_core/test/splitter.cpp
+2
-2
libcaf_core/test/stateful_actor.cpp
libcaf_core/test/stateful_actor.cpp
+0
-1
libcaf_core/test/typed_response_promise.cpp
libcaf_core/test/typed_response_promise.cpp
+1
-4
libcaf_core/test/typed_spawn.cpp
libcaf_core/test/typed_spawn.cpp
+44
-63
No files found.
libcaf_core/test/custom_exception_handler.cpp
View file @
05df7bfe
...
@@ -61,36 +61,33 @@ CAF_TEST(test_custom_exception_handler) {
...
@@ -61,36 +61,33 @@ CAF_TEST(test_custom_exception_handler) {
}
}
return
exit_reason
::
unhandled_exception
;
return
exit_reason
::
unhandled_exception
;
};
};
{
scoped_actor
self
{
system
};
scoped_actor
self
{
system
};
auto
testee1
=
self
->
spawn
<
monitored
>
([
=
](
event_based_actor
*
eb_self
)
{
auto
testee1
=
self
->
spawn
<
monitored
>
([
=
](
event_based_actor
*
eb_self
)
{
eb_self
->
set_exception_handler
(
handler
);
eb_self
->
set_exception_handler
(
handler
);
throw
std
::
runtime_error
(
"ping"
);
throw
std
::
runtime_error
(
"ping"
);
});
});
auto
testee2
=
self
->
spawn
<
monitored
>
([
=
](
event_based_actor
*
eb_self
)
{
auto
testee2
=
self
->
spawn
<
monitored
>
([
=
](
event_based_actor
*
eb_self
)
{
eb_self
->
set_exception_handler
(
handler
);
eb_self
->
set_exception_handler
(
handler
);
throw
std
::
logic_error
(
"pong"
);
throw
std
::
logic_error
(
"pong"
);
});
});
auto
testee3
=
self
->
spawn
<
exception_testee
,
monitored
>
();
auto
testee3
=
self
->
spawn
<
exception_testee
,
monitored
>
();
self
->
send
(
testee3
,
"foo"
);
self
->
send
(
testee3
,
"foo"
);
// receive all down messages
// receive all down messages
auto
i
=
0
;
auto
i
=
0
;
self
->
receive_for
(
i
,
3
)(
self
->
receive_for
(
i
,
3
)(
[
&
](
const
down_msg
&
dm
)
{
[
&
](
const
down_msg
&
dm
)
{
if
(
dm
.
source
==
testee1
)
{
if
(
dm
.
source
==
testee1
)
{
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
normal
);
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
normal
);
}
else
if
(
dm
.
source
==
testee2
)
{
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
unhandled_exception
);
}
else
if
(
dm
.
source
==
testee3
)
{
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
remote_link_unreachable
);
}
else
{
throw
std
::
runtime_error
(
"received message from unexpected source"
);
}
}
}
);
else
if
(
dm
.
source
==
testee2
)
{
self
->
await_all_other_actors_done
();
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
unhandled_exception
);
}
}
else
if
(
dm
.
source
==
testee3
)
{
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
remote_link_unreachable
);
}
else
{
throw
std
::
runtime_error
(
"received message from unexpected source"
);
}
}
);
}
}
libcaf_core/test/dynamic_spawn.cpp
View file @
05df7bfe
...
@@ -564,9 +564,8 @@ CAF_TEST(constructor_attach) {
...
@@ -564,9 +564,8 @@ CAF_TEST(constructor_attach) {
},
},
[
=
](
ok_atom
,
const
error
&
reason
)
{
[
=
](
ok_atom
,
const
error
&
reason
)
{
CAF_CHECK_EQUAL
(
reason
,
exit_reason
::
user_shutdown
);
CAF_CHECK_EQUAL
(
reason
,
exit_reason
::
user_shutdown
);
if
(
++
downs_
==
2
)
{
if
(
++
downs_
==
2
)
quit
(
reason
);
quit
(
reason
);
}
},
},
[
=
](
exit_msg
&
msg
)
{
[
=
](
exit_msg
&
msg
)
{
delegate
(
testee_
,
std
::
move
(
msg
));
delegate
(
testee_
,
std
::
move
(
msg
));
...
...
libcaf_core/test/local_group.cpp
View file @
05df7bfe
...
@@ -31,26 +31,26 @@ using namespace caf;
...
@@ -31,26 +31,26 @@ using namespace caf;
using
msg_atom
=
atom_constant
<
atom
(
"msg"
)
>
;
using
msg_atom
=
atom_constant
<
atom
(
"msg"
)
>
;
using
timeout_atom
=
atom_constant
<
atom
(
"timeout"
)
>
;
using
timeout_atom
=
atom_constant
<
atom
(
"timeout"
)
>
;
void
testee
(
event_based_actor
*
self
)
{
behavior
testee
(
event_based_actor
*
self
)
{
auto
counter
=
std
::
make_shared
<
int
>
(
0
);
auto
counter
=
std
::
make_shared
<
int
>
(
0
);
auto
grp
=
self
->
system
().
groups
().
get
(
"local"
,
"test"
);
auto
grp
=
self
->
system
().
groups
().
get
(
"local"
,
"test"
);
self
->
join
(
grp
);
self
->
join
(
grp
);
CAF_MESSAGE
(
"self joined group"
);
CAF_MESSAGE
(
"self joined group"
);
self
->
become
(
self
->
send
(
grp
,
msg_atom
::
value
);
return
{
[
=
](
msg_atom
)
{
[
=
](
msg_atom
)
{
CAF_MESSAGE
(
"received `msg_atom`"
);
CAF_MESSAGE
(
"received `msg_atom`"
);
++*
counter
;
++*
counter
;
self
->
leave
(
grp
);
self
->
leave
(
grp
);
self
->
send
(
grp
,
msg_atom
::
value
);
self
->
send
(
grp
,
msg_atom
::
value
);
self
->
send
(
self
,
timeout_atom
::
value
);
},
},
[
=
](
timeout_atom
)
{
[
=
](
timeout_atom
)
{
// this actor should receive only 1 message
// this actor should receive only 1 message
CAF_CHECK_EQUAL
(
*
counter
,
1
);
CAF_CHECK_EQUAL
(
*
counter
,
1
);
self
->
quit
();
self
->
quit
();
}
}
);
};
self
->
send
(
grp
,
msg_atom
::
value
);
self
->
delayed_send
(
self
,
std
::
chrono
::
seconds
(
1
),
timeout_atom
::
value
);
}
}
CAF_TEST
(
test_local_group
)
{
CAF_TEST
(
test_local_group
)
{
...
...
libcaf_core/test/request.cpp
→
libcaf_core/test/request
_response
.cpp
View file @
05df7bfe
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include "caf/config.hpp"
#include "caf/config.hpp"
#define CAF_SUITE request
#define CAF_SUITE request
_response
#include "caf/test/unit_test.hpp"
#include "caf/test/unit_test.hpp"
#include "caf/all.hpp"
#include "caf/all.hpp"
...
@@ -409,24 +409,22 @@ CAF_TEST(client_server_worker_user_case) {
...
@@ -409,24 +409,22 @@ CAF_TEST(client_server_worker_user_case) {
);
);
}
}
behavior
snyc_send_no_then_A
(
event_based_actor
*
self
)
{
behavior
request_no_then_A
(
event_based_actor
*
)
{
return
[
=
](
int
number
)
{
return
[
=
](
int
number
)
{
CAF_MESSAGE
(
"got "
<<
number
);
CAF_MESSAGE
(
"got "
<<
number
);
self
->
quit
();
};
};
}
}
behavior
snyc_send_no_then_B
(
event_based_actor
*
self
)
{
behavior
request_no_then_B
(
event_based_actor
*
self
)
{
return
{
return
{
[
=
](
int
number
)
{
[
=
](
int
number
)
{
self
->
request
(
self
->
spawn
(
snyc_send_no_then_A
),
infinite
,
number
);
self
->
request
(
self
->
spawn
(
request_no_then_A
),
infinite
,
number
);
self
->
quit
();
}
}
};
};
}
}
CAF_TEST
(
request_no_then
)
{
CAF_TEST
(
request_no_then
)
{
anon_send
(
system
.
spawn
(
snyc_send
_no_then_B
),
8
);
anon_send
(
system
.
spawn
(
request
_no_then_B
),
8
);
}
}
CAF_TEST
(
async_request
)
{
CAF_TEST
(
async_request
)
{
...
...
libcaf_core/test/request_timeout.cpp
View file @
05df7bfe
...
@@ -29,6 +29,9 @@
...
@@ -29,6 +29,9 @@
using
namespace
caf
;
using
namespace
caf
;
using
std
::
chrono
::
seconds
;
using
std
::
chrono
::
milliseconds
;
namespace
{
namespace
{
using
ping_atom
=
atom_constant
<
atom
(
"ping"
)
>
;
using
ping_atom
=
atom_constant
<
atom
(
"ping"
)
>
;
...
@@ -38,7 +41,7 @@ using send_ping_atom = atom_constant<atom("send_ping")>;
...
@@ -38,7 +41,7 @@ using send_ping_atom = atom_constant<atom("send_ping")>;
behavior
pong
()
{
behavior
pong
()
{
return
{
return
{
[
=
]
(
ping_atom
)
{
[
=
]
(
ping_atom
)
{
std
::
this_thread
::
sleep_for
(
s
td
::
chrono
::
s
econds
(
1
));
std
::
this_thread
::
sleep_for
(
seconds
(
1
));
return
pong_atom
::
value
;
return
pong_atom
::
value
;
}
}
};
};
...
@@ -49,7 +52,7 @@ behavior ping1(event_based_actor* self, const actor& pong_actor) {
...
@@ -49,7 +52,7 @@ behavior ping1(event_based_actor* self, const actor& pong_actor) {
self
->
send
(
self
,
send_ping_atom
::
value
);
self
->
send
(
self
,
send_ping_atom
::
value
);
return
{
return
{
[
=
](
send_ping_atom
)
{
[
=
](
send_ping_atom
)
{
self
->
request
(
pong_actor
,
std
::
chrono
::
milliseconds
(
100
),
ping_atom
::
value
).
then
(
self
->
request
(
pong_actor
,
milliseconds
(
100
),
ping_atom
::
value
).
then
(
[
=
](
pong_atom
)
{
[
=
](
pong_atom
)
{
CAF_ERROR
(
"received pong atom"
);
CAF_ERROR
(
"received pong atom"
);
self
->
quit
(
exit_reason
::
user_shutdown
);
self
->
quit
(
exit_reason
::
user_shutdown
);
...
@@ -69,7 +72,7 @@ behavior ping2(event_based_actor* self, const actor& pong_actor) {
...
@@ -69,7 +72,7 @@ behavior ping2(event_based_actor* self, const actor& pong_actor) {
auto
received_inner
=
std
::
make_shared
<
bool
>
(
false
);
auto
received_inner
=
std
::
make_shared
<
bool
>
(
false
);
return
{
return
{
[
=
](
send_ping_atom
)
{
[
=
](
send_ping_atom
)
{
self
->
request
(
pong_actor
,
std
::
chrono
::
milliseconds
(
100
),
ping_atom
::
value
).
then
(
self
->
request
(
pong_actor
,
milliseconds
(
100
),
ping_atom
::
value
).
then
(
[
=
](
pong_atom
)
{
[
=
](
pong_atom
)
{
CAF_ERROR
(
"received pong atom"
);
CAF_ERROR
(
"received pong atom"
);
self
->
quit
(
exit_reason
::
user_shutdown
);
self
->
quit
(
exit_reason
::
user_shutdown
);
...
@@ -81,7 +84,7 @@ behavior ping2(event_based_actor* self, const actor& pong_actor) {
...
@@ -81,7 +84,7 @@ behavior ping2(event_based_actor* self, const actor& pong_actor) {
}
}
);
);
},
},
after
(
std
::
chrono
::
milliseconds
(
100
))
>>
[
=
]
{
after
(
milliseconds
(
100
))
>>
[
=
]
{
CAF_CHECK_EQUAL
(
*
received_inner
,
true
);
CAF_CHECK_EQUAL
(
*
received_inner
,
true
);
self
->
quit
(
exit_reason
::
user_shutdown
);
self
->
quit
(
exit_reason
::
user_shutdown
);
}
}
...
@@ -93,7 +96,7 @@ behavior ping3(event_based_actor* self, const actor& pong_actor) {
...
@@ -93,7 +96,7 @@ behavior ping3(event_based_actor* self, const actor& pong_actor) {
self
->
send
(
self
,
send_ping_atom
::
value
);
self
->
send
(
self
,
send_ping_atom
::
value
);
return
{
return
{
[
=
](
send_ping_atom
)
{
[
=
](
send_ping_atom
)
{
self
->
request
(
pong_actor
,
std
::
chrono
::
milliseconds
(
100
),
self
->
request
(
pong_actor
,
milliseconds
(
100
),
ping_atom
::
value
).
then
(
ping_atom
::
value
).
then
(
[
=
](
pong_atom
)
{
[
=
](
pong_atom
)
{
CAF_ERROR
(
"received pong atom"
);
CAF_ERROR
(
"received pong atom"
);
...
@@ -115,7 +118,7 @@ behavior ping4(event_based_actor* self, const actor& pong_actor) {
...
@@ -115,7 +118,7 @@ behavior ping4(event_based_actor* self, const actor& pong_actor) {
auto
received_outer
=
std
::
make_shared
<
bool
>
(
false
);
auto
received_outer
=
std
::
make_shared
<
bool
>
(
false
);
return
{
return
{
[
=
](
send_ping_atom
)
{
[
=
](
send_ping_atom
)
{
self
->
request
(
pong_actor
,
std
::
chrono
::
milliseconds
(
100
),
self
->
request
(
pong_actor
,
milliseconds
(
100
),
ping_atom
::
value
).
then
(
ping_atom
::
value
).
then
(
[
=
](
pong_atom
)
{
[
=
](
pong_atom
)
{
CAF_ERROR
(
"received pong atom"
);
CAF_ERROR
(
"received pong atom"
);
...
@@ -128,7 +131,7 @@ behavior ping4(event_based_actor* self, const actor& pong_actor) {
...
@@ -128,7 +131,7 @@ behavior ping4(event_based_actor* self, const actor& pong_actor) {
}
}
);
);
},
},
after
(
std
::
chrono
::
milliseconds
(
50
))
>>
[
=
]
{
after
(
milliseconds
(
50
))
>>
[
=
]
{
CAF_MESSAGE
(
"outer timeout: check"
);
CAF_MESSAGE
(
"outer timeout: check"
);
*
received_outer
=
true
;
*
received_outer
=
true
;
}
}
...
@@ -138,7 +141,7 @@ behavior ping4(event_based_actor* self, const actor& pong_actor) {
...
@@ -138,7 +141,7 @@ behavior ping4(event_based_actor* self, const actor& pong_actor) {
void
ping5
(
event_based_actor
*
self
,
const
actor
&
pong_actor
)
{
void
ping5
(
event_based_actor
*
self
,
const
actor
&
pong_actor
)
{
self
->
link_to
(
pong_actor
);
self
->
link_to
(
pong_actor
);
auto
timeouts
=
std
::
make_shared
<
int
>
(
0
);
auto
timeouts
=
std
::
make_shared
<
int
>
(
0
);
self
->
request
(
pong_actor
,
std
::
chrono
::
milliseconds
(
100
),
self
->
request
(
pong_actor
,
milliseconds
(
100
),
ping_atom
::
value
).
then
(
ping_atom
::
value
).
then
(
[
=
](
pong_atom
)
{
[
=
](
pong_atom
)
{
CAF_ERROR
(
"received pong atom"
);
CAF_ERROR
(
"received pong atom"
);
...
@@ -149,7 +152,7 @@ void ping5(event_based_actor* self, const actor& pong_actor) {
...
@@ -149,7 +152,7 @@ void ping5(event_based_actor* self, const actor& pong_actor) {
self
->
quit
();
self
->
quit
();
}
}
);
);
self
->
request
(
pong_actor
,
std
::
chrono
::
milliseconds
(
100
),
self
->
request
(
pong_actor
,
milliseconds
(
100
),
ping_atom
::
value
).
await
(
ping_atom
::
value
).
await
(
[
=
](
pong_atom
)
{
[
=
](
pong_atom
)
{
CAF_ERROR
(
"received pong atom"
);
CAF_ERROR
(
"received pong atom"
);
...
...
libcaf_core/test/sequencer.cpp
View file @
05df7bfe
...
@@ -92,10 +92,6 @@ CAF_TEST(identity) {
...
@@ -92,10 +92,6 @@ CAF_TEST(identity) {
CAF_CHECK_NOT_EQUAL
(
h
->
id
(),
g
->
id
());
CAF_CHECK_NOT_EQUAL
(
h
->
id
(),
g
->
id
());
CAF_CHECK_NOT_EQUAL
(
h
.
address
(),
g
.
address
());
CAF_CHECK_NOT_EQUAL
(
h
.
address
(),
g
.
address
());
CAF_CHECK_EQUAL
(
h
->
message_types
(),
g
->
home_system
().
message_types
(
h
));
CAF_CHECK_EQUAL
(
h
->
message_types
(),
g
->
home_system
().
message_types
(
h
));
anon_send_exit
(
f
,
exit_reason
::
kill
);
anon_send_exit
(
g
,
exit_reason
::
kill
);
// killing both f and g triggers down messages to h,
// ultimately clearing up held references and h will become unreachable
}
}
// spawned dead if `g` is already dead upon spawning
// spawned dead if `g` is already dead upon spawning
...
@@ -107,7 +103,6 @@ CAF_TEST(lifetime_1a) {
...
@@ -107,7 +103,6 @@ CAF_TEST(lifetime_1a) {
wait_until_is_terminated
();
wait_until_is_terminated
();
auto
h
=
f
*
g
;
auto
h
=
f
*
g
;
CAF_CHECK
(
exited
(
h
));
CAF_CHECK
(
exited
(
h
));
anon_send_exit
(
f
,
exit_reason
::
kill
);
}
}
// spawned dead if `f` is already dead upon spawning
// spawned dead if `f` is already dead upon spawning
...
@@ -119,7 +114,6 @@ CAF_TEST(lifetime_1b) {
...
@@ -119,7 +114,6 @@ CAF_TEST(lifetime_1b) {
wait_until_is_terminated
();
wait_until_is_terminated
();
auto
h
=
f
*
g
;
auto
h
=
f
*
g
;
CAF_CHECK
(
exited
(
h
));
CAF_CHECK
(
exited
(
h
));
anon_send_exit
(
g
,
exit_reason
::
kill
);
}
}
// `f.g` exits when `g` exits
// `f.g` exits when `g` exits
...
@@ -129,8 +123,6 @@ CAF_TEST(lifetime_2a) {
...
@@ -129,8 +123,6 @@ CAF_TEST(lifetime_2a) {
auto
h
=
f
*
g
;
auto
h
=
f
*
g
;
self
->
monitor
(
h
);
self
->
monitor
(
h
);
anon_send
(
g
,
message
{});
anon_send
(
g
,
message
{});
wait_until_is_terminated
();
anon_send_exit
(
f
,
exit_reason
::
kill
);
}
}
// `f.g` exits when `f` exits
// `f.g` exits when `f` exits
...
@@ -140,8 +132,6 @@ CAF_TEST(lifetime_2b) {
...
@@ -140,8 +132,6 @@ CAF_TEST(lifetime_2b) {
auto
h
=
f
*
g
;
auto
h
=
f
*
g
;
self
->
monitor
(
h
);
self
->
monitor
(
h
);
anon_send
(
f
,
message
{});
anon_send
(
f
,
message
{});
wait_until_is_terminated
();
anon_send_exit
(
g
,
exit_reason
::
kill
);
}
}
CAF_TEST
(
request_response_promise
)
{
CAF_TEST
(
request_response_promise
)
{
...
@@ -158,8 +148,6 @@ CAF_TEST(request_response_promise) {
...
@@ -158,8 +148,6 @@ CAF_TEST(request_response_promise) {
CAF_CHECK_EQUAL
(
err
.
code
(),
static_cast
<
uint8_t
>
(
sec
::
request_receiver_down
));
CAF_CHECK_EQUAL
(
err
.
code
(),
static_cast
<
uint8_t
>
(
sec
::
request_receiver_down
));
}
}
);
);
anon_send_exit
(
f
,
exit_reason
::
kill
);
anon_send_exit
(
g
,
exit_reason
::
kill
);
}
}
// single composition of distinct actors
// single composition of distinct actors
...
@@ -172,8 +160,6 @@ CAF_TEST(dot_composition_1) {
...
@@ -172,8 +160,6 @@ CAF_TEST(dot_composition_1) {
CAF_CHECK_EQUAL
(
res
,
(
42
*
2.0
)
*
(
42
*
4.0
));
CAF_CHECK_EQUAL
(
res
,
(
42
*
2.0
)
*
(
42
*
4.0
));
}
}
);
);
anon_send_exit
(
first
,
exit_reason
::
kill
);
anon_send_exit
(
second
,
exit_reason
::
kill
);
}
}
// multiple self composition
// multiple self composition
...
@@ -189,7 +175,6 @@ CAF_TEST(dot_composition_2) {
...
@@ -189,7 +175,6 @@ CAF_TEST(dot_composition_2) {
CAF_CHECK
(
false
);
CAF_CHECK
(
false
);
}
}
);
);
anon_send_exit
(
dbl_actor
,
exit_reason
::
kill
);
}
}
CAF_TEST_FIXTURE_SCOPE_END
()
CAF_TEST_FIXTURE_SCOPE_END
()
libcaf_core/test/serial_reply.cpp
View file @
05df7bfe
...
@@ -101,5 +101,4 @@ CAF_TEST(test_serial_reply) {
...
@@ -101,5 +101,4 @@ CAF_TEST(test_serial_reply) {
}
}
);
);
CAF_REQUIRE
(
self
->
mailbox
().
count
()
==
0
);
CAF_REQUIRE
(
self
->
mailbox
().
count
()
==
0
);
self
->
send_exit
(
master
,
exit_reason
::
user_shutdown
);
}
}
libcaf_core/test/shutdown.cpp
deleted
100644 → 0
View file @
765b76a8
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/config.hpp"
#define CAF_SUITE shutdown
#include "caf/test/unit_test.hpp"
#include "caf/all.hpp"
using
namespace
caf
;
namespace
{
behavior
testee
()
{
return
{
[]
{
// nop
}
};
}
}
// namespace <anonymous>
CAF_TEST
(
repeated_shutdown
)
{
actor_system
system
;
for
(
auto
i
=
0
;
i
<
10
;
++
i
)
{
CAF_MESSAGE
(
"run #"
<<
i
);
auto
g
=
system
.
groups
().
anonymous
();
for
(
auto
j
=
0
;
j
<
10
;
++
j
)
system
.
spawn_in_group
(
g
,
testee
);
anon_send
(
g
,
"hello actors"
);
anon_send
(
g
,
exit_msg
{
invalid_actor_addr
,
exit_reason
::
user_shutdown
});
system
.
await_all_actors_done
();
}
}
libcaf_core/test/simple_reply_response.cpp
deleted
100644 → 0
View file @
765b76a8
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/config.hpp"
#define CAF_SUITE simple_reply_response
#include "caf/test/unit_test.hpp"
#include "caf/all.hpp"
using
namespace
caf
;
CAF_TEST
(
simple_reply_response
)
{
actor_system
system
;
auto
s
=
system
.
spawn
([](
event_based_actor
*
self
)
->
behavior
{
return
(
[
=
](
ok_atom
x
)
->
atom_value
{
self
->
quit
();
return
x
;
}
);
});
scoped_actor
self
{
system
};
self
->
send
(
s
,
ok_atom
::
value
);
self
->
receive
(
[](
ok_atom
)
{
// nop
}
);
}
libcaf_core/test/splitter.cpp
View file @
05df7bfe
...
@@ -133,8 +133,8 @@ CAF_TEST(typed_splicing) {
...
@@ -133,8 +133,8 @@ CAF_TEST(typed_splicing) {
CAF_CHECK_EQUAL
(
z
,
(
23.0
*
42.0
));
CAF_CHECK_EQUAL
(
z
,
(
23.0
*
42.0
));
}
}
);
);
anon_send_exit
(
x
,
exit_reason
::
kill
);
// x and y go out of scope, leaving only the references
anon_send_exit
(
y
,
exit_reason
::
kill
);
// in x_and_y, which will also go out of scope
}
}
CAF_TEST_FIXTURE_SCOPE_END
()
CAF_TEST_FIXTURE_SCOPE_END
()
libcaf_core/test/stateful_actor.cpp
View file @
05df7bfe
...
@@ -98,7 +98,6 @@ struct fixture {
...
@@ -98,7 +98,6 @@ struct fixture {
CAF_CHECK_EQUAL
(
x
,
20
);
CAF_CHECK_EQUAL
(
x
,
20
);
}
}
);
);
anon_send_exit
(
aut
,
exit_reason
::
kill
);
}
}
template
<
class
State
>
template
<
class
State
>
...
...
libcaf_core/test/typed_response_promise.cpp
View file @
05df7bfe
...
@@ -131,10 +131,6 @@ struct fixture {
...
@@ -131,10 +131,6 @@ struct fixture {
// nop
// nop
}
}
~
fixture
()
{
self
->
send_exit
(
foo
,
exit_reason
::
kill
);
}
actor_system
system
;
actor_system
system
;
scoped_actor
self
;
scoped_actor
self
;
foo_actor
foo
;
foo_actor
foo
;
...
@@ -146,6 +142,7 @@ CAF_TEST_FIXTURE_SCOPE(typed_spawn_tests, fixture)
...
@@ -146,6 +142,7 @@ CAF_TEST_FIXTURE_SCOPE(typed_spawn_tests, fixture)
CAF_TEST
(
typed_response_promise
)
{
CAF_TEST
(
typed_response_promise
)
{
typed_response_promise
<
int
>
resp
;
typed_response_promise
<
int
>
resp
;
CAF_MESSAGE
(
"trigger 'invalid response promise' error"
);
resp
.
deliver
(
1
);
// delivers on an invalid promise has no effect
resp
.
deliver
(
1
);
// delivers on an invalid promise has no effect
self
->
request
(
foo
,
infinite
,
get_atom
::
value
,
42
).
receive
(
self
->
request
(
foo
,
infinite
,
get_atom
::
value
,
42
).
receive
(
[](
int
x
)
{
[](
int
x
)
{
...
...
libcaf_core/test/typed_spawn.cpp
View file @
05df7bfe
...
@@ -127,45 +127,6 @@ void client(event_based_actor* self, actor parent, server_type serv) {
...
@@ -127,45 +127,6 @@ void client(event_based_actor* self, actor parent, server_type serv) {
);
);
}
}
void
test_typed_spawn
(
server_type
ts
)
{
actor_system
system
;
scoped_actor
self
{
system
};
self
->
send
(
ts
,
my_request
{
1
,
2
});
self
->
receive
(
[](
bool
value
)
{
CAF_CHECK_EQUAL
(
value
,
false
);
}
);
self
->
send
(
ts
,
my_request
{
42
,
42
});
self
->
receive
(
[](
bool
value
)
{
CAF_CHECK_EQUAL
(
value
,
true
);
}
);
self
->
request
(
ts
,
infinite
,
my_request
{
10
,
20
}).
receive
(
[](
bool
value
)
{
CAF_CHECK_EQUAL
(
value
,
false
);
}
);
self
->
request
(
ts
,
infinite
,
my_request
{
0
,
0
}).
receive
(
[](
bool
value
)
{
CAF_CHECK_EQUAL
(
value
,
true
);
}
);
self
->
spawn
<
monitored
>
(
client
,
self
,
ts
);
self
->
receive
(
[](
passed_atom
)
{
CAF_MESSAGE
(
"received `passed_atom`"
);
}
);
self
->
receive
(
[](
const
down_msg
&
dmsg
)
{
CAF_CHECK_EQUAL
(
dmsg
.
reason
,
exit_reason
::
normal
);
}
);
self
->
send_exit
(
ts
,
exit_reason
::
user_shutdown
);
}
/******************************************************************************
/******************************************************************************
* test skipping of messages intentionally + using become() *
* test skipping of messages intentionally + using become() *
******************************************************************************/
******************************************************************************/
...
@@ -308,12 +269,6 @@ behavior foo(event_based_actor* self) {
...
@@ -308,12 +269,6 @@ behavior foo(event_based_actor* self) {
[
=
](
int
i
,
int_actor
server
)
{
[
=
](
int
i
,
int_actor
server
)
{
self
->
delegate
(
server
,
i
);
self
->
delegate
(
server
,
i
);
self
->
quit
();
self
->
quit
();
/*
return self->request(server, i).then([=](int result) -> int {
self->quit(exit_reason::normal);
return result;
});
*/
}
}
};
};
}
}
...
@@ -346,11 +301,51 @@ behavior foo2(event_based_actor* self) {
...
@@ -346,11 +301,51 @@ behavior foo2(event_based_actor* self) {
struct
fixture
{
struct
fixture
{
actor_system
system
;
actor_system
system
;
scoped_actor
self
;
fixture
()
:
system
(
actor_system_config
()
fixture
()
:
system
(
actor_system_config
()
.
add_message_type
<
get_state_msg
>
(
"get_state_msg"
))
{
.
add_message_type
<
get_state_msg
>
(
"get_state_msg"
)),
self
(
system
)
{
// nop
// nop
}
}
void
test_typed_spawn
(
server_type
ts
)
{
self
->
send
(
ts
,
my_request
{
1
,
2
});
self
->
receive
(
[](
bool
value
)
{
CAF_CHECK_EQUAL
(
value
,
false
);
}
);
self
->
send
(
ts
,
my_request
{
42
,
42
});
self
->
receive
(
[](
bool
value
)
{
CAF_CHECK_EQUAL
(
value
,
true
);
}
);
self
->
request
(
ts
,
infinite
,
my_request
{
10
,
20
}).
receive
(
[](
bool
value
)
{
CAF_CHECK_EQUAL
(
value
,
false
);
}
);
self
->
request
(
ts
,
infinite
,
my_request
{
0
,
0
}).
receive
(
[](
bool
value
)
{
CAF_CHECK_EQUAL
(
value
,
true
);
}
);
CAF_CHECK_EQUAL
(
system
.
registry
().
running
(),
2u
);
self
->
spawn
<
monitored
>
(
client
,
self
,
ts
);
self
->
receive
(
[](
passed_atom
)
{
CAF_MESSAGE
(
"received `passed_atom`"
);
}
);
self
->
receive
(
[](
const
down_msg
&
dm
)
{
CAF_CHECK
(
dm
.
reason
==
exit_reason
::
normal
);
}
);
CAF_CHECK_EQUAL
(
system
.
registry
().
running
(),
2u
);
}
};
};
}
// namespace <anonymous>
}
// namespace <anonymous>
...
@@ -364,23 +359,20 @@ CAF_TEST_FIXTURE_SCOPE(typed_spawn_tests, fixture)
...
@@ -364,23 +359,20 @@ CAF_TEST_FIXTURE_SCOPE(typed_spawn_tests, fixture)
CAF_TEST
(
typed_spawns
)
{
CAF_TEST
(
typed_spawns
)
{
// run test series with typed_server(1|2)
// run test series with typed_server(1|2)
test_typed_spawn
(
system
.
spawn
(
typed_server1
));
test_typed_spawn
(
system
.
spawn
(
typed_server1
));
s
ystem
.
await_all
_actors_done
();
s
elf
->
await_all_other
_actors_done
();
CAF_MESSAGE
(
"finished test series with `typed_server1`"
);
CAF_MESSAGE
(
"finished test series with `typed_server1`"
);
test_typed_spawn
(
system
.
spawn
(
typed_server2
));
test_typed_spawn
(
system
.
spawn
(
typed_server2
));
s
ystem
.
await_all
_actors_done
();
s
elf
->
await_all_other
_actors_done
();
CAF_MESSAGE
(
"finished test series with `typed_server2`"
);
CAF_MESSAGE
(
"finished test series with `typed_server2`"
);
scoped_actor
self
{
system
};
test_typed_spawn
(
self
->
spawn
<
typed_server3
>
(
"hi there"
,
self
));
test_typed_spawn
(
self
->
spawn
<
typed_server3
>
(
"hi there"
,
self
));
self
->
receive
(
self
->
receive
(
[](
const
string
&
str
)
{
[](
const
string
&
str
)
{
CAF_REQUIRE
(
str
==
"hi there"
);
CAF_REQUIRE
_EQUAL
(
str
,
"hi there"
);
}
}
);
);
}
}
CAF_TEST
(
event_testee_series
)
{
CAF_TEST
(
event_testee_series
)
{
// run test series with event_testee
scoped_actor
self
{
system
};
auto
et
=
self
->
spawn
<
event_testee
>
();
auto
et
=
self
->
spawn
<
event_testee
>
();
string
result
;
string
result
;
self
->
send
(
et
,
1
);
self
->
send
(
et
,
1
);
...
@@ -411,15 +403,11 @@ CAF_TEST(event_testee_series) {
...
@@ -411,15 +403,11 @@ CAF_TEST(event_testee_series) {
throw
runtime_error
(
"event_testee does not reply"
);
throw
runtime_error
(
"event_testee does not reply"
);
}
}
);
);
self
->
send_exit
(
et
,
exit_reason
::
user_shutdown
);
self
->
await_all_other_actors_done
();
CAF_CHECK_EQUAL
(
result
,
"wait4int"
);
CAF_CHECK_EQUAL
(
result
,
"wait4int"
);
}
}
CAF_TEST
(
string_delegator_chain
)
{
CAF_TEST
(
string_delegator_chain
)
{
// run test series with string reverter
// run test series with string reverter
scoped_actor
self
{
system
};
// actor-under-test
auto
aut
=
self
->
spawn
<
monitored
>
(
string_delegator
,
auto
aut
=
self
->
spawn
<
monitored
>
(
string_delegator
,
system
.
spawn
(
string_reverter
),
system
.
spawn
(
string_reverter
),
true
);
true
);
...
@@ -430,7 +418,6 @@ CAF_TEST(string_delegator_chain) {
...
@@ -430,7 +418,6 @@ CAF_TEST(string_delegator_chain) {
CAF_CHECK_EQUAL
(
answer
,
"!dlroW olleH"
);
CAF_CHECK_EQUAL
(
answer
,
"!dlroW olleH"
);
}
}
);
);
anon_send_exit
(
aut
,
exit_reason
::
user_shutdown
);
}
}
CAF_TEST
(
maybe_string_delegator_chain
)
{
CAF_TEST
(
maybe_string_delegator_chain
)
{
...
@@ -453,12 +440,8 @@ CAF_TEST(maybe_string_delegator_chain) {
...
@@ -453,12 +440,8 @@ CAF_TEST(maybe_string_delegator_chain) {
self
->
request
(
aut
,
infinite
,
"abcd"
).
receive
(
self
->
request
(
aut
,
infinite
,
"abcd"
).
receive
(
[](
ok_atom
,
const
string
&
str
)
{
[](
ok_atom
,
const
string
&
str
)
{
CAF_CHECK_EQUAL
(
str
,
"dcba"
);
CAF_CHECK_EQUAL
(
str
,
"dcba"
);
},
[](
const
error
&
)
{
throw
std
::
logic_error
(
"unexpected error!"
);
}
}
);
);
anon_send_exit
(
aut
,
exit_reason
::
user_shutdown
);
}
}
CAF_TEST
(
sending_typed_actors
)
{
CAF_TEST
(
sending_typed_actors
)
{
...
@@ -470,7 +453,6 @@ CAF_TEST(sending_typed_actors) {
...
@@ -470,7 +453,6 @@ CAF_TEST(sending_typed_actors) {
CAF_CHECK_EQUAL
(
i
,
100
);
CAF_CHECK_EQUAL
(
i
,
100
);
}
}
);
);
self
->
send_exit
(
aut
,
exit_reason
::
user_shutdown
);
}
}
CAF_TEST
(
sending_typed_actors_and_down_msg
)
{
CAF_TEST
(
sending_typed_actors_and_down_msg
)
{
...
@@ -503,7 +485,6 @@ CAF_TEST(check_signature) {
...
@@ -503,7 +485,6 @@ CAF_TEST(check_signature) {
}
}
};
};
};
};
scoped_actor
self
{
system
};
self
->
spawn
<
monitored
>
(
bar_action
);
self
->
spawn
<
monitored
>
(
bar_action
);
self
->
receive
(
self
->
receive
(
[](
const
down_msg
&
dm
)
{
[](
const
down_msg
&
dm
)
{
...
...
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