From e8e347d61552be45d5db505a47b5ceec99149ca0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 14 May 2012 06:18:58 +0000 Subject: Fully test Thread::set_scheduling(). git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4414 a436a847-0d15-0410-975c-d299462d15a1 --- test/thread_test.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test/thread_test.cpp') 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 +#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; } -- cgit v1.2.1