From ca7100fdbf36ea22ae79ecf672e1d607e5722a34 Mon Sep 17 00:00:00 2001 From: Martin Hierholzer <martin.hierholzer@desy.de> Date: Thu, 29 Sep 2022 15:27:43 +0200 Subject: [PATCH] fix testScriptedInitialisationHandler --- .../testScriptedInitialisationHandler.cc | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/executables_src/testScriptedInitialisationHandler.cc b/tests/executables_src/testScriptedInitialisationHandler.cc index a9605d9b..67770680 100644 --- a/tests/executables_src/testScriptedInitialisationHandler.cc +++ b/tests/executables_src/testScriptedInitialisationHandler.cc @@ -13,13 +13,13 @@ using namespace ChimeraTK; -struct DMapSetter { - DMapSetter() { setDMapFilePath("test.dmap"); } -}; +/*********************************************************************************************************************/ struct TestApp : public Application { using Application::Application; - ~TestApp() { shutdown(); } + ~TestApp() override { shutdown(); } + + SetDMapFilePath dmap{"test.dmap"}; DeviceModule dev1{this, "Dummy0", "/MyModule/actuator"}; // pick one of the writable variables to AC knows that data type for the trigger @@ -31,18 +31,24 @@ struct TestApp : public Application { this, "InitHander2", "description", "./deviceInitScript2.bash", dev1, "secondInitScriptOutput", 1}; }; +/*********************************************************************************************************************/ + struct Fixture { - DMapSetter dmapSetter; TestApp testApp{"ScriptedInitApp"}; TestFacility testFacility{testApp, false}; }; +/*********************************************************************************************************************/ +/*********************************************************************************************************************/ + BOOST_FIXTURE_TEST_CASE(testSuccess, Fixture) { (void)std::filesystem::remove("device1Init.success"); (void)std::filesystem::remove("continueDevice1Init"); (void)std::filesystem::remove("produceDevice1InitError"); + testFacility.runApplication(); // testApp.dumpConnections(); + auto initMessage = testFacility.getScalar<std::string>("/Devices/Dummy0/initScriptOutput"); initMessage.read(); @@ -82,6 +88,8 @@ BOOST_FIXTURE_TEST_CASE(testSuccess, Fixture) { (void)std::filesystem::remove("continueDevice1Init"); } +/*********************************************************************************************************************/ + BOOST_FIXTURE_TEST_CASE(testError, Fixture) { std::ofstream produceErrorFile; // If the file exists, the script produces an error produceErrorFile.open("produceDevice2InitError", std::ios::out); @@ -126,3 +134,5 @@ BOOST_FIXTURE_TEST_CASE(testError, Fixture) { (void)std::filesystem::remove("device1Init.success"); (void)std::filesystem::remove("continueDevice1Init"); } + +/*********************************************************************************************************************/ -- GitLab