ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
testNumericAddressedBackendUnified.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#define BOOST_TEST_DYN_LINK
5// Define a name for the test module.
6#define BOOST_TEST_MODULE NumericAddressedBackendUnified
7// Only after defining the name include the unit test header.
8#include <boost/test/unit_test.hpp>
9using namespace boost::unit_test_framework;
10
11#include "BackendFactory.h"
12#include "Device.h"
13#include "DummyBackend.h"
16#include "TransferGroup.h"
17#include "UnifiedBackendTest.h"
18
19namespace ChimeraTK {
20 using namespace ChimeraTK;
21}
22using namespace ChimeraTK;
23
24/* ===============================================================================================
25 * Despite its name, this test also qualifies as an unified test for the (Exception)DummyBackend.
26 * They are thinish implementations of the NumericAddressedBackend's internal interface.
27 * ==============================================================================================*/
28
29// Create a test suite which holds all your tests.
30BOOST_AUTO_TEST_SUITE(NumericAddressedBackendUnifiedTestSuite)
31
32/**********************************************************************************************************************/
33
34static std::string cdd("(ExceptionDummy:1?map=test3.map)");
35static auto exceptionDummy =
36 boost::dynamic_pointer_cast<ExceptionDummy>(BackendFactory::getInstance().createBackend(cdd));
37
38static std::string cddMuxed("(ExceptionDummy:1?map=muxedDataAcessor.map)");
39static auto exceptionDummyMuxed =
40 boost::dynamic_pointer_cast<ExceptionDummy>(BackendFactory::getInstance().createBackend(cddMuxed));
41
42/**********************************************************************************************************************/
43
45 std::string path() { return "/Integers/signed32"; }
46 bool isWriteable() { return true; }
47 bool isReadable() { return true; }
49 size_t nChannels() { return 1; }
50 size_t nElementsPerChannel() { return 1; }
51 size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
52 size_t nRuntimeErrorCases() { return 1; }
53 typedef int32_t minimumUserType;
55
56 static constexpr auto capabilities = TestCapabilities<>()
58 .disableAsyncReadInconsistency()
59 .disableSwitchReadOnly()
60 .disableSwitchWriteOnly()
61 .disableTestWriteNeverLosesData()
62 .enableTestRawTransfer();
63
65
66 template<typename Type>
67 std::vector<std::vector<Type>> generateValue([[maybe_unused]] bool raw = false) {
68 return {{acc + 3}};
69 }
70
71 template<typename UserType>
72 std::vector<std::vector<UserType>> getRemoteValue([[maybe_unused]] bool raw = false) {
73 return {{acc}};
74 }
75
76 void setRemoteValue() { acc = generateValue<minimumUserType>()[0][0]; }
77
78 void setForceRuntimeError(bool enable, size_t) {
79 exceptionDummy->throwExceptionRead = enable;
80 exceptionDummy->throwExceptionWrite = enable;
81 exceptionDummy->throwExceptionOpen = enable;
82 }
83};
84
86 std::string path() { return "/Integers/signed32_async"; }
87 bool isWriteable() { return false; }
88 bool isReadable() { return true; }
92 size_t nChannels() { return 1; }
93 size_t nElementsPerChannel() { return 1; }
94 size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
95 size_t nRuntimeErrorCases() { return 1; }
96 typedef int32_t minimumUserType;
98
99 static constexpr auto capabilities = TestCapabilities<>()
101 .disableAsyncReadInconsistency()
102 .disableSwitchReadOnly()
103 .disableSwitchWriteOnly()
104 .disableTestWriteNeverLosesData()
105 .enableTestRawTransfer();
106
108
109 template<typename Type>
110 std::vector<std::vector<Type>> generateValue([[maybe_unused]] bool raw = false) {
111 return {{acc + 3}};
112 }
113
114 template<typename UserType>
115 std::vector<std::vector<UserType>> getRemoteValue([[maybe_unused]] bool raw = false) {
116 return {{acc}};
117 }
118
120 acc = generateValue<minimumUserType>()[0][0];
121 if(exceptionDummy->isOpen()) exceptionDummy->triggerInterrupt(6);
122 }
123
124 void forceAsyncReadInconsistency() { acc = generateValue<minimumUserType>()[0][0]; }
125
126 void setForceRuntimeError(bool enable, size_t) {
127 exceptionDummy->throwExceptionRead = enable;
128 exceptionDummy->throwExceptionWrite = enable;
129 exceptionDummy->throwExceptionOpen = enable;
130 if(exceptionDummy->isOpen()) exceptionDummy->triggerInterrupt(6);
131 }
132};
134 // Using the DUMMY_WRITEABLE register here since usually an async register is r/o implicitly
135 std::string path() { return "/Integers/signed32_async/DUMMY_WRITEABLE"; }
136 bool isWriteable() { return true; }
137 bool isReadable() { return true; }
141 size_t nChannels() { return 1; }
142 size_t nElementsPerChannel() { return 1; }
143 size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
144 size_t nRuntimeErrorCases() { return 1; }
145 typedef int32_t minimumUserType;
147
148 static constexpr auto capabilities = TestCapabilities<>()
150 .disableAsyncReadInconsistency()
151 .disableSwitchReadOnly()
152 .disableSwitchWriteOnly()
153 .disableTestWriteNeverLosesData()
154 .enableTestRawTransfer();
155
156 DummyRegisterAccessor<int32_t> acc{exceptionDummy.get(), "", "/Integers/signed32_async"};
157
158 template<typename Type>
159 std::vector<std::vector<Type>> generateValue([[maybe_unused]] bool raw = false) {
160 return {{acc + 3}};
161 }
162
163 template<typename UserType>
164 std::vector<std::vector<UserType>> getRemoteValue([[maybe_unused]] bool raw = false) {
165 return {{acc}};
166 }
167
169 acc = generateValue<minimumUserType>()[0][0];
170 if(exceptionDummy->isOpen()) exceptionDummy->triggerInterrupt(6);
171 }
172
173 void forceAsyncReadInconsistency() { acc = generateValue<minimumUserType>()[0][0]; }
174
175 void setForceRuntimeError(bool enable, size_t) {
176 exceptionDummy->throwExceptionRead = enable;
177 exceptionDummy->throwExceptionWrite = enable;
178 exceptionDummy->throwExceptionOpen = enable;
179 if(exceptionDummy->isOpen()) exceptionDummy->triggerInterrupt(6);
180 }
181};
182
183/**********************************************************************************************************************/
184
185template<typename Derived, typename rawUserType>
187 Derived* derived{static_cast<Derived*>(this)};
188
189 bool isWriteable() { return true; }
190 bool isReadable() { return true; }
192 size_t nChannels() { return 1; }
193 size_t nElementsPerChannel() { return 1; }
194 size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
195 size_t nRuntimeErrorCases() { return 1; }
196
197 // The padding (i.e. the bits of the 32 bit word which are not part of the register under test but of the neighbouring
198 // registers) needs to be checked to be unchanged in write operations. This test assumes that in between the calls to
199 // generateValue() and getRemoteValue() the padding bits are not *intentionally* changed (e.g. by testing another
200 // register in between). This is true for the UnifiedBackendTest right now.
201 // TODO: In future it may be better to foresee a "no-side-effect" test in the UnifiedBackendTest, which tests that
202 // other registers stay unchanged (caveat: need to specify which registers to look at! We have intentionally
203 // overlapping registers in this test which of course will change!)
204 int32_t lastPadding{0};
206
207 static constexpr auto capabilities = TestCapabilities<>()
209 .disableAsyncReadInconsistency()
210 .disableSwitchReadOnly()
211 .disableSwitchWriteOnly()
212 .disableTestWriteNeverLosesData()
213 .enableTestRawTransfer();
214
215 // This register shares the address space with all our test registers. It gives us direct access to the 4 byte
216 // address range, so we can test the correct placement of the unaligned values.
217 DummyRegisterRawAccessor acc{exceptionDummy, "", "/Integers/unsigned32"};
218
219 rawUserType get() { return (acc & derived->bitmask) >> derived->bitshift; }
220
221 void set(rawUserType val) {
222 acc &= ~derived->bitmask;
225 acc |= (val << derived->bitshift) & derived->bitmask;
226 }
227
228 // Type can be user type or raw type, depeding of the raw flag
229 template<typename Type>
230 std::vector<std::vector<Type>> generateValue(bool raw = false) {
231 rawUserType newRawValue = static_cast<rawUserType>(get() + derived->rawIncrement);
232 Type v = (raw ? newRawValue : (newRawValue * derived->rawToCooked));
233 /* std::cout << "generateValue " << derived->path() << " " << float(rawUserType(get() + derived->rawIncrement))
234 << " -> " << float(v) << std::endl; */
235 lastPadding = acc & ~derived->bitmask;
237 return {{v}};
238 }
239
240 // We use the same function to implement raw and cooked reading.
241 // Do the calculation on the target type, then decide on the padding error.
242 // rawToCooked might undo the ++ effect in case
243 // of rounding. When getting cooked, the ++ must happen on the UserType.
244 // Type can be UserType or RawType.
245 template<typename Type>
246 std::vector<std::vector<Type>> getRemoteValue(bool raw = false) {
247 Type v = get() * (raw ? 1 : derived->rawToCooked);
248 if((acc & ~derived->bitmask) != lastPadding) {
250 std::cerr << "getRemoteValue(): Padding data has changed. Test will be failed by returing a false remote value "
251 << "(off by one)." << std::endl;
253 }
254 v++;
255 return {{v}};
256 }
257 /* std::cout << "getRemoteValue " << derived->path() << " " << float(get()) << " -> " << float(v) << std::endl; */
258 return {{v}};
259 }
260
262 set(get() + derived->rawIncrement);
263 /* std::cout << "setRemoteValue " << derived->path() << " " << float(get()) << " -> " <<
264 getRemoteValue<float>()[0][0]
265 << std::endl; */
266 }
267
268 void setForceRuntimeError(bool enable, size_t) {
269 exceptionDummy->throwExceptionRead = enable;
270 exceptionDummy->throwExceptionWrite = enable;
271 exceptionDummy->throwExceptionOpen = enable;
272 }
273};
274
275/**********************************************************************************************************************/
276
277struct ShortRaw_signed16 : ShortRaw_base<ShortRaw_signed16, int16_t> {
278 std::string path() { return "/ShortRaw/signed16"; }
279 typedef int16_t minimumUserType;
281
282 int16_t rawToCooked = 1;
283 // The rawIncrements are chosen such that we generate different values for different variables, and to cover the
284 // specific value range with very few values (to check signed vs. unsigned). Uncomment the above couts in the base
285 // class to check the generated values.
286 int16_t rawIncrement = 17117;
287 int bitshift = 0;
288 int32_t bitmask = 0x0000FFFF;
289};
290
291/**********************************************************************************************************************/
292
293struct ShortRaw_unsigned16 : ShortRaw_base<ShortRaw_unsigned16, uint16_t> {
294 std::string path() { return "/ShortRaw/unsigned16"; }
295 typedef uint16_t minimumUserType;
296 typedef int16_t rawUserType;
297
298 int16_t rawToCooked = 1;
299 int16_t rawIncrement = 17119;
300 int bitshift = 16;
301 int32_t bitmask = 0xFFFF0000;
302};
303
304/**********************************************************************************************************************/
305
306struct ShortRaw_fixedPoint16_8u : ShortRaw_base<ShortRaw_fixedPoint16_8u, uint16_t> {
307 std::string path() { return "/ShortRaw/fixedPoint16_8u"; }
308 typedef float minimumUserType;
309 typedef int16_t rawUserType;
310
311 float rawToCooked = 1. / 256.;
312 int16_t rawIncrement = 17121;
313 int bitshift = 0;
314 int32_t bitmask = 0x0000FFFF;
315};
316
317/**********************************************************************************************************************/
318
319struct ShortRaw_fixedPoint16_8s : ShortRaw_base<ShortRaw_fixedPoint16_8s, int16_t> {
320 std::string path() { return "/ShortRaw/fixedPoint16_8s"; }
321 typedef float minimumUserType;
322 typedef int16_t rawUserType;
323
324 float rawToCooked = 1. / 256.;
325 int16_t rawIncrement = 17123;
326 int bitshift = 16;
327 int32_t bitmask = 0xFFFF0000;
328};
329
330/**********************************************************************************************************************/
331
332struct ByteRaw_signed8 : ShortRaw_base<ByteRaw_signed8, int8_t> {
333 std::string path() { return "/ByteRaw/signed8"; }
334 typedef int8_t minimumUserType;
335 typedef int8_t rawUserType;
336
337 int8_t rawToCooked = 1;
338 int8_t rawIncrement = 119;
339 int bitshift = 0;
340 int32_t bitmask = 0x000000FF;
341};
342
343/**********************************************************************************************************************/
344
345struct ByteRaw_unsigned8 : ShortRaw_base<ByteRaw_unsigned8, uint8_t> {
346 std::string path() { return "/ByteRaw/unsigned8"; }
347 typedef uint8_t minimumUserType;
348 typedef int8_t rawUserType;
349
350 uint8_t rawToCooked = 1;
351 int8_t rawIncrement = 121;
352 int bitshift = 8;
353 int32_t bitmask = 0x0000FF00;
354};
355
356/**********************************************************************************************************************/
357
358struct ByteRaw_fixedPoint8_4u : ShortRaw_base<ByteRaw_fixedPoint8_4u, uint8_t> {
359 std::string path() { return "/ByteRaw/fixedPoint8_4u"; }
360 typedef float minimumUserType;
361 typedef int8_t rawUserType;
362
363 float rawToCooked = 1. / 16.;
364 int8_t rawIncrement = 123;
365 int bitshift = 16;
366 int32_t bitmask = 0x00FF0000;
367};
368
369/**********************************************************************************************************************/
370
371struct ByteRaw_fixedPoint8_4s : ShortRaw_base<ByteRaw_fixedPoint8_4s, int8_t> {
372 std::string path() { return "/ByteRaw/fixedPoint8_4s"; }
373 typedef float minimumUserType;
374 typedef int8_t rawUserType;
375
376 float rawToCooked = 1. / 16.;
377 int8_t rawIncrement = 125;
378 int bitshift = 24;
379 int32_t bitmask = 0xFF000000;
380};
381
382/**********************************************************************************************************************/
383
384struct AsciiData {
385 static std::string path() { return "/Text/someAsciiData"; }
386 static bool isWriteable() { return true; }
387 static bool isReadable() { return true; }
388 using minimumUserType = std::string;
390
391 static size_t nChannels() { return 1; }
392 static size_t nElementsPerChannel() { return 1; }
393 static size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
394 static size_t nRuntimeErrorCases() { return 1; }
395
396 static constexpr auto capabilities = TestCapabilities<>()
398 .disableAsyncReadInconsistency()
399 .disableSwitchReadOnly()
400 .disableSwitchWriteOnly()
401 .disableTestWriteNeverLosesData()
402 .disableTestRawTransfer();
403
404 // Note: The DummyRegisterAccessor does not yet work properly with none 32-bit word sizes.
405 DummyRegisterAccessor<uint32_t> acc{exceptionDummy.get(), "Text", "someAsciiData_as_i32"};
406
407 std::string textBase{"Some $%#@! characters "};
408 size_t counter{0};
409 const size_t asciiLength{35};
410
411 template<typename UserType>
412 std::vector<std::vector<UserType>> generateValue() {
413 return {{textBase + std::to_string(counter++)}};
414 }
415
416 template<typename UserType>
417 std::vector<std::vector<UserType>> getRemoteValue() {
418 std::vector<std::vector<UserType>> v{{""}};
419 for(size_t i = 0; i < asciiLength; ++i) {
420 size_t word = i / 4;
421 size_t byteInWord = i % 4;
422 char ch = char((acc[word] >> (byteInWord * 8U)) & 0xFF);
423 if(ch == 0) break;
424 v[0][0] += ch;
425 }
426 std::cout << "getRemoteValue: " << v[0][0] << std::endl;
427 return v;
428 }
429
431 auto v = generateValue<minimumUserType>();
432 for(size_t i = 0; i < acc.getNumberOfElements(); ++i) {
433 acc[i] = 0;
434 }
435 for(size_t i = 0; i < std::min(asciiLength, v[0][0].length()); ++i) {
436 char ch = v[0][0][i];
437 size_t word = i / 4;
438 size_t byteInWord = i % 4;
439 acc[word] = acc[word] | uint32_t(ch) << (byteInWord * 8U);
440 }
441 std::cout << "setRemoteValue: " << v[0][0] << std::endl;
442 }
443
444 static void setForceRuntimeError(bool enable, size_t) {
445 exceptionDummy->throwExceptionRead = enable;
446 exceptionDummy->throwExceptionWrite = enable;
447 exceptionDummy->throwExceptionOpen = enable;
448 }
449};
450
451/**********************************************************************************************************************/
452
454 std::string path() { return "/TEST/NODMA"; }
455 bool isWriteable() { return true; }
456 bool isReadable() { return true; }
458
459 size_t nChannels() { return 16; }
460 size_t nElementsPerChannel() { return 4; }
461 size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
462 size_t nRuntimeErrorCases() { return 1; }
463 typedef uint16_t minimumUserType;
465
466 static constexpr auto capabilities = TestCapabilities<>()
468 .disableAsyncReadInconsistency()
469 .disableSwitchReadOnly()
470 .disableSwitchWriteOnly()
471 .disableTestWriteNeverLosesData()
472 .disableTestRawTransfer();
473
474 DummyMultiplexedRegisterAccessor<uint16_t> acc{exceptionDummyMuxed.get(), "TEST", "NODMA"};
475
476 template<typename UserType>
477 std::vector<std::vector<UserType>> generateValue() {
478 std::vector<std::vector<UserType>> v;
479 v.resize(nChannels());
480 for(size_t c = 0; c < nChannels(); ++c) {
481 for(size_t e = 0; e < nElementsPerChannel(); ++e) {
482 v[c].push_back(uint16_t(acc[c][e] + 7 * c + 3 * e));
483 }
484 }
485 return v;
486 }
487
488 template<typename UserType>
489 std::vector<std::vector<UserType>> getRemoteValue() {
490 std::vector<std::vector<UserType>> v;
491 v.resize(nChannels());
492 for(size_t c = 0; c < nChannels(); ++c) {
493 for(size_t e = 0; e < nElementsPerChannel(); ++e) {
494 v[c].push_back(acc[c][e]);
495 }
496 }
497 return v;
498 }
499
501 auto v = generateValue<minimumUserType>();
502 for(size_t c = 0; c < nChannels(); ++c) {
503 for(size_t e = 0; e < nElementsPerChannel(); ++e) {
504 acc[c][e] = v[c][e];
505 }
506 }
507 }
508
509 void setForceRuntimeError(bool enable, size_t) {
510 exceptionDummyMuxed->throwExceptionRead = enable;
511 exceptionDummyMuxed->throwExceptionWrite = enable;
512 exceptionDummyMuxed->throwExceptionOpen = enable;
513 }
514};
515
517 std::string path() { return "/TEST/NODMAASYNC"; }
518 bool isWriteable() { return false; }
519 bool isReadable() { return true; }
521
522 size_t nChannels() { return 16; }
523 size_t nElementsPerChannel() { return 4; }
524 size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
525 size_t nRuntimeErrorCases() { return 1; }
526 typedef uint16_t minimumUserType;
528
529 static constexpr auto capabilities = TestCapabilities<>()
531 .disableAsyncReadInconsistency()
532 .disableSwitchReadOnly()
533 .disableSwitchWriteOnly()
534 .disableTestWriteNeverLosesData()
535 .disableTestRawTransfer();
536
537 DummyMultiplexedRegisterAccessor<uint16_t> acc{exceptionDummyMuxed.get(), "TEST", "NODMAASYNC"};
538
539 template<typename UserType>
540 std::vector<std::vector<UserType>> generateValue() {
541 std::vector<std::vector<UserType>> v;
542 v.resize(nChannels());
543 for(size_t c = 0; c < nChannels(); ++c) {
544 for(size_t e = 0; e < nElementsPerChannel(); ++e) {
545 v[c].push_back(uint16_t(acc[c][e] + 7 * c + 3 * e));
546 }
547 }
548 return v;
549 }
550
551 template<typename UserType>
552 std::vector<std::vector<UserType>> getRemoteValue() {
553 std::vector<std::vector<UserType>> v;
554 v.resize(nChannels());
555 for(size_t c = 0; c < nChannels(); ++c) {
556 for(size_t e = 0; e < nElementsPerChannel(); ++e) {
557 v[c].push_back(acc[c][e]);
558 }
559 }
560 return v;
561 }
562
564 auto v = generateValue<minimumUserType>();
565 for(size_t c = 0; c < nChannels(); ++c) {
566 for(size_t e = 0; e < nElementsPerChannel(); ++e) {
567 acc[c][e] = v[c][e];
568 }
569 }
570 if(exceptionDummyMuxed->isOpen()) exceptionDummyMuxed->triggerInterrupt(6);
571 }
572
573 void setForceRuntimeError(bool enable, size_t) {
574 exceptionDummyMuxed->throwExceptionRead = enable;
575 exceptionDummyMuxed->throwExceptionWrite = enable;
576 exceptionDummyMuxed->throwExceptionOpen = enable;
577 if(exceptionDummyMuxed->isOpen()) exceptionDummyMuxed->triggerInterrupt(6);
578 }
579};
580
581/**********************************************************************************************************************/
582
584 std::string path() { return "/TEST/FLOAT"; }
585 bool isWriteable() { return true; }
586 bool isReadable() { return true; }
588
589 size_t nChannels() { return 4; }
590 size_t nElementsPerChannel() { return 8; }
591 size_t nRuntimeErrorCases() { return 1; }
592 typedef float minimumUserType;
593 // typedef int32_t rawUserType;
594
595 static constexpr auto capabilities = TestCapabilities<>()
597 .disableAsyncReadInconsistency()
598 .disableSwitchReadOnly()
599 .disableSwitchWriteOnly()
600 .disableTestWriteNeverLosesData()
601 .disableTestRawTransfer();
602
603 DummyMultiplexedRegisterAccessor<int32_t> rawAcc{exceptionDummyMuxed.get(), "TEST", "FLOAT"};
604
605 template<typename UserType>
606 std::vector<std::vector<UserType>> generateValue() {
607 std::vector<std::vector<UserType>> v;
608 v.resize(nChannels());
609 for(uint32_t c = 0; c < nChannels(); ++c) {
610 for(uint32_t e = 0; e < nElementsPerChannel(); ++e) {
611 int32_t rawValue = rawAcc[c][e];
612 float* cookedValue = reinterpret_cast<float*>(&rawValue);
613 v[c].push_back(*cookedValue + 0.7f * c + 3 * e);
614 }
615 }
616 return v;
617 }
618
619 template<typename UserType>
620 std::vector<std::vector<UserType>> getRemoteValue() {
621 std::vector<std::vector<UserType>> v;
622 v.resize(nChannels());
623 for(uint32_t c = 0; c < nChannels(); ++c) {
624 for(uint32_t e = 0; e < nElementsPerChannel(); ++e) {
625 int32_t rawValue = rawAcc[c][e];
626 float* cookedValue = reinterpret_cast<float*>(&rawValue);
627 v[c].push_back(*cookedValue);
628 }
629 }
630 return v;
631 }
632
634 auto v = generateValue<minimumUserType>();
635 for(uint32_t c = 0; c < nChannels(); ++c) {
636 for(uint32_t e = 0; e < nElementsPerChannel(); ++e) {
637 int32_t rawValue;
638 float* cookedValue = reinterpret_cast<float*>(&rawValue);
639 *cookedValue = v[c][e];
640 std::cout << "raw value is " << rawValue << "; cookedValue is " << *cookedValue << std::endl;
641 rawAcc[c][e] = rawValue;
642 }
643 }
644 }
645
646 void setForceRuntimeError(bool enable, size_t) {
647 exceptionDummyMuxed->throwExceptionRead = enable;
648 exceptionDummyMuxed->throwExceptionWrite = enable;
649 exceptionDummyMuxed->throwExceptionOpen = enable;
650 }
651};
652
653/**********************************************************************************************************************/
654
655BOOST_AUTO_TEST_CASE(testRegisterAccessor) {
656 std::cout << "*** testRegisterAccessor *** " << std::endl;
659 .addRegister<Integers_signed32_async>()
660 /* .addRegister<Integers_signed32_async_rw>() // disabled for now as .DUMMY_WRITABLE no longer supports
661 wait_for_new_data */
662 .addRegister<ShortRaw_signed16>()
663 .addRegister<ShortRaw_unsigned16>()
664 .addRegister<ShortRaw_fixedPoint16_8u>()
665 .addRegister<ShortRaw_fixedPoint16_8s>()
666 .addRegister<ByteRaw_signed8>()
667 .addRegister<ByteRaw_unsigned8>()
668 .addRegister<ByteRaw_fixedPoint8_4s>()
669 .addRegister<ByteRaw_fixedPoint8_4u>()
670 .addRegister<AsciiData>()
671 .runTests(cdd);
672}
673
674/**********************************************************************************************************************/
675
676BOOST_AUTO_TEST_CASE(testMultiplexedRegisterAccessor) {
677 std::cout << "*** testMultiplexedRegisterAccessor *** " << std::endl;
680 .addRegister<MuxedNodmaAsync>()
681 .addRegister<MuxedFloat>()
682 .runTests(cddMuxed);
683}
684
685/**********************************************************************************************************************/
686
687BOOST_AUTO_TEST_SUITE_END()
Set of AccessMode flags with additional functionality for an easier handling.
Definition AccessMode.h:48
static BackendFactory & getInstance()
Static function to get an instance of factory.
Register accessor for accessing multiplexed 2D array registers internally of a DummyBackend implement...
Register accessor for accessing single word or 1D array registers internally of a DummyBackend implem...
unsigned int getNumberOfElements()
return number of elements
Accessor for raw 32 bit integer access to the underlying memory space.
Class to test any backend for correct behaviour.
UnifiedBackendTest< typename boost::mpl::push_back< VECTOR_OF_REGISTERS_T, REG_T >::type > addRegister()
Add a register to be used by the test.
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...
std::string to_string(const std::string &v)
std::vector< std::vector< UserType > > generateValue()
std::vector< std::vector< UserType > > getRemoteValue()
DummyRegisterAccessor< uint32_t > acc
static constexpr auto capabilities
static ChimeraTK::AccessModeFlags supportedFlags()
static void setForceRuntimeError(bool enable, size_t)
Descriptor for the test capabilities for each register.
constexpr TestCapabilities< _syncRead, TestCapability::disabled, _asyncReadInconsistency, _switchReadOnly, _switchWriteOnly, _writeNeverLosesData, _testWriteOnly, _testReadOnly, _testRawTransfer, _testCatalogue, _setRemoteValueIncrementsVersion, _testPartialAccessor > disableForceDataLossWrite() const
std::vector< std::vector< Type > > generateValue(bool raw=false)
std::vector< std::vector< UserType > > getRemoteValue(bool raw=false)
std::vector< std::vector< Type > > generateValue(bool raw=false)
ChimeraTK::AccessModeFlags supportedFlags()
std::vector< std::vector< UserType > > getRemoteValue(bool raw=false)
DummyRegisterAccessor< int32_t > acc
std::vector< std::vector< Type > > generateValue(bool raw=false)
void setForceRuntimeError(bool enable, size_t)
DummyRegisterAccessor< int32_t > acc
ChimeraTK::AccessModeFlags supportedFlags()
std::vector< std::vector< UserType > > getRemoteValue(bool raw=false)
static constexpr auto capabilities
void setForceRuntimeError(bool enable, size_t)
DummyMultiplexedRegisterAccessor< int32_t > rawAcc
std::vector< std::vector< UserType > > generateValue()
ChimeraTK::AccessModeFlags supportedFlags()
std::vector< std::vector< UserType > > getRemoteValue()
std::vector< std::vector< UserType > > getRemoteValue()
DummyMultiplexedRegisterAccessor< uint16_t > acc
ChimeraTK::AccessModeFlags supportedFlags()
void setForceRuntimeError(bool enable, size_t)
std::vector< std::vector< UserType > > generateValue()
DummyMultiplexedRegisterAccessor< uint16_t > acc
void setForceRuntimeError(bool enable, size_t)
std::vector< std::vector< UserType > > getRemoteValue()
ChimeraTK::AccessModeFlags supportedFlags()
static constexpr auto capabilities
std::vector< std::vector< UserType > > generateValue()
void setForceRuntimeError(bool enable, size_t)
ChimeraTK::AccessModeFlags supportedFlags()
std::vector< std::vector< Type > > generateValue(bool raw=false)
std::vector< std::vector< Type > > getRemoteValue(bool raw=false)
std::string cdd
auto exceptionDummy
BOOST_AUTO_TEST_CASE(testRegisterAccessor)