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
dc3741ab
Commit
dc3741ab
authored
5 years ago
by
Klaus Zenker (HZDR)
Committed by
Zenker, Dr. Klaus (FWKE) - 126506
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add device module tests for the history module.
parent
1ba37d98
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
tests/executables_src/testHistory.C
+143
-54
143 additions, 54 deletions
tests/executables_src/testHistory.C
tests/test.dmap
+2
-0
2 additions, 0 deletions
tests/test.dmap
tests/test.xlmap
+11
-0
11 additions, 0 deletions
tests/test.xlmap
with
157 additions
and
54 deletions
CMakeLists.txt
+
1
−
0
View file @
dc3741ab
...
...
@@ -106,6 +106,7 @@ if(TESTING_IS_ENABLED)
# copy config files
FILE
(
COPY
${
CMAKE_SOURCE_DIR
}
/tests/test.map DESTINATION
${
PROJECT_BINARY_DIR
}
)
FILE
(
COPY
${
CMAKE_SOURCE_DIR
}
/tests/test.xlmap DESTINATION
${
PROJECT_BINARY_DIR
}
)
FILE
(
COPY
${
CMAKE_SOURCE_DIR
}
/tests/test2.map DESTINATION
${
PROJECT_BINARY_DIR
}
)
FILE
(
COPY
${
CMAKE_SOURCE_DIR
}
/tests/test3.map DESTINATION
${
PROJECT_BINARY_DIR
}
)
FILE
(
COPY
${
CMAKE_SOURCE_DIR
}
/tests/test4.map DESTINATION
${
PROJECT_BINARY_DIR
}
)
...
...
This diff is collapsed.
Click to expand it.
tests/executables_src/testHistory.C
+
143
−
54
View file @
dc3741ab
...
...
@@ -17,6 +17,10 @@
#include
"TestFacility.h"
using
namespace
boost
::
unit_test_framework
;
// list of user types the accessors are tested with
typedef
boost
::
mpl
::
list
<
int8_t
,
uint8_t
,
int16_t
,
uint16_t
,
int32_t
,
uint32_t
,
float
,
double
>
test_types
;
template
<
typename
UserType
>
struct
Dummy
:
public
ChimeraTK
::
ApplicationModule
{
using
ChimeraTK
::
ApplicationModule
::
ApplicationModule
;
...
...
@@ -26,7 +30,7 @@ struct Dummy: public ChimeraTK::ApplicationModule{
void
mainLoop
()
override
{
while
(
true
){
in
.
read
();
out
=
1
.
0
*
in
;
out
=
(
UserType
)
in
;
out
.
write
();
}
}
...
...
@@ -42,7 +46,7 @@ struct DummyArray: public ChimeraTK::ApplicationModule{
while
(
true
){
in
.
read
();
for
(
size_t
i
=
0
;
i
<
3
;
i
++
)
out
[
i
]
=
1
.
0
*
in
[
i
];
out
[
i
]
=
(
UserType
)
in
[
i
];
out
.
write
();
}
}
...
...
@@ -66,8 +70,7 @@ struct testApp : public ChimeraTK::Application {
void
defineConnections
()
override
{
hist
.
addSource
(
dummy
.
findTag
(
"history"
),
"history/"
+
dummy
.
getName
());
hist
.
findTag
(
"CS"
).
connectTo
(
cs
);
dummy
.
in
>>
cs
(
"out"
);
cs
(
"in"
)
>>
dummy
.
in
;
dummy
.
connectTo
(
cs
);
}
};
...
...
@@ -89,76 +92,103 @@ struct testAppArray : public ChimeraTK::Application {
void
defineConnections
()
override
{
hist
.
addSource
(
dummy
.
findTag
(
"history"
),
"history/"
+
dummy
.
getName
());
hist
.
findTag
(
"CS"
).
connectTo
(
cs
);
dummy
.
in
>>
cs
(
"out"
);
cs
(
"in"
)
>>
dummy
.
in
;
dummy
.
connectTo
(
cs
);
}
};
BOOST_AUTO_TEST_CASE
(
testHistory_float
)
{
testApp
<
float
>
app
;
/**
* Define a test app to test the device module in combination with the History Module.
*/
struct
testAppDev
:
public
ChimeraTK
::
Application
{
testAppDev
()
:
Application
(
"test"
){
ChimeraTK
::
BackendFactory
::
getInstance
().
setDMapFilePath
(
"test.dmap"
);
}
~
testAppDev
()
{
shutdown
();
}
ChimeraTK
::
history
::
ServerHistory
hist
{
this
,
"ServerHistory"
,
"History of selected process variables."
,
20
};
ChimeraTK
::
DeviceModule
dev
{
this
,
"Dummy1Mapped"
};
DummyArray
<
int
>
dummy
{
this
,
"Dummy"
,
"Dummy module"
};
ChimeraTK
::
ControlSystemModule
cs
;
void
defineConnections
()
override
{
dummy
.
connectTo
(
cs
);
hist
.
addSource
(
dev
.
virtualiseFromCatalog
(),
"history"
,
dummy
.
out
);
hist
.
findTag
(
"CS"
).
connectTo
(
cs
);
}
};
BOOST_AUTO_TEST_CASE_TEMPLATE
(
testScalarHistory
,
T
,
test_types
)
{
testApp
<
T
>
app
;
ChimeraTK
::
TestFacility
tf
;
auto
i
=
tf
.
getScalar
<
float
>
(
"in"
);
auto
i
=
tf
.
getScalar
<
T
>
(
"in"
);
tf
.
runApplication
();
i
=
42
.;
i
.
write
();
tf
.
stepApplication
();
BOOST_CHECK_EQUAL
(
tf
.
readScalar
<
float
>
(
"out"
),
42
.
0
);
std
::
vector
<
float
>
v_ref
(
20
);
v_ref
.
back
()
=
42
.
0
;
auto
v
=
tf
.
readArray
<
float
>
(
"history/Dummy/out"
);
std
::
vector
<
T
>
v_ref
(
20
);
v_ref
.
back
()
=
42
.;
auto
v
=
tf
.
readArray
<
T
>
(
"history/Dummy/out"
);
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
i
=
42
.
0
;
i
=
42
.;
i
.
write
();
tf
.
stepApplication
();
*
(
v_ref
.
end
()
-
2
)
=
42
.
0
;
v
=
tf
.
readArray
<
float
>
(
"history/Dummy/out"
);
*
(
v_ref
.
end
()
-
2
)
=
42
.;
v
=
tf
.
readArray
<
T
>
(
"history/Dummy/out"
);
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
}
BOOST_AUTO_TEST_CASE
(
testHistory_double
)
{
testApp
<
double
>
app
;
/* 'if constexpr' not working with gcc version < 7 so
* add string case manually.
*/
BOOST_AUTO_TEST_CASE
(
testScalarHistoryString
)
{
testApp
<
std
::
string
>
app
;
ChimeraTK
::
TestFacility
tf
;
auto
i
=
tf
.
getScalar
<
double
>
(
"in"
);
auto
i
=
tf
.
getScalar
<
std
::
string
>
(
"in"
);
tf
.
runApplication
();
i
=
42
.
;
i
=
"
42
"
;
i
.
write
();
tf
.
stepApplication
();
BOOST_CHECK_EQUAL
(
tf
.
readScalar
<
double
>
(
"out"
),
42
.
0
);
std
::
vector
<
double
>
v_ref
(
20
);
v_ref
.
back
()
=
42
.
0
;
auto
v
=
tf
.
readArray
<
double
>
(
"history/Dummy/out"
);
std
::
vector
<
std
::
string
>
v_ref
(
20
);
v_ref
.
back
()
=
"42"
;
auto
v
=
tf
.
readArray
<
std
::
string
>
(
"history/Dummy/out"
);
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
i
=
42
.
0
;
i
=
"42"
;
i
.
write
();
tf
.
stepApplication
();
*
(
v_ref
.
end
()
-
2
)
=
42
.
0
;
v
=
tf
.
readArray
<
double
>
(
"history/Dummy/out"
);
*
(
v_ref
.
end
()
-
2
)
=
"42"
;
v
=
tf
.
readArray
<
std
::
string
>
(
"history/Dummy/out"
);
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
}
BOOST_AUTO_TEST_CASE
(
testHistory_floatArray
)
{
testAppArray
<
float
>
app
;
BOOST_AUTO_TEST_CASE_TEMPLATE
(
testArrayHistory
,
T
,
test_types
)
{
testAppArray
<
T
>
app
;
ChimeraTK
::
TestFacility
tf
;
auto
arr
=
tf
.
getArray
<
float
>
(
"in"
);
auto
arr
=
tf
.
getArray
<
T
>
(
"in"
);
tf
.
runApplication
();
arr
[
0
]
=
42
.;
arr
[
1
]
=
43
.;
arr
[
2
]
=
44
.;
arr
.
write
();
tf
.
stepApplication
();
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
float
>
(
"out"
)[
0
],
42
.
0
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
float
>
(
"out"
)[
1
],
43
.
0
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
float
>
(
"out"
)[
2
],
44
.
0
);
std
::
vector
<
float
>
v_ref
(
20
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
T
>
(
"out"
)[
0
],
42
.
0
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
T
>
(
"out"
)[
1
],
43
.
0
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
T
>
(
"out"
)[
2
],
44
.
0
);
std
::
vector
<
T
>
v_ref
(
20
);
for
(
size_t
i
=
0
;
i
<
3
;
i
++
){
v_ref
.
back
()
=
42
.
0
+
i
;
auto
v
=
tf
.
readArray
<
float
>
(
"history/Dummy/out_"
+
std
::
to_string
(
i
));
auto
v
=
tf
.
readArray
<
T
>
(
"history/Dummy/out_"
+
std
::
to_string
(
i
));
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
}
...
...
@@ -171,7 +201,7 @@ BOOST_AUTO_TEST_CASE( testHistory_floatArray) {
for
(
size_t
i
=
0
;
i
<
3
;
i
++
){
*
(
v_ref
.
end
()
-
2
)
=
42
.
0
+
i
;
*
(
v_ref
.
end
()
-
1
)
=
1
.
0
+
i
;
auto
v
=
tf
.
readArray
<
float
>
(
"history/Dummy/out_"
+
std
::
to_string
(
i
));
auto
v
=
tf
.
readArray
<
T
>
(
"history/Dummy/out_"
+
std
::
to_string
(
i
));
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
...
...
@@ -179,37 +209,96 @@ BOOST_AUTO_TEST_CASE( testHistory_floatArray) {
}
BOOST_AUTO_TEST_CASE
(
testHistory_doubleArray
)
{
testAppArray
<
double
>
app
;
/* 'if constexpr' not working with gcc version < 7 so
* add string case manually.
*/
BOOST_AUTO_TEST_CASE
(
testArrayHistoryString
)
{
testAppArray
<
std
::
string
>
app
;
ChimeraTK
::
TestFacility
tf
;
auto
arr
=
tf
.
getArray
<
double
>
(
"in"
);
auto
arr
=
tf
.
getArray
<
std
::
string
>
(
"in"
);
tf
.
runApplication
();
arr
[
0
]
=
42
.
;
arr
[
1
]
=
43
.
;
arr
[
2
]
=
44
.
;
arr
[
0
]
=
"
42
"
;
arr
[
1
]
=
"
43
"
;
arr
[
2
]
=
"
44
"
;
arr
.
write
();
tf
.
stepApplication
();
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
double
>
(
"out"
)[
0
],
42
.
0
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
double
>
(
"out"
)[
1
],
43
.
0
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
double
>
(
"out"
)[
2
],
44
.
0
);
std
::
vector
<
double
>
v_ref
(
20
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
std
::
string
>
(
"out"
)[
0
],
"
42
"
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
std
::
string
>
(
"out"
)[
1
],
"
43
"
);
BOOST_CHECK_EQUAL
(
tf
.
readArray
<
std
::
string
>
(
"out"
)[
2
],
"
44
"
);
std
::
vector
<
std
::
string
>
v_ref
(
20
);
for
(
size_t
i
=
0
;
i
<
3
;
i
++
){
v_ref
.
back
()
=
42
.
0
+
i
;
auto
v
=
tf
.
readArray
<
double
>
(
"history/Dummy/out_"
+
std
::
to_string
(
i
));
v_ref
.
back
()
=
std
::
to_string
(
42
+
i
)
;
auto
v
=
tf
.
readArray
<
std
::
string
>
(
"history/Dummy/out_"
+
std
::
to_string
(
i
));
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
}
arr
[
0
]
=
1
.
0
;
arr
[
1
]
=
2
.
0
;
arr
[
2
]
=
3
.
0
;
arr
[
0
]
=
"1"
;
arr
[
1
]
=
"2"
;
arr
[
2
]
=
"3"
;
arr
.
write
();
tf
.
stepApplication
();
for
(
size_t
i
=
0
;
i
<
3
;
i
++
){
*
(
v_ref
.
end
()
-
2
)
=
42
.
0
+
i
;
*
(
v_ref
.
end
()
-
1
)
=
1
.
0
+
i
;
auto
v
=
tf
.
readArray
<
double
>
(
"history/Dummy/out_"
+
std
::
to_string
(
i
));
*
(
v_ref
.
end
()
-
2
)
=
std
::
to_string
(
42
+
i
)
;
*
(
v_ref
.
end
()
-
1
)
=
std
::
to_string
(
1
+
i
)
;
auto
v
=
tf
.
readArray
<
std
::
string
>
(
"history/Dummy/out_"
+
std
::
to_string
(
i
));
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
}
}
BOOST_AUTO_TEST_CASE
(
testDeviceHistory
)
{
testAppDev
app
;
ChimeraTK
::
TestFacility
tf
;
// We use this device directly to change its values
ChimeraTK
::
Device
dev
;
// Use Dummy1 to change device values, since Dummy1Mapped is read only
dev
.
open
(
"Dummy1"
);
dev
.
write
(
"/FixedPoint/value"
,
42
);
// Trigger the reading of the device
auto
i
=
tf
.
getScalar
<
int
>
(
"in"
);
tf
.
runApplication
();
i
=
1
.;
i
.
write
();
tf
.
stepApplication
();
// check new history buffer that ends with 42
std
::
vector
<
double
>
v_ref
(
20
);
v_ref
.
back
()
=
42
;
auto
v
=
tf
.
readArray
<
double
>
(
"history/Device/signed32"
);
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
// Trigger the reading of the device
i
=
1
.;
i
.
write
();
tf
.
stepApplication
();
// check new history buffer that ends with 42,42
*
(
v_ref
.
end
()
-
2
)
=
42
;
v
=
tf
.
readArray
<
double
>
(
"history/Device/signed32"
);
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
dev
.
write
(
"/FixedPoint/value"
,
43
);
// Trigger the reading of the device
i
=
1
.;
i
.
write
();
tf
.
stepApplication
();
// check new history buffer that ends with 42,42,43
*
(
v_ref
.
end
()
-
1
)
=
43
;
*
(
v_ref
.
end
()
-
3
)
=
42
;
v
=
tf
.
readArray
<
double
>
(
"history/Device/signed32"
);
BOOST_CHECK_EQUAL_COLLECTIONS
(
v
.
begin
(),
v
.
end
(),
v_ref
.
begin
(),
v_ref
.
end
());
}
This diff is collapsed.
Click to expand it.
tests/test.dmap
+
2
−
0
View file @
dc3741ab
Dummy0 (dummy?map=test2.map)
Dummy1 (dummy?map=test3.map)
Dummy1Mapped (logicalNameMap?map=test.xlmap)
This diff is collapsed.
Click to expand it.
tests/test.xlmap
0 → 100644
+
11
−
0
View file @
dc3741ab
<logicalNameMap>
<module name="Device">
<redirectedRegister name="signed32">
<targetDevice>Dummy1</targetDevice>
<targetRegister>/FixedPoint/value</targetRegister>
<targetStartIndex>0</targetStartIndex>
<numberOfElements>1</numberOfElements>
<plugin name="forceReadOnly"/>
</redirectedRegister>
</module>
</logicalNameMap>
\ No newline at end of file
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