4#define BOOST_TEST_DYN_LINK
5#define BOOST_TEST_MODULE SubdeviceBackendUnifiedTest
6#include <boost/test/unit_test.hpp>
7using namespace boost::unit_test_framework;
15BOOST_AUTO_TEST_SUITE(SubdeviceBackendUnifiedTestSuite)
19static std::string
cdd(
"(ExceptionDummy:1?map=SubdeviceTarget.map)");
27 assert(target !=
nullptr);
54 std::cout <<
"Error in writeCallback: chipSelect is " <<
chipSelect <<
", expected " <<
chipId << std::endl;
69 uint32_t theData =
data;
75 for(
size_t i = 0; i <
areaSize; ++i) {
76 uint32_t theData =
area[i];
88 std::cout <<
"Error in readCallback: chipSelect is " <<
chipSelect <<
", expected " <<
chipId << std::endl;
107 for(
size_t i = 0; i <
areaSize; ++i) {
121template<
typename Register>
132 .disableAsyncReadInconsistency()
133 .enableTestRawTransfer()
134 .disableTestPartialAccessor();
138 template<
typename Type>
143 for(
size_t i = 0; i < this->nElementsPerChannel(); ++i) {
149 typename Register::minimumUserType e = this->fromRaw(cv) + this->increment * (i + 1);
150 auto limited = this->limitGenerated(e);
151 v.push_back(
raw ? this->toRaw(limited) : limited);
156 template<
typename Type>
161 for(
size_t i = 0; i < this->nElementsPerChannel(); ++i) {
163 auto* bufferStart = std::bit_cast<std::byte*>(core.
currentValue.data());
165 v.push_back(
raw ? rawValue : this->fromRaw(rawValue));
171 auto v = generateValue<typename Register::minimumUserType>()[0];
172 auto* bufferStart = std::bit_cast<std::byte*>(core.
currentValue.data());
175 for(
size_t i = 0; i < this->nElementsPerChannel(); ++i) {
176 auto rawVal = this->toRaw(v[i]);
183 target->throwExceptionRead = enable;
184 target->throwExceptionWrite = enable;
185 target->throwExceptionOpen = enable;
191template<
typename Register>
198template<
typename Register>
206 std::string
path() {
return "/APP.0/MY_REGISTER1"; }
209 uint32_t
toRaw(uint32_t v) {
return v; }
220 std::string
path() {
return "/APP.0/MY_AREA1"; }
223 uint32_t
toRaw(
double v) {
return int32_t(v * 65536.); }
224 double fromRaw(uint32_t v) {
return std::bit_cast<int32_t>(v) / 65536.; }
226 while(e > 32768.F) e -= 65535.;
227 while(e < -32767.F) e += 65535.;
238 std::string
path() {
return "/APP.0/THE_AREA_1"; }
241 uint32_t
toRaw(uint32_t v) {
return v; }
252 std::string
path() {
return "/APP.0/THE_AREA_2"; }
255 uint32_t
toRaw(
float v) {
return v * 65536.F; }
256 float fromRaw(uint32_t v) {
return v / 65536.F; }
258 while(e > 32768.F) e -= 65535.F;
259 while(e < -32767.F) e += 65535.F;
270 static std::string
path() {
return "/APP.0/EIGHT_BIT"; }
273 static uint8_t
toRaw(int8_t v) {
return std::bit_cast<uint8_t>(v); }
274 static int8_t
fromRaw(uint8_t v) {
return std::bit_cast<int8_t>(v); }
284 static std::string
path() {
return "/APP.0/EIGHT_BIT_ARRAY"; }
287 static uint8_t
toRaw(int8_t v) {
return std::bit_cast<uint8_t>(v); }
288 static int8_t
fromRaw(uint8_t v) {
return std::bit_cast<int8_t>(v); }
298 static std::string
path() {
return "/APP.0/SIXTEEN_BIT"; }
301 static uint16_t
toRaw(int16_t v) {
return std::bit_cast<uint16_t>(v); }
302 static int16_t
fromRaw(uint16_t v) {
return std::bit_cast<int16_t>(v); }
312 static std::string
path() {
return "/APP.0/SIXTEEN_OFF1"; }
315 static uint16_t
toRaw(int16_t v) {
return std::bit_cast<uint16_t>(v); }
316 static int16_t
fromRaw(uint16_t v) {
return std::bit_cast<int16_t>(v); }
326 static std::string
path() {
return "/APP.0/SIXTEEN_OFF2"; }
329 static uint16_t
toRaw(int16_t v) {
return std::bit_cast<uint16_t>(v); }
330 static int16_t
fromRaw(uint16_t v) {
return std::bit_cast<int16_t>(v); }
340 static std::string
path() {
return "/APP.0/SIXTEEN_BIT_ARRAY"; }
343 static uint16_t
toRaw(int16_t v) {
return std::bit_cast<uint16_t>(v); }
344 static int16_t
fromRaw(uint16_t v) {
return std::bit_cast<int16_t>(v); }
354 static std::string
path() {
return "/APP.0/SIXTEEN_ARRAY_OFF2"; }
357 static uint16_t
toRaw(int16_t v) {
return std::bit_cast<uint16_t>(v); }
358 static int16_t
fromRaw(uint16_t v) {
return std::bit_cast<int16_t>(v); }
368 static std::string
path() {
return "/APP.0/SIXTYFOUR_BIT"; }
371 static uint64_t
toRaw(int64_t v) {
return std::bit_cast<uint64_t>(v); }
372 static int64_t
fromRaw(uint64_t v) {
return std::bit_cast<int64_t>(v); }
384 "(subdevice?type=regWindow&device=" +
cdd +
385 "&address=APP.1.ADDRESS&data=APP.1.DATA&status=APP.1.STATUS&map=Subdevice.map)");
394 "(subdevice?type=regWindow&device=" +
cdd +
395 "&address=APP.1.ADDRESS&data=APP.1.DATA&sleep=1000&map=Subdevice.map)");
406 "(subdevice?type=regWindow&device=" +
cdd +
407 "&address=APP.1.ADDRESS&data=APP.0.THE_AREA&status=APP.1.STATUS&map=SubdeviceMuxedArea.map)");
416 "(subdevice?type=regWindow&device=" +
cdd +
417 "&address=APP.1.ADDRESS&writeData=APP.1.DATA&busy=APP.1.STATUS&readRequest=APP.REG_WIN.READ_REQUEST&readData=APP."
418 "REG_WIN.READOUT_SINGLE&chipSelectRegister=APP.REG_WIN.CHIP_SELECT&chipIndex=3&map=Subdevice.map)");
428 "(subdevice?type=regWindow&device=" +
cdd +
429 "&address=APP.1.ADDRESS&writeData=APP.0.THE_AREA&busy=APP.1.STATUS&readRequest=APP.REG_WIN.READ_REQUEST&readData="
430 "APP.REG_WIN.READOUT_AREA&chipSelectRegister=APP.REG_WIN.CHIP_SELECT&map=SubdeviceMuxedArea.map)");
441 .runTests(
"(subdevice?type=regWindow&device=" +
cdd +
442 "&address=APP.1.ADDRESS&busy=APP.1.STATUS&readRequest=APP.REG_WIN.READ_REQUEST&readData=APP."
443 "REG_WIN.READOUT_SINGLE&chipSelectRegister=APP.REG_WIN.CHIP_SELECT&chipIndex=3&map=Subdevice.map)");
453 .runTests(
"(subdevice?type=regWindow&device=" +
cdd +
454 "&address=APP.1.ADDRESS&writeData=APP.1.DATA&busy=APP.1.STATUS&readRequest=APP.REG_WIN.READ_REQUEST&readData="
455 "APP.REG_WIN.READOUT_SINGLE&chipSelectRegister=APP.REG_WIN.CHIP_SELECT&map=Subdevice.map)");
467 .runTests(
"(subdevice?type=regWindow&device=" +
cdd +
468 "&address=APP.1.ADDRESS&writeData=APP.1.DATA&busy=APP.1.STATUS&readRequest=APP.REG_WIN.READ_REQUEST&readData="
469 "APP.REG_WIN.READOUT_SINGLE&chipSelectRegister=APP.REG_WIN.CHIP_SELECT&map=Subdevice.map)");
477 "(subdevice?type=regWindow&device=" +
cdd +
478 "&address=APP.1.ADDRESS&writeData=APP.1.DATA&busy=APP.1.STATUS&readRequest=APP.REG_WIN.READ_REQUEST&readData="
479 "APP.REG_WIN.READOUT_SINGLE&chipSelectRegister=APP.REG_WIN.CHIP_SELECT&map=Subdevice.map)");
497 .runTests(
"(subdevice?type=regWindow&device=" +
cdd +
498 "&address=APP.1.ADDRESS&writeData=APP.1.WRITE_DATA_8BIT&busy=APP.1.STATUS&readRequest=APP.REG_WIN.READ_"
499 "REQUEST&readData=APP.REG_WIN.READOUT_8BIT&chipSelectRegister=APP.REG_WIN.CHIP_SELECT&map=Subdevice.map)");
503BOOST_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 single word or 1D array registers internally of a DummyBackend implem...
unsigned int getNumberOfElements()
return number of elements
void setWriteCallback(const std::function< void()> &writeCallback)
Set callback function which is called when the register is written to (through the normal Device inte...
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.
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...
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
static std::string path()
static int8_t fromRaw(uint8_t v)
static uint8_t toRaw(int8_t v)
static size_t nElementsPerChannel()
static int8_t limitGenerated(int8_t e)
static size_t nElementsPerChannel()
static std::string path()
static uint8_t toRaw(int8_t v)
static int8_t fromRaw(uint8_t v)
static int8_t limitGenerated(int8_t e)
uint32_t fromRaw(uint32_t v)
uint32_t toRaw(uint32_t v)
uint32_t limitGenerated(uint32_t e)
size_t nElementsPerChannel()
float limitGenerated(float e)
size_t nElementsPerChannel()
float fromRaw(uint32_t v)
double limitGenerated(double e)
size_t nElementsPerChannel()
double fromRaw(uint32_t v)
uint32_t limitGenerated(uint32_t e)
size_t nElementsPerChannel()
uint32_t toRaw(uint32_t v)
uint32_t fromRaw(uint32_t v)
size_t nRuntimeErrorCases()
static constexpr auto capabilities
size_t writeQueueLength()
std::vector< std::vector< Type > > generateValue(bool raw=false)
std::vector< std::vector< Type > > getRemoteValue(bool raw=false)
ChimeraTK::AccessModeFlags supportedFlags()
typename Register::rawUserType RegisterRawType
void setForceRuntimeError(bool enable, size_t)
static size_t nElementsPerChannel()
static int16_t limitGenerated(int16_t e)
static int16_t fromRaw(uint16_t v)
static std::string path()
static uint16_t toRaw(int16_t v)
static uint16_t toRaw(int16_t v)
static size_t nElementsPerChannel()
static int16_t fromRaw(uint16_t v)
static int16_t limitGenerated(int16_t e)
static std::string path()
static size_t nElementsPerChannel()
static int16_t limitGenerated(int16_t e)
static std::string path()
static uint16_t toRaw(int16_t v)
static int16_t fromRaw(uint16_t v)
static int16_t limitGenerated(int16_t e)
static uint16_t toRaw(int16_t v)
static std::string path()
static int16_t fromRaw(uint16_t v)
static size_t nElementsPerChannel()
static uint16_t toRaw(int16_t v)
static size_t nElementsPerChannel()
static std::string path()
static int16_t limitGenerated(int16_t e)
static int16_t fromRaw(uint16_t v)
static size_t nElementsPerChannel()
static int64_t fromRaw(uint64_t v)
static uint64_t toRaw(int64_t v)
static int64_t limitGenerated(int64_t e)
static std::string path()
DummyRegisterAccessor< uint32_t > area
std::vector< std::byte > currentValue
DummyRegisterAccessor< uint32_t > data
static constexpr size_t areaSize
DummyRegisterAccessor< uint32_t > transferAddress
DummyRegisterAccessor< uint32_t > readArea
DummyRegisterAccessor< uint32_t > status
DummyRegisterAccessor< uint32_t > chipSelect
DummyRegisterAccessor< uint32_t > readRequest
DummyRegisterAccessor< uint32_t > readData
static constexpr uint32_t lastAddress
BOOST_AUTO_TEST_CASE(TestUnified3Reg)