4#define BOOST_TEST_DYN_LINK
5#define BOOST_TEST_MODULE GenericMuxedInterruptDistributorTest
10#include <boost/test/unit_test.hpp>
16using namespace boost::unit_test_framework;
19 auto startTime = std::chrono::steady_clock::now();
20 auto currentTime = startTime;
21 while(currentTime < startTime + std::chrono::milliseconds(msTimeout)) {
22 std::this_thread::sleep_for(std::chrono::milliseconds(10));
26 currentTime = std::chrono::steady_clock::now();
31BOOST_AUTO_TEST_SUITE(INTCHandlerTestSuite)
33static constexpr std::string_view testCdd{
"(WriteMonitoring:xdma/slot5?map=irq_test.mapp)"};
59 [[maybe_unused]] std::string address, std::map<std::string, std::string> parameters) {
60 if(parameters[
"map"].empty()) {
94 if(activateAsyncFirst) {
100 "!" +
std::to_string(interrupt) +
":4", {ChimeraTK::AccessMode::wait_for_new_data}));
107 isrName /=
"DUMMY_WRITEABLE";
111 if(activateAsyncFirst) {
135 BOOST_CHECK_MESSAGE(
false,
"Creating register \"" + testRegister +
"\" did not throw as expected!");
138 std::cout <<
"Caught expected exception for " << boost::unit_test::framework::current_test_case().p_name
139 <<
". Print for manual check of message: " << e.
what() << std::endl;
155 BOOST_TEST(0x0 == ier);
156 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0);
161 BOOST_TEST(0x10 == ier);
162 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x10);
163 dummyBackend->acknowledged[
"ISR"] = 0;
167 BOOST_TEST(ier == 0x30);
168 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x20);
176 BOOST_TEST(ier == 0x20);
183 BOOST_TEST(ier == 0x0);
192 BOOST_TEST(0x10 == ier);
193 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x10);
214 auto dummyInterruptTrigger =
216 dummyInterruptTrigger.
write();
227 device.
read<int32_t>(
"TEST3/MER/DUMMY_READABLE") == 0x3);
230 BOOST_TEST(
device.
read<uint32_t>(
"TEST3/IER") == (1U << 0));
238 BOOST_TEST(
device.
read<int32_t>(
"TEST3/SUB1/MER") == 0x3);
239 BOOST_TEST(
device.
read<uint32_t>(
"TEST3/SUB1/IER") == (1U << 3));
384 device.
open(
"(dummy:xdma/slot5?map=irq_test.mapp)");
388 imr.setAndWrite(0x7F);
393 BOOST_CHECK_MESSAGE(
false,
"IMR not detected as invalid option.");
396 std::cout <<
"Caught expected exeption. Print for manual check of message: " << e.
what() << std::endl;
403 BOOST_TEST(imr.readAndGet() == 0x6F);
420 BOOST_TEST(sie.readAndGet() == 0x0);
421 BOOST_TEST(cie.readAndGet() == 0x0);
422 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x0);
423 BOOST_TEST(isr.readAndGet() == 0x0);
429 BOOST_TEST(sie.readAndGet() == 0x10);
430 BOOST_TEST(isr.readAndGet() == 0x10);
431 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x10);
432 BOOST_TEST(cie.readAndGet() == 0x0);
437 BOOST_TEST(cie.readAndGet() == 0x10);
447 BOOST_TEST(sie.readAndGet() == 0x10);
448 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x10);
449 dummyBackend->acknowledged[
"ISR"] = 0x0;
453 BOOST_CHECK_MESSAGE((sie == 0x20) ||
455 "SIE is " +
std::to_string(sie) +
", but should be 0x20 or 0x30");
456 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x20);
463 BOOST_TEST(cie.readAndGet() == 0x10);
472 BOOST_TEST(cie.readAndGet() == 0x20);
475 BOOST_TEST(cie.readAndGet() == 0x30);
483 BOOST_TEST(dummyBackend->sie == 0x0);
484 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x0);
489 BOOST_TEST(dummyBackend->sie == 0x30);
490 BOOST_TEST(dummyBackend->acknowledged[
"ISR"] == 0x30);
712BOOST_AUTO_TEST_SUITE_END()
static BackendFactory & getInstance()
Static function to get an instance of factory.
void registerBackendType(const std::string &backendType, boost::shared_ptr< DeviceBackend >(*creatorFunction)(std::string address, std::map< std::string, std::string > parameters), const std::vector< std::string > &sdmParameterNames={}, const std::string &deviceAccessVersion=CHIMERATK_DEVICEACCESS_VERSION)
Register a backend by the name backendType with the given creatorFunction.
Class allows to read/write registers from device.
bool isOpened() const
Check if the device is currently opened.
void close()
Close the device.
boost::shared_ptr< DeviceBackend > getBackend()
Obtain the backend.
VoidRegisterAccessor getVoidRegisterAccessor(const RegisterPath ®isterPathName, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a VoidRegisterAccessor object for the given register.
ScalarRegisterAccessor< UserType > getScalarRegisterAccessor(const RegisterPath ®isterPathName, size_t wordOffsetInRegister=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a ScalarRegisterObject object for the given register.
RegisterCatalogue getRegisterCatalogue() const
Return the register catalogue with detailed information on all registers.
UserType read(const RegisterPath ®isterPathName, const AccessModeFlags &flags=AccessModeFlags({})) const
Inefficient convenience function to read a single-word register without obtaining an accessor.
void activateAsyncRead() noexcept
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
void open(std::string const &aliasName)
Open a device by the given alias name from the DMAP file.
The dummy device opens a mapping file instead of a device, and implements all registers defined in th...
DummyRegisterRawAccessor getRawAccessor(const std::string &module, const std::string ®ister_name)
Get a raw accessor to the underlying memory with the convenience of using register names.
void setWriteCallbackFunction(AddressRange addressRange, boost::function< void(void)> const &writeCallbackFunction)
void replace(const NDRegisterAccessorAbstractor< UserType > &newAccessor)
Assign a new accessor to this NDRegisterAccessorAbstractor.
RegisterInfo getRegister(const RegisterPath ®isterPathName) const
Get register information for a given full path name.
bool isWriteable() const
Return whether the register is writeable.
Class to store a register path name.
Accessor class to read and write scalar registers transparently by using the accessor object like a v...
UserType readAndGet()
Convenience function to read and return a value of UserType.
void setAndWrite(UserType newValue, VersionNumber versionNumber={})
Convenience function to set and write new value.
bool write(ChimeraTK::VersionNumber versionNumber={})
Write the data to device.
Accessor class to read and write void-typed registers.
Exception thrown when a logic error has occured.
const char * what() const noexcept override
Return the message describing what exactly went wrong.
std::map< std::string, uint32_t > acknowledged
static boost::shared_ptr< DeviceBackend > createInstance(std::string address, std::map< std::string, std::string > parameters)
WriteMonitoringBackend(const std::string &mapFileName)
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
std::string to_string(const std::string &v)
AcknowledgeTest(uint32_t interrupt, std::string ackReg)
VoidRegisterAccessor accInterrupt2
InvalidJson1TestFixture()
InvalidJson2TestFixture()
MasterEnableTest(uint32_t interrupt, std::string meRegister, bool enableFirst)
ScalarRegisterAccessor< uint32_t > masterEnable
MieGieAndMerTestFixture()
NonexistendPathTestFixture()
TestFixture(uint32_t interrupt, bool activateAsyncFirst)
VoidRegisterAccessor accInterrupt
VoidRegisterAccessor dummyInterrupt
boost::shared_ptr< WriteMonitoringBackend > dummyBackend
ScalarRegisterAccessor< uint32_t > isr
Test that a logic error is thrown as soon as you try to get an accessor with invalid map file entries...
ThrowTestFixture(uint32_t interrupt)
VoidRegisterAccessor accInterrupt
UnknownMainKeyTestFixture()
UnknownOptionTestFixture()
UnknownVersionTestFixture()
BOOST_AUTO_TEST_CASE(activateOnActiveDomain)
bool readWithTimeout(VoidRegisterAccessor &acc, size_t msTimeout=3000)
BOOST_FIXTURE_TEST_CASE(inactiveIER, Inactive0)