μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fixtures.cpp
Go to the documentation of this file.
1
3
4
8
9
10namespace uhal {
11namespace tests {
12
13
17
19{
20 std::string lURI(connectionFileURI);
21 lURI.replace(lURI.size() - 15, 11, "address");
22 return lURI;
23}
24
25template <>
27 devicePort(50001),
28 deviceId("dummy.udp")
29{
30}
31
32template <>
34 devicePort(50002),
35 deviceId("dummy.tcp")
36{
37}
38
39template <>
41 devicePort(50001),
42 deviceId("dummy.controlhub")
43{
44}
45
46template <>
48 devicePort(60001),
49 deviceId("dummy.udp2")
50{
51}
52
53template <>
55 devicePort(60002),
56 deviceId("dummy.tcp2")
57{
58}
59
60template <>
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
94template <>
96 hwRunner(new UDPDummyHardware<1,3>(devicePort, 0, false))
97{
98}
99
100template <>
102 hwRunner(new UDPDummyHardware<1,3>(devicePort, 0, false))
103{
104}
105
106template <>
108 hwRunner(new TCPDummyHardware<1,3>(devicePort, 0, false))
109{
110}
111
112template <>
114 hwRunner(new UDPDummyHardware<2,0>(devicePort, 0, false))
115{
116}
117
118template <>
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)
125 hw.getClient().read(0);
126 try {
127 hw.dispatch();
128 }
129 catch ( ... ) {
130 }
131 }
132}
133
134template <>
136 hwRunner(new TCPDummyHardware<2,0>(devicePort, 0, false))
137{
138}
139
140template <>
142 hwRunner(new PCIeDummyHardware(clientToHardwareFile, hardwareToClientFile, 0, false))
143{
144}
145
146} // end ns tests
147} // end ns uhal
ValWord< uint32_t > read(const uint32_t &aAddr)
Read a single, unmasked, unsigned word.
A class to open and manage XML connection files and wrap up the interfaces to the NodeTreeBuilder and...
HwInterface getDevice(const std::string &aId)
Retrieves protocol, host, and port from the connection file to create an IPbus Client Retrieves the a...
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
Definition: HwInterface.hpp:56
void dispatch()
Make the IPbus client issue a dispatch.
ClientInterface & getClient()
Get the underlying IPbus client.
Definition: HwInterface.cpp:78
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod)
A method to modify the timeout period for any pending or future transactions.
Concrete implementation of emulator of hardware using TCP.
Concrete implementation of emulator of hardware using UDP.
None tests(nox.Session session)
Definition: noxfile.py:19
HwInterface hw
@ IPBUS_2_0_CONTROLHUB
Definition: definitions.hpp:45
static std::string connectionFileURI
Definition: fixtures.hpp:56
static std::string getAddressFileURI()
Definition: fixtures.cpp:18
static const DeviceType deviceType
Definition: fixtures.hpp:74
uhal::HwInterface getHwInterface() const
Definition: fixtures.hpp:123