From 74fb6ec3dc08abaf1a013894b50b65553e3eb631 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Thu, 17 Jan 2019 15:42:26 +0000 Subject: test: timer: Add a 32 bit wraparound test Add a test which catches a timer running longer than the nanosecond resolution of 32 bits. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- test/timer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/timer.cpp') diff --git a/test/timer.cpp b/test/timer.cpp index e47cb21b..41c132bd 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -81,6 +81,19 @@ protected: return TestFail; } + /* + * 32 bit wrap test + * Nanosecond resolution in a 32 bit value wraps at 4.294967 + * seconds (0xFFFFFFFF / 1000000) + */ + timer.start(4295); + dispatcher->processEvents(); + + if (timer.isRunning() || timer.jitter() > 50) { + cout << "Timer expiration test failed" << endl; + return TestFail; + } + /* Timer restart. */ timer.start(500); -- cgit v1.2.1