ChimeraTK-DeviceAccess  03.18.00
testPcieBackend.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 
7 using namespace boost::unit_test_framework;
8 
9 #define PCIEDEV_TEST_SLOT 0
10 #define LLRFDRV_TEST_SLOT 4
11 #define PCIEUNI_TEST_SLOT 6
12 
13 #include "BackendFactory.h"
14 #include "Device.h"
15 #include "Exception.h"
16 #include "NumericAddress.h"
17 #include "PcieBackend.h"
18 #include <sys/file.h>
19 #include <sys/stat.h>
20 #include <sys/types.h>
21 
22 namespace ChimeraTK {
23  using namespace ChimeraTK;
24 }
25 using namespace ChimeraTK;
27 
28 // constants for the registers and their contents. We keep the hard coded
29 // values at one place and only use the constants in the code below.
30 #define WORD_FIRMWARE_OFFSET 0x0
31 #define WORD_COMPILATION_OFFSET 0x4
32 #define WORD_USER_OFFSET 0xC
33 #define WORD_CLK_CNT_OFFSET 0x10
34 #define WORD_DUMMY_OFFSET 0x3C
35 #define DMMY_AS_ASCII 0x444D4D59
36 #define WORD_ADC_ENA_OFFSET 0x44
37 #define N_WORDS_DMA 25
38 #define PCIE_DEVICE "PCIE6"
39 #define LLRF_DEVICE "LLRF10"
40 //#define PCIE_UNI_DEVICE "PCIEUNI11"
41 #define PCIE_UNI_DEVICE "PCIE0"
42 #define NON_EXISTING_DEVICE "DUMMY9"
43 
44 /**********************************************************************************************************************/
45 
46 // Use a file lock on /var/run/lock/mtcadummy/<devicenode> for all device nodes
47 // we are using in this test, to ensure we are not running concurrent tests in
48 // parallel using the same kernel dummy drivers.
49 //
50 // Note: The lock is automatically released when the process terminates!
51 struct TestLocker {
52  std::vector<std::string> usedNodes{"mtcadummys0", "llrfdummys4", "noioctldummys5", "pcieunidummys6"};
53 
55  mkdir("/var/run/lock/mtcadummy",
56  0777); // ignore errors intentionally, as directory might already exist
57  for(auto& node : usedNodes) {
58  std::string lockfile = "/var/run/lock/mtcadummy/" + node;
59 
60  // open dmap file for locking
61  int fd = open(lockfile.c_str(), O_WRONLY | O_CREAT, 0777);
62  if(fd == -1) {
63  std::cout << "Cannot open file '" << lockfile << "' for locking." << std::endl;
64  exit(1);
65  }
66 
67  // obtain lock
68  int res = flock(fd, LOCK_EX);
69  if(res == -1) {
70  std::cout << "Cannot acquire lock on file 'shareddummyTest.dmap'." << std::endl;
71  exit(1);
72  }
73  }
74  }
75 
77  for(auto& node : usedNodes) {
78  std::string lockfile = "/var/run/lock/mtcadummy/" + node;
79  unlink(lockfile.c_str());
80  }
81  }
82 };
83 static TestLocker testLocker;
84 
85 /**********************************************************************************************************************/
86 
96 static BackendFactory& factoryInstance = BackendFactory::getInstance();
98  public:
99  PcieBackendTest(std::string const& deviceFileName, unsigned int slot);
100 
106  static void testConstructor();
107 
112  void testFailIfClosed();
113 
114  // Try Creating a backend and check if it is connected.
115  void testCreateBackend();
116 
117  // Try opening the created backend and check it's open status.
118  void testOpen();
119 
120  // Try closing the created backend and check it's open status.
121  void testClose();
122 
123  void testRead();
124  void testWriteArea();
125 
126  void testReadRegister();
127  void testWriteRegister();
128 
129  void testReadDMA();
130  void testWriteDMA();
131 
132  void testReadDeviceInfo();
134  void testFailIfBackendClosed();
135 
136  private:
137  PcieBackend _pcieBackend;
138  std::string _deviceFileName;
139  unsigned int _slot;
140 
141  boost::shared_ptr<PcieBackend> _pcieBackendInstance;
142 
143  // Internal function for better code readablility.
144  // Returns an error message. If the message is empty the test succeeded.
145  std::string checkDmaValues(std::vector<int32_t> const& dmaBuffer);
146 };
147 
148 /**********************************************************************************************************************/
149 
150 class PcieBackendTestSuite : public test_suite {
151  public:
152  PcieBackendTestSuite(std::string const& deviceFileName, unsigned int slot) : test_suite("PcieBackend test suite") {
153  BackendFactory::getInstance().setDMapFilePath(TEST_DMAP_FILE_PATH);
154  // add member function test cases to a test suite
155  boost::shared_ptr<PcieBackendTest> pcieBackendTest(new PcieBackendTest(deviceFileName, slot));
156 
157  test_case* createBackendTestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testCreateBackend, pcieBackendTest);
158  test_case* openTestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testOpen, pcieBackendTest);
159 
160  test_case* readTestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testRead, pcieBackendTest);
161  test_case* writeAreaTestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testWriteArea, pcieBackendTest);
162 
163  test_case* readRegisterTestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testReadRegister, pcieBackendTest);
164  test_case* writeRegisterTestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testWriteRegister, pcieBackendTest);
165 
166  test_case* readDMATestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testReadDMA, pcieBackendTest);
167  test_case* writeDMATestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testWriteDMA, pcieBackendTest);
168 
169  test_case* readDeviceInfoTestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testReadDeviceInfo, pcieBackendTest);
170 
171  test_case* closeTestCase = BOOST_CLASS_TEST_CASE(&PcieBackendTest::testClose, pcieBackendTest);
172 
173  test_case* testConstructor = BOOST_TEST_CASE(&PcieBackendTest::testConstructor);
174 
175  createBackendTestCase->depends_on(testConstructor);
176  openTestCase->depends_on(createBackendTestCase);
177  readTestCase->depends_on(openTestCase);
178  writeAreaTestCase->depends_on(readTestCase);
179  readRegisterTestCase->depends_on(writeAreaTestCase);
180  writeRegisterTestCase->depends_on(readRegisterTestCase);
181  readDMATestCase->depends_on(writeRegisterTestCase);
182  writeDMATestCase->depends_on(readDMATestCase);
183  readDeviceInfoTestCase->depends_on(writeDMATestCase);
184  closeTestCase->depends_on(readDeviceInfoTestCase);
185 
186  add(testConstructor);
187 
188  add(createBackendTestCase);
189  add(openTestCase);
190 
191  add(readTestCase);
192  add(writeAreaTestCase);
193 
194  add(readRegisterTestCase);
195  add(writeRegisterTestCase);
196 
197  add(readDMATestCase);
198  add(writeDMATestCase);
199 
200  add(readDeviceInfoTestCase);
201 
202  add(closeTestCase);
203  }
204 
205  private:
206 };
207 
208 /**********************************************************************************************************************/
209 
211  framework::master_test_suite().p_name.value = "PcieBackend test suite";
212 
213  std::stringstream llrfdummyFileName;
214  llrfdummyFileName << "/dev/llrfdummys" << LLRFDRV_TEST_SLOT;
215  // framework::master_test_suite().add( new
216  // PcieBackendTestSuite(llrfdummyFileName.str(), LLRFDRV_TEST_SLOT) );
217  // framework::master_test_suite().add( new PcieBackendTestSuite(LLRF_DEVICE,
218  // LLRFDRV_TEST_SLOT) );
219 
220  std::stringstream mtcadummyFileName;
221  mtcadummyFileName << "/dev/mtcadummys" << PCIEDEV_TEST_SLOT;
222  // framework::master_test_suite().add( new PcieBackendTestSuite(PCIE_DEVICE,
223  // PCIEDEV_TEST_SLOT) );
224 
225  std::stringstream pcieunidummyFileName;
226  pcieunidummyFileName << "/dev/pcieunidummys" << PCIEUNI_TEST_SLOT;
227  framework::master_test_suite().add(new PcieBackendTestSuite(PCIE_UNI_DEVICE, PCIEUNI_TEST_SLOT));
228 
229  return true;
230 }
231 
232 /**********************************************************************************************************************/
233 
234 // The implementations of the individual tests
235 
237  std::cout << "testConstructor" << std::endl;
238  PcieBackend pcieBackend("");
239  BOOST_CHECK(pcieBackend.isOpen() == false);
240 }
241 
242 PcieBackendTest::PcieBackendTest(std::string const& deviceFileName, unsigned int slot)
243 : _pcieBackend(deviceFileName), _deviceFileName(deviceFileName), _slot(slot) {}
244 
245 std::string PcieBackendTest::checkDmaValues(std::vector<int32_t> const& dmaBuffer) {
246  std::cout << "testDmaValues" << std::endl;
247  bool dmaValuesOK = true;
248  size_t i; // we need this after the loop
249  for(i = 0; i < dmaBuffer.size(); ++i) {
250  if(dmaBuffer[i] != static_cast<int32_t>(i * i)) {
251  dmaValuesOK = false;
252  break;
253  }
254  }
255 
256  if(dmaValuesOK) {
257  return std::string(); // an empty string means test is ok
258  }
259 
260  std::stringstream errorMessage;
261  errorMessage << "Content of transferred DMA block is not valid. First wrong "
262  "value at index "
263  << i << " is " << dmaBuffer[i] << std::endl;
264 
265  return errorMessage.str();
266 }
267 
268 /**********************************************************************************************************************/
269 
271  std::cout << "testReadDeviceInfo" << std::endl;
272  // The device info returns slot and driver version (major and minor).
273  // For the dummy major and minor are the same as firmware and compilation,
274  // respectively.
275  int32_t major;
276  //_pcieBackendInstance->readReg(WORD_FIRMWARE_OFFSET, &major, /*bar*/ 0);
277  _pcieBackendInstance->read(/*bar*/ 0, WORD_FIRMWARE_OFFSET, &major, 4);
278  int32_t minor;
279  //_pcieBackendInstance->readReg(WORD_COMPILATION_OFFSET, &minor, /*bar*/ 0);
280  _pcieBackendInstance->read(/*bar*/ 0, WORD_COMPILATION_OFFSET, &minor, 4);
281  std::stringstream referenceInfo;
282  referenceInfo << "SLOT: " << _slot << " DRV VER: " << major << "." << minor;
283 
284  std::string deviceInfo;
285  deviceInfo = _pcieBackendInstance->readDeviceInfo();
286  BOOST_CHECK_EQUAL(referenceInfo.str(), deviceInfo);
287 }
288 
289 /**********************************************************************************************************************/
290 
292  std::cout << "testReadDMA" << std::endl;
293  // Start the ADC on the dummy device. This will fill the "DMA" buffer with the
294  // default values (index^2) in the first 25 words.
295  //_pcieBackendInstance->writeReg(/*bar*/ 0, WORD_ADC_ENA_OFFSET, 1);
296  int32_t data = 1;
297  _pcieBackendInstance->write(/*bar*/ 0, WORD_ADC_ENA_OFFSET, &data, 4);
298 
299  std::vector<int32_t> dmaUserBuffer(N_WORDS_DMA, -1);
300 
301  _pcieBackendInstance->read(/*the dma bar*/ 2, /*offset*/ 0, &dmaUserBuffer[0], N_WORDS_DMA * sizeof(int32_t));
302 
303  std::string errorMessage = checkDmaValues(dmaUserBuffer);
304  BOOST_CHECK_MESSAGE(errorMessage.empty(), errorMessage);
305 
306  // test dma with offset
307  // read 20 words from address 5
308  std::vector<int32_t> smallBuffer(20, -1);
309  static const unsigned int readOffset = 5;
310  _pcieBackendInstance->read(
311  /*the dma bar*/ 2, /*offset*/ readOffset * sizeof(int32_t), &smallBuffer[0],
312  smallBuffer.size() * sizeof(int32_t));
313 
314  for(size_t i = 0; i < smallBuffer.size(); ++i) {
315  BOOST_CHECK(smallBuffer[i] == static_cast<int32_t>((i + readOffset) * (i + readOffset)));
316  }
317 }
318 
319 /**********************************************************************************************************************/
320 
322  std::cout << "testWriteDMA" << std::endl;
323 }
324 
325 /**********************************************************************************************************************/
326 
328  std::cout << "testRead" << std::endl;
329  // FIXME: Change the driver to have the standard register set and adapt this
330  // code
331 
332  // Read the first two words, which are WORD_FIRMWARE and WORD_COMPILATION
333  // We checked that single reading worked, so we use it to create the
334  // reference.
335  int32_t firmwareContent;
336  _pcieBackendInstance->read(/*bar*/ 0, WORD_FIRMWARE_OFFSET, &firmwareContent, 4);
337  int32_t compilationContent;
338  _pcieBackendInstance->read(/*bar*/ 0, WORD_COMPILATION_OFFSET, &compilationContent, 4);
339 
340  // Now try reading them as area
341  int32_t twoWords[2];
342  twoWords[0] = 0xFFFFFFFF;
343  twoWords[1] = 0xFFFFFFFF;
344 
345  _pcieBackendInstance->read(/*bar*/ 0, WORD_FIRMWARE_OFFSET, twoWords, 2 * sizeof(int32_t));
346  BOOST_CHECK((twoWords[0] == firmwareContent) && (twoWords[1] == compilationContent));
347 
348  // now try to read only six of the eight bytes. This should throw an exception
349  // because it is not a multiple of 4.
350  BOOST_CHECK_THROW(
351  _pcieBackendInstance->read(/*bar*/ 0, /*offset*/ 0, twoWords, /*nBytes*/ 6), ChimeraTK::runtime_error);
352 
353  // also check another bar
354  // Start the ADC on the dummy device. This will fill bar 2 (the "DMA" buffer)
355  // with the default values (index^2) in the first 25 words.
356  int32_t data = 1;
357  _pcieBackendInstance->write(/*bar*/ 0, WORD_ADC_ENA_OFFSET, &data, 4);
358  // use the same test as for DMA
359  std::vector<int32_t> bar2Buffer(N_WORDS_DMA, -1);
360  _pcieBackendInstance->read(/*the dma bar*/ 2, /*offset*/ 0, &bar2Buffer[0], N_WORDS_DMA * sizeof(int32_t));
361 
362  std::string errorMessage = checkDmaValues(bar2Buffer);
363  BOOST_CHECK_MESSAGE(errorMessage.empty(), errorMessage);
364 }
365 
366 /**********************************************************************************************************************/
367 
369  std::cout << "testWriteArea" << std::endl;
370  // FIXME: Change the driver to have the standard register set and adapt this
371  // code
372 
373  // Read the two WORD_CLK_CNT words, write them and read them back
374  int32_t originalClockCounts[2];
375  int32_t increasedClockCounts[2];
376  int32_t readbackClockCounts[2];
377 
378  _pcieBackendInstance->read(/*bar*/ 0, WORD_CLK_CNT_OFFSET, originalClockCounts, 2 * sizeof(int32_t));
379  increasedClockCounts[0] = originalClockCounts[0] + 1;
380  increasedClockCounts[1] = originalClockCounts[1] + 1;
381  _pcieBackendInstance->write(/*bar*/ 0, WORD_CLK_CNT_OFFSET, increasedClockCounts, 2 * sizeof(int32_t));
382  _pcieBackendInstance->read(/*bar*/ 0, WORD_CLK_CNT_OFFSET, readbackClockCounts, 2 * sizeof(int32_t));
383  BOOST_CHECK(
384  (increasedClockCounts[0] == readbackClockCounts[0]) && (increasedClockCounts[1] == readbackClockCounts[1]));
385 
386  // now try to write only six of the eight bytes. This should throw an
387  // exception because it is not a multiple of 4.
388  BOOST_CHECK_THROW(_pcieBackendInstance->write(/*bar*/ 0, WORD_CLK_CNT_OFFSET, originalClockCounts,
389  /*nBytes*/ 6),
391 
392  // also test another bar (area in bar 2), the usual drill: write and read
393  // back, we know that reading works from the previous test
394  std::vector<int32_t> writeBuffer(N_WORDS_DMA, 0xABCDEF01);
395  std::vector<int32_t> readbackBuffer(N_WORDS_DMA, -1);
396  _pcieBackendInstance->write(/*bar*/ 2, 0, &writeBuffer[0], N_WORDS_DMA * sizeof(int32_t));
397  _pcieBackendInstance->read(/*bar*/ 2, 0, &readbackBuffer[0], N_WORDS_DMA * sizeof(int32_t));
398  BOOST_CHECK(readbackBuffer == writeBuffer);
399 }
400 
401 /**********************************************************************************************************************/
402 
404  std::cout << "testReadRegister" << std::endl;
405  // FIXME: Change the driver to have the standard register set and adapt this
406  // code
407 
408  // read the WORD_COMPILATION register in bar 0. It's value is not 0.
409  int32_t dataWord = 0; // initialise with 0 so we can check if reading the content works.
410 
411  _pcieBackendInstance->open(); // no need to check if this works because we did
412  // the open test first
413  //_pcieBackendInstance->readReg(WORD_DUMMY_OFFSET, &dataWord, /*bar*/ 0);
414  _pcieBackendInstance->read(/*bar*/ 0, WORD_DUMMY_OFFSET, &dataWord, 4);
415  BOOST_CHECK_EQUAL(dataWord, DMMY_AS_ASCII);
416 
419  // BOOST_CHECK_THROW( _pcieBackendInstance->readReg(WORD_DUMMY_OFFSET,
420  // &dataWord, /*bar*/ 6),
421  BOOST_CHECK_THROW(_pcieBackendInstance->getRegisterAccessor<int>("#6/0x3C", 4, 0, {}), ChimeraTK::logic_error);
422 }
423 
424 /**********************************************************************************************************************/
425 
427  std::cout << "testWriteRegister" << std::endl;
428  // FIXME: Change the driver to have the standard register set and adapt this
429  // code
430 
431  // We read the user register, increment it by one, write it and reread it.
432  // As we checked that reading work, this is a reliable test that writing is
433  // ok.
434  int32_t originalUserWord, newUserWord;
435  _pcieBackendInstance->read(/*bar*/ 0, WORD_USER_OFFSET, &originalUserWord, 4);
436  int32_t data = originalUserWord + 1;
437  _pcieBackendInstance->write(/*bar*/ 0, WORD_USER_OFFSET, &data, 4);
438  _pcieBackendInstance->read(/*bar*/ 0, WORD_USER_OFFSET, &newUserWord, 4);
439 
440  BOOST_CHECK_EQUAL(originalUserWord + 1, newUserWord);
441 }
442 
443 /**********************************************************************************************************************/
444 
446  std::cout << "testClose" << std::endl;
447  /* Try closing the backend */
448  _pcieBackendInstance->close();
449  /* backend should not be open now */
450  BOOST_CHECK(_pcieBackendInstance->isOpen() == false);
451  // It always has to be possible to call close again.
452  _pcieBackendInstance->close();
453  BOOST_CHECK(_pcieBackendInstance->isOpen() == false);
454 }
455 
456 /**********************************************************************************************************************/
457 
459  std::cout << "testOpen" << std::endl;
460  _pcieBackendInstance->open();
461  BOOST_CHECK(_pcieBackendInstance->isOpen() == true);
462  // It must always be possible to re-open a backend. It should try to re-connect.
463  _pcieBackendInstance->open();
464  BOOST_CHECK(_pcieBackendInstance->isOpen());
465 }
466 
467 /**********************************************************************************************************************/
468 
470  std::cout << "testCreateBackend" << std::endl;
472  BOOST_CHECK_THROW(factoryInstance.createBackend(NON_EXISTING_DEVICE), ChimeraTK::logic_error);
474  _pcieBackendInstance = boost::dynamic_pointer_cast<PcieBackend>(factoryInstance.createBackend(_deviceFileName));
475  BOOST_CHECK(_pcieBackendInstance != nullptr);
477  BOOST_CHECK(_pcieBackendInstance->isOpen() == false);
478 
479  // OK, now that we know that basic creation is working let's do some tests of
480  // the specifics of the create function. We use the device interface because
481  // it is much more convenient.
482 
483  // There are four situations where the map-file information is coming from
484  // 1. From the dmap file (old way, third column in dmap file)
485  // 2. From the URI (new, recommended, not supported by dmap parser at the
486  // moment)
487  // 3. No map file at all (not supported by the dmap parser at the moment)
488  // 4. Both dmap file and URI contain the information (prints a warning and
489  // takes the one from the dmap file)
490 
491  // 1. The original way with map file as third column in the dmap file
492  Device firstDevice;
493  firstDevice.open("PCIE0");
494  // this backend is without module in the register name
495  firstDevice.write<double>("WORD_USER", 48);
496  BOOST_CHECK(true);
497 
498  // 2. Creating without map file in the dmap only works by putting an sdm on
499  // creation because we have to bypass the dmap file parser which at the time
500  // of writing this requires a map file as third column
501  Device secondDevice;
502  secondDevice.open("(pci:pcieunidummys6?map=mtcadummy.map)");
503  BOOST_CHECK(secondDevice.read<double>("BOARD/WORD_USER") == 48);
504 
505  Device secondDevice2;
506  // try opening same device again.
507  secondDevice2.open("(pci:pcieunidummys6?map=mtcadummy.map)");
508  BOOST_CHECK(secondDevice2.read<double>("BOARD/WORD_USER") == 48);
509 
510  // 3. We don't have a map file, so we have to use numerical addressing
511  Device thirdDevice;
512  thirdDevice.open("(pci:pcieunidummys6)");
513  BOOST_CHECK(thirdDevice.read<int32_t>(BAR() / 0 / 0xC) == 48 << 3); // The user register is on bar 0, address 0xC.
514  // We have no fixed point data conversion but 3
515  // fractional bits.
516 
517  // 4. This should print a warning. We can't check that, so we just check that
518  // it does work like the other two options.
519  Device fourthDevice;
520  fourthDevice.open("PCIE_DOUBLEMAP");
521  BOOST_CHECK(fourthDevice.read<double>("BOARD/WORD_USER") == 48);
522 
523  // close the backend for the following tests. One of the Devices has opened
524  // it...
525  _pcieBackendInstance->close();
526 }
527 
528 /**********************************************************************************************************************/
PcieBackendTest::testReadDMA
void testReadDMA()
Definition: testPcieBackend.cpp:291
PcieBackendTestSuite
Definition: testPcieBackend.cpp:150
ChimeraTK::BackendFactory::createBackend
boost::shared_ptr< DeviceBackend > createBackend(const std::string &aliasOrUri)
Create a new backend and return the instance as a shared pointer.
Definition: BackendFactory.cc:201
PcieBackendTest::testClose
void testClose()
Definition: testPcieBackend.cpp:445
PcieBackendTestSuite::PcieBackendTestSuite
PcieBackendTestSuite(std::string const &deviceFileName, unsigned int slot)
Definition: testPcieBackend.cpp:152
ChimeraTK::Device::read
UserType read(const RegisterPath &registerPathName, const AccessModeFlags &flags=AccessModeFlags({})) const
Inefficient convenience function to read a single-word register without obtaining an accessor.
Definition: Device.h:293
PcieBackendTest::testWriteArea
void testWriteArea()
Definition: testPcieBackend.cpp:368
PcieBackend.h
TestLocker
Definition: testPcieBackend.cpp:51
boost_dynamic_init_test.h
NON_EXISTING_DEVICE
#define NON_EXISTING_DEVICE
Definition: testPcieBackend.cpp:42
PCIEUNI_TEST_SLOT
#define PCIEUNI_TEST_SLOT
Definition: testPcieBackend.cpp:11
N_WORDS_DMA
#define N_WORDS_DMA
Definition: testPcieBackend.cpp:37
WORD_COMPILATION_OFFSET
#define WORD_COMPILATION_OFFSET
Definition: testPcieBackend.cpp:31
PcieBackendTest::testRead
void testRead()
Definition: testPcieBackend.cpp:327
ChimeraTK::runtime_error
Exception thrown when a runtime error has occured.
Definition: Exception.h:18
PcieBackendTest::PcieBackendTest
PcieBackendTest(std::string const &deviceFileName, unsigned int slot)
Definition: testPcieBackend.cpp:242
init_unit_test
bool init_unit_test()
Definition: testPcieBackend.cpp:210
PcieBackendTest::testWriteRegister
void testWriteRegister()
Definition: testPcieBackend.cpp:426
PcieBackendTest::testOpen
void testOpen()
Definition: testPcieBackend.cpp:458
PcieBackendTest::testReadDeviceInfo
void testReadDeviceInfo()
Definition: testPcieBackend.cpp:270
ChimeraTK::PcieBackend
A class to provide the Pcie device functionality.
Definition: PcieBackend.h:17
PcieBackendTest::testWriteDMA
void testWriteDMA()
Definition: testPcieBackend.cpp:321
WORD_USER_OFFSET
#define WORD_USER_OFFSET
Definition: testPcieBackend.cpp:32
PcieBackendTest::testConstructor
static void testConstructor()
A simple test which calls the default constructor and checks that the backend is closed.
Definition: testPcieBackend.cpp:236
PCIEDEV_TEST_SLOT
#define PCIEDEV_TEST_SLOT
Definition: testPcieBackend.cpp:9
ChimeraTK::BackendFactory
BackendFactory is a the factory class to create devices.
Definition: BackendFactory.h:26
Device.h
ChimeraTK::numeric_address::BAR
RegisterPath BAR()
The numeric_address::BAR() function can be used to directly access registers by numeric addresses,...
Definition: NumericAddress.cc:7
PcieBackendTest::testReadRegister
void testReadRegister()
Definition: testPcieBackend.cpp:403
DMMY_AS_ASCII
#define DMMY_AS_ASCII
Definition: testPcieBackend.cpp:35
NumericAddress.h
ChimeraTK::Device
Class allows to read/write registers from device.
Definition: Device.h:39
TestLocker::TestLocker
TestLocker()
Definition: testPcieBackend.cpp:54
PCIE_UNI_DEVICE
#define PCIE_UNI_DEVICE
Definition: testPcieBackend.cpp:41
TestLocker::~TestLocker
~TestLocker()
Definition: testPcieBackend.cpp:76
WORD_ADC_ENA_OFFSET
#define WORD_ADC_ENA_OFFSET
Definition: testPcieBackend.cpp:36
ChimeraTK::Device::open
void open(std::string const &aliasName)
Open a device by the given alias name from the DMAP file.
Definition: Device.cc:58
BackendFactory.h
PcieBackendTest::testCreateBackend
void testCreateBackend()
Definition: testPcieBackend.cpp:469
WORD_DUMMY_OFFSET
#define WORD_DUMMY_OFFSET
Definition: testPcieBackend.cpp:34
TEST_DMAP_FILE_PATH
#define TEST_DMAP_FILE_PATH
Definition: BackendFactory.h:18
WORD_FIRMWARE_OFFSET
#define WORD_FIRMWARE_OFFSET
Definition: testPcieBackend.cpp:30
Exception.h
ChimeraTK::DeviceBackendImpl::isOpen
bool isOpen() override
Return whether a device has been opened or not.
Definition: DeviceBackendImpl.h:27
ChimeraTK::Device::write
void write(const RegisterPath &registerPathName, UserType value, const AccessModeFlags &flags=AccessModeFlags({}))
Inefficient convenience function to write a single-word register without obtaining an accessor.
Definition: Device.h:314
ChimeraTK
Definition: DummyBackend.h:16
PcieBackendTest
Definition: testPcieBackend.cpp:97
WORD_CLK_CNT_OFFSET
#define WORD_CLK_CNT_OFFSET
Definition: testPcieBackend.cpp:33
LLRFDRV_TEST_SLOT
#define LLRFDRV_TEST_SLOT
Definition: testPcieBackend.cpp:10
ChimeraTK::logic_error
Exception thrown when a logic error has occured.
Definition: Exception.h:51