/** * This is the actual function that the thread executes. * It receives a block from the scheduler, class its run() method and returns it to the scheduler. * The thread runs until the it is told to stop by setting the m_stop boolean flag */ void operator()() { if(CPU_COUNT(&m_mask)>0) { pthread_t id = pthread_self(); int ret = pthread_setaffinity_np(id, sizeof(m_mask), &m_mask); if(ret != 0) { perror("setaffinity"); throw(std::runtime_error("set affinity failed")); } } while(!m_stop.load()) { std::shared_ptr<Block>torun(m_scheduler.next_task(m_id)); if(torun) { torun->run(); m_scheduler.task_done(m_id, std::move(torun)); } else { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } m_stop.store(false); }
int Suite::run( vector<string> suites ){ for ( unsigned int i = 0; i < suites.size(); i++ ) { if ( _suites->find( suites[i] ) == _suites->end() ) { cout << "invalid test [" << suites[i] << "], use --list to see valid names" << endl; return -1; } } list<string> torun(suites.begin(), suites.end()); if ( torun.size() == 0 ) for ( map<string,Suite*>::iterator i=_suites->begin() ; i!=_suites->end(); i++ ) torun.push_back( i->first ); list<Result*> results; for ( list<string>::iterator i=torun.begin(); i!=torun.end(); i++ ){ string name = *i; Suite * s = (*_suites)[name]; assert( s ); log() << "going to run suite: " << name << endl; results.push_back( s->run() ); } Logstream::get().flush(); cout << "**************************************************" << endl; cout << "**************************************************" << endl; cout << "**************************************************" << endl; int rc = 0; int tests = 0; int fails = 0; int asserts = 0; for ( list<Result*>::iterator i=results.begin(); i!=results.end(); i++ ){ Result * r = *i; cout << r->toString(); if ( abs( r->rc() ) > abs( rc ) ) rc = r->rc(); tests += r->_tests; fails += r->_fails; asserts += r->_asserts; } Result totals ("TOTALS"); totals._tests = tests; totals._fails = fails; totals._asserts = asserts; cout << totals.toString(); // includes endl return rc; }
int Suite::run( const std::vector<std::string>& suites , const std::string& filter , int runsPerTest ) { if (_allSuites().empty()) { log() << "error: no suites registered."; return EXIT_FAILURE; } for ( unsigned int i = 0; i < suites.size(); i++ ) { if ( _allSuites().count( suites[i] ) == 0 ) { log() << "invalid test suite [" << suites[i] << "], use --list to see valid names" << std::endl; return EXIT_FAILURE; } } std::vector<std::string> torun(suites); if ( torun.empty() ) { for ( SuiteMap::const_iterator i = _allSuites().begin(); i !=_allSuites().end(); ++i ) { torun.push_back( i->first ); } } std::vector<Result*> results; for ( std::vector<std::string>::iterator i=torun.begin(); i!=torun.end(); i++ ) { std::string name = *i; Suite* s = _allSuites()[name]; fassert( 16145, s ); log() << "going to run suite: " << name << std::endl; results.push_back( s->run( filter, runsPerTest ) ); } log() << "**************************************************" << std::endl; int rc = 0; int tests = 0; int asserts = 0; int millis = 0; Result totals ("TOTALS"); std::vector<std::string> failedSuites; for ( std::vector<Result*>::iterator i=results.begin(); i!=results.end(); i++ ) { Result* r = *i; log() << r->toString(); if ( abs( r->rc() ) > abs( rc ) ) rc = r->rc(); tests += r->_tests; if ( !r->_fails.empty() ) { failedSuites.push_back(r->toString()); for ( std::vector<std::string>::const_iterator j=r->_fails.begin(); j!=r->_fails.end(); j++ ) { const std::string& s = (*j); totals._fails.push_back(r->_name + "/" + s); } } asserts += r->_asserts; millis += r->_millis; } totals._tests = tests; totals._asserts = asserts; totals._millis = millis; log() << totals.toString(); // includes endl // summary if ( !totals._fails.empty() ) { log() << "Failing tests:" << std::endl; for ( std::vector<std::string>::const_iterator i=totals._fails.begin(); i!=totals._fails.end(); i++ ) { const std::string& s = (*i); log() << "\t " << s << " Failed"; } log() << "FAILURE - " << totals._fails.size() << " tests in " << failedSuites.size() << " suites failed"; } else { log() << "SUCCESS - All tests in all suites passed"; } return rc; }
int Suite::run( const std::vector<std::string>& suites , const std::string& filter , int runsPerTest ) { if (_allSuites().empty()) { log() << "error: no suites registered."; return EXIT_FAILURE; } for ( unsigned int i = 0; i < suites.size(); i++ ) { if ( _allSuites().count( suites[i] ) == 0 ) { log() << "invalid test suite [" << suites[i] << "], use --list to see valid names" << std::endl; return EXIT_FAILURE; } } std::vector<std::string> torun(suites); if ( torun.empty() ) { for ( SuiteMap::const_iterator i = _allSuites().begin(); i !=_allSuites().end(); ++i ) { torun.push_back( i->first ); } } std::vector<Result*> results; for ( std::vector<std::string>::iterator i=torun.begin(); i!=torun.end(); i++ ) { std::string name = *i; Suite* s = _allSuites()[name]; fassert( 16145, s ); log() << "going to run suite: " << name << std::endl; results.push_back( s->run( filter, runsPerTest ) ); } log() << "**************************************************" << std::endl; int rc = 0; int tests = 0; int fails = 0; int asserts = 0; for ( std::vector<Result*>::iterator i=results.begin(); i!=results.end(); i++ ) { Result* r = *i; log() << r->toString(); if ( abs( r->rc() ) > abs( rc ) ) rc = r->rc(); tests += r->_tests; fails += r->_fails; asserts += r->_asserts; } Result totals ("TOTALS"); totals._tests = tests; totals._fails = fails; totals._asserts = asserts; log() << totals.toString(); // includes endl return rc; }