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>
This commit is contained in:
Laurent Pinchart 2020-02-13 14:26:48 +02:00
parent a6388e494e
commit a9b83617d2

View file

@ -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;
}