4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE LMapBackendTest
6 #include <boost/test/unit_test.hpp>
7 using namespace boost::unit_test_framework;
17 BOOST_AUTO_TEST_SUITE(LMapBackendTestSuite)
22 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
51 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
59 BOOST_CHECK(info.getRegisterName() ==
"/SingleWord");
60 BOOST_CHECK(info.getNumberOfElements() == 1);
61 BOOST_CHECK(info.getNumberOfChannels() == 1);
62 BOOST_CHECK(info.getNumberOfDimensions() == 0);
65 BOOST_CHECK(info.getRegisterName() ==
"/FullArea");
66 BOOST_CHECK(info.getNumberOfElements() == 0x400);
67 BOOST_CHECK(info.getNumberOfChannels() == 1);
68 BOOST_CHECK(info.getNumberOfDimensions() == 1);
71 BOOST_CHECK(info.getRegisterName() ==
"/PartOfArea");
72 BOOST_CHECK(info.getNumberOfElements() == 20);
73 BOOST_CHECK(info.getNumberOfChannels() == 1);
74 BOOST_CHECK(info.getNumberOfDimensions() == 1);
77 target1.
open(
"PCIE3");
79 unsigned int nSamples = accTarget[3].size();
82 BOOST_CHECK(info.getRegisterName() ==
"/Channel3");
83 BOOST_CHECK(info.getNumberOfElements() == nSamples);
84 BOOST_CHECK(info.getNumberOfChannels() == 1);
85 BOOST_CHECK(info.getNumberOfDimensions() == 1);
88 BOOST_CHECK(info.getRegisterName() ==
"/Constant2");
89 BOOST_CHECK(info.getNumberOfElements() == 1);
90 BOOST_CHECK(info.getNumberOfChannels() == 1);
91 BOOST_CHECK(info.getNumberOfDimensions() == 0);
93 info = catalogue.
getRegister(
"/MyModule/SomeSubmodule/Variable");
94 BOOST_CHECK(info.getRegisterName() ==
"/MyModule/SomeSubmodule/Variable");
95 BOOST_CHECK(info.getNumberOfElements() == 1);
96 BOOST_CHECK(info.getNumberOfChannels() == 1);
97 BOOST_CHECK(info.getNumberOfDimensions() == 0);
110 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
114 BOOST_CHECK(
device.
read<
int>(
"Constant") == 42);
118 BOOST_CHECK(
device.
read<
int>(
"Constant") == 42);
122 BOOST_CHECK(acc.getNElements() == 1);
123 BOOST_CHECK(acc[0] == 0);
126 BOOST_CHECK(acc[0] == 42);
132 boost::shared_ptr<NDRegisterAccessor<int32_t>> impl, impl2, impl3;
133 impl = boost::dynamic_pointer_cast<NDRegisterAccessor<int32_t>>(acc.getHighLevelImplElement());
134 impl2 = boost::dynamic_pointer_cast<NDRegisterAccessor<int32_t>>(acc2.getHighLevelImplElement());
135 impl3 = boost::dynamic_pointer_cast<NDRegisterAccessor<int32_t>>(acc3.getHighLevelImplElement());
140 BOOST_CHECK(impl->mayReplaceOther(impl3) ==
false);
143 BOOST_CHECK_EQUAL(arrayConstant.getNElements(), 5);
144 BOOST_CHECK_EQUAL(arrayConstant[0], 0);
145 BOOST_CHECK_EQUAL(arrayConstant[1], 0);
146 BOOST_CHECK_EQUAL(arrayConstant[2], 0);
147 BOOST_CHECK_EQUAL(arrayConstant[3], 0);
148 BOOST_CHECK_EQUAL(arrayConstant[4], 0);
149 arrayConstant.read();
150 BOOST_CHECK_EQUAL(arrayConstant[0], 1111);
151 BOOST_CHECK_EQUAL(arrayConstant[1], 2222);
152 BOOST_CHECK_EQUAL(arrayConstant[2], 3333);
153 BOOST_CHECK_EQUAL(arrayConstant[3], 4444);
154 BOOST_CHECK_EQUAL(arrayConstant[4], 5555);
158 BOOST_CHECK_EQUAL(partOfArrayConstant.getNElements(), 2);
159 BOOST_CHECK_EQUAL(partOfArrayConstant[0], 0);
160 BOOST_CHECK_EQUAL(partOfArrayConstant[1], 0);
161 partOfArrayConstant.read();
162 BOOST_CHECK_EQUAL(partOfArrayConstant[0], 2222);
163 BOOST_CHECK_EQUAL(partOfArrayConstant[1], 3333);
172 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
180 BOOST_CHECK(acc.getVersionNumber() ==
VersionNumber(
nullptr));
181 BOOST_CHECK(acc2.getVersionNumber() ==
VersionNumber(
nullptr));
182 BOOST_CHECK(acc.getNElements() == 1);
183 BOOST_CHECK(acc[0] == 0);
184 BOOST_CHECK(acc2[0] == 0);
186 BOOST_CHECK(acc[0] == 2);
188 BOOST_CHECK(acc[0] == 3);
189 BOOST_CHECK(acc2[0] == 0);
192 BOOST_CHECK(acc[0] == 3);
193 BOOST_CHECK(acc2[0] == 3);
197 BOOST_CHECK_EQUAL(arrayVariable.getNElements(), 6);
198 BOOST_CHECK_EQUAL(arrayVariable[0], 0);
199 BOOST_CHECK_EQUAL(arrayVariable[1], 0);
200 BOOST_CHECK_EQUAL(arrayVariable[2], 0);
201 BOOST_CHECK_EQUAL(arrayVariable[3], 0);
202 BOOST_CHECK_EQUAL(arrayVariable[4], 0);
203 BOOST_CHECK_EQUAL(arrayVariable[5], 0);
204 arrayVariable.read();
205 BOOST_CHECK_EQUAL(arrayVariable[0], 11);
206 BOOST_CHECK_EQUAL(arrayVariable[1], 22);
207 BOOST_CHECK_EQUAL(arrayVariable[2], 33);
208 BOOST_CHECK_EQUAL(arrayVariable[3], 44);
209 BOOST_CHECK_EQUAL(arrayVariable[4], 55);
210 BOOST_CHECK_EQUAL(arrayVariable[5], 66);
211 arrayVariable = std::vector<int>({6, 5, 4, 3, 2, 1});
212 arrayVariable.write();
213 BOOST_CHECK_EQUAL(arrayVariable[0], 6);
214 BOOST_CHECK_EQUAL(arrayVariable[1], 5);
215 BOOST_CHECK_EQUAL(arrayVariable[2], 4);
216 BOOST_CHECK_EQUAL(arrayVariable[3], 3);
217 BOOST_CHECK_EQUAL(arrayVariable[4], 2);
218 BOOST_CHECK_EQUAL(arrayVariable[5], 1);
219 arrayVariable = std::vector<int>({0, 0, 0, 0, 0, 0});
220 arrayVariable.read();
221 BOOST_CHECK_EQUAL(arrayVariable[0], 6);
222 BOOST_CHECK_EQUAL(arrayVariable[1], 5);
223 BOOST_CHECK_EQUAL(arrayVariable[2], 4);
224 BOOST_CHECK_EQUAL(arrayVariable[3], 3);
225 BOOST_CHECK_EQUAL(arrayVariable[4], 2);
226 BOOST_CHECK_EQUAL(arrayVariable[5], 1);
229 BOOST_CHECK_EQUAL(partOfArrayVariable.getNElements(), 3);
230 BOOST_CHECK_EQUAL(partOfArrayVariable[0], 0);
231 BOOST_CHECK_EQUAL(partOfArrayVariable[1], 0);
232 BOOST_CHECK_EQUAL(partOfArrayVariable[2], 0);
233 partOfArrayVariable.read();
234 BOOST_CHECK_EQUAL(partOfArrayVariable[0], 4);
235 BOOST_CHECK_EQUAL(partOfArrayVariable[1], 3);
236 BOOST_CHECK_EQUAL(partOfArrayVariable[2], 2);
237 partOfArrayVariable = std::vector<int>({42, 120, 31415});
238 partOfArrayVariable.write();
239 BOOST_CHECK_EQUAL(partOfArrayVariable[0], 42);
240 BOOST_CHECK_EQUAL(partOfArrayVariable[1], 120);
241 BOOST_CHECK_EQUAL(partOfArrayVariable[2], 31415);
242 partOfArrayVariable = std::vector<int>({0, 0, 0});
243 partOfArrayVariable.read();
244 BOOST_CHECK_EQUAL(partOfArrayVariable[0], 42);
245 BOOST_CHECK_EQUAL(partOfArrayVariable[1], 120);
246 BOOST_CHECK_EQUAL(partOfArrayVariable[2], 31415);
248 BOOST_CHECK_EQUAL(arrayVariable[0], 6);
249 BOOST_CHECK_EQUAL(arrayVariable[1], 5);
250 BOOST_CHECK_EQUAL(arrayVariable[2], 4);
251 BOOST_CHECK_EQUAL(arrayVariable[3], 3);
252 BOOST_CHECK_EQUAL(arrayVariable[4], 2);
253 BOOST_CHECK_EQUAL(arrayVariable[5], 1);
254 arrayVariable.read();
255 BOOST_CHECK_EQUAL(arrayVariable[0], 6);
256 BOOST_CHECK_EQUAL(arrayVariable[1], 5);
257 BOOST_CHECK_EQUAL(arrayVariable[2], 42);
258 BOOST_CHECK_EQUAL(arrayVariable[3], 120);
259 BOOST_CHECK_EQUAL(arrayVariable[4], 31415);
260 BOOST_CHECK_EQUAL(arrayVariable[5], 1);
268 std::vector<int> area(1024);
270 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
273 target1.
open(
"PCIE2");
276 target1.
write(
"BOARD.WORD_USER", 120);
277 BOOST_CHECK(
device.
read<
int>(
"SingleWord") == 120);
279 target1.
write(
"BOARD.WORD_USER", 66);
280 BOOST_CHECK(
device.
read<
int>(
"SingleWord") == 66);
283 BOOST_CHECK(target1.
read<
int>(
"BOARD.WORD_USER") == 42);
286 BOOST_CHECK(target1.
read<
int>(
"BOARD.WORD_USER") == 12);
289 for(
int i = 0; i < 1024; i++) area[i] = 12345 + 3 * i;
290 target1.
write(
"ADC.AREA_DMAABLE", area);
292 for(
int i = 0; i < 1024; i++) BOOST_CHECK(area[i] == 12345 + 3 * i);
294 for(
int i = 0; i < 1024; i++) area[i] = -876543210 + 42 * i;
295 target1.
write(
"ADC.AREA_DMAABLE", area);
297 for(
int i = 0; i < 1024; i++) BOOST_CHECK(area[i] == -876543210 + 42 * i);
299 for(
int i = 0; i < 1024; i++) area[i] = 12345 + 3 * i;
301 area = target1.
read<
int>(
"ADC.AREA_DMAABLE", 1024);
302 for(
int i = 0; i < 1024; i++) BOOST_CHECK(area[i] == 12345 + 3 * i);
304 for(
int i = 0; i < 1024; i++) area[i] = -876543210 + 42 * i;
306 area = target1.
read<
int>(
"ADC.AREA_DMAABLE", 1024);
307 for(
int i = 0; i < 1024; i++) BOOST_CHECK(area[i] == -876543210 + 42 * i);
315 std::vector<int> area(1024);
317 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
321 target1.
open(
"PCIE2");
323 for(
int i = 0; i < 1024; i++) area[i] = 0;
324 for(
int i = 0; i < 20; i++) area[i + 10] = 12345 + 3 * i;
325 target1.
write(
"ADC.AREA_DMAABLE", area);
327 for(
int i = 0; i < 20; i++) BOOST_CHECK(area[i] == 12345 + 3 * i);
330 for(
int i = 0; i < 1024; i++) area[i] = 0;
331 for(
int i = 0; i < 20; i++) area[i + 10] = -876543210 + 42 * i;
332 target1.
write(
"ADC.AREA_DMAABLE", area);
333 for(
int i = 0; i < 1024; i++) area[i] = 0;
335 for(
int i = 0; i < 20; i++) BOOST_CHECK(area[i] == -876543210 + 42 * i);
343 std::vector<int> area(1024);
346 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
350 target1.
open(
"PCIE2");
353 BOOST_CHECK(!acc.isReadOnly());
354 BOOST_CHECK(acc.isReadable());
355 BOOST_CHECK(acc.isWriteable());
359 boost::shared_ptr<NDRegisterAccessor<int32_t>> impl, impl2;
360 impl = boost::dynamic_pointer_cast<NDRegisterAccessor<int32_t>>(acc.getHighLevelImplElement());
361 impl2 = boost::dynamic_pointer_cast<NDRegisterAccessor<int32_t>>(acc2.getHighLevelImplElement());
363 BOOST_CHECK(impl != impl2);
364 BOOST_CHECK(impl->mayReplaceOther(impl) ==
true);
365 BOOST_CHECK(impl2->mayReplaceOther(impl) ==
false);
366 BOOST_CHECK(impl->mayReplaceOther(impl2) ==
false);
371 for(
int i = 0; i < 1024; i++) area[i] = 12345 + 3 * i;
372 target1.
write(
"ADC.AREA_DMAABLE", area);
374 for(
int i = 0; i < 1024; i++) BOOST_CHECK(acc[i] == 12345 + 3 * i);
376 for(
int i = 0; i < 1024; i++) area[i] = -876543210 + 42 * i;
377 target1.
write(
"ADC.AREA_DMAABLE", area);
379 for(
int i = 0; i < 1024; i++) BOOST_CHECK(acc[i] == -876543210 + 42 * i);
382 for(
int i = 0; i < 1024; i++) acc[i] = 12345 + 3 * i;
384 area = target1.
read<
int>(
"ADC.AREA_DMAABLE", 1024);
385 for(
int i = 0; i < 1024; i++) BOOST_CHECK(area[i] == 12345 + 3 * i);
387 for(
int i = 0; i < 1024; i++) acc[i] = -876543210 + 42 * i;
389 area = target1.
read<
int>(
"ADC.AREA_DMAABLE", 1024);
390 for(
int i = 0; i < 1024; i++) BOOST_CHECK(area[i] == -876543210 + 42 * i);
394 for(
auto it = acc.begin(); it != acc.end(); ++it) {
395 BOOST_CHECK(*it == -876543210 + 42 * index);
398 BOOST_CHECK(index == 1024);
402 for(
auto it = acc_const.
begin(); it != acc_const.
end(); ++it) {
403 BOOST_CHECK(*it == -876543210 + 42 * index);
406 BOOST_CHECK(index == 1024);
410 for(
auto it = acc.rbegin(); it != acc.rend(); ++it) {
412 BOOST_CHECK(*it == -876543210 + 42 * index);
414 BOOST_CHECK(index == 0);
418 for(
auto it = acc_const.
rbegin(); it != acc_const.
rend(); ++it) {
420 BOOST_CHECK(*it == -876543210 + 42 * index);
422 BOOST_CHECK(index == 0);
425 std::vector<int32_t> vec(1024);
427 for(
unsigned int i = 0; i < vec.size(); i++) {
428 BOOST_CHECK(vec[i] == -876543210 + 42 *
static_cast<signed>(i));
437 std::vector<int> area(1024);
440 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
444 target1.
open(
"PCIE2");
447 BOOST_CHECK(acc.isReadOnly() ==
false);
448 BOOST_CHECK(acc.isReadable());
449 BOOST_CHECK(acc.isWriteable());
453 for(
int i = 0; i < 20; i++) area[i + 10] = 12345 + 3 * i;
454 target1.
write(
"ADC.AREA_DMAABLE", area);
456 for(
int i = 0; i < 20; i++) BOOST_CHECK(acc[i] == 12345 + 3 * i);
458 for(
int i = 0; i < 20; i++) area[i + 10] = -876543210 + 42 * i;
459 target1.
write(
"ADC.AREA_DMAABLE", area);
461 for(
int i = 0; i < 20; i++) BOOST_CHECK(acc[i] == -876543210 + 42 * i);
465 for(
auto it = acc.begin(); it != acc.end(); ++it) {
466 BOOST_CHECK(*it == -876543210 + 42 * index);
469 BOOST_CHECK(index == 20);
473 for(
auto it = acc_const.
begin(); it != acc_const.
end(); ++it) {
474 BOOST_CHECK(*it == -876543210 + 42 * index);
477 BOOST_CHECK(index == 20);
481 for(
auto it = acc.rbegin(); it != acc.rend(); ++it) {
483 BOOST_CHECK(*it == -876543210 + 42 * index);
485 BOOST_CHECK(index == 0);
489 for(
auto it = acc_const.
rbegin(); it != acc_const.
rend(); ++it) {
491 BOOST_CHECK(*it == -876543210 + 42 * index);
493 BOOST_CHECK(index == 0);
496 for(
int i = 0; i < 20; i++) acc[i] = 24507 + 33 * i;
498 area = target1.
read<
int>(
"ADC.AREA_DMAABLE", 1024);
499 for(
int i = 0; i < 20; i++) BOOST_CHECK(area[i + 10] == 24507 + 33 * i);
507 std::vector<int> area(1024);
509 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
513 target1.
open(
"PCIE3");
520 boost::shared_ptr<NDRegisterAccessor<int32_t>> impl3, impl4, impl3_2;
521 impl3 = boost::dynamic_pointer_cast<NDRegisterAccessor<int32_t>>(acc3.getHighLevelImplElement());
522 impl4 = boost::dynamic_pointer_cast<NDRegisterAccessor<int32_t>>(acc4.getHighLevelImplElement());
523 impl3_2 = boost::dynamic_pointer_cast<NDRegisterAccessor<int32_t>>(acc3_2.getHighLevelImplElement());
524 BOOST_CHECK(impl3->mayReplaceOther(impl3_2) ==
true);
525 BOOST_CHECK(impl3->mayReplaceOther(impl4) ==
false);
528 unsigned int nSamples = accTarget[3].size();
529 BOOST_CHECK(accTarget[4].size() == nSamples);
530 BOOST_CHECK(acc3.getNElements() == nSamples);
531 BOOST_CHECK(acc4.getNElements() == nSamples);
534 for(
unsigned int i = 0; i < nSamples; i++) {
535 accTarget[3][i] = 3000 + i;
536 accTarget[4][i] = 4000 - i;
541 for(
unsigned int i = 0; i < nSamples; i++) {
548 for(
unsigned int i = 0; i < nSamples; i++) {
549 BOOST_CHECK(acc3[i] == (
signed)(3000 + i));
550 BOOST_CHECK(acc4[i] == 0);
553 for(
unsigned int i = 0; i < nSamples; i++) {
554 BOOST_CHECK(acc3[i] == (
signed)(3000 + i));
555 BOOST_CHECK(acc4[i] == (
signed)(4000 - i));
559 unsigned int idx = 0;
560 for(
auto it = acc3.begin(); it != acc3.end(); ++it) {
561 BOOST_CHECK(*it == (
signed)(3000 + idx));
564 BOOST_CHECK(idx == nSamples);
569 for(
auto it = acc3_const.
begin(); it != acc3_const.
end(); ++it) {
570 BOOST_CHECK(*it == (
signed)(3000 + idx));
573 BOOST_CHECK(idx == nSamples);
577 for(
auto it = acc3.rbegin(); it != acc3.rend(); ++it) {
579 BOOST_CHECK(*it == (
signed)(3000 + idx));
581 BOOST_CHECK(idx == 0);
585 for(
auto it = acc3_const.
rbegin(); it != acc3_const.
rend(); ++it) {
587 BOOST_CHECK(*it == (
signed)(3000 + idx));
589 BOOST_CHECK(idx == 0);
592 std::vector<int> someVector(nSamples);
593 acc3.swap(someVector);
594 for(
unsigned int i = 0; i < nSamples; i++) {
595 BOOST_CHECK(someVector[i] == (
signed)(3000 + i));
599 BOOST_CHECK(acc3.isReadOnly());
600 BOOST_CHECK(acc3.isReadable());
601 BOOST_CHECK(acc3.isWriteable() ==
false);
603 BOOST_CHECK(acc4.isReadOnly());
604 BOOST_CHECK(acc4.isReadable());
605 BOOST_CHECK(acc4.isWriteable() ==
false);
616 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
631 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
633 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
635 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
637 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
643 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
645 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
647 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
649 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
655 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
657 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 1);
659 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
661 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
667 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
669 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 1);
671 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
673 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
679 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
681 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
683 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 1);
685 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
691 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
693 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
695 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
697 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"1");
703 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
705 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 1);
707 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 1);
709 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"1");
715 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
717 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
719 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
721 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
727 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
729 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
731 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
733 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
739 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
741 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
743 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
745 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
750 BOOST_CHECK_EQUAL(
static_cast<int>(bitField), 5);
755 BOOST_CHECK_EQUAL(
static_cast<int>(bitField), 7);
760 BOOST_CHECK_EQUAL(
static_cast<int>(bitField), 6);
765 BOOST_CHECK_EQUAL(
static_cast<int>(bitField), 14);
778 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
779 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
780 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
781 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
787 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
788 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
789 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
790 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
796 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
797 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 1);
798 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
799 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
805 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
806 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 1);
807 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
808 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
814 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
815 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
816 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 1);
817 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
823 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
824 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
825 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
826 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"1");
832 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
833 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 1);
834 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 1);
835 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"1");
841 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 0);
842 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
843 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
844 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
850 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
851 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
852 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
853 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
859 BOOST_CHECK_EQUAL(
static_cast<uint8_t
>(bit0), 1);
860 BOOST_CHECK_EQUAL(
static_cast<uint16_t
>(bit1), 0);
861 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(bit2), 0);
862 BOOST_CHECK_EQUAL(
static_cast<std::string
>(bit3),
"0");
867 BOOST_CHECK_EQUAL(
static_cast<int>(bitField), 5);
872 BOOST_CHECK_EQUAL(
static_cast<int>(bitField), 7);
877 BOOST_CHECK_EQUAL(
static_cast<int>(bitField), 6);
882 BOOST_CHECK_EQUAL(
static_cast<int>(bitField), 14);
890 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
901 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
906 BOOST_CHECK_EQUAL(
device.
read<
int>(
"SingleWordWithParams"), 42);
912 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
916 target.
open(
"PCIE2");
924 wordUserScaled.read();
925 BOOST_CHECK_CLOSE(
double(wordUserScaled), 2 * 4.2, 0.001);
929 wordUserScaled.read();
930 BOOST_CHECK_CLOSE(
double(wordUserScaled), 3 * 4.2, 0.001);
932 wordUserScaled = 10 / 4.2;
933 wordUserScaled.write();
935 BOOST_CHECK_EQUAL(
int(wordUser), 10);
937 wordUserScaled = 5.4 / 4.2;
938 wordUserScaled.write();
940 BOOST_CHECK_EQUAL(
int(wordUser), 5);
942 wordUserScaled = 3.6 / 4.2;
943 wordUserScaled.write();
945 BOOST_CHECK_EQUAL(
int(wordUser), 4);
947 wordUserScaled = -5.4 / 4.2;
948 wordUserScaled.write();
950 BOOST_CHECK_EQUAL(
int(wordUser), -5);
952 wordUserScaled = -3.6 / 4.2;
953 wordUserScaled.write();
955 BOOST_CHECK_EQUAL(
int(wordUser), -4);
962 wordUserScaledTwice.read();
963 BOOST_CHECK_CLOSE(
double(wordUserScaledTwice), 2 * 6, 0.001);
967 wordUserScaledTwice.read();
968 BOOST_CHECK_CLOSE(
double(wordUserScaledTwice), 3 * 6, 0.001);
970 wordUserScaledTwice = 10. / 6.;
971 wordUserScaledTwice.write();
973 BOOST_CHECK_EQUAL(
int(wordUser), 10);
979 BOOST_CHECK_EQUAL(area.getNElements(), 1024);
980 BOOST_CHECK_EQUAL(areaScaled.getNElements(), 1024);
982 for(
int i = 0; i < 1024; ++i) area[i] = 100 + i;
985 for(
int i = 0; i < 1024; ++i) BOOST_CHECK_CLOSE(areaScaled[i], (100 + i) * 0.5, 0.001);
987 for(
int i = 0; i < 1024; ++i) areaScaled[i] = (-100 + i) / 0.5;
990 for(
int i = 0; i < 1024; ++i) BOOST_CHECK_EQUAL(area[i], -100 + i);
995 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
996 auto exceptionDummyBackend = boost::dynamic_pointer_cast<ExceptionDummy>(
997 BackendFactory::getInstance().createBackend(
"(ExceptionDummy:1?map=test3.map)"));
1001 BOOST_CHECK(d.isFunctional() ==
true);
1003 d.setException(
"Test Exception");
1004 BOOST_CHECK(d.isFunctional() ==
false);
1007 BOOST_CHECK(d.isFunctional() ==
true);
1010 BOOST_CHECK(d.isFunctional() ==
false);
1016 BackendFactory::getInstance().setDMapFilePath(
"logicalnamemap.dmap");
1029 boost::shared_ptr<NDRegisterAccessor<int>> impl[6];
1030 for(
int i = 0; i < 6; i++) {
1036 for(
int i = 0; i < 6; i++) {
1037 BOOST_CHECK(impl[i]->getHardwareAccessingElements().size() == 1);
1038 for(
int k = i + 1; k < 6; k++) {
1039 BOOST_CHECK(impl[i]->getHardwareAccessingElements()[0] != impl[k]->getHardwareAccessingElements()[0]);
1045 for(
int i = 0; i < 6; i++) {
1050 BOOST_CHECK(impl[3]->getHardwareAccessingElements()[0] == impl[4]->getHardwareAccessingElements()[0]);
1051 BOOST_CHECK(impl[1]->getHardwareAccessingElements()[0] == impl[2]->getHardwareAccessingElements()[0]);
1054 BOOST_CHECK(impl[0]->getHardwareAccessingElements()[0] != impl[1]->getHardwareAccessingElements()[0]);
1055 BOOST_CHECK(impl[0]->getHardwareAccessingElements()[0] != impl[3]->getHardwareAccessingElements()[0]);
1056 BOOST_CHECK(impl[0]->getHardwareAccessingElements()[0] != impl[5]->getHardwareAccessingElements()[0]);
1057 BOOST_CHECK(impl[1]->getHardwareAccessingElements()[0] != impl[3]->getHardwareAccessingElements()[0]);
1058 BOOST_CHECK(impl[1]->getHardwareAccessingElements()[0] != impl[5]->getHardwareAccessingElements()[0]);
1059 BOOST_CHECK(impl[3]->getHardwareAccessingElements()[0] != impl[5]->getHardwareAccessingElements()[0]);
1065 target1.
open(
"PCIE2");
1066 target2.
open(
"PCIE3");
1073 for(
unsigned int i = 0; i <
t2.getNElements(); i++) {
1074 t2[i] = 67890 + 66 * signed(i);
1081 BOOST_CHECK(a[0][0] == 120);
1084 for(
unsigned int i = 0; i <
t2.getNElements(); i++) {
1085 BOOST_CHECK(a[1][i] == 67890 + 66 *
signed(i));
1088 BOOST_CHECK(a[2].getNElements() == 20);
1089 for(
unsigned int i = 0; i < a[2].
getNElements(); i++) {
1090 BOOST_CHECK(a[2][i] == 67890 + 66 *
signed(i + 10));
1093 BOOST_CHECK(a[5][0] == 42);
1096 for(
unsigned int i = 0; i < t3.getNChannels(); i++) {
1097 for(
unsigned int k = 0; k < t3[i].size(); k++) {
1098 t3[i][k] = signed(i * 10 + k);
1106 BOOST_CHECK(a[3].getNElements() == t3[3].size());
1107 for(
unsigned int i = 0; i < a[3].
getNElements(); i++) {
1108 BOOST_CHECK(a[3][i] == 3 * 10 +
signed(i));
1111 BOOST_CHECK(a[4].getNElements() == t3[4].size());
1112 for(
unsigned int i = 0; i < a[4].
getNElements(); i++) {
1113 BOOST_CHECK(a[4][i] == 4 * 10 +
signed(i));
1122 BOOST_AUTO_TEST_SUITE_END()