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
5970fa33
Commit
5970fa33
authored
4 years ago
by
vargheseg
Browse files
Options
Downloads
Patches
Plain Diff
Implemented testFaultReporting
parent
17b1a5ef
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
+105
-1
105 additions, 1 deletion
tests/executables_src/testExceptionHandling.cc
with
105 additions
and
1 deletion
tests/executables_src/testExceptionHandling.cc
+
105
−
1
View file @
5970fa33
#include
<cstring>
#include
<future>
#define BOOST_TEST_MODULE testExceptionHandling
...
...
@@ -21,6 +22,87 @@
using
namespace
boost
::
unit_test_framework
;
namespace
ctk
=
ChimeraTK
;
// TODO: extend/rename test application as required/ make new test applications as the exception
// handling cases are covered.
/**************************/
struct
Module
:
ctk
::
ApplicationModule
{
using
ctk
::
ApplicationModule
::
ApplicationModule
;
ctk
::
ScalarPollInput
<
int
>
fromDevice
{
this
,
"REG1"
,
""
,
""
,
{
"DEVICE"
}};
ctk
::
ScalarOutput
<
int
>
toCs
{
this
,
"o1"
,
""
,
""
,
{
"CS"
}};
void
mainLoop
()
override
{
while
(
true
)
{
readAll
();
toCs
=
static_cast
<
int
>
(
fromDevice
);
writeAll
();
boost
::
this_thread
::
sleep_for
(
boost
::
chrono
::
milliseconds
(
100
));
}
}
};
struct
DummyApplication
:
ctk
::
Application
{
// +----------+ poll_type_variable +------+
// |Module x<------------------------+Device|
// +----------+ +------+
constexpr
static
char
const
*
ExceptionDummyCDD1
=
"(ExceptionDummy:1?map=test.map)"
;
DummyApplication
()
:
Application
(
"testFault"
)
{}
~
DummyApplication
()
{
shutdown
();
}
Module
m
{
this
,
""
,
""
};
ctk
::
ControlSystemModule
cs
;
ctk
::
DeviceModule
device
{
this
,
ExceptionDummyCDD1
};
void
defineConnections
()
override
{
findTag
(
"CS"
).
connectTo
(
cs
);
findTag
(
"DEVICE"
).
connectTo
(
device
);
}
};
struct
Fixture_noTestFacility
{
Fixture_noTestFacility
()
:
deviceBackend
(
boost
::
dynamic_pointer_cast
<
ctk
::
ExceptionDummy
>
(
ChimeraTK
::
BackendFactory
::
getInstance
().
createBackend
(
DummyApplication
::
ExceptionDummyCDD1
)))
{
deviceBackend
->
open
();
testFacitiy
.
runApplication
();
//
// As a test precondition, the DeviceModule must have completed its startup procedure. The code
// block below is a workaround to ensure this.
//
// Code below depends on behavior of process variable 'status', where 'status' is initialized
// with 0 as default after which its written with:
// - 1 (before DeviceModule begins opening the device),
// - 0 (once DeviceModule successfully opens the device/device startup is complete).
// This sequence is similar for the associated 'message' variable; replace 0/1 values above
// with an empty/non-empty string.
//
// Thus checking for two writes on these variables is a resonable indication that device startup
// is done. (provided the assumption explained above holds).
/************************************************************************************************/
auto
status
=
testFacitiy
.
getScalar
<
int
>
(
ctk
::
RegisterPath
(
"/Devices"
)
/
DummyApplication
::
ExceptionDummyCDD1
/
"status"
);
auto
message
=
testFacitiy
.
getScalar
<
std
::
string
>
(
ctk
::
RegisterPath
(
"/Devices"
)
/
DummyApplication
::
ExceptionDummyCDD1
/
"message"
);
CHECK_TIMEOUT
(
status
.
readNonBlocking
()
==
true
,
100000
);
CHECK_TIMEOUT
(
status
.
readNonBlocking
()
==
true
,
100000
);
CHECK_TIMEOUT
(
message
.
readNonBlocking
()
==
true
,
100000
);
CHECK_TIMEOUT
(
message
.
readNonBlocking
()
==
true
,
100000
);
/************************************************************************************************/
}
~
Fixture_noTestFacility
()
{
deviceBackend
->
throwExceptionRead
=
false
;
}
ctk
::
TestFacility
testFacitiy
{
false
};
boost
::
shared_ptr
<
ctk
::
ExceptionDummy
>
deviceBackend
;
DummyApplication
app
;
};
/* **********************************/
/*
* This test suite checks behavior on a device related runtime error.
*/
...
...
@@ -38,7 +120,29 @@ BOOST_AUTO_TEST_SUITE(checkRuntimeErrorHandling)
*
* \anchor testExceptionHandling_b_2_1 \ref exceptionHandling_b_2_1 "B.2.1"
*/
BOOST_FIXTURE_TEST_CASE
(
testFaultReporting
)
{}
BOOST_FIXTURE_TEST_CASE
(
testFaultReporting
,
Fixture_noTestFacility
)
{
auto
status
=
testFacitiy
.
getScalar
<
int
>
(
ctk
::
RegisterPath
(
"/Devices"
)
/
DummyApplication
::
ExceptionDummyCDD1
/
"status"
);
auto
message
=
testFacitiy
.
getScalar
<
std
::
string
>
(
ctk
::
RegisterPath
(
"/Devices"
)
/
DummyApplication
::
ExceptionDummyCDD1
/
"message"
);
BOOST_CHECK_EQUAL
(
status
,
0
);
BOOST_CHECK_EQUAL
(
static_cast
<
std
::
string
>
(
message
),
""
);
deviceBackend
->
throwExceptionRead
=
true
;
CHECK_TIMEOUT
(
status
.
readNonBlocking
()
==
true
,
10000
);
CHECK_TIMEOUT
(
message
.
readNonBlocking
()
==
true
,
10000
);
BOOST_CHECK_EQUAL
(
status
,
1
);
BOOST_CHECK
(
static_cast
<
std
::
string
>
(
message
)
!=
""
);
deviceBackend
->
throwExceptionRead
=
false
;
CHECK_TIMEOUT
(
status
.
readNonBlocking
()
==
true
,
10000
);
CHECK_TIMEOUT
(
message
.
readNonBlocking
()
==
true
,
10000
);
BOOST_CHECK_EQUAL
(
status
,
0
);
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
...
...
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