Generic hardware access library
|
00001 #include "hal/TestMaster.hh" 00002 00003 HAL::TestMaster::TestMaster( std::ostream& os ) 00004 : os_(os) { 00005 testDone_ = false; 00006 } 00007 00008 void HAL::TestMaster::registerTester( HAL::TesterInterface& newTester ) { 00009 testerList_.push_back( &newTester ); 00010 } 00011 00012 bool HAL::TestMaster::doTest() 00013 throw( HardwareAccessException ) { 00014 testDone_ = true; 00015 bool allOk = true; 00016 bool testResult; 00017 std::list<HAL::TesterInterface*>::const_iterator it; 00018 for ( it=testerList_.begin(); it != testerList_.end(); it++ ) { 00019 os_ << "==============================================================================" << std::endl; 00020 os_ << " doing test : " << (*it)->getName() << std::endl; 00021 os_ << "==============================================================================" << std::endl; 00022 testResult = (*it)->execute(); 00023 os_ << "\nThe test " ; 00024 testResult ? os_ << "was successfull." : os_ << "failed."; 00025 os_ << std::endl; 00026 os_ << "==============================================================================" << std::endl; 00027 resultMap_[*it] = testResult; 00028 allOk &= testResult; 00029 } 00030 return allOk; 00031 } 00032 00033 void HAL::TestMaster::printShortReport() { 00034 if ( ! testDone_ ) { 00035 os_ << "Tests have not yet been done!" << std::endl; 00036 return; 00037 } 00038 std::list<HAL::TesterInterface*>::iterator it; 00039 for ( it=testerList_.begin(); it != testerList_.end(); it++ ) { 00040 os_ << (*it)->getName() << " : " << resultMap_[*it] << std::endl; 00041 } 00042 } 00043 00044 void HAL::TestMaster::printLongReport() { 00045 if ( ! testDone_ ) { 00046 os_ << "Tests have not yet been done!" << std::endl; 00047 return; 00048 } 00049 std::list<HAL::TesterInterface*>::iterator it; 00050 for ( it=testerList_.begin(); it != testerList_.end(); it++ ) { 00051 os_ << "==============================================================================" << std::endl; 00052 os_ << " Test for : " << (*it)->getName() << std::endl; 00053 os_ << "Description:" << std::endl; 00054 os_ << (*it)->getDescription() << std::endl; 00055 if ( resultMap_[*it] ) { 00056 os_ << "Result: The test was successfull" << std::endl; 00057 } else { 00058 os_ << "Result: The test failed" << std::endl; 00059 } 00060 } 00061 os_ << "==============================================================================\n\n" << std::endl; 00062 } 00063