Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic-graph
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
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
Olivier Stasse
dynamic-graph
Commits
4925f7fb
Commit
4925f7fb
authored
6 years ago
by
Olivier Stasse
Browse files
Options
Downloads
Patches
Plain Diff
[tests] Add test for logger.h
parent
9d38d93a
No related branches found
No related tags found
No related merge requests found
Pipeline
#3149
passed
6 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/debug-logger.cpp
+86
-0
86 additions, 0 deletions
tests/debug-logger.cpp
with
87 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
4925f7fb
...
...
@@ -71,3 +71,4 @@ DYNAMIC_GRAPH_TEST(real-time-logger)
DYNAMIC_GRAPH_TEST
(
debug-trace
)
DYNAMIC_GRAPH_TEST
(
debug-tracer
)
TARGET_LINK_LIBRARIES
(
debug-tracer tracer
)
DYNAMIC_GRAPH_TEST
(
debug-logger
)
This diff is collapsed.
Click to expand it.
tests/debug-logger.cpp
0 → 100644
+
86
−
0
View file @
4925f7fb
/* Copyright 2019, LAAS-CNRS
*
* Olivier Stasse
*
* See LICENSE file
*
*/
#include
<sstream>
#include
<iostream>
#include
<dynamic-graph/entity.h>
#include
<dynamic-graph/exception-factory.h>
#include
"dynamic-graph/factory.h"
#include
"dynamic-graph/pool.h"
#define ENABLE_RT_LOG
#include
<dynamic-graph/real-time-logger.h>
#include
<dynamic-graph/logger.h>
#define BOOST_TEST_MODULE debug-logger
#include
<boost/test/unit_test.hpp>
#include
<boost/test/output_test_stream.hpp>
using
boost
::
test_tools
::
output_test_stream
;
namespace
dynamicgraph
{
class
CustomEntity
:
public
Entity
{
public:
static
const
std
::
string
CLASS_NAME
;
virtual
const
std
::
string
&
getClassName
()
const
{
return
CLASS_NAME
;
}
CustomEntity
(
const
std
::
string
n
)
:
Entity
(
n
)
{
logger_
.
setTimeSample
(
0.001
);
logger_
.
setStreamPrintPeriod
(
0.005
);
logger_
.
setVerbosity
(
VERBOSITY_ALL
);
LoggerVerbosity
alv
=
logger_
.
getVerbosity
();
BOOST_CHECK
(
alv
==
VERBOSITY_ALL
);
}
~
CustomEntity
()
{
}
void
testDebugTrace
()
{
sendMsg
(
"This is a message of level MSG_TYPE_DEBUG"
,
MSG_TYPE_DEBUG
);
sendMsg
(
"This is a message of level MSG_TYPE_INFO"
,
MSG_TYPE_INFO
);
sendMsg
(
"This is a message of level MSG_TYPE_WARNING"
,
MSG_TYPE_WARNING
);
sendMsg
(
"This is a message of level MSG_TYPE_ERROR"
,
MSG_TYPE_ERROR
);
sendMsg
(
"This is a message of level MSG_TYPE_DEBUG_STREAM"
,
MSG_TYPE_DEBUG_STREAM
);
sendMsg
(
"This is a message of level MSG_TYPE_INFO_STREAM"
,
MSG_TYPE_INFO_STREAM
);
sendMsg
(
"This is a message of level MSG_TYPE_WARNING_STREAM"
,
MSG_TYPE_WARNING_STREAM
);
sendMsg
(
"This is a message of level MSG_TYPE_ERROR_STREAM"
,
MSG_TYPE_ERROR_STREAM
);
logger_
.
countdown
();
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
CustomEntity
,
"CustomEntity"
);
}
BOOST_AUTO_TEST_CASE
(
debug_logger
)
{
std
::
ofstream
of
;
of
.
open
(
"/tmp/dg-LOGS.txt"
,
std
::
ofstream
::
out
|
std
::
ofstream
::
app
);
dgADD_OSTREAM_TO_RTLOG
(
of
);
BOOST_CHECK_EQUAL
(
dynamicgraph
::
CustomEntity
::
CLASS_NAME
,
"CustomEntity"
);
dynamicgraph
::
CustomEntity
&
entity
=
*
(
dynamic_cast
<
dynamicgraph
::
CustomEntity
*>
(
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
newEntity
(
"CustomEntity"
,
"my-entity"
)));
for
(
unsigned
int
i
=
0
;
i
<
10000
;
i
++
)
{
entity
.
testDebugTrace
();
}
}
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