diff --git a/tests/executables_src/testFanoutConnections.cc b/tests/executables_src/testFanoutConnections.cc index 4115849742ca81cb1f8fda2e8b13f8cb247dc012..ed9b1c8342baaadb6411010b516b0ebe40513e1f 100644 --- a/tests/executables_src/testFanoutConnections.cc +++ b/tests/executables_src/testFanoutConnections.cc @@ -32,13 +32,21 @@ struct TestModule1 : ctk::ApplicationModule { } }; +// the connection code has to create a consuming fan out because m1.i3 is a poll type consumer, +// and a trigger fan out because m1.i1 only has one push type consumer in the CS struct TestApplication1 : ctk::Application { - TestApplication1() : Application("testApp") {} + TestApplication1(bool connectDeviceFirst) : Application("testApp"), _connectDeviceFirst(connectDeviceFirst) {} ~TestApplication1() { shutdown(); } void defineConnections() { - findTag(".*").connectTo(cs); - device.connectTo(cs, cs("deviceTrigger", typeid(int), 1)); + if(_connectDeviceFirst) { + device.connectTo(cs, cs("deviceTrigger", typeid(int), 1)); + findTag(".*").connectTo(cs); + } + else { + findTag(".*").connectTo(cs); + device.connectTo(cs, cs("deviceTrigger", typeid(int), 1)); + } } constexpr static char const* dummyCDD1 = "(dummy?map=testDataValidity1.map)"; @@ -46,43 +54,46 @@ struct TestApplication1 : ctk::Application { ctk::DeviceModule device{this, dummyCDD1}; ctk::ControlSystemModule cs; + bool _connectDeviceFirst; }; BOOST_AUTO_TEST_CASE(testConnectConsumingFanout) { - TestApplication1 theApp; - ctk::TestFacility testFacility; - ChimeraTK::Device dummy(TestApplication1::dummyCDD1); + for(int deviceFirst = 0; deviceFirst < 2; ++deviceFirst) { + TestApplication1 theApp(deviceFirst); + ctk::TestFacility testFacility; + ChimeraTK::Device dummy(TestApplication1::dummyCDD1); - // write iniial values to the dummy before starting the application - dummy.open(); - dummy.write("m1/i1/DUMMY_WRITEABLE", 12); - dummy.write("m1/i3/DUMMY_WRITEABLE", 32); + // write iniial values to the dummy before starting the application + dummy.open(); + dummy.write("m1/i1/DUMMY_WRITEABLE", 12); + dummy.write("m1/i3/DUMMY_WRITEABLE", 32); - testFacility.runApplication(); + testFacility.runApplication(); - BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i1"), 12); - BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i3"), 32); + BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i1"), 12); + BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i3"), 32); - // check that the trigger only affects i1 - dummy.write("m1/i1/DUMMY_WRITEABLE", 13); - dummy.write("m1/i3/DUMMY_WRITEABLE", 33); + // check that the trigger only affects i1 + dummy.write("m1/i1/DUMMY_WRITEABLE", 13); + dummy.write("m1/i3/DUMMY_WRITEABLE", 33); - testFacility.writeScalar<int>("deviceTrigger", 1); - testFacility.stepApplication(); + testFacility.writeScalar<int>("deviceTrigger", 1); + testFacility.stepApplication(); - BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i1"), 13); - BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i3"), 32); + BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i1"), 13); + BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i3"), 32); - // check that the module trigger updates i3 - BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/moduleOutput"), 0); + // check that the module trigger updates i3 + BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/moduleOutput"), 0); - dummy.write("m1/i1/DUMMY_WRITEABLE", 14); - dummy.write("m1/i3/DUMMY_WRITEABLE", 34); + dummy.write("m1/i1/DUMMY_WRITEABLE", 14); + dummy.write("m1/i3/DUMMY_WRITEABLE", 34); - testFacility.writeScalar<int>("m1/moduleTrigger", 1); - testFacility.stepApplication(); + testFacility.writeScalar<int>("m1/moduleTrigger", 1); + testFacility.stepApplication(); - BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i1"), 13); - BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i3"), 34); - BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/moduleOutput"), 34); + BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i1"), 13); + BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/i3"), 34); + BOOST_CHECK_EQUAL(testFacility.readScalar<int>("m1/moduleOutput"), 34); + } }