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
7be10d77
Commit
7be10d77
authored
4 years ago
by
vargheseg
Browse files
Options
Downloads
Patches
Plain Diff
testcase: runtimeErrorHandling_testPolledRead
parent
468fe158
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/testExceptionHandling.cc
+80
-7
80 additions, 7 deletions
tests/executables_src/testExceptionHandling.cc
with
80 additions
and
7 deletions
tests/executables_src/testExceptionHandling.cc
+
80
−
7
View file @
7be10d77
#include
<ChimeraTK/ScalarRegisterAccessor.h>
#include
<cstring>
#include
<cstring>
#include
<future>
#include
<future>
...
@@ -85,6 +86,8 @@ struct Fixture_noTestFacility {
...
@@ -85,6 +86,8 @@ struct Fixture_noTestFacility {
deviceBackend
->
open
();
deviceBackend
->
open
();
testFacitiy
.
runApplication
();
testFacitiy
.
runApplication
();
hwRegister
.
replace
(
application
.
device
.
device
.
getScalarRegisterAccessor
<
int
>
(
"/REG1"
));
status
.
replace
(
status
.
replace
(
testFacitiy
.
getScalar
<
int
>
(
ctk
::
RegisterPath
(
"/Devices"
)
/
DummyApplication
::
ExceptionDummyCDD1
/
"status"
));
testFacitiy
.
getScalar
<
int
>
(
ctk
::
RegisterPath
(
"/Devices"
)
/
DummyApplication
::
ExceptionDummyCDD1
/
"status"
));
message
.
replace
(
testFacitiy
.
getScalar
<
std
::
string
>
(
message
.
replace
(
testFacitiy
.
getScalar
<
std
::
string
>
(
...
@@ -120,6 +123,7 @@ struct Fixture_noTestFacility {
...
@@ -120,6 +123,7 @@ struct Fixture_noTestFacility {
ctk
::
ScalarRegisterAccessor
<
int
>
status
;
ctk
::
ScalarRegisterAccessor
<
int
>
status
;
ctk
::
ScalarRegisterAccessor
<
std
::
string
>
message
;
ctk
::
ScalarRegisterAccessor
<
std
::
string
>
message
;
ctk
::
ScalarRegisterAccessor
<
int
>
hwRegister
;
};
};
/*
/*
...
@@ -165,14 +169,83 @@ BOOST_FIXTURE_TEST_CASE(runtimeErrorHandling_testFaultReporting, Fixture_noTestF
...
@@ -165,14 +169,83 @@ BOOST_FIXTURE_TEST_CASE(runtimeErrorHandling_testFaultReporting, Fixture_noTestF
BOOST_CHECK
(
static_cast
<
std
::
string
>
(
message
)
==
""
);
BOOST_CHECK
(
static_cast
<
std
::
string
>
(
message
)
==
""
);
}
}
BOOST_AUTO_TEST_CASE
(
testBlockingRead
)
{
// wait_for_new_data
/*
// how does the api of the accessor look like
* Test read operation on poll type variable when a device runtime exception occours; A poll type
//device1DummyBackend["m1"]("i3")[cs("trigger", typeid(int), 1)] >> cs("i3", typeid(int), 1);
* variable does not have its AccessMode as wait_for_new_data.
// make one with wait_for_new_data
*
* For such a variable:
* - read is skipped till device recovers.
* - first skipped instance of read changes datavalidity flag to faulty and generates a new version
* number which stays the same till the device recovers
*/
BOOST_FIXTURE_TEST_CASE
(
runtimeErrorHandling_testPolledRead
,
Fixture_noTestFacility
)
{
std
::
cout
<<
"runtimeErrorHandling_testPolledRead"
<<
std
::
endl
;
// since the testFacility cannot access the poll type process variable directly, we make use of
// proxy variable o1 that is linked with this poll type variable.
auto
proxyVariable
=
testFacitiy
.
getScalar
<
int
>
(
"/o1"
);
// initialize to known value in deviceBackend register
hwRegister
=
100
;
hwRegister
.
write
();
// verify normal operation
/************************************************************************************************/
application
.
pollModule
.
triggerRead
();
proxyVariable
.
read
();
auto
versionNumberBeforeRuntimeError
=
proxyVariable
.
getVersionNumber
();
BOOST_CHECK_EQUAL
(
proxyVariable
,
100
);
BOOST_CHECK
(
proxyVariable
.
dataValidity
()
==
ctk
::
DataValidity
::
ok
);
/************************************************************************************************/
// Behavior on Runtime error on device:
/************************************************************************************************/
hwRegister
=
10
;
hwRegister
.
write
();
// The framework decides the accessmode flags based on how the wiring looks like:
deviceBackend
->
throwExceptionRead
=
true
;
//
// we will have to make up wiring to get what we desire.
application
.
pollModule
.
triggerRead
();
proxyVariable
.
read
();
auto
versionNumberOnRuntimeError
=
proxyVariable
.
getVersionNumber
();
BOOST_CHECK_EQUAL
(
proxyVariable
,
100
);
BOOST_CHECK
(
proxyVariable
.
dataValidity
()
==
ctk
::
DataValidity
::
faulty
);
BOOST_CHECK
(
versionNumberOnRuntimeError
>
versionNumberBeforeRuntimeError
);
/************************************************************************************************/
// Behavior on persisting Runtime error:
/************************************************************************************************/
application
.
pollModule
.
triggerRead
();
proxyVariable
.
read
();
auto
versionNumber
=
proxyVariable
.
getVersionNumber
();
BOOST_CHECK_EQUAL
(
proxyVariable
,
100
);
BOOST_CHECK
(
proxyVariable
.
dataValidity
()
==
ctk
::
DataValidity
::
faulty
);
BOOST_CHECK
(
versionNumber
==
versionNumberOnRuntimeError
);
/************************************************************************************************/
deviceBackend
->
throwExceptionRead
=
false
;
// workaround: wait till device module recovey completes; assumption: status variable == 0 =>
// device recovered.
CHECK_TIMEOUT
(
[
&
]()
{
status
.
readLatest
();
return
static_cast
<
int
>
(
status
);
}()
==
0
,
10000
);
// Behavior on device recovery
/************************************************************************************************/
application
.
pollModule
.
triggerRead
();
proxyVariable
.
read
();
auto
versionNumberAfterRecovery
=
proxyVariable
.
getVersionNumber
();
BOOST_CHECK_EQUAL
((
int
)
proxyVariable
,
10
);
BOOST_CHECK
(
proxyVariable
.
dataValidity
()
==
ctk
::
DataValidity
::
ok
);
BOOST_CHECK
(
versionNumberAfterRecovery
>
versionNumberOnRuntimeError
);
/************************************************************************************************/
}
}
BOOST_AUTO_TEST_CASE
(
testReadLatest
)
{}
BOOST_AUTO_TEST_CASE
(
testReadLatest
)
{}
...
...
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