summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-06 06:48:03 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-07 06:20:16 +0300
commitc5d682a54882599070777ea131653b99d19d423b (patch)
tree906abd70df03a61ff8db31455f817e1d02f4a455
parent9d250417a2583c2cad663fe3d8a93959182e3b2b (diff)
test: timer: Test start() with absolute deadline
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--test/timer.cpp19
1 files changed, 19 insertions, 0 deletions
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);