Generic hardware access library
|
00001 #include "VMEAddressTableTester.hh" 00002 #include <sstream> 00003 00004 std::string HAL::VMEAddressTableTester::getDescription() const { 00005 std::stringstream text; 00006 text << "Tests the boundary check if the HAL::VMEAddressTable.\n" 00007 << "The function checkAddressLimits(item, offset) is\n" 00008 << "used to perform the test" 00009 << std::ends; 00010 return text.str(); 00011 } 00012 00013 bool HAL::VMEAddressTableTester::execute() { 00014 try { 00015 HAL::VMEAddressTableASCIIReader reader( VMEADDRESSTABLE ); 00016 HAL::VMEAddressTable table( "VMEADDRESSTABLE", reader); 00017 00018 // display table: 00019 std::cout << "\n\n\n\n"; 00020 table.print(); 00021 std::cout << "\n"; 00022 00023 //display calculated boundaries 00024 std::vector<uint32_t> minimum, maximum; 00025 table.getAddressBoundaries( minimum, maximum ); 00026 std::cout << std::hex << "Minumum offset : " << minimum[0] << std::endl; 00027 std::cout << std::hex << "Maximum offset : " << maximum[0] << std::endl; 00028 std::cout << "\n\n"; 00029 if ( minimum[0] != 0x10 || maximum[0] != 0x103 ) return false; 00030 // test the limit checker 00031 std::cout << "\ntry first and last item of table" << std::endl; 00032 table.checkAddressLimits( "firstItem", 0); 00033 table.checkAddressLimits( "lastItem" ,0); 00034 // below limit: 00035 try { 00036 std::cout << "\ntry above limit" << std::endl; 00037 table.checkAddressLimits( "lastItem", 1); 00038 } catch ( HAL::HardwareAccessException& e ) { 00039 std::cout << "expected exception: " << std::endl; 00040 std::cout << e.what() << std::endl; 00041 } 00042 // above limit: 00043 try { 00044 std::cout << "\ntry below limit" << std::endl; 00045 table.checkAddressLimits( "firstItem", (uint32_t)-1); 00046 } catch ( HAL::HardwareAccessException& e ) { 00047 std::cout << "expected exception: " << std::endl; 00048 std::cout << e.what() << std::endl; 00049 } 00050 00051 } catch (HAL::HardwareAccessException& e) { 00052 std::cout << "!!! ERROR !!! UNEXPECTED EXCETPION !!!" << std::endl; 00053 std::cout << e.what() << std::endl; 00054 return false; 00055 } 00056 // all ok if arrived here 00057 return true; 00058 }