4 #define BOOST_TEST_DYN_LINK
6 #define BOOST_TEST_MODULE MapFileParser
7 #include <boost/test/unit_test.hpp>
8 using namespace boost::unit_test_framework;
18 using namespace boost::unit_test_framework;
20 BOOST_AUTO_TEST_SUITE(MapFileParserTestSuite)
25 ostr <<
"Register " << info.pathName <<
": at " << info.bar <<
"," << info.address <<
" nElems = " << info.nElements
26 <<
" pitch = " << info.elementPitchBits <<
" access: " << int(info.registerAccess) <<
" int: [";
27 for(
auto i : info.interruptId) {
30 ostr <<
"]" << std::endl;
32 for(
const auto& c : info.channels) {
33 ostr <<
" channel " << ich <<
" at: " << c.bitOffset <<
" " << c.width <<
" " << c.nFractionalBits <<
" "
34 << c.signedFlag <<
" " << int(c.dataType) << std::endl;
42 const std::vector<ChimeraTK::NumericAddressedRegisterInfo>& RegisterInfoents) {
47 auto mapIter = regcat.
begin();
48 auto elementsIter = RegisterInfoents.begin();
49 for(; mapIter != regcat.
end() && elementsIter != RegisterInfoents.end(); ++mapIter, ++elementsIter) {
50 std::stringstream message;
51 message <<
"Failed comparison:" << std::endl;
54 BOOST_CHECK_MESSAGE(*mapIter == *elementsIter, message.str());
100 auto [regcat, mdcat] = map_file_parser.
parse(
"goodMapFile_withoutModules.map");
102 std::string metaDataNameToRetrieve;
103 std::string retrievedValue;
105 metaDataNameToRetrieve =
"HW_VERSION";
106 retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
107 BOOST_CHECK(retrievedValue ==
"1.6");
109 metaDataNameToRetrieve =
"FW_VERSION";
110 retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
111 BOOST_CHECK(retrievedValue ==
"2.5");
116 std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents;
117 RegisterInfoents.emplace_back(
"WORD_FIRMWARE", 0x00000001, 0x00000000, 0x00000004, 0x0, 32, 0,
true);
118 RegisterInfoents.emplace_back(
"WORD_COMPILATION", 0x00000001, 0x00000004, 0x00000004, 0x00000000, 32, 0,
true);
119 RegisterInfoents.emplace_back(
"WORD_STATUS", 0x00000001, 0x00000008, 0x00000004, 0x00000000, 32, 0,
true);
120 RegisterInfoents.emplace_back(
"WORD_USER1", 0x00000001, 0x0000000C, 0x00000004, 0x00000000, 32, 0,
true);
121 RegisterInfoents.emplace_back(
"WORD_USER2", 0x00000001, 0x00000010, 0x00000004, 0x00000000, 32, 0,
false);
124 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
false},
125 {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
false},
126 {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
false}},
127 NumericAddressedRegisterInfo::Access::READ_WRITE, {}));
129 RegisterInfoents.emplace_back(
131 NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {}));
140 auto [regcat, mdcat] = map_file_parser.
parse(
"goodMapFile.map");
142 BOOST_CHECK_EQUAL(regcat.getNumberOfRegisters(), 22);
144 std::string metaDataNameToRetrieve;
145 std::string retrievedValue;
147 metaDataNameToRetrieve =
"HW_VERSION";
148 retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
149 BOOST_CHECK(retrievedValue ==
"1.6");
151 metaDataNameToRetrieve =
"FW_VERSION";
152 retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
153 BOOST_CHECK(retrievedValue ==
"2.5");
155 std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(22);
157 RegisterInfoents[0] =
159 RegisterInfoents[1] =
161 RegisterInfoents[2] =
163 RegisterInfoents[3] =
167 RegisterInfoents[6] =
169 RegisterInfoents[7] =
171 RegisterInfoents[8] =
173 RegisterInfoents[9] =
175 RegisterInfoents[10] =
178 "MODULE1.WORD_USER3", 0x01, 0x28, 0x04, 0x01, 18, 5,
false, NumericAddressedRegisterInfo::Access::READ_ONLY);
179 RegisterInfoents[12] =
181 RegisterInfoents[13] =
183 RegisterInfoents[14] =
186 true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::IEEE754);
188 true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::IEEE754);
189 RegisterInfoents[17] =
191 RegisterInfoents[18] =
194 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {3});
196 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {2});
198 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {6});
207 auto [regcat, mdcat] = map_file_parser.
parse(
"mixedMapFile.map");
209 std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(4);
234 auto [regcat, mdcat] = fileparser.
parse(
"interruptMapFile.map");
236 std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(13);
239 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {0});
242 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {1, 1});
245 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {2, 2, 2});
248 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {20});
250 RegisterInfoents[4] =
252 NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {21, 1});
254 RegisterInfoents[5] =
256 NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {22, 3, 4});
258 RegisterInfoents[6] =
260 NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {3});
262 RegisterInfoents[7] =
264 NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {3});
267 0,
false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {4});
270 true, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {4});
272 RegisterInfoents[10] =
274 NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {4});
277 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
false},
278 {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
false},
279 {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
false}},
280 NumericAddressedRegisterInfo::Access::INTERRUPT, {5});
282 RegisterInfoents[12] =
284 true, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {5});
293 auto [regcat, mdcat] = map_file_parser.
parse(
"goodMapFileWithComments.map");
295 BOOST_CHECK_EQUAL(regcat.getNumberOfRegisters(), 22);
297 std::string metaDataNameToRetrieve;
298 std::string retrievedValue;
300 metaDataNameToRetrieve =
"HW_VERSION";
301 retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
302 BOOST_CHECK(retrievedValue ==
"1.6");
304 metaDataNameToRetrieve =
"FW_VERSION";
305 retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
306 BOOST_CHECK(retrievedValue ==
"2.5");
308 std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(22);
310 RegisterInfoents[0] =
312 RegisterInfoents[1] =
314 RegisterInfoents[2] =
316 RegisterInfoents[3] =
320 RegisterInfoents[6] =
322 RegisterInfoents[7] =
324 RegisterInfoents[8] =
326 RegisterInfoents[9] =
328 RegisterInfoents[10] =
331 "MODULE1.WORD_USER3", 0x01, 0x28, 0x04, 0x01, 18, 5,
false, NumericAddressedRegisterInfo::Access::READ_ONLY);
332 RegisterInfoents[12] =
334 RegisterInfoents[13] =
336 RegisterInfoents[14] =
339 true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::IEEE754);
341 true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::IEEE754);
342 RegisterInfoents[17] =
344 RegisterInfoents[18] =
347 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {1, 3});
349 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {1, 2});
351 false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {5, 6});
360 auto [regcat, mdcat] = map_file_parser.
parse(
"newSequences.mapp");
362 BOOST_CHECK_EQUAL(regcat.getNumberOfRegisters(), 18);
364 std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(18);
366 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0,
true},
367 {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0,
true},
368 {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0,
true}},
369 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
372 true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
375 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
376 {8, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
377 {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true}},
378 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
381 0,
true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
384 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
true},
385 {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
true},
386 {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
true}},
387 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
390 0,
true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
393 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 1,
true},
394 {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 2,
true},
395 {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 3,
true}},
396 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
398 RegisterInfoents[7] =
400 NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
403 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 1,
true},
404 {8, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 2,
true},
405 {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 3,
true}},
406 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
408 RegisterInfoents[9] =
410 NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
413 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 1,
true},
414 {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 2,
true},
415 {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 3,
true}},
416 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
418 RegisterInfoents[11] =
420 NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
423 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
424 {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
425 {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
426 {48, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
427 {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
428 {80, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
429 {96, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
430 {112, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
431 {128, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
432 {144, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
433 {160, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
434 {176, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
435 {192, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
436 {208, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
437 {224, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true},
438 {240, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2,
true}},
439 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
442 0,
true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
445 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
446 {8, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
true},
447 {24, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0,
true}},
448 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
450 RegisterInfoents[15] =
452 NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
455 {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
true},
456 {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
true},
457 {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 18, 0,
true},
458 {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
true},
459 {80, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0,
true},
460 {96, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
461 {112, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
462 {128, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
463 {136, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
464 {144, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
465 {152, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
466 {160, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
467 {192, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0,
true},
468 {224, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0,
true},
469 {256, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0,
false},
470 {288, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0,
false},
471 {320, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0,
false}},
472 NumericAddressedRegisterInfo::Access::READ_WRITE, {});
474 RegisterInfoents[17] =
476 NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
483 BOOST_AUTO_TEST_SUITE_END()