From a9b83617d27891853888a0eebb6702d02677090d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 13 Feb 2020 14:26:48 +0200 Subject: test: thread: Test waiting on a thread that is not running Test that Thread::wait() on a thread that hasn't been started, or on a thread that is known to have completed, returns without a timeout. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/threads.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/threads.cpp b/test/threads.cpp index 1fa26020..0454761d 100644 --- a/test/threads.cpp +++ b/test/threads.cpp @@ -101,6 +101,25 @@ protected: delete thread; + /* Test waiting on a thread that isn't running. */ + thread = new Thread(); + + timeout = !thread->wait(); + if (timeout) { + cout << "Waiting for non-started thread timed out" << endl; + return TestFail; + } + + thread->start(); + thread->exit(0); + thread->wait(); + + timeout = !thread->wait(); + if (timeout) { + cout << "Waiting for already stopped thread timed out" << endl; + return TestFail; + } + return TestPass; } -- cgit v1.2.1