Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ApplicationCore
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
ChimeraTK Mirror
ApplicationCore
Commits
c6a2bb87
Commit
c6a2bb87
authored
5 years ago
by
Zenker, Dr. Klaus (FWKE) - 126506
Browse files
Options
Downloads
Patches
Plain Diff
Fix test and use direct connection to the control system.
parent
e019a35e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/executables_src/testLogging.cc
+19
-28
19 additions, 28 deletions
tests/executables_src/testLogging.cc
with
19 additions
and
28 deletions
tests/executables_src/testLogging.cc
+
19
−
28
View file @
c6a2bb87
...
...
@@ -42,17 +42,12 @@ struct testApp : public ChimeraTK::Application {
LoggingModule
log
{
this
,
"LoggingModule"
,
"LoggingModule test"
};
Logger
logger
{
&
log
};
boost
::
shared_ptr
<
Logger
>
logger
{
new
Logger
(
&
log
)
};
ChimeraTK
::
ControlSystemModule
cs
;
void
defineConnections
()
override
{
cs
(
"targetStream"
)
>>
log
.
targetStream
;
cs
(
"logLevel"
)
>>
log
.
logLevel
;
cs
(
"logFile"
)
>>
log
.
logFile
;
cs
(
"tailLength"
)
>>
log
.
tailLength
;
log
.
addSource
(
&
logger
);
log
.
addSource
(
logger
);
log
.
findTag
(
"CS"
).
connectTo
(
cs
);
}
...
...
@@ -63,13 +58,12 @@ BOOST_AUTO_TEST_CASE(testLogMsg) {
testApp
app
;
ChimeraTK
::
TestFacility
tf
;
tf
.
runApplication
();
auto
tailLength
=
tf
.
getScalar
<
uint
>
(
"
t
ailLength"
);
auto
tailLength
=
tf
.
getScalar
<
uint
>
(
"
maxT
ailLength"
);
tailLength
=
1
;
tailLength
.
write
();
app
.
logger
->
sendMessage
(
"test"
,
LogLevel
::
DEBUG
);
tf
.
stepApplication
();
app
.
logger
.
sendMessage
(
"test"
,
LogLevel
::
DEBUG
);
tf
.
stepApplication
();
std
::
string
ss
=
(
std
::
string
)
tf
.
readScalar
<
std
::
string
>
(
"LogTail"
);
std
::
string
ss
=
(
std
::
string
)
tf
.
readScalar
<
std
::
string
>
(
"logTail"
);
BOOST_CHECK_EQUAL
(
ss
.
substr
(
ss
.
find
(
"->"
)
+
3
),
std
::
string
(
"test
\n
"
));
}
...
...
@@ -81,11 +75,10 @@ BOOST_AUTO_TEST_CASE(testLogfileFails) {
tf
.
runApplication
();
logFile
=
std
::
string
(
"/tmp/testLogging/test.log"
);
logFile
.
write
();
tf
.
stepApplication
();
// message not considered here but used to step through the application
app
.
logger
.
sendMessage
(
"test"
,
LogLevel
::
DEBUG
);
app
.
logger
->
sendMessage
(
"test"
,
LogLevel
::
DEBUG
);
tf
.
stepApplication
();
std
::
string
ss
=
(
std
::
string
)
tf
.
readScalar
<
std
::
string
>
(
"
L
ogTail"
);
std
::
string
ss
=
(
std
::
string
)
tf
.
readScalar
<
std
::
string
>
(
"
l
ogTail"
);
std
::
vector
<
std
::
string
>
strs
;
boost
::
split
(
strs
,
ss
,
boost
::
is_any_of
(
"
\n
"
),
boost
::
token_compress_on
);
BOOST_CHECK_EQUAL
(
strs
.
at
(
2
).
substr
(
strs
.
at
(
2
).
find
(
"->"
)
+
3
),
...
...
@@ -102,9 +95,8 @@ BOOST_AUTO_TEST_CASE(testLogfile) {
tf
.
runApplication
();
logFile
=
std
::
string
(
"/tmp/testLogging/test.log"
);
logFile
.
write
();
tf
.
stepApplication
();
// message not considered here but used to step through the application
app
.
logger
.
sendMessage
(
"test"
,
LogLevel
::
DEBUG
);
app
.
logger
->
sendMessage
(
"test"
,
LogLevel
::
DEBUG
);
tf
.
stepApplication
();
std
::
fstream
file
;
file
.
open
(
"/tmp/testLogging/test.log"
);
...
...
@@ -124,19 +116,18 @@ BOOST_AUTO_TEST_CASE(testLogging) {
ChimeraTK
::
TestFacility
tf
;
auto
logLevel
=
tf
.
getScalar
<
uint
>
(
"logLevel"
);
auto
tailLength
=
tf
.
getScalar
<
uint
>
(
"
t
ailLength"
);
auto
tailLength
=
tf
.
getScalar
<
uint
>
(
"
maxT
ailLength"
);
tf
.
runApplication
();
logLevel
=
0
;
logLevel
.
write
();
tailLength
=
2
;
tailLength
.
write
();
app
.
logger
->
sendMessage
(
"1st test message"
,
LogLevel
::
DEBUG
);
tf
.
stepApplication
();
app
.
logger
.
sendMessage
(
"1st test message"
,
LogLevel
::
DEBUG
);
tf
.
stepApplication
();
app
.
logger
.
sendMessage
(
"2nd test message"
,
LogLevel
::
DEBUG
);
app
.
logger
->
sendMessage
(
"2nd test message"
,
LogLevel
::
DEBUG
);
tf
.
stepApplication
();
auto
tail
=
tf
.
readScalar
<
std
::
string
>
(
"
L
ogTail"
);
auto
tail
=
tf
.
readScalar
<
std
::
string
>
(
"
l
ogTail"
);
std
::
vector
<
std
::
string
>
result
;
boost
::
algorithm
::
split
(
result
,
tail
,
boost
::
is_any_of
(
"
\n
"
));
// result length should be 3 not 2, because new line is used to split, which
...
...
@@ -146,9 +137,9 @@ BOOST_AUTO_TEST_CASE(testLogging) {
/**** Test log level ****/
logLevel
=
2
;
logLevel
.
write
();
app
.
logger
.
sendMessage
(
"3rd test message"
,
LogLevel
::
DEBUG
);
app
.
logger
->
sendMessage
(
"3rd test message"
,
LogLevel
::
DEBUG
);
tf
.
stepApplication
();
tail
=
tf
.
readScalar
<
std
::
string
>
(
"
L
ogTail"
);
tail
=
tf
.
readScalar
<
std
::
string
>
(
"
l
ogTail"
);
boost
::
algorithm
::
split
(
result
,
tail
,
boost
::
is_any_of
(
"
\n
"
));
// should still be 3 because log level was too low!
BOOST_CHECK_EQUAL
(
result
.
size
(),
3
);
...
...
@@ -156,16 +147,16 @@ BOOST_AUTO_TEST_CASE(testLogging) {
/**** Test tail length ****/
tailLength
=
3
;
tailLength
.
write
();
// tf.stepApplication();
app
.
logger
->
sendMessage
(
"4th test message"
,
LogLevel
::
ERROR
);
tf
.
stepApplication
();
app
.
logger
.
sendMessage
(
"4th test message"
,
LogLevel
::
ERROR
);
tf
.
stepApplication
();
tail
=
tf
.
readScalar
<
std
::
string
>
(
"LogTail"
);
tail
=
tf
.
readScalar
<
std
::
string
>
(
"logTail"
);
boost
::
algorithm
::
split
(
result
,
tail
,
boost
::
is_any_of
(
"
\n
"
));
BOOST_CHECK_EQUAL
(
result
.
size
(),
4
);
app
.
logger
.
sendMessage
(
"5th test message"
,
LogLevel
::
ERROR
);
app
.
logger
->
sendMessage
(
"5th test message"
,
LogLevel
::
ERROR
);
tf
.
stepApplication
();
tail
=
tf
.
readScalar
<
std
::
string
>
(
"
L
ogTail"
);
tail
=
tf
.
readScalar
<
std
::
string
>
(
"
l
ogTail"
);
boost
::
algorithm
::
split
(
result
,
tail
,
boost
::
is_any_of
(
"
\n
"
));
// should still be 4 because tailLength is 3!
BOOST_CHECK_EQUAL
(
result
.
size
(),
4
);
...
...
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