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
6cf26532
Commit
6cf26532
authored
Feb 23, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor unpublish unit test
parent
88695412
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
26 deletions
+17
-26
unit_testing/test_unpublish.cpp
unit_testing/test_unpublish.cpp
+17
-26
No files found.
unit_testing/test_unpublish.cpp
View file @
6cf26532
...
@@ -43,47 +43,38 @@ class dummy : public event_based_actor {
...
@@ -43,47 +43,38 @@ class dummy : public event_based_actor {
}
}
};
};
uint16_t
publish_at_some_port
(
uint16_t
first_port
,
actor
whom
)
{
void
test_invalid_unpublish
(
const
actor
&
published
,
uint16_t
port
)
{
auto
port
=
first_port
;
for
(;;)
{
try
{
io
::
publish
(
whom
,
port
);
return
port
;
}
catch
(
bind_failure
&
)
{
// try next port
++
port
;
}
}
}
actor
invalid_unpublish
(
uint16_t
port
)
{
auto
d
=
spawn
<
dummy
>
();
auto
d
=
spawn
<
dummy
>
();
io
::
unpublish
(
d
,
port
);
io
::
unpublish
(
d
,
port
);
auto
ra
=
io
::
remote_actor
(
"127.0.0.1"
,
port
);
CAF_CHECK
(
ra
!=
d
);
CAF_CHECK
(
ra
==
published
);
anon_send_exit
(
d
,
exit_reason
::
user_shutdown
);
anon_send_exit
(
d
,
exit_reason
::
user_shutdown
);
d
=
invalid_actor
;
return
io
::
remote_actor
(
"127.0.0.1"
,
port
);
}
}
}
// namespace <anonymous>
void
test_unpublish
()
{
int
main
()
{
CAF_TEST
(
test_unpublish
);
auto
d
=
spawn
<
dummy
>
();
auto
d
=
spawn
<
dummy
>
();
auto
port
=
publish_at_some_port
(
4242
,
d
);
auto
port
=
io
::
publish
(
d
,
0
);
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
50
));
CAF_CHECKPOINT
();
CAF_CHECK_EQUAL
(
invalid_unpublish
(
port
),
d
);
test_invalid_unpublish
(
d
,
port
);
CAF_CHECKPOINT
();
io
::
unpublish
(
d
,
port
);
io
::
unpublish
(
d
,
port
);
CAF_CHECKPOINT
();
CAF_CHECKPOINT
();
// must fail now
// must fail now
try
{
try
{
auto
oops
=
io
::
remote_actor
(
"127.0.0.1"
,
port
);
io
::
remote_actor
(
"127.0.0.1"
,
port
);
CAF_FAILURE
(
"unexpected: remote actor succeeded!"
);
CAF_FAILURE
(
"unexpected: remote actor succeeded!"
);
}
catch
(
network_error
&
)
{
}
catch
(
network_error
&
)
{
CAF_CHECKPOINT
();
CAF_CHECKPOINT
();
}
}
anon_send_exit
(
d
,
exit_reason
::
user_shutdown
);
anon_send_exit
(
d
,
exit_reason
::
user_shutdown
);
d
=
invalid_actor
;
}
}
// namespace <anonymous>
int
main
()
{
CAF_TEST
(
test_unpublish
);
test_unpublish
();
await_all_actors_done
();
await_all_actors_done
();
shutdown
();
shutdown
();
CAF_CHECK_EQUAL
(
s_dtor_called
.
load
(),
2
);
CAF_CHECK_EQUAL
(
s_dtor_called
.
load
(),
2
);
...
...
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