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:
parent
a6388e494e
commit
a9b83617d2
1 changed files with 19 additions and 0 deletions
|
@ -101,6 +101,25 @@ protected:
|
||||||
|
|
||||||
delete thread;
|
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;
|
return TestPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue