Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ControlSystemAdapter-DoocsAdapter
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
ControlSystemAdapter-DoocsAdapter
Commits
05ee1a5c
Commit
05ee1a5c
authored
4 years ago
by
Christoph Kampmeyer
Browse files
Options
Downloads
Patches
Plain Diff
Data matching:
- Clean up serverTestDataMatching - Fix missing include in test
parent
bb3c2cc5
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/src/serverTestDataMatching.cpp
+11
-63
11 additions, 63 deletions
tests/src/serverTestDataMatching.cpp
with
11 additions
and
63 deletions
tests/src/serverTestDataMatching.cpp
+
11
−
63
View file @
05ee1a5c
...
...
@@ -6,65 +6,13 @@
#include
<ChimeraTK/ControlSystemAdapter/Testing/ReferenceTestApplication.h>
//#include <doocs-server-test-helper/ThreadedDoocsServer.h>
#include
<doocs-server-test-helper/doocsServerTestHelper.h>
#include
<
eq_client
.h>
#include
<
doocs-server-test-helper/ThreadedDoocsServer
.h>
#include
<vector>
using
namespace
boost
::
unit_test_framework
;
using
namespace
ChimeraTK
;
//DOOCS_ADAPTER_DEFAULT_FIXTURE_STATIC_APPLICATION
static
ReferenceTestApplication
referenceTestApplication
(
"serverTestDataMatching"
);
extern
int
eq_server
(
int
,
char
**
);
struct
DoocsLauncher
{
DoocsLauncher
()
{
// choose random RPC number
std
::
random_device
rd
;
std
::
uniform_int_distribution
<
int
>
dist
(
620000000
,
999999999
);
rpc_no
=
std
::
to_string
(
dist
(
rd
));
// update config file with the RPC number
std
::
string
command
=
"sed -i serverTestDataMatching.conf -e "
"'s/^SVR.RPC_NUMBER:.*$/SVR.RPC_NUMBER: "
+
rpc_no
+
"/'"
;
auto
rc
=
std
::
system
(
command
.
c_str
());
(
void
)
rc
;
// start the server
doocsServerThread
=
std
::
thread
(
eq_server
,
boost
::
unit_test
::
framework
::
master_test_suite
().
argc
,
boost
::
unit_test
::
framework
::
master_test_suite
().
argv
);
// wait until server has started (both the update thread and the rpc thread)
EqCall
eq
;
EqAdr
ea
;
EqData
src
,
dst
;
ea
.
adr
(
"doocs://localhost:"
+
rpc_no
+
"/F/D/UINT/FROM_DEVICE_SCALAR"
);
while
(
eq
.
get
(
&
ea
,
&
src
,
&
dst
))
usleep
(
100000
);
referenceTestApplication
.
initialiseManualLoopControl
();
}
/**
* @brief For compatibility with older DOOCS versions declare our own eq_exit
*
* Can be removed once a new doocs server version is released.
*/
void
eq_exit
()
{
auto
nativeHandle
=
doocsServerThread
.
native_handle
();
if
(
nativeHandle
!=
0
)
pthread_kill
(
nativeHandle
,
SIGTERM
);
}
~
DoocsLauncher
()
{
referenceTestApplication
.
releaseManualLoopControl
();
eq_exit
();
doocsServerThread
.
join
();
}
std
::
thread
doocsServerThread
;
static
std
::
string
rpc_no
;
};
std
::
string
DoocsLauncher
::
rpc_no
;
BOOST_GLOBAL_FIXTURE
(
DoocsLauncher
)
DOOCS_ADAPTER_DEFAULT_FIXTURE_STATIC_APPLICATION
/**********************************************************************************************************************/
...
...
@@ -76,12 +24,12 @@ BOOST_GLOBAL_FIXTURE(DoocsLauncher)
BOOST_AUTO_TEST_CASE
(
testProcessScalar
)
{
std
::
cout
<<
"testProcessScalar"
<<
std
::
endl
;
auto
appPVmanager
=
referenceTestApplication
.
getPVManager
();
auto
appPVmanager
=
GlobalFixture
::
referenceTestApplication
.
getPVManager
();
// We need data consistency between macro pulse number and the data
// Everything from now on will get the same version number, until we manually
// set a new one.
referenceTestApplication
.
versionNumber
=
ChimeraTK
::
VersionNumber
();
GlobalFixture
::
referenceTestApplication
.
versionNumber
=
ChimeraTK
::
VersionNumber
();
int
macroPulseNumber
=
12345
;
DoocsServerTestHelper
::
doocsSet
<
int
>
(
"//UNMAPPED/INT.TO_DEVICE_SCALAR"
,
macroPulseNumber
);
...
...
@@ -91,7 +39,7 @@ BOOST_AUTO_TEST_CASE(testProcessScalar) {
DoocsServerTestHelper
::
doocsSet
<
unsigned
int
>
(
"//UINT/TO_DEVICE_SCALAR"
,
expectedUnsignedInt
);
DoocsServerTestHelper
::
doocsSet
<
float
>
(
"//UNMAPPED/FLOAT.TO_DEVICE_SCALAR"
,
expectedFloat
);
referenceTestApplication
.
runMainLoopOnce
();
GlobalFixture
::
referenceTestApplication
.
runMainLoopOnce
();
CHECK_WITH_TIMEOUT
(
DoocsServerTestHelper
::
doocsGet
<
unsigned
int
>
(
"//UINT/FROM_DEVICE_SCALAR"
)
-
expectedUnsignedInt
<
1e-6
);
...
...
@@ -99,17 +47,17 @@ BOOST_AUTO_TEST_CASE(testProcessScalar) {
DoocsServerTestHelper
::
doocsGet
<
float
>
(
"//UNMAPPED/FLOAT.FROM_DEVICE_SCALAR"
)
-
expectedFloat
<
1e-6
);
// Send MPN and values with different version numbers
referenceTestApplication
.
versionNumber
=
ChimeraTK
::
VersionNumber
();
referenceTestApplication
.
runMainLoopOnce
();
GlobalFixture
::
referenceTestApplication
.
versionNumber
=
ChimeraTK
::
VersionNumber
();
GlobalFixture
::
referenceTestApplication
.
runMainLoopOnce
();
referenceTestApplication
.
versionNumber
=
ChimeraTK
::
VersionNumber
();
GlobalFixture
::
referenceTestApplication
.
versionNumber
=
ChimeraTK
::
VersionNumber
();
auto
lastExpectedUnsignedInt
=
expectedUnsignedInt
;
expectedUnsignedInt
=
2U
;
expectedFloat
=
2.42
f
;
DoocsServerTestHelper
::
doocsSet
<
unsigned
int
>
(
"//UINT/TO_DEVICE_SCALAR"
,
expectedUnsignedInt
);
DoocsServerTestHelper
::
doocsSet
<
float
>
(
"//UNMAPPED/FLOAT.TO_DEVICE_SCALAR"
,
expectedFloat
);
referenceTestApplication
.
runMainLoopOnce
();
GlobalFixture
::
referenceTestApplication
.
runMainLoopOnce
();
// Unsigned int value must not be updated because it has data matching exact
// FIXME Better way to check this?
...
...
@@ -123,12 +71,12 @@ BOOST_AUTO_TEST_CASE(testProcessScalar) {
DoocsServerTestHelper
::
doocsGet
<
float
>
(
"//UNMAPPED/FLOAT.FROM_DEVICE_SCALAR"
)
-
expectedFloat
<
1e-6
);
// Another iteration, now back to consistent version number
referenceTestApplication
.
versionNumber
=
ChimeraTK
::
VersionNumber
();
GlobalFixture
::
referenceTestApplication
.
versionNumber
=
ChimeraTK
::
VersionNumber
();
++
macroPulseNumber
;
DoocsServerTestHelper
::
doocsSet
<
int
>
(
"//UNMAPPED/INT.TO_DEVICE_SCALAR"
,
macroPulseNumber
);
expectedFloat
=
12.42
f
;
DoocsServerTestHelper
::
doocsSet
<
float
>
(
"//UNMAPPED/FLOAT.TO_DEVICE_SCALAR"
,
expectedFloat
);
referenceTestApplication
.
runMainLoopOnce
();
GlobalFixture
::
referenceTestApplication
.
runMainLoopOnce
();
CHECK_WITH_TIMEOUT
(
DoocsServerTestHelper
::
doocsGet
<
float
>
(
"//UNMAPPED/FLOAT.FROM_DEVICE_SCALAR"
)
-
expectedFloat
<
1e-6
);
}
...
...
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