From 7a5f78108b3726c068399805fd90681a160483df Mon Sep 17 00:00:00 2001
From: Jens Georg <jens.georg@desy.de>
Date: Wed, 12 Oct 2022 17:03:09 +0200
Subject: [PATCH] Fix missing bits of testDeviceAccessors

---
 tests/executables_src/testDeviceAccessors.cc | 22 ++++++++++++--------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/tests/executables_src/testDeviceAccessors.cc b/tests/executables_src/testDeviceAccessors.cc
index bd888751..0c5f02c1 100644
--- a/tests/executables_src/testDeviceAccessors.cc
+++ b/tests/executables_src/testDeviceAccessors.cc
@@ -159,15 +159,17 @@ BOOST_AUTO_TEST_CASE(testConsumeFromDevice) {
   app.testModule.consumingPoll = {&app.testModule, "/MyModule/readBack", "MV/m", ""};
 
   ctk::TestFacility test{app};
+
+  // Set the default value through the CS. The actuator and readBack map to the same register in the map file
+  // Not setting a default will overwrite whatever is put into the device before the TestFacility::runApplication()
+  // So we feed the default for the register through the IV mechanism of TestFacility.
+  test.setScalarDefault<int>("/MyModule/actuator", 1);
+  test.runApplication();
+
   ChimeraTK::Device dev;
   dev.open("Dummy0");
   auto regacc = dev.getScalarRegisterAccessor<int>("/MyModule/readBack.DUMMY_WRITEABLE");
 
-  regacc = 1; // write initial value which should be present in accessor after app start
-  regacc.write();
-
-  test.runApplication();
-
   BOOST_REQUIRE(app.testModule.hasReachedTestableMode());
 
   BOOST_CHECK(app.testModule.consumingPoll == 1);
@@ -207,15 +209,17 @@ BOOST_AUTO_TEST_CASE(testConsumingFanOut) {
   app.testModule.consumingPush2 = {&app.testModule, "/MyModule/readBack", "MV/m", ""};
 
   ctk::TestFacility test{app};
+
+  // Set the default value through the CS. The actuator and readBack map to the same register in the map file
+  // Not setting a default will overwrite whatever is put into the device before the TestFacility::runApplication()
+  // So we feed the default for the register through the IV mechanism of TestFacility.
+  test.setScalarDefault<int>("/MyModule/actuator", 1);
   ChimeraTK::Device dev;
   dev.open("Dummy0");
   auto regacc = dev.getScalarRegisterAccessor<int>("/MyModule/readBack.DUMMY_WRITEABLE");
-
-  regacc = 1; // write initial value which should be present in accessor after app start
-  regacc.write();
-
   test.runApplication();
 
+
   // single threaded test only, since read() does not block in this case
   BOOST_CHECK(app.testModule.consumingPoll == 1);
   BOOST_CHECK(app.testModule.consumingPush2 == 1);
-- 
GitLab