ChimeraTK-DeviceAccess  03.18.00
testDummyBackendUnified.cc
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 DummyBackendUnified
7 // Only after defining the name include the unit test header.
8 #include <boost/test/unit_test.hpp>
9 using namespace boost::unit_test_framework;
10 
11 #include "BackendFactory.h"
12 #include "Device.h"
13 #include "DummyBackend.h"
14 #include "DummyRegisterAccessor.h"
15 #include "ExceptionDummyBackend.h"
16 #include "TransferGroup.h"
17 #include "UnifiedBackendTest.h"
18 
19 namespace ChimeraTK {
20  using namespace ChimeraTK;
21 }
22 using namespace ChimeraTK;
23 
24 /* ===============================================================================================
25  * This test covers accessors and features that are specific to the DummyBackend
26  * ==============================================================================================*/
27 
28 // Create a test suite which holds all your tests.
29 BOOST_AUTO_TEST_SUITE(DummyBackendUnifiedTestSuite)
30 
31 /**********************************************************************************************************************/
32 
33 static std::string cdd("(ExceptionDummy:1?map=test3.map)");
34 static auto exceptionDummy =
35  boost::dynamic_pointer_cast<ExceptionDummy>(BackendFactory::getInstance().createBackend(cdd));
36 
37 /**********************************************************************************************************************/
38 
40  std::string path() { return "/DUMMY_INTERRUPT_6"; }
41  bool isWriteable() { return true; }
42  bool isReadable() { return false; }
44  size_t nChannels() { return 1; }
45  size_t nElementsPerChannel() { return 1; }
46  size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
47  size_t nRuntimeErrorCases() { return 1; }
48  typedef int32_t minimumUserType;
50 
51  static constexpr auto capabilities = TestCapabilities<>()
53  .disableAsyncReadInconsistency()
54  .disableSwitchReadOnly()
55  .disableSwitchWriteOnly()
56  .disableTestWriteNeverLosesData();
57 
58  template<typename UserType>
59  std::vector<std::vector<UserType>> generateValue() {
60  return {{1}};
61  }
62 
63  template<typename UserType>
64  std::vector<std::vector<UserType>> getRemoteValue() {
65  return {{1}};
66  }
67 
68  void setRemoteValue() {}
69 
70  void setForceRuntimeError(bool enable, size_t) {
71  exceptionDummy->throwExceptionRead = enable;
72  exceptionDummy->throwExceptionWrite = enable;
73  exceptionDummy->throwExceptionOpen = enable;
74  }
75 };
76 
77 BOOST_AUTO_TEST_CASE(testRegisterAccessor) {
78  std::cout << "*** testRegisterAccessor *** " << std::endl;
80 }
81 BOOST_AUTO_TEST_SUITE_END()
ExceptionDummyBackend.h
TransferGroup.h
Interrupt_dummy::rawUserType
minimumUserType rawUserType
Definition: testDummyBackendUnified.cc:49
Interrupt_dummy::nRuntimeErrorCases
size_t nRuntimeErrorCases()
Definition: testDummyBackendUnified.cc:47
DummyBackend.h
Interrupt_dummy::writeQueueLength
size_t writeQueueLength()
Definition: testDummyBackendUnified.cc:46
Interrupt_dummy::setRemoteValue
void setRemoteValue()
Definition: testDummyBackendUnified.cc:68
cdd
std::string cdd
Definition: testAsyncRead.cpp:25
ChimeraTK::TestCapabilities
Descriptor for the test capabilities for each register.
Definition: UnifiedBackendTest.h:54
Interrupt_dummy::supportedFlags
ChimeraTK::AccessModeFlags supportedFlags()
Definition: testDummyBackendUnified.cc:43
Interrupt_dummy::isReadable
bool isReadable()
Definition: testDummyBackendUnified.cc:42
Interrupt_dummy::nChannels
size_t nChannels()
Definition: testDummyBackendUnified.cc:44
Interrupt_dummy::minimumUserType
int32_t minimumUserType
Definition: testDummyBackendUnified.cc:48
Interrupt_dummy::nElementsPerChannel
size_t nElementsPerChannel()
Definition: testDummyBackendUnified.cc:45
Device.h
Interrupt_dummy::setForceRuntimeError
void setForceRuntimeError(bool enable, size_t)
Definition: testDummyBackendUnified.cc:70
Interrupt_dummy::getRemoteValue
std::vector< std::vector< UserType > > getRemoteValue()
Definition: testDummyBackendUnified.cc:64
ChimeraTK::UnifiedBackendTest
Class to test any backend for correct behaviour.
Definition: UnifiedBackendTest.h:259
Interrupt_dummy::isWriteable
bool isWriteable()
Definition: testDummyBackendUnified.cc:41
Interrupt_dummy::path
std::string path()
Definition: testDummyBackendUnified.cc:40
Interrupt_dummy
Definition: testDummyBackendUnified.cc:39
ChimeraTK::TestCapabilities::disableForceDataLossWrite
constexpr TestCapabilities< _syncRead, TestCapability::disabled, _asyncReadInconsistency, _switchReadOnly, _switchWriteOnly, _writeNeverLosesData, _testWriteOnly, _testReadOnly, _testRawTransfer, _testCatalogue, _setRemoteValueIncrementsVersion > disableForceDataLossWrite() const
Definition: UnifiedBackendTest.h:81
Interrupt_dummy::generateValue
std::vector< std::vector< UserType > > generateValue()
Definition: testDummyBackendUnified.cc:59
DummyRegisterAccessor.h
BackendFactory.h
ChimeraTK::AccessModeFlags
Set of AccessMode flags with additional functionality for an easier handling.
Definition: AccessMode.h:48
ChimeraTK
Definition: DummyBackend.h:16
UnifiedBackendTest.h
exceptionDummy
auto exceptionDummy
Definition: testExceptionDummyDevice.cc:16
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(testRegisterAccessor)
Definition: testDummyBackendUnified.cc:77
ChimeraTK::UnifiedBackendTest::addRegister
UnifiedBackendTest< typename boost::mpl::push_back< VECTOR_OF_REGISTERS_T, REG_T >::type > addRegister()
Add a register to be used by the test.
Definition: UnifiedBackendTest.h:352