diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2019-01-17 15:42:26 +0000 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2019-01-17 21:31:33 +0000 |
commit | 74fb6ec3dc08abaf1a013894b50b65553e3eb631 (patch) | |
tree | 7af002a0c71a7462074ede57ebd4fbc3dbf8bc5a /test/timer.cpp | |
parent | b523982920d656eabe574c066e09483cb511575a (diff) |
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 <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'test/timer.cpp')
-rw-r--r-- | test/timer.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
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); |