diff --git a/include/Application.h b/include/Application.h index d3c35ef5c1ff7f99d80f11d80f7501dfeb89513b..35f91eb9c65ca65730a4f176baccff0f4a659ef0 100644 --- a/include/Application.h +++ b/include/Application.h @@ -211,6 +211,9 @@ namespace ChimeraTK { template<typename UserType> friend class Accessor; + template<typename UserType> + friend class ExceptionHandlingDecorator; + /** Finalise connections, i.e. decide still-undecided details mostly for * Device and ControlSystem variables */ void finaliseNetworks(); diff --git a/include/TestFacility.h b/include/TestFacility.h index ba5151736876659dbb43b7d00e3e4b4072cfca78..c03ba20bef6421a31cfd62acd207a67ba046b722 100644 --- a/include/TestFacility.h +++ b/include/TestFacility.h @@ -65,6 +65,14 @@ namespace ChimeraTK { if(allOpened) break; } Application::testableModeLock("waitDevicesToOpen"); + // make sure all initial values have been propagated when in testable mode + if(Application::getInstance().isTestableModeEnabled()) { + // call stepApplication() only in testable mode and only if the queues are not empty + if(Application::getInstance().testableMode_counter != 0) { + stepApplication(); + } + } + // receive all initial values for the control system variables if(Application::getInstance().isTestableModeEnabled()) { for(auto& pv : pvManager->getAllProcessVariables()) { diff --git a/src/ExceptionHandlingDecorator.cc b/src/ExceptionHandlingDecorator.cc index 92b1ae29e28fd39f7a51b1e0769ce8d450dcc9cb..d8d9d45a510ad847c1a83076b999d01290738e6e 100644 --- a/src/ExceptionHandlingDecorator.cc +++ b/src/ExceptionHandlingDecorator.cc @@ -58,9 +58,18 @@ namespace ChimeraTK { deviceModule.writeAfterOpen.push_back(this->_recoveryAccessor); return false; } - Application::getInstance().testableModeUnlock("waitForDeviceOpen"); + // We artificially increase the testabel mode counter so the test does not slip out of testable mode here in case + // the queues are empty. At the moment, the exception handling has to be done before you get the lock back in your test. + // Exception handling cannot be tested in testable mode at the moment. + if(Application::getInstance().isTestableModeEnabled()) { + ++Application::getInstance().testableMode_counter; + Application::getInstance().testableModeUnlock("waitForDeviceOpen"); + } boost::this_thread::sleep(boost::posix_time::millisec(DeviceOpenTimeout)); - Application::getInstance().testableModeLock("waitForDeviceOpen"); + if(Application::getInstance().isTestableModeEnabled()) { + Application::getInstance().testableModeLock("waitForDeviceOpen"); + --Application::getInstance().testableMode_counter; + } continue; } auto retval = callable();