19using namespace boost::unit_test_framework;
35 std::string _cardAlias;
50 DeviceInfo getDeviceDetailsFromDMap(
const std::string& cardAlias);
60 boost::shared_ptr<RebotTestClass> rebotTest(
new RebotTestClass(cardAlias));
67 if(framework::master_test_suite().argc < 2) {
68 std::cout <<
"Usage: " << framework::master_test_suite().argv[0] <<
" cardAlias [dmapFile]" << std::endl;
71 auto cardAlias = framework::master_test_suite().argv[1];
75 if(framework::master_test_suite().argc > 2) {
79 framework::master_test_suite().p_name.value =
"Rebot backend test suite";
87: _cardAlias(cardAlias), _rebotServer(getServerDetails(cardAlias)) {}
90 DeviceInfo deviceDetails = getDeviceDetailsFromDMap(cardAlias);
91 return extractServerDetailsFromUri(deviceDetails.
uri);
94DeviceInfo RebotTestClass::getDeviceDetailsFromDMap(
const std::string& cardAlias) {
97 boost::shared_ptr<ChimeraTK::DeviceInfoMap> listOfDevicesInDMapFile;
98 listOfDevicesInDMapFile = dMapParser.
parse(dmapFileLocation);
100 listOfDevicesInDMapFile->getDeviceInfo(cardAlias, deviceDetails);
101 return deviceDetails;
106 std::map<std::string, std::string>& serverParameters = parsedSDM.
parameters;
107 std::string ip = serverParameters[
"ip"];
108 std::string port = serverParameters[
"port"];
116 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
false);
118 BOOST_CHECK_NO_THROW(rebotBackend.
open());
119 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
true);
122 BOOST_CHECK_NO_THROW(rebotBackend.
open());
123 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
true);
125 BOOST_CHECK_NO_THROW(rebotBackend.
close());
126 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
false);
129 BOOST_CHECK_NO_THROW(rebotBackend.
close());
130 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
false);
138 uint32_t address = 0x04;
139 int32_t readValue = 0;
140 rebotBackend.
read(uint64_t(0), address, &readValue,
sizeof(readValue));
141 BOOST_CHECK_EQUAL(0xDEADBEEF, readValue);
145 uint64_t word_status_register_address = 0x8;
148 rebotBackend.
write(0, word_status_register_address, &data,
sizeof(data));
150 rebotBackend.
read(0, word_status_register_address, &readValue,
sizeof(readValue));
152 BOOST_CHECK_EQUAL(data, readValue);
156 uint32_t word_clk_mux_addr = 28;
157 int32_t dataToWrite[4] = {rand(), rand(), rand(), rand()};
158 int32_t readInData[4];
160 rebotBackend.
write(0, word_clk_mux_addr, dataToWrite,
sizeof(dataToWrite));
161 rebotBackend.
read(0, word_clk_mux_addr, readInData,
sizeof(readInData));
163 for(
int i = 0; i < 4; i++) {
164 BOOST_CHECK_EQUAL(dataToWrite[i], readInData[i]);
167 uint32_t test_area_Addr = 0x00000030;
168 std::vector<int32_t> test_area_data(1024);
169 for(uint32_t i = 0; i < test_area_data.size(); ++i) {
170 test_area_data.at(i) = i;
172 std::vector<int32_t> test_area_ReadIndata(1024);
174 rebotBackend.
write(0, test_area_Addr, test_area_data.data(),
sizeof(int32_t) * test_area_data.size());
175 rebotBackend.
read(0, test_area_Addr, test_area_ReadIndata.data(),
sizeof(int32_t) * test_area_ReadIndata.size());
177 for(uint32_t i = 0; i < test_area_ReadIndata.size(); i++) {
178 BOOST_CHECK_EQUAL(test_area_data[i], test_area_ReadIndata[i]);
static BackendFactory & getInstance()
Static function to get an instance of factory.
void setDMapFilePath(std::string dMapFilePath)
This function sets the _DMapFilePath.
std::string getDMapFilePath()
Returns the _DMapFilePath.
Provides method to parse DMAP file.
static DeviceInfoMapPointer parse(const std::string &file_name)
Performs parsing of specified DMAP file.
bool isOpen() override
Return whether a device has been opened or not.
Class allows to read/write registers from device.
Stores information about one device.
std::string uri
uri which describes the device (or name of the device file in /dev in backward compatibility mode)
void close() final
Deactivates all asynchronous accessors and calls closeImpl().
void read(uint8_t bar, uint32_t addressInBytes, int32_t *data, size_t sizeInBytes) override
Deprecated read function using 32bit address for backwards compatibility.
void open() override
The function opens the connection to the device.
void write(uint8_t bar, uint32_t addressInBytes, int32_t const *data, size_t sizeInBytes) override
Deprecated write function using 32bit address for backwards compatibility.
RebotDeviceTestSuite(std::string const &cardAlias)
void testReadWriteAPIOfRebotBackend()
RebotTestClass(std::string const &cardAlias)
DeviceDescriptor parseDeviceDesciptor(std::string cddString)
Parse a ChimeraTK device descriptor (CDD) and return the information in the DeviceDescriptor struct.
RegisterPath BAR()
The numeric_address::BAR() function can be used to directly access registers by numeric addresses,...
This structure holds the information of an ChimeraTK device descriptor.
std::map< std::string, std::string > parameters
RebotServerDetails()=default
RebotServerDetails(std::string &ipAddress, std::string portNumber)
ChimeraTK::DeviceInfoMap::DeviceInfo DeviceInfo