3#define BOOST_TEST_MODULE testDeviceExceptionFlagPropagation
13#include <ChimeraTK/DummyRegisterAccessor.h>
14#include <ChimeraTK/ExceptionDummyBackend.h>
16#define BOOST_NO_EXCEPTIONS
17#include <boost/test/included/unit_test.hpp>
18#undef BOOST_NO_EXCEPTIONS
19using namespace boost::unit_test_framework;
34 using ctk::ApplicationModule::ApplicationModule;
37 using ctk::VariableGroup::VariableGroup;
39 }
name{(
this),
"name",
""};
46 using ctk::ApplicationModule::ApplicationModule;
51 using ctk::VariableGroup::VariableGroup;
55 } vars{
this,
".",
""};
74 vars.read.readNonBlocking();
77 vars.read.readLatest();
86 vars.set.writeDestructively();
94 }
module{this, "module", ""};
102 for(
int readMode = 0; readMode < 2; ++readMode) {
103 std::cout <<
"testDirectConnectOpen (readMode = " << readMode <<
")" << std::endl;
107 boost::shared_ptr<ctk::ExceptionDummy> dummyBackend1 = boost::dynamic_pointer_cast<ctk::ExceptionDummy>(
113 dummyBackend1->throwExceptionOpen =
true;
116 std::cout <<
"Read mode is: " << app.
module.
readMode <<
". Run application.\n";
131 dummyBackend1->throwExceptionOpen =
false;
139 std::cout <<
"testDirectConnectRead" << std::endl;
141 boost::shared_ptr<ctk::ExceptionDummy> dummyBackend1 = boost::dynamic_pointer_cast<ctk::ExceptionDummy>(
144 app.
module.vars.tick = {&app.
module.vars,
"/trigger/tick",
"",
""};
156 BOOST_CHECK(app.
module.vars.read.dataValidity() == ctk::DataValidity::ok);
159 std::cout <<
"Checking read mode " << app.
module.
readMode <<
"\n";
160 dummyBackend1->throwExceptionRead =
true;
163 BOOST_CHECK(app.
module.vars.read.dataValidity() == ctk::DataValidity::faulty);
166 dummyBackend1->throwExceptionRead =
false;
177 std::cout <<
"testDirectConnectWrite" << std::endl;
179 boost::shared_ptr<ctk::ExceptionDummy> dummyBackend1 = boost::dynamic_pointer_cast<ctk::ExceptionDummy>(
192 BOOST_CHECK(app.
module.vars.set.dataValidity() == ctk::DataValidity::ok);
195 dummyBackend1->throwExceptionWrite =
true;
199 BOOST_CHECK(app.
module.vars.set.dataValidity() == ctk::DataValidity::ok);
202 dummyBackend1->throwExceptionWrite =
false;
#define CHECK_EQUAL_TIMEOUT(left, right, maxMilliseconds)
Model::RootProxy getModel()
Return the root of the application model.
void shutdown() override
This will remove the global pointer to the instance and allows creating another instance afterwards.
void writeGraphViz(const std::string &filename, Args... args) const
Implementations of RootProxy.
bool write(ChimeraTK::VersionNumber versionNumber)=delete
Convenience class for output scalar accessors (always UpdateMode::push)
Helper class to facilitate tests of applications based on ApplicationCore.
TYPE readScalar(const std::string &name)
Convenience function to read the latest value of a scalar process variable in a single call.
void writeScalar(const std::string &name, TYPE value)
Convenience function to write a scalar process variable in a single call.
void stepApplication(bool waitForDeviceInitialisation=true) const
Perform a "step" of the application.
void runApplication() const
Start the application in testable mode.
InvalidityTracer application module.
BOOST_AUTO_TEST_CASE(testDirectConnectOpen)
constexpr std::string_view ExceptionDummyCDD1
ctk::ScalarPollInput< int > read
ctk::ScalarPushInput< uint64_t > tick
ctk::ScalarOutput< int > set
void prepare() override
Prepare the execution of the module.
std::atomic< ctk::DataValidity > readDataValidity
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
ctk::ScalarOutput< uint64_t > tick
Tests::testDeviceExceptionFlagPropagation::TestApplication::Name::Name2 ctk::VariableGroup name
Tests::testDeviceExceptionFlagPropagation::TestApplication::Name::Name2 ctk::VariableGroup void prepare() override
Prepare the execution of the module.
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
Tests::testDeviceExceptionFlagPropagation::TestApplication::Module module
~TestApplication() override
Tests::testDeviceExceptionFlagPropagation::TestApplication::Name name
#define CHECK_TIMEOUT(condition, maxMilliseconds)