test: timer-thread: Move timer start from wrong thread to separate test
Starting a timer from the wrong thread is expected to fail, and we test this in the timer-thread unit test. This is however not something that a caller is allowed to do, and libcamera will get assertion failures to catch this invalid usage. The unit test will then fail. To prepare for this, split the unit test in two, with a test that is expected by meson to succeed, and one that is expected to fail. The assertion will then cause an expected failure, making the test suite succeed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
This commit is contained in:
parent
dfe81fd702
commit
4f76beae86
3 changed files with 109 additions and 25 deletions
|
@ -29,12 +29,6 @@ public:
|
|||
timer_.start(100ms);
|
||||
}
|
||||
|
||||
void restart()
|
||||
{
|
||||
timeout_ = false;
|
||||
timer_.start(100ms);
|
||||
}
|
||||
|
||||
bool timeout() const
|
||||
{
|
||||
return timeout_;
|
||||
|
@ -74,22 +68,6 @@ protected:
|
|||
return TestFail;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that starting the timer from another thread fails. We
|
||||
* need to interrupt the event dispatcher to make sure we don't
|
||||
* succeed simply because the event dispatcher hasn't noticed
|
||||
* the timer restart.
|
||||
*/
|
||||
timeout_.restart();
|
||||
thread_.eventDispatcher()->interrupt();
|
||||
|
||||
this_thread::sleep_for(chrono::milliseconds(200));
|
||||
|
||||
if (timeout_.timeout()) {
|
||||
cout << "Timer restart test failed" << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
return TestPass;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue