diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/thread_test.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/thread_test.cpp b/test/thread_test.cpp index 95bdb76..00539eb 100644 --- a/test/thread_test.cpp +++ b/test/thread_test.cpp @@ -16,6 +16,7 @@ #include <iostream> +#include "raul/log.hpp" #include "raul/AtomicInt.hpp" #include "raul/Semaphore.hpp" #include "raul/Thread.hpp" @@ -29,18 +30,24 @@ Raul::AtomicInt n_errors(0); class Waiter : public Raul::Thread { public: - Waiter(Semaphore& sem) : Raul::Thread("Waiter"), _sem(sem) {} + Waiter(Semaphore& sem) : Raul::Thread("Waiter"), _sem(sem) { + if (set_scheduling(true, 10)) { + Raul::warn << "Set priority on non-existent thread" << endl; + } + } private: void _run() { - set_scheduling(true, 10); + if (!set_scheduling(true, 10)) { + Raul::error << "Failed to set priority" << endl; + } var = 41; cout << "[Waiter] Waiting for signal..." << endl; _sem.wait(); cout << "[Waiter] Received signal, exiting" << endl; var = 42; if (var != 42) { - cerr << "[Waiter] error: var != 42" << endl; + Raul::error << "[Waiter] var != 42" << endl; ++n_errors; } } @@ -53,7 +60,7 @@ main() { Thread& main_thread = Thread::get("Main"); if (main_thread.name() != "Main") { - cerr << "error: Main thread name is not 'Main'" << endl; + Raul::error << "[Main] Thread name is not 'Main'" << endl; return 1; } @@ -72,7 +79,7 @@ main() cout << "[Main] Exiting" << endl; if (var != 24) { - cerr << "[Main] error: var != 24" << endl; + Raul::error << "[Main] var != 24" << endl; ++n_errors; } |