Skip to content
Snippets Groups Projects
Commit a7801df7 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

extended logical test coverage for testStatusModule, and streamlined the test logic.

parent ef247d0c
No related branches found
No related tags found
No related merge requests found
...@@ -45,17 +45,17 @@ BOOST_AUTO_TEST_CASE(testMaxMonitor) { ...@@ -45,17 +45,17 @@ BOOST_AUTO_TEST_CASE(testMaxMonitor) {
//app.cs.dump(); //app.cs.dump();
auto warning = test.getScalar<double_t>(std::string("/Monitor/upperWarningThreshold")); auto warning = test.getScalar<double_t>(std::string("/Monitor/upperWarningThreshold"));
warning = 45.1; warning = 50.0;
warning.write(); warning.write();
test.stepApplication(); test.stepApplication();
auto error = test.getScalar<double_t>(std::string("/Monitor/upperErrorThreshold")); auto error = test.getScalar<double_t>(std::string("/Monitor/upperErrorThreshold"));
error = 50.1; error = 60.0;
error.write(); error.write();
test.stepApplication(); test.stepApplication();
auto watch = test.getScalar<double_t>(std::string("/watch")); auto watch = test.getScalar<double_t>(std::string("/watch"));
watch = 40.1; watch = 40.0;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
...@@ -65,62 +65,67 @@ BOOST_AUTO_TEST_CASE(testMaxMonitor) { ...@@ -65,62 +65,67 @@ BOOST_AUTO_TEST_CASE(testMaxMonitor) {
//should be in OK state. //should be in OK state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK); BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
//set watch value exceeding warning level // //just below the warning level
watch = 46.1; watch = 49.99;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in WARNING state. BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//set watch value exceeding error level // slightly above at the upper warning threshold (exact is not good due to rounding errors in floats/doubles)
watch = 51.1; watch = 50.01;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in ERROR state. BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
//increase error value greater than watch //just below the error threshold,. still warning
error = 60.1; watch = 59.99;
error.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in WARNING state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING); BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//increase warning value greater than watch // slightly above at the upper error threshold (exact is not good due to rounding errors in floats/doubles)
warning = 55.1; watch = 60.01;
warning.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in OK state. BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
//set watch value exceeding error level //increase well above the upper error level
watch = 65.1; watch = 65;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in ERROR state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR); BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
//decrease watch value lower than error level but still greater than warning level // now check that changing the status is updated correctly if we change the limits
watch = 58.1;
watch.write(); //increase error value greater than watch
error = 68;
error.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in WARNING state. //should be in WARNING state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING); BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//decrease watch value lower than warning level //increase warning value greater than watch
watch = 54.1; warning = 66;
watch.write(); warning.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in OK state. //should be in OK state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK); BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// Set the upper error limit below the upper warning limit and below the current temperature. The warning is not active, but the error.
// Although this is not a reasonable configuration the error limit must superseed the warning and the status has to be error.
error = 60;
error.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// check that the tags are applied correctly // check that the tags are applied correctly
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status"));
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MonitorOutput/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MonitorOutput/Monitor/status"));
...@@ -195,6 +200,35 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) { ...@@ -195,6 +200,35 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) {
status.readLatest(); status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR); BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// move the temperature back to the good range and check that the status updates correctly when changing the limits
watch = 41;
watch.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// change upper warning limit
warning = 42;
warning.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
// rise the temperature above the lower warning limit
watch = 43;
watch.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// Set the lower error limit above the lower warning limit. The warning is not active, but the error.
// Although this is not a reasonable configuration the error limit must superseed the warning and the status has to be error.
error = 44;
error.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// check that the tags are applied correctly // check that the tags are applied correctly
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status"));
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MonitorOutput/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MonitorOutput/Monitor/status"));
...@@ -314,6 +348,64 @@ BOOST_AUTO_TEST_CASE(testRangeMonitor) { ...@@ -314,6 +348,64 @@ BOOST_AUTO_TEST_CASE(testRangeMonitor) {
status.readLatest(); status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR); BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// Put the value back to the good range, then check that chaning the threshold also updated the status
watch = 49;
watch.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// change upper warning limit
warningUpperLimit = 48;
warningUpperLimit.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
// lower the temperature below the upper warning limit
watch = 47;
watch.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// Set the upper error limit below the upper warning limit. The warning is not active, but the error.
// Although this is not a reasonable configuration the error limit must superseed the warning and the status has to be error.
errorUpperLimit = 46;
errorUpperLimit.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// move the temperature back to the good range and repeat for the lower limits
watch = 41;
watch.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// change upper warning limit
warningLowerLimit = 42;
warningLowerLimit.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
// rise the temperature above the lower warning limit
watch = 43;
watch.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// Set the lower error limit above the lower warning limit. The warning is not active, but the error.
// Although this is not a reasonable configuration the error limit must superseed the warning and the status has to be error.
errorLowerLimit = 44;
errorLowerLimit.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// check that the tags are applied correctly // check that the tags are applied correctly
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status"));
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MonitorOutput/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MonitorOutput/Monitor/status"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment