Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
9ad9cfb8
Commit
9ad9cfb8
authored
Aug 17, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed mpmc_q test for osx in travis
parent
a281d21f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
.travis.yml
.travis.yml
+0
-2
includes.h
tests/includes.h
+1
-0
test_mpmc_q.cpp
tests/test_mpmc_q.cpp
+20
-15
No files found.
.travis.yml
View file @
9ad9cfb8
...
...
@@ -84,8 +84,6 @@ matrix:
before_script
:
-
if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi
-
if [ -n "$CLANG_VERSION" ]; then export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"; fi
...
...
tests/includes.h
View file @
9ad9cfb8
...
...
@@ -7,6 +7,7 @@
#include <exception>
#include <fstream>
#include <ostream>
#include <iostream>
#include <string>
#define SPDLOG_TRACE_ON
...
...
tests/test_mpmc_q.cpp
View file @
9ad9cfb8
...
...
@@ -2,25 +2,27 @@
using
namespace
std
::
chrono
;
using
std
::
chrono
::
milliseconds
;
using
std
::
chrono
::
system_clock
;
using
test_clock
=
std
::
chrono
::
high_resolution_clock
;
system_clock
::
time_point
now_millis
()
static
milliseconds
millis_from
(
const
test_clock
::
time_point
&
tp0
)
{
return
time_point_cast
<
milliseconds
>
(
system_clock
::
now
()
);
return
std
::
chrono
::
duration_cast
<
milliseconds
>
(
test_clock
::
now
()
-
tp0
);
}
TEST_CASE
(
"dequeue-empty-nowait"
,
"[mpmc_blocking_q]"
)
{
size_t
q_size
=
100
;
milliseconds
tolerance_wait
(
1
0
);
milliseconds
tolerance_wait
(
3
0
);
spdlog
::
details
::
mpmc_blocking_queue
<
int
>
q
(
q_size
);
int
popped_item
;
auto
millis_0
=
now_millis
();
auto
start
=
test_clock
::
now
();
auto
rv
=
q
.
dequeue_for
(
popped_item
,
milliseconds
::
zero
());
auto
millis_1
=
now_millis
(
);
auto
delta_ms
=
millis_from
(
start
);
REQUIRE
(
rv
==
false
);
REQUIRE
((
millis_1
-
millis_0
)
<=
tolerance_wait
);
INFO
(
"Delta "
<<
delta_ms
.
count
()
<<
" millis"
);
REQUIRE
(
delta_ms
<=
tolerance_wait
);
}
TEST_CASE
(
"dequeue-empty-wait"
,
"[mpmc_blocking_q]"
)
...
...
@@ -28,16 +30,17 @@ TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]")
size_t
q_size
=
100
;
milliseconds
wait_ms
(
250
);
milliseconds
tolerance_wait
(
1
0
);
milliseconds
tolerance_wait
(
3
0
);
spdlog
::
details
::
mpmc_blocking_queue
<
int
>
q
(
q_size
);
int
popped_item
;
auto
millis_0
=
now_millis
();
auto
start
=
test_clock
::
now
();
auto
rv
=
q
.
dequeue_for
(
popped_item
,
wait_ms
);
auto
millis_1
=
now_millis
();
auto
delta_ms
=
millis_1
-
millis_0
;
auto
delta_ms
=
millis_from
(
start
);
REQUIRE
(
rv
==
false
);
INFO
(
"Delta "
<<
delta_ms
.
count
()
<<
" millis"
);
REQUIRE
(
delta_ms
>=
wait_ms
);
REQUIRE
(
delta_ms
<=
wait_ms
+
tolerance_wait
);
}
...
...
@@ -47,15 +50,17 @@ TEST_CASE("enqueue_nowait", "[mpmc_blocking_q]")
size_t
q_size
=
1
;
spdlog
::
details
::
mpmc_blocking_queue
<
int
>
q
(
q_size
);
milliseconds
tolerance_wait
(
1
0
);
milliseconds
tolerance_wait
(
3
0
);
q
.
enqueue
(
1
);
REQUIRE
(
q
.
overrun_counter
()
==
0
);
auto
millis_0
=
now_millis
();
auto
start
=
test_clock
::
now
();
q
.
enqueue_nowait
(
2
);
auto
millis_1
=
now_millis
();
REQUIRE
((
millis_1
-
millis_0
)
<=
tolerance_wait
);
auto
delta_ms
=
millis_from
(
start
);
INFO
(
"Delta "
<<
delta_ms
.
count
()
<<
" millis"
);
REQUIRE
(
delta_ms
<=
tolerance_wait
);
REQUIRE
(
q
.
overrun_counter
()
==
1
);
}
...
...
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