19 using namespace boost::unit_test_framework;
30 RebotServerDetails(std::string& ipAddress, std::string portNumber) : ip(ipAddress), port(portNumber) {}
35 std::string _cardAlias;
40 void testConnection();
41 void testReadWriteAPIOfRebotBackend();
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);
94 DeviceInfo 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"];
117 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
false);
119 BOOST_CHECK_NO_THROW(rebotBackend.
open());
120 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
true);
123 BOOST_CHECK_NO_THROW(rebotBackend.
open());
124 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
true);
126 BOOST_CHECK_NO_THROW(rebotBackend.
close());
127 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
false);
130 BOOST_CHECK_NO_THROW(rebotBackend.
close());
131 BOOST_CHECK_EQUAL(rebotBackend.
isOpen(),
false);
139 uint32_t address = 0x04;
140 int32_t readValue = 0;
141 rebotBackend.
read(uint64_t(0), address, &readValue,
sizeof(readValue));
142 BOOST_CHECK_EQUAL(0xDEADBEEF, readValue);
146 uint64_t word_status_register_address = 0x8;
149 rebotBackend.
write(0, word_status_register_address, &data,
sizeof(data));
151 rebotBackend.
read(0, word_status_register_address, &readValue,
sizeof(readValue));
153 BOOST_CHECK_EQUAL(data, readValue);
157 uint32_t word_clk_mux_addr = 28;
158 int32_t dataToWrite[4] = {rand(), rand(), rand(), rand()};
159 int32_t readInData[4];
161 rebotBackend.
write(0, word_clk_mux_addr, dataToWrite,
sizeof(dataToWrite));
162 rebotBackend.
read(0, word_clk_mux_addr, readInData,
sizeof(readInData));
164 for(
int i = 0; i < 4; i++) {
165 BOOST_CHECK_EQUAL(dataToWrite[i], readInData[i]);
168 uint32_t test_area_Addr = 0x00000030;
169 std::vector<int32_t> test_area_data(1024);
170 for(uint32_t i = 0; i < test_area_data.size(); ++i) {
171 test_area_data.at(i) = i;
173 std::vector<int32_t> test_area_ReadIndata(1024);
175 rebotBackend.
write(0, test_area_Addr, test_area_data.data(),
sizeof(int32_t) * test_area_data.size());
176 rebotBackend.
read(0, test_area_Addr, test_area_ReadIndata.data(),
sizeof(int32_t) * test_area_ReadIndata.size());
178 for(uint32_t i = 0; i < test_area_ReadIndata.size(); i++) {
179 BOOST_CHECK_EQUAL(test_area_data[i], test_area_ReadIndata[i]);