summaryrefslogtreecommitdiff
path: root/test/threads.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-02-13 14:26:48 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-02-14 15:06:42 +0200
commita9b83617d27891853888a0eebb6702d02677090d (patch)
treecab1080e7d3fe839d99c22b10f2f74cd43acacab /test/threads.cpp
parenta6388e494e88b4a284bba7cce8b9cb5c3a558ab6 (diff)
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'test/threads.cpp')
-rw-r--r--test/threads.cpp19
1 files changed, 19 insertions, 0 deletions
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;
}