μHAL (v2.7.9)
Part of the IPbus software repository
fixtures.cpp
Go to the documentation of this file.
1 
3 
4 
8 
9 
10 namespace uhal {
11 namespace tests {
12 
13 
14 std::string AbstractFixture::connectionFileURI = "";
15 size_t AbstractFixture::timeout = 1;
16 bool AbstractFixture::quickTest = false;
17 
19 {
20  std::string lURI(connectionFileURI);
21  lURI.replace(lURI.size() - 15, 11, "address");
22  return lURI;
23 }
24 
25 template <>
27  devicePort(50001),
28  deviceId("dummy.udp")
29 {
30 }
31 
32 template <>
34  devicePort(50002),
35  deviceId("dummy.tcp")
36 {
37 }
38 
39 template <>
41  devicePort(50001),
42  deviceId("dummy.controlhub")
43 {
44 }
45 
46 template <>
48  devicePort(60001),
49  deviceId("dummy.udp2")
50 {
51 }
52 
53 template <>
55  devicePort(60002),
56  deviceId("dummy.tcp2")
57 {
58 }
59 
60 template <>
62  devicePort(60001),
63  deviceId("dummy.controlhub2")
64 {
65 }
66 
68  hardwareToClientFile("/tmp/uhal_pcie_device2client"),
69  clientToHardwareFile("/tmp/uhal_pcie_client2device"),
70  deviceId("dummy.pcie2")
71 {
72 }
73 
74 
76 {
77 }
78 
79 
81 {
82  ConnectionManager manager(connectionFileURI);
83  HwInterface hw(manager.getDevice(deviceId));
84  hw.setTimeoutPeriod(timeout);
85  return hw;
86 }
87 
88 
90 
91 
92 
93 
94 template <>
96  hwRunner(new UDPDummyHardware<1,3>(devicePort, 0, false))
97 {
98 }
99 
100 template <>
102  hwRunner(new UDPDummyHardware<1,3>(devicePort, 0, false))
103 {
104 }
105 
106 template <>
108  hwRunner(new TCPDummyHardware<1,3>(devicePort, 0, false))
109 {
110 }
111 
112 template <>
114  hwRunner(new UDPDummyHardware<2,0>(devicePort, 0, false))
115 {
116 }
117 
118 template <>
120  hwRunner(new UDPDummyHardware<2,0>(devicePort, 0, false))
121 {
122  // FIXME : Ensure that controlhub cache is reset after dummy hardware reboot, but before unit tests (temporary solution)
123  if ( deviceType == IPBUS_2_0_CONTROLHUB ) {
125  hw.getClient().read(0);
126  try {
127  hw.dispatch();
128  }
129  catch ( ... ) {
130  }
131  }
132 }
133 
134 template <>
136  hwRunner(new TCPDummyHardware<2,0>(devicePort, 0, false))
137 {
138 }
139 
140 template <>
142  hwRunner(new PCIeDummyHardware(clientToHardwareFile, hardwareToClientFile, 0, false))
143 {
144 }
145 
146 } // end ns tests
147 } // end ns uhal
uhal::HwInterface
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
Definition: HwInterface.hpp:61
uhal::ConnectionManager::getDevice
HwInterface getDevice(const std::string &aId)
Retrieves protocol, host, and port from the connection file to create an IPbus Client Retrieves the a...
Definition: ConnectionManager.cpp:140
uhal::tests::PCIeDummyHardware
Definition: PCIeDummyHardware.hpp:46
fixtures.hpp
uhal::HwInterface::setTimeoutPeriod
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod)
A method to modify the timeout period for any pending or future transactions.
Definition: HwInterface.cpp:124
uhal::tests::DeviceType
DeviceType
Definition: definitions.hpp:39
uhal::tests::AbstractFixture::connectionFileURI
static std::string connectionFileURI
Definition: fixtures.hpp:56
uhal::tests::IPBUS_2_0_PCIE
@ IPBUS_2_0_PCIE
Definition: definitions.hpp:46
uhal::tests::DummyHardwareFixture::DummyHardwareFixture
DummyHardwareFixture()
uhal::tests::AbstractFixture::timeout
static size_t timeout
Definition: fixtures.hpp:58
uhal::tests::MinimalFixture::getHwInterface
uhal::HwInterface getHwInterface() const
Definition: fixtures.hpp:123
uhal::HwInterface::dispatch
void dispatch()
Make the IPbus client issue a dispatch.
Definition: HwInterface.cpp:106
TCPDummyHardware.hpp
uhal
Definition: HttpResponseGrammar.hpp:49
uhal::tests::MinimalFixture::~MinimalFixture
virtual ~MinimalFixture()
Definition: fixtures.hpp:118
uhal::tests::hw
HwInterface hw
Definition: test_rawclient.cpp:93
uhal::tests::TCPDummyHardware
Concrete implementation of emulator of hardware using TCP.
Definition: TCPDummyHardware.hpp:47
uhal::tests::MinimalFixture::MinimalFixture
MinimalFixture()
uhal::ClientInterface::read
ValWord< uint32_t > read(const uint32_t &aAddr)
Read a single, unmasked, unsigned word.
Definition: ClientInterface.cpp:458
PCIeDummyHardware.hpp
uhal::HwInterface::getClient
ClientInterface & getClient()
Get the underlying IPbus client.
Definition: HwInterface.cpp:83
uhal::tests::IPBUS_2_0_CONTROLHUB
@ IPBUS_2_0_CONTROLHUB
Definition: definitions.hpp:45
UDPDummyHardware.hpp
uhal::ConnectionManager
A class to open and manage XML connection files and wrap up the interfaces to the NodeTreeBuilder and...
Definition: ConnectionManager.hpp:79
uhal::tests::MinimalFixture::deviceId
std::string deviceId
Definition: fixtures.hpp:78
uhal::tests::MinimalFixture::deviceType
static const DeviceType deviceType
Definition: fixtures.hpp:74
uhal::tests::UDPDummyHardware
Concrete implementation of emulator of hardware using UDP.
Definition: UDPDummyHardware.hpp:45
uhal::tests::AbstractFixture::quickTest
static bool quickTest
Definition: fixtures.hpp:59
uhal::tests::MinimalFixture
Definition: fixtures.hpp:64
uhal::tests::AbstractFixture::getAddressFileURI
static std::string getAddressFileURI()
Definition: fixtures.cpp:18