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
e932cc00
Commit
e932cc00
authored
Jul 16, 2018
by
Dominik Charousset
Committed by
Dominik Charousset
Jul 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new test for the default multiplexer
parent
50443a0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
0 deletions
+105
-0
libcaf_io/test/default_multiplexer.cpp
libcaf_io/test/default_multiplexer.cpp
+105
-0
No files found.
libcaf_io/test/default_multiplexer.cpp
0 → 100644
View file @
e932cc00
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* 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 io_default_multiplexer
#include "caf/test/io_dsl.hpp"
#include <vector>
#include <algorithm>
#include "caf/all.hpp"
#include "caf/io/all.hpp"
#include "caf/io/network/default_multiplexer.hpp"
#include "caf/io/network/operation.hpp"
using
namespace
caf
;
namespace
{
struct
sub_fixture
:
test_coordinator_fixture
<>
{
io
::
network
::
default_multiplexer
mpx
;
sub_fixture
()
:
mpx
(
&
sys
)
{
// nop
}
bool
exec_all
()
{
size_t
count
=
0
;
while
(
mpx
.
poll_once
(
false
))
{
++
count
;
}
return
count
!=
0
;
}
};
struct
fixture
{
sub_fixture
client
;
sub_fixture
server
;
void
exec_all
()
{
while
(
client
.
exec_all
()
||
server
.
exec_all
())
{
// Rince and repeat.
}
}
};
}
// namespace <anonymous>
CAF_TEST_FIXTURE_SCOPE
(
default_multiplexer_tests
,
fixture
)
CAF_TEST
(
doorman
io_failure
)
{
CAF_MESSAGE
(
"add doorman to server"
);
// The multiplexer adds a pipe reader on startup.
CAF_CHECK_EQUAL
(
server
.
mpx
.
num_socket_handlers
(),
1u
);
auto
doorman
=
unbox
(
server
.
mpx
.
new_tcp_doorman
(
0
,
nullptr
,
false
));
doorman
->
add_to_loop
();
server
.
mpx
.
handle_internal_events
();
CAF_CHECK_EQUAL
(
server
.
mpx
.
num_socket_handlers
(),
2u
);
CAF_MESSAGE
(
"trigger I/O failure in doorman"
);
doorman
->
io_failure
(
&
server
.
mpx
,
io
::
network
::
operation
::
propagate_error
);
server
.
mpx
.
handle_internal_events
();
CAF_CHECK_EQUAL
(
server
.
mpx
.
num_socket_handlers
(),
1u
);
}
CAF_TEST
(
scribe
io_failure
)
{
CAF_MESSAGE
(
"add doorman to server"
);
CAF_CHECK_EQUAL
(
server
.
mpx
.
num_socket_handlers
(),
1u
);
auto
doorman
=
unbox
(
server
.
mpx
.
new_tcp_doorman
(
0
,
nullptr
,
false
));
doorman
->
add_to_loop
();
server
.
mpx
.
handle_internal_events
();
CAF_CHECK_EQUAL
(
server
.
mpx
.
num_socket_handlers
(),
2u
);
CAF_MESSAGE
(
"connect to server (add scribe to client)"
);
auto
scribe
=
unbox
(
client
.
mpx
.
new_tcp_scribe
(
"localhost"
,
doorman
->
port
()));
CAF_CHECK_EQUAL
(
client
.
mpx
.
num_socket_handlers
(),
1u
);
scribe
->
add_to_loop
();
client
.
mpx
.
handle_internal_events
();
CAF_CHECK_EQUAL
(
client
.
mpx
.
num_socket_handlers
(),
2u
);
CAF_MESSAGE
(
"trigger I/O failure in scribe"
);
scribe
->
io_failure
(
&
client
.
mpx
,
io
::
network
::
operation
::
propagate_error
);
client
.
mpx
.
handle_internal_events
();
CAF_CHECK_EQUAL
(
client
.
mpx
.
num_socket_handlers
(),
1u
);
CAF_MESSAGE
(
"trigger I/O failure in doorman"
);
doorman
->
io_failure
(
&
server
.
mpx
,
io
::
network
::
operation
::
propagate_error
);
server
.
mpx
.
handle_internal_events
();
CAF_CHECK_EQUAL
(
server
.
mpx
.
num_socket_handlers
(),
1u
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
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