33 #include <lunchbox/sleep.h> 34 #include <lunchbox/thread.h> 40 #define OUTPUT lunchbox::Log::instance( __FILE__, __LINE__ ) 44 LBVERB << "Test " << #x << std::endl; \ 47 OUTPUT << #x << " failed (l." << __LINE__ << ')' << std::endl; \ 49 ::exit( EXIT_FAILURE ); \ 53 #define TESTINFO( x, info ) \ 55 LBVERB << "Test " << #x << ": " << info << std::endl; \ 58 OUTPUT << #x << " failed (l." << __LINE__ << "): " << info \ 61 ::exit( EXIT_FAILURE ); \ 65 #define TESTRESULT( x, type ) \ 67 LBVERB << "Test " << #x << std::endl; \ 68 const type& testRes = (x); \ 71 OUTPUT << #x << " failed with " << testRes << " (l." \ 72 << __LINE__ << ")" << std::endl; \ 74 ::exit( EXIT_FAILURE ); \ 78 int testMain(
int argc,
char **argv );
85 explicit Watchdog(
const std::string& name ) : _name( name ) {}
89 lunchbox::Thread::setName(
"Watchdog" );
92 std::cerr <<
"Watchdog triggered - " << _name
93 <<
" did not terminate within " << TEST_RUNTIME <<
"s" 97 std::cerr <<
"Watchdog triggered - " << _name
98 <<
" did not terminate within 1 minute" << std::endl;
100 lunchbox::abort(
true );
104 const std::string _name;
108 int main(
int argc,
char **argv )
110 #ifndef TEST_NO_WATCHDOG 111 Watchdog watchdog( argv[0] );
117 const int result = testMain( argc, argv );
118 if( result != EXIT_SUCCESS )
121 catch(
const std::runtime_error& e )
123 LBINFO <<
"Test exception: " << e.what() << std::endl;
127 #ifndef TEST_NO_WATCHDOG 134 # define main testMain 136 #endif // LBTEST_TEST_H Utility class to execute code in a separate execution thread.
void sleep(const uint32_t milliSeconds)
Sleep the current thread for a number of milliseconds.
#define LBINFO
Output an informational message to the per-thread Log.
This file contains logging classes.
virtual void run()=0
The entry function for the child thread.