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." << __LINE__ \ 72 << ")" << std::endl; \ 74 ::exit(EXIT_FAILURE); \ 78 int testMain(
int argc,
char** argv);
85 explicit Watchdog(
const std::string& name)
92 lunchbox::Thread::setName(
"Watchdog");
95 std::cerr <<
"Watchdog triggered - " << _name
96 <<
" did not terminate within " << TEST_RUNTIME <<
"s" 100 std::cerr <<
"Watchdog triggered - " << _name
101 <<
" did not terminate within 1 minute" << std::endl;
103 lunchbox::abort(
true );
107 const std::string _name;
111 int main(
int argc,
char** argv)
113 #ifndef TEST_NO_WATCHDOG 114 Watchdog watchdog(argv[0]);
120 const int result = testMain(argc, argv);
121 if (result != EXIT_SUCCESS)
124 catch (
const std::runtime_error& e)
126 LBINFO <<
"Test exception: " << e.what() << std::endl;
130 #ifndef TEST_NO_WATCHDOG 137 #define main testMain 139 #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.