From c5d682a54882599070777ea131653b99d19d423b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 6 Oct 2019 06:48:03 +0300 Subject: test: timer: Test start() with absolute deadline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- test/timer.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/timer.cpp') diff --git a/test/timer.cpp b/test/timer.cpp index 5ff94dbb..2bdb006e 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -35,6 +35,15 @@ public: Timer::start(msec); } + void start(std::chrono::steady_clock::time_point deadline) + { + count_ = 0; + start_ = std::chrono::steady_clock::now(); + expiration_ = std::chrono::steady_clock::time_point(); + + Timer::start(deadline); + } + int jitter() { std::chrono::steady_clock::duration duration = expiration_ - deadline(); @@ -127,6 +136,16 @@ protected: return TestFail; } + /* Timer with absolute deadline. */ + timer.start(std::chrono::steady_clock::now() + std::chrono::milliseconds(200)); + + dispatcher->processEvents(); + + if (timer.hasFailed()) { + cout << "Absolute deadline test failed" << endl; + return TestFail; + } + /* Two timers. */ timer.start(1000); timer2.start(300); -- cgit v1.2.1