5 #define BOOST_TEST_DYN_LINK
6 #define BOOST_TEST_MODULE LMapMathPluginTest
7 #include <boost/test/unit_test.hpp>
8 using namespace boost::unit_test_framework;
15 BOOST_AUTO_TEST_SUITE(LMapMathPluginTestSuite)
20 using LogicalNameMappingBackend::LogicalNameMappingBackend;
22 static boost::shared_ptr<DeviceBackend>
createInstance(std::string, std::map<std::string, std::string>) {
23 return boost::make_shared<DummyForCleanupCheck>(
"mathPluginWithPushPars.xlmap");
26 std::cout <<
"~DummyForCleanupCheck()" << std::endl;
36 static std::atomic_bool cleanupCalled;
51 auto targetWriteCount = [&targetDevice]() {
52 auto exceptionDummyForTargetDev = boost::static_pointer_cast<ExceptionDummy>(targetDevice.
getBackend());
53 return exceptionDummyForTargetDev->getWriteCount(
"MATHTEST/TARGET");
55 size_t writeCount = 0;
57 targetDevice.
open(
"HOLD");
62 logicalDevice.activateAsyncRead();
63 auto pushPar = logicalDevice.getScalarRegisterAccessor<uint32_t>(
"DET/PUSHPAR");
68 auto accMathWrite = logicalDevice.getScalarRegisterAccessor<
double>(
"DET/X");
72 BOOST_TEST(
int(accTarget) == 0);
73 BOOST_TEST(targetWriteCount() == writeCount);
79 BOOST_TEST(
int(accTarget) == 10 * pushPar + accMathWrite);
82 BOOST_TEST(targetWriteCount() == writeCount);
89 BOOST_TEST(
int(accTarget) == 10 * pushPar + accMathWrite);
91 BOOST_TEST(targetWriteCount() == writeCount);
94 logicalDevice.close();
100 logicalDevice.activateAsyncRead();
103 accMathWrite.write();
106 BOOST_CHECK_EQUAL(
int(accTarget), 0);
107 BOOST_TEST(targetWriteCount() == writeCount);
111 BOOST_TEST(
int(accTarget) == 10 * pushPar + accMathWrite);
113 BOOST_TEST(targetWriteCount() == writeCount);
116 logicalDevice.close();
117 logicalDevice.open();
121 BOOST_TEST(targetWriteCount() == writeCount);
123 accMathWrite.write();
127 BOOST_TEST(
int(accTarget) == 0);
128 BOOST_TEST(targetWriteCount() == writeCount);
129 logicalDevice.activateAsyncRead();
130 BOOST_TEST(targetWriteCount() == writeCount);
132 BOOST_TEST(
int(accTarget) == 10 * pushPar + accMathWrite);
135 auto pushPar2 = logicalDevice.getScalarRegisterAccessor<uint32_t>(
"DET/PUSHPAR2");
136 auto accMathWrite2 = logicalDevice.getScalarRegisterAccessor<
double>(
"DET/X2");
138 auto targetWriteCount2 = [&targetDevice]() {
139 auto exceptionDummyForTargetDev = boost::static_pointer_cast<ExceptionDummy>(targetDevice.
getBackend());
140 return exceptionDummyForTargetDev->getWriteCount(
"MATHTEST/TARGET2");
142 size_t writeCount2 = 0;
148 accMathWrite2.write();
150 BOOST_TEST(
int(accTarget2) == 200 * pushPar2 + 20 * pushPar + 2 * accMathWrite2);
152 BOOST_TEST(targetWriteCount2() == writeCount2);
153 logicalDevice.close();
154 logicalDevice.open();
157 accMathWrite2.write();
159 BOOST_TEST(targetWriteCount2() == writeCount2);
160 logicalDevice.activateAsyncRead();
161 BOOST_TEST(
int(accTarget2) == 200 * pushPar2 + 20 * pushPar + 2 * accMathWrite2);
162 BOOST_TEST(targetWriteCount2() == writeCount2);
175 auto targetWriteCount = [&targetDevice]() {
176 auto exceptionDummyForTargetDev = boost::static_pointer_cast<ExceptionDummy>(targetDevice.
getBackend());
177 return exceptionDummyForTargetDev->getWriteCount(
"MATHTEST/TARGET");
179 size_t writeCount = 0;
181 targetDevice.
open(
"HOLD");
185 auto pushPar = logicalDevice.getScalarRegisterAccessor<uint32_t>(
"DET/PUSHPAR");
186 auto accMathWrite = logicalDevice.getScalarRegisterAccessor<
double>(
"DET/X");
187 logicalDevice.open();
188 logicalDevice.activateAsyncRead();
195 accMathWrite.write();
197 BOOST_TEST(
int(accTarget) == 10 * pushPar + accMathWrite);
200 BOOST_TEST(targetWriteCount() == writeCount);
207 BOOST_TEST(
int(accTarget) == 10 * pushPar + accMathWrite);
209 BOOST_TEST(targetWriteCount() == writeCount);
216 BOOST_AUTO_TEST_SUITE_END()