4#define BOOST_TEST_DYN_LINK
6#define BOOST_TEST_MODULE NumericAddressedBackendUnified
8#include <boost/test/unit_test.hpp>
9using namespace boost::unit_test_framework;
30BOOST_AUTO_TEST_SUITE(NumericAddressedBackendUnifiedTestSuite)
34static std::string
cdd(
"(ExceptionDummy:1?map=test3.map)");
38static std::string cddMuxed(
"(ExceptionDummy:1?map=muxedDataAcessor.map)");
39static auto exceptionDummyMuxed =
45 std::string
path() {
return "/Integers/signed32"; }
58 .disableAsyncReadInconsistency()
59 .disableSwitchReadOnly()
60 .disableSwitchWriteOnly()
61 .disableTestWriteNeverLosesData()
62 .enableTestRawTransfer();
66 template<
typename Type>
71 template<
typename UserType>
86 std::string
path() {
return "/Integers/signed32_async"; }
101 .disableAsyncReadInconsistency()
102 .disableSwitchReadOnly()
103 .disableSwitchWriteOnly()
104 .disableTestWriteNeverLosesData()
105 .enableTestRawTransfer();
109 template<
typename Type>
114 template<
typename UserType>
120 acc = generateValue<minimumUserType>()[0][0];
135 std::string
path() {
return "/Integers/signed32_async/DUMMY_WRITEABLE"; }
150 .disableAsyncReadInconsistency()
151 .disableSwitchReadOnly()
152 .disableSwitchWriteOnly()
153 .disableTestWriteNeverLosesData()
154 .enableTestRawTransfer();
158 template<
typename Type>
163 template<
typename UserType>
169 acc = generateValue<minimumUserType>()[0][0];
185template<
typename Derived,
typename rawUserType>
187 Derived*
derived{
static_cast<Derived*
>(
this)};
209 .disableAsyncReadInconsistency()
210 .disableSwitchReadOnly()
211 .disableSwitchWriteOnly()
212 .disableTestWriteNeverLosesData()
213 .enableTestRawTransfer();
221 void set(rawUserType val) {
222 acc &= ~derived->bitmask;
229 template<
typename Type>
231 rawUserType newRawValue =
static_cast<rawUserType
>(
get() +
derived->rawIncrement);
232 Type v = (
raw ? newRawValue : (newRawValue *
derived->rawToCooked));
245 template<
typename Type>
250 std::cerr <<
"getRemoteValue(): Padding data has changed. Test will be failed by returing a false remote value "
251 <<
"(off by one)." << std::endl;
278 std::string
path() {
return "/ShortRaw/signed16"; }
294 std::string
path() {
return "/ShortRaw/unsigned16"; }
307 std::string
path() {
return "/ShortRaw/fixedPoint16_8u"; }
320 std::string
path() {
return "/ShortRaw/fixedPoint16_8s"; }
333 std::string
path() {
return "/ByteRaw/signed8"; }
346 std::string
path() {
return "/ByteRaw/unsigned8"; }
359 std::string
path() {
return "/ByteRaw/fixedPoint8_4u"; }
372 std::string
path() {
return "/ByteRaw/fixedPoint8_4s"; }
385 static std::string
path() {
return "/Text/someAsciiData"; }
398 .disableAsyncReadInconsistency()
399 .disableSwitchReadOnly()
400 .disableSwitchWriteOnly()
401 .disableTestWriteNeverLosesData()
402 .disableTestRawTransfer();
411 template<
typename UserType>
416 template<
typename UserType>
418 std::vector<std::vector<UserType>> v{{
""}};
421 size_t byteInWord = i % 4;
422 char ch = char((
acc[word] >> (byteInWord * 8U)) & 0xFF);
426 std::cout <<
"getRemoteValue: " << v[0][0] << std::endl;
431 auto v = generateValue<minimumUserType>();
435 for(
size_t i = 0; i < std::min(
asciiLength, v[0][0].length()); ++i) {
436 char ch = v[0][0][i];
438 size_t byteInWord = i % 4;
439 acc[word] =
acc[word] | uint32_t(ch) << (byteInWord * 8U);
441 std::cout <<
"setRemoteValue: " << v[0][0] << std::endl;
454 std::string
path() {
return "/TEST/NODMA"; }
468 .disableAsyncReadInconsistency()
469 .disableSwitchReadOnly()
470 .disableSwitchWriteOnly()
471 .disableTestWriteNeverLosesData()
472 .disableTestRawTransfer();
476 template<
typename UserType>
478 std::vector<std::vector<UserType>> v;
480 for(
size_t c = 0; c <
nChannels(); ++c) {
482 v[c].push_back(uint16_t(
acc[c][e] + 7 * c + 3 * e));
488 template<
typename UserType>
490 std::vector<std::vector<UserType>> v;
492 for(
size_t c = 0; c <
nChannels(); ++c) {
494 v[c].push_back(
acc[c][e]);
501 auto v = generateValue<minimumUserType>();
502 for(
size_t c = 0; c <
nChannels(); ++c) {
510 exceptionDummyMuxed->throwExceptionRead = enable;
511 exceptionDummyMuxed->throwExceptionWrite = enable;
512 exceptionDummyMuxed->throwExceptionOpen = enable;
517 std::string
path() {
return "/TEST/NODMAASYNC"; }
531 .disableAsyncReadInconsistency()
532 .disableSwitchReadOnly()
533 .disableSwitchWriteOnly()
534 .disableTestWriteNeverLosesData()
535 .disableTestRawTransfer();
539 template<
typename UserType>
541 std::vector<std::vector<UserType>> v;
543 for(
size_t c = 0; c <
nChannels(); ++c) {
545 v[c].push_back(uint16_t(
acc[c][e] + 7 * c + 3 * e));
551 template<
typename UserType>
553 std::vector<std::vector<UserType>> v;
555 for(
size_t c = 0; c <
nChannels(); ++c) {
557 v[c].push_back(
acc[c][e]);
564 auto v = generateValue<minimumUserType>();
565 for(
size_t c = 0; c <
nChannels(); ++c) {
570 if(exceptionDummyMuxed->isOpen()) exceptionDummyMuxed->triggerInterrupt(6);
574 exceptionDummyMuxed->throwExceptionRead = enable;
575 exceptionDummyMuxed->throwExceptionWrite = enable;
576 exceptionDummyMuxed->throwExceptionOpen = enable;
577 if(exceptionDummyMuxed->isOpen()) exceptionDummyMuxed->triggerInterrupt(6);
584 std::string
path() {
return "/TEST/FLOAT"; }
597 .disableAsyncReadInconsistency()
598 .disableSwitchReadOnly()
599 .disableSwitchWriteOnly()
600 .disableTestWriteNeverLosesData()
601 .disableTestRawTransfer();
605 template<
typename UserType>
607 std::vector<std::vector<UserType>> v;
609 for(uint32_t c = 0; c <
nChannels(); ++c) {
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);
619 template<
typename UserType>
621 std::vector<std::vector<UserType>> v;
623 for(uint32_t c = 0; c <
nChannels(); ++c) {
625 int32_t rawValue =
rawAcc[c][e];
626 float* cookedValue =
reinterpret_cast<float*
>(&rawValue);
627 v[c].push_back(*cookedValue);
634 auto v = generateValue<minimumUserType>();
635 for(uint32_t c = 0; c <
nChannels(); ++c) {
638 float* cookedValue =
reinterpret_cast<float*
>(&rawValue);
639 *cookedValue = v[c][e];
640 std::cout <<
"raw value is " << rawValue <<
"; cookedValue is " << *cookedValue << std::endl;
647 exceptionDummyMuxed->throwExceptionRead = enable;
648 exceptionDummyMuxed->throwExceptionWrite = enable;
649 exceptionDummyMuxed->throwExceptionOpen = enable;
656 std::cout <<
"*** testRegisterAccessor *** " << std::endl;
659 .addRegister<Integers_signed32_async>()
663 .addRegister<ShortRaw_unsigned16>()
665 .addRegister<ShortRaw_fixedPoint16_8s>()
667 .addRegister<ByteRaw_unsigned8>()
669 .addRegister<ByteRaw_fixedPoint8_4u>()
677 std::cout <<
"*** testMultiplexedRegisterAccessor *** " << std::endl;
680 .addRegister<MuxedNodmaAsync>()
687BOOST_AUTO_TEST_SUITE_END()
Set of AccessMode flags with additional functionality for an easier handling.
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()
static size_t writeQueueLength()
DummyRegisterAccessor< uint32_t > acc
static size_t nChannels()
static bool isWriteable()
std::string minimumUserType
static constexpr auto capabilities
static std::string path()
static size_t nRuntimeErrorCases()
static ChimeraTK::AccessModeFlags supportedFlags()
static size_t nElementsPerChannel()
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)
size_t writeQueueLength()
static constexpr auto capabilities
void forceAsyncReadInconsistency()
std::vector< std::vector< UserType > > getRemoteValue(bool raw=false)
minimumUserType rawUserType
size_t nRuntimeErrorCases()
DummyRegisterAccessor< int32_t > acc
size_t nElementsPerChannel()
ChimeraTK::AccessModeFlags supportedFlags()
void setForceRuntimeError(bool enable, size_t)
std::vector< std::vector< Type > > generateValue(bool raw=false)
minimumUserType rawUserType
ChimeraTK::AccessModeFlags supportedFlags()
std::vector< std::vector< UserType > > getRemoteValue(bool raw=false)
size_t nElementsPerChannel()
void forceAsyncReadInconsistency()
static constexpr auto capabilities
void setForceRuntimeError(bool enable, size_t)
DummyRegisterAccessor< int32_t > acc
size_t nRuntimeErrorCases()
size_t writeQueueLength()
size_t nRuntimeErrorCases()
std::vector< std::vector< Type > > generateValue(bool raw=false)
void setForceRuntimeError(bool enable, size_t)
size_t writeQueueLength()
DummyRegisterAccessor< int32_t > acc
ChimeraTK::AccessModeFlags supportedFlags()
minimumUserType rawUserType
size_t nElementsPerChannel()
std::vector< std::vector< UserType > > getRemoteValue(bool raw=false)
static constexpr auto capabilities
static constexpr auto capabilities
void setForceRuntimeError(bool enable, size_t)
size_t nRuntimeErrorCases()
DummyMultiplexedRegisterAccessor< int32_t > rawAcc
size_t nElementsPerChannel()
std::vector< std::vector< UserType > > generateValue()
ChimeraTK::AccessModeFlags supportedFlags()
std::vector< std::vector< UserType > > getRemoteValue()
size_t nRuntimeErrorCases()
static constexpr auto capabilities
std::vector< std::vector< UserType > > getRemoteValue()
DummyMultiplexedRegisterAccessor< uint16_t > acc
minimumUserType rawUserType
ChimeraTK::AccessModeFlags supportedFlags()
void setForceRuntimeError(bool enable, size_t)
size_t nElementsPerChannel()
size_t writeQueueLength()
std::vector< std::vector< UserType > > generateValue()
size_t writeQueueLength()
DummyMultiplexedRegisterAccessor< uint16_t > acc
void setForceRuntimeError(bool enable, size_t)
size_t nRuntimeErrorCases()
size_t nElementsPerChannel()
std::vector< std::vector< UserType > > getRemoteValue()
ChimeraTK::AccessModeFlags supportedFlags()
minimumUserType rawUserType
static constexpr auto capabilities
std::vector< std::vector< UserType > > generateValue()
void setForceRuntimeError(bool enable, size_t)
ChimeraTK::AccessModeFlags supportedFlags()
DummyRegisterRawAccessor acc
size_t writeQueueLength()
std::vector< std::vector< Type > > generateValue(bool raw=false)
size_t nRuntimeErrorCases()
bool printPaddingChangedMessage
static constexpr auto capabilities
void set(rawUserType val)
std::vector< std::vector< Type > > getRemoteValue(bool raw=false)
size_t nElementsPerChannel()
minimumUserType rawUserType
BOOST_AUTO_TEST_CASE(testRegisterAccessor)