Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TEC ApplicationModule
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
MSK-SW
Infrastructure and Support
TEC
TEC ApplicationModule
Commits
52e95ccd
Commit
52e95ccd
authored
4 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
wip #6588: split test into its own cc file, extend tests a bit
parent
dc9a8e65
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/executable_src/testErrorCodes.cc
+128
-0
128 additions, 0 deletions
tests/executable_src/testErrorCodes.cc
tests/executable_src/testWrite.cc
+0
-41
0 additions, 41 deletions
tests/executable_src/testWrite.cc
with
128 additions
and
41 deletions
tests/executable_src/testErrorCodes.cc
0 → 100644
+
128
−
0
View file @
52e95ccd
// Define a name for the test module.
#define BOOST_TEST_MODULE testErrorCodes
// Only after defining the name include the unit test header.
#include
<boost/test/included/unit_test.hpp>
#include
<ChimeraTK/ApplicationCore/TestFacility.h>
#include
<ChimeraTK/BackendFactory.h>
#include
"Server.h"
#include
"TecDummy.h"
using
namespace
boost
::
unit_test_framework
;
struct
Fixture_t
{
Server
theServer
{
"tec_dummy"
};
ChimeraTK
::
TestFacility
testFacility
;
boost
::
shared_ptr
<
TecDummy
>
dummy
{
boost
::
dynamic_pointer_cast
<
TecDummy
>
(
ChimeraTK
::
BackendFactory
::
getInstance
().
createBackend
(
"ActualDevice"
))};
};
/// TestSuite for the server, adapt name
BOOST_AUTO_TEST_SUITE
(
TecServerTestSuite
)
/**********************************************************************************************************************/
/// Test write of an out-of-range value
BOOST_FIXTURE_TEST_CASE
(
testOutOfRange
,
Fixture_t
)
{
std
::
cout
<<
"testOutOfRange"
<<
std
::
endl
;
auto
fanControlEnable
=
testFacility
.
getScalar
<
int
>
(
"TecModule/ctrl_ch1_fanControlEnable_wr"
);
auto
fanTargetTemp
=
testFacility
.
getScalar
<
float
>
(
"TecModule/ctrl_ch1_fanTargetTemp_wr"
);
auto
writeCh1Group7
=
testFacility
.
getScalar
<
int
>
(
"TecModule/writeCh1Group7_wr"
);
auto
targetObjectTemp
=
testFacility
.
getScalar
<
float
>
(
"TecModule/ctrl_ch1_targetObjectTemp_wr"
);
auto
writeCh1Group1
=
testFacility
.
getScalar
<
int
>
(
"TecModule/writeCh1Group1_wr"
);
auto
errorMessage
=
testFacility
.
getScalar
<
std
::
string
>
(
"TecModule/errorMessage"
);
auto
errorStatus
=
testFacility
.
getScalar
<
int
>
(
"TecModule/errorStatus"
);
auto
errorReset
=
testFacility
.
getScalar
<
int
>
(
"TecModule/errorReset"
);
testFacility
.
runApplication
();
// initially everything should work as normal, no error message must be produced
fanControlEnable
=
1
;
fanControlEnable
.
write
();
writeCh1Group7
.
write
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
0
);
testFacility
.
stepApplication
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
BOOST_CHECK
(
!
errorMessage
.
readLatest
());
BOOST_CHECK
(
!
errorStatus
.
readLatest
());
BOOST_CHECK
(
std
::
string
(
errorMessage
)
==
""
);
BOOST_CHECK
(
errorStatus
==
0
);
// inject error in dummy
dummy
->
errorFlags
[
TecFrame
::
TecParameter
::
ExpFanControlEnable
]
=
TecErrorCode
::
EER_PAR_OUT_OF_RANGE
;
fanControlEnable
=
42
;
fanControlEnable
.
write
();
writeCh1Group7
.
write
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
testFacility
.
stepApplication
();
BOOST_CHECK
(
errorMessage
.
readLatest
());
BOOST_CHECK
(
errorStatus
.
readLatest
());
BOOST_CHECK
(
std
::
string
(
errorMessage
)
!=
""
);
BOOST_CHECK
(
std
::
string
(
errorMessage
).
find
(
"ctrl_ch1_fanControlEnable"
)
!=
std
::
string
::
npos
);
BOOST_CHECK
(
errorStatus
!=
0
);
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
// error needs to be reset manually
errorReset
.
write
();
BOOST_CHECK
(
errorMessage
.
readLatest
());
BOOST_CHECK
(
errorStatus
.
readLatest
());
BOOST_CHECK
(
std
::
string
(
errorMessage
)
==
""
);
BOOST_CHECK
(
errorStatus
==
0
);
// check other variable in different group: no error should be observed
targetObjectTemp
=
3.1415
;
targetObjectTemp
.
write
();
writeCh1Group1
.
write
();
BOOST_CHECK_CLOSE
(
dummy
->
getFloat
(
TecFrame
::
TecParameter
::
TemTargetObjectTemp
),
0.0
,
0.0001
);
testFacility
.
stepApplication
();
BOOST_CHECK_CLOSE
(
dummy
->
getFloat
(
TecFrame
::
TecParameter
::
TemTargetObjectTemp
),
3.1415
,
0.0001
);
BOOST_CHECK
(
!
errorMessage
.
readLatest
());
BOOST_CHECK
(
!
errorStatus
.
readLatest
());
BOOST_CHECK
(
std
::
string
(
errorMessage
)
==
""
);
BOOST_CHECK
(
errorStatus
==
0
);
// verify that error is still there for the first variable
writeCh1Group7
.
write
();
testFacility
.
stepApplication
();
BOOST_CHECK
(
errorMessage
.
readLatest
());
BOOST_CHECK
(
errorStatus
.
readLatest
());
BOOST_CHECK
(
std
::
string
(
errorMessage
)
!=
""
);
BOOST_CHECK
(
std
::
string
(
errorMessage
).
find
(
"ctrl_ch1_fanControlEnable"
)
!=
std
::
string
::
npos
);
BOOST_CHECK
(
errorStatus
!=
0
);
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
// generate error for another variable in the same group
dummy
->
errorFlags
[
TecFrame
::
TecParameter
::
ExpFanTargetTemp
]
=
TecErrorCode
::
EER_PAR_OUT_OF_RANGE
;
fanTargetTemp
=
1500.
;
fanTargetTemp
.
write
();
writeCh1Group7
.
write
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
testFacility
.
stepApplication
();
BOOST_CHECK
(
errorMessage
.
readLatest
());
BOOST_CHECK
(
errorStatus
.
readLatest
());
BOOST_CHECK
(
std
::
string
(
errorMessage
)
!=
""
);
BOOST_CHECK
(
std
::
string
(
errorMessage
).
find
(
"ctrl_ch1_fanControlEnable"
)
!=
std
::
string
::
npos
);
BOOST_CHECK
(
errorStatus
!=
0
);
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
// remove error from dummy and check again
dummy
->
errorFlags
[
TecFrame
::
TecParameter
::
ExpFanControlEnable
]
=
TecErrorCode
::
NO_ERROR
;
fanControlEnable
=
-
120
;
fanControlEnable
.
write
();
writeCh1Group7
.
write
();
testFacility
.
stepApplication
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
-
120
);
// error needs to be reset manually
BOOST_CHECK
(
!
errorMessage
.
readLatest
());
BOOST_CHECK
(
!
errorStatus
.
readLatest
());
errorReset
.
write
();
BOOST_CHECK
(
errorMessage
.
readLatest
());
BOOST_CHECK
(
errorStatus
.
readLatest
());
BOOST_CHECK
(
std
::
string
(
errorMessage
)
==
""
);
BOOST_CHECK
(
errorStatus
==
0
);
}
/**********************************************************************************************************************/
BOOST_AUTO_TEST_SUITE_END
()
This diff is collapsed.
Click to expand it.
tests/executable_src/testWrite.cc
+
0
−
41
View file @
52e95ccd
...
...
@@ -128,45 +128,4 @@ BOOST_FIXTURE_TEST_CASE(testFlashWrite, Fixture_t) {
/**********************************************************************************************************************/
/// Test write of an out-of-range value
BOOST_FIXTURE_TEST_CASE
(
testOutOfRange
,
Fixture_t
)
{
std
::
cout
<<
"testOutOfRange"
<<
std
::
endl
;
auto
fanControlEnable
=
testFacility
.
getScalar
<
int
>
(
"TecModule/ctrl_ch1_fanControlEnable_wr"
);
auto
writeCh1Group7
=
testFacility
.
getScalar
<
int
>
(
"TecModule/writeCh1Group7_wr"
);
auto
errorMessage
=
testFacility
.
getScalar
<
std
::
string
>
(
"TecModule/errorMessage"
);
auto
errorStatus
=
testFacility
.
getScalar
<
int
>
(
"TecModule/errorStatus"
);
auto
errorReset
=
testFacility
.
getScalar
<
int
>
(
"TecModule/errorReset"
);
testFacility
.
runApplication
();
fanControlEnable
=
1
;
fanControlEnable
.
write
();
writeCh1Group7
.
write
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
0
);
testFacility
.
stepApplication
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
dummy
->
errorFlags
[
TecFrame
::
TecParameter
::
ExpFanControlEnable
]
=
TecErrorCode
::
EER_PAR_OUT_OF_RANGE
;
fanControlEnable
=
42
;
fanControlEnable
.
write
();
writeCh1Group7
.
write
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
testFacility
.
stepApplication
();
BOOST_CHECK
(
errorMessage
.
readLatest
());
BOOST_CHECK
(
errorStatus
.
readLatest
());
BOOST_CHECK
(
std
::
string
(
errorMessage
)
!=
""
);
BOOST_CHECK
(
errorStatus
!=
0
);
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
1
);
fanControlEnable
=
-
120
;
fanControlEnable
.
write
();
writeCh1Group7
.
write
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
42
);
testFacility
.
stepApplication
();
BOOST_CHECK_EQUAL
(
dummy
->
getInt
(
TecFrame
::
TecParameter
::
ExpFanControlEnable
),
-
120
);
}
/**********************************************************************************************************************/
BOOST_AUTO_TEST_SUITE_END
()
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