Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
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
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
Libraries
spdlog
Commits
13e91359
Commit
13e91359
authored
Aug 27, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test_backtrace.cpp
parent
5c1e44a9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
8 deletions
+42
-8
tests/test_backtrace.cpp
tests/test_backtrace.cpp
+42
-8
No files found.
tests/test_backtrace.cpp
View file @
13e91359
#include "includes.h"
#include "test_sink.h"
#include "spdlog/async.h"
...
...
@@ -11,7 +12,7 @@ TEST_CASE("bactrace1", "[bactrace]")
auto
test_sink
=
std
::
make_shared
<
test_sink_st
>
();
int
backtrace_size
=
5
;
spdlog
::
logger
logger
(
"test"
,
test_sink
);
spdlog
::
logger
logger
(
"test
-backtrace
"
,
test_sink
);
logger
.
set_pattern
(
"%v"
);
logger
.
enable_backtrace
(
backtrace_size
);
...
...
@@ -23,14 +24,47 @@ TEST_CASE("bactrace1", "[bactrace]")
REQUIRE
(
test_sink
->
lines
()[
0
]
==
"info message"
);
logger
.
dump_backtrace
();
REQUIRE
(
test_sink
->
lines
().
size
()
==
8
);
REQUIRE
(
test_sink
->
lines
().
size
()
==
backtrace_size
+
3
);
REQUIRE
(
test_sink
->
lines
()[
1
]
==
"****************** Backtrace Start ******************"
);
for
(
int
i
=
0
;
i
<
backtrace_size
;
i
++
)
{
REQUIRE
(
test_sink
->
lines
()[
i
+
2
]
==
fmt
::
format
(
"debug message {}"
,
100
-
backtrace_size
+
i
));
}
REQUIRE
(
test_sink
->
lines
()[
2
]
==
"debug message 95"
);
REQUIRE
(
test_sink
->
lines
()[
3
]
==
"debug message 96"
);
REQUIRE
(
test_sink
->
lines
()[
4
]
==
"debug message 97"
);
REQUIRE
(
test_sink
->
lines
()[
5
]
==
"debug message 98"
);
REQUIRE
(
test_sink
->
lines
()[
6
]
==
"debug message 99"
);
REQUIRE
(
test_sink
->
lines
()[
7
]
==
"****************** Backtrace End ********************"
);
}
TEST_CASE
(
"bactrace-async"
,
"[bactrace]"
)
{
using
spdlog
::
sinks
::
test_sink_mt
;
auto
test_sink
=
std
::
make_shared
<
test_sink_mt
>
();
using
spdlog
::
details
::
os
::
sleep_for_millis
;
int
backtrace_size
=
5
;
spdlog
::
init_thread_pool
(
120
,
1
);
auto
logger
=
std
::
make_shared
<
spdlog
::
async_logger
>
(
"test-bactrace-async"
,
test_sink
,
spdlog
::
thread_pool
());
logger
->
set_pattern
(
"%v"
);
logger
->
enable_backtrace
(
backtrace_size
);
logger
->
info
(
"info message"
);
for
(
int
i
=
0
;
i
<
100
;
i
++
)
logger
->
debug
(
"debug message {}"
,
i
);
sleep_for_millis
(
10
);
REQUIRE
(
test_sink
->
lines
().
size
()
==
1
);
REQUIRE
(
test_sink
->
lines
()[
0
]
==
"info message"
);
logger
->
dump_backtrace
();
sleep_for_millis
(
100
);
// give time for the async dump to complete
REQUIRE
(
test_sink
->
lines
().
size
()
==
backtrace_size
+
3
);
REQUIRE
(
test_sink
->
lines
()[
1
]
==
"****************** Backtrace Start ******************"
);
REQUIRE
(
test_sink
->
lines
()[
2
]
==
"debug message 95"
);
REQUIRE
(
test_sink
->
lines
()[
3
]
==
"debug message 96"
);
REQUIRE
(
test_sink
->
lines
()[
4
]
==
"debug message 97"
);
REQUIRE
(
test_sink
->
lines
()[
5
]
==
"debug message 98"
);
REQUIRE
(
test_sink
->
lines
()[
6
]
==
"debug message 99"
);
REQUIRE
(
test_sink
->
lines
()[
7
]
==
"****************** Backtrace 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