4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE LMapMonostableTriggerPluginTest
6 #include <boost/test/unit_test.hpp>
7 using namespace boost::unit_test_framework;
11 #include "DeviceAccessVersion.h"
16 BOOST_AUTO_TEST_SUITE(LMapMonostableTriggerPluginTestSuite)
24 size_t sequenceCounter{0};
25 bool sequenceComplete{
true};
28 std::chrono::milliseconds
delay;
29 std::chrono::time_point<std::chrono::steady_clock>
t0;
31 static boost::shared_ptr<DeviceBackend>
createInstance(std::string, std::map<std::string, std::string> parameters) {
32 return boost::shared_ptr<DeviceBackend>(
new TestDummy(parameters[
"map"]));
35 void write(uint64_t bar, uint64_t address, int32_t
const* data,
size_t sizeInBytes)
override {
36 if(bar == 0 && address == 0x44 && sizeInBytes == 4) {
37 if(sequenceComplete) {
39 sequenceComplete =
false;
47 sequenceComplete =
true;
65 std::cout <<
"TestDummy::BackendRegisterer: registering backend type TestDummy" << std::endl;
72 std::cout <<
"testDefaultValues" << std::endl;
74 device.
open(
"(logicalNameMap?map=monostableTriggerPlugin.xlmap)");
76 auto target = boost::dynamic_pointer_cast<TestDummy>(
78 assert(target !=
nullptr);
82 BOOST_CHECK_EQUAL(target->sequenceCounter, 0);
83 BOOST_CHECK_EQUAL(target->sequenceComplete,
true);
85 for(
size_t i = 1; i < 5; ++i) {
88 BOOST_CHECK_EQUAL(target->sequenceCounter, i);
89 BOOST_CHECK_EQUAL(target->sequenceComplete,
true);
90 BOOST_CHECK_EQUAL(target->active, 1);
91 BOOST_CHECK_EQUAL(target->inactive, 0);
92 BOOST_CHECK(target->delay.count() > 90);
93 BOOST_CHECK(target->delay.count() < 200);
100 std::cout <<
"testNonDefaultValues" << std::endl;
102 device.
open(
"(logicalNameMap?map=monostableTriggerPlugin.xlmap)");
104 auto target = boost::dynamic_pointer_cast<TestDummy>(
106 assert(target !=
nullptr);
110 BOOST_CHECK_EQUAL(target->sequenceCounter, 0);
111 BOOST_CHECK_EQUAL(target->sequenceComplete,
true);
113 for(
size_t i = 1; i < 5; ++i) {
114 accTrigger1 = 10 * i;
116 BOOST_CHECK_EQUAL(target->sequenceCounter, i);
117 BOOST_CHECK_EQUAL(target->sequenceComplete,
true);
118 BOOST_CHECK_EQUAL(target->active, 42);
119 BOOST_CHECK_EQUAL(target->inactive, 120);
120 BOOST_CHECK(target->delay.count() > 90);
121 BOOST_CHECK(target->delay.count() < 200);
128 std::cout <<
"testDifferentDelay" << std::endl;
130 device.
open(
"(logicalNameMap?map=monostableTriggerPlugin.xlmap)");
132 auto target = boost::dynamic_pointer_cast<TestDummy>(
134 assert(target !=
nullptr);
138 BOOST_CHECK_EQUAL(target->sequenceCounter, 0);
139 BOOST_CHECK_EQUAL(target->sequenceComplete,
true);
141 for(
size_t i = 1; i < 5; ++i) {
142 accTrigger1 = 10 * i;
144 BOOST_CHECK_EQUAL(target->sequenceCounter, i);
145 BOOST_CHECK_EQUAL(target->sequenceComplete,
true);
146 BOOST_CHECK_EQUAL(target->active, 1);
147 BOOST_CHECK_EQUAL(target->inactive, 0);
148 BOOST_CHECK(target->delay.count() > 450);
149 BOOST_CHECK(target->delay.count() < 600);
154 BOOST_AUTO_TEST_SUITE_END()