Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ReadMailReallyFast
code
Commits
5a3f7add
Commit
5a3f7add
authored
1 year ago
by
Benny Baumann
Browse files
Options
Downloads
Patches
Plain Diff
Simplify timeout check
This fixes an interference between different unit tests
parent
bb3d9f3c
Branches
socket-api-refactor
No related tags found
No related merge requests found
Pipeline
#10806
failed
1 year ago
Stage: prebuild
Stage: build
Stage: testing
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/socket_test.cpp
+14
-10
14 additions, 10 deletions
test/socket_test.cpp
with
14 additions
and
10 deletions
test/socket_test.cpp
+
14
−
10
View file @
5a3f7add
...
...
@@ -26,9 +26,7 @@ const std::string test_string_tcp = "Moin from TCP";
const
std
::
string
test_string_udp
=
"Moin from UDP"
;
const
std
::
string
test_string_unix
=
"Moin from UNIX"
;
volatile
bool
tcp_called
=
false
;
volatile
bool
udp_called
=
false
;
volatile
bool
unix_called
=
false
;
volatile
bool
test_medium_called
=
false
;
int
udp_source_family
;
...
...
@@ -38,7 +36,7 @@ static void timeout_cb (::ev::timer& w, int revents) {
// Terminate the timer
w
.
stop
();
if
(
!
t
cp_called
&&
!
udp
_called
)
{
if
(
!
t
est_medium
_called
)
{
// Report failure
BOOST_CHECK_MESSAGE
(
false
,
"Timeout"
);
}
...
...
@@ -67,7 +65,7 @@ void udp_test_cb(const iorecord& data) {
msg_ss
<<
"Received UDP packet from: "
<<
data
.
get_address
().
str
();
BOOST_TEST_MESSAGE
(
msg_ss
.
str
());
BOOST_CHECK_EQUAL
(
data
.
get_address
().
family
(),
udp_source_family
);
udp
_called
=
true
;
test_medium
_called
=
true
;
}
void
run_udp_test
()
{
...
...
@@ -109,7 +107,7 @@ void run_tcp_test(const socketaddr& interface_addr) {
client
->
set_incomming_data_callback
(
[](
const
iorecord
&
data
)
{
BOOST_CHECK_EQUAL
(
data
.
str
(),
test_string_tcp
);
t
cp
_called
=
true
;
t
est_medium
_called
=
true
;
});
client
->
write_data
(
iorecord
(
test_string_tcp
.
c_str
(),
test_string_tcp
.
length
()));
...
...
@@ -140,7 +138,7 @@ void run_unix_test() {
client
->
set_incomming_data_callback
(
[](
const
iorecord
&
data
)
{
BOOST_CHECK_EQUAL
(
data
.
str
(),
test_string_unix
);
unix
_called
=
true
;
test_medium
_called
=
true
;
});
client
->
write_data
(
iorecord
(
test_string_unix
.
c_str
(),
test_string_unix
.
length
()));
...
...
@@ -155,6 +153,8 @@ void run_unix_test() {
BOOST_AUTO_TEST_CASE
(
Netio_Socket_TCP
)
{
using
namespace
std
::
chrono_literals
;
test_medium_called
=
false
;
std
::
thread
ev_thread
(
ev_thread_callable
);
const
auto
interface_addr
=
get_first_general_socketaddr
(
"127.0.0.1"
,
9861
);
//(void)interface_addr;
...
...
@@ -166,12 +166,14 @@ BOOST_AUTO_TEST_CASE(Netio_Socket_TCP) {
ev_thread
.
join
();
BOOST_CHECK
(
t
cp
_called
);
BOOST_CHECK
(
t
est_medium
_called
);
}
BOOST_AUTO_TEST_CASE
(
Netio_Socket_UDP
)
{
using
namespace
std
::
chrono_literals
;
test_medium_called
=
false
;
std
::
thread
ev_thread
(
ev_thread_callable
);
BOOST_CHECK_NO_THROW
(
run_udp_test
());
// TODO put in own test while keeping same ev loop setup
...
...
@@ -181,12 +183,14 @@ BOOST_AUTO_TEST_CASE(Netio_Socket_UDP) {
ev_thread
.
join
();
BOOST_CHECK
(
udp
_called
);
BOOST_CHECK
(
test_medium
_called
);
}
BOOST_AUTO_TEST_CASE
(
Netio_Socket_UNIX
)
{
using
namespace
std
::
chrono_literals
;
test_medium_called
=
false
;
std
::
thread
ev_thread
(
ev_thread_callable
);
BOOST_CHECK_NO_THROW
(
run_unix_test
());
// TODO put in own test while keeping same ev loop setup
...
...
@@ -196,5 +200,5 @@ BOOST_AUTO_TEST_CASE(Netio_Socket_UNIX) {
ev_thread
.
join
();
BOOST_CHECK
(
unix
_called
);
BOOST_CHECK
(
test_medium
_called
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment