From 349c15dfe478b52b53f5f85c8ec218b6a1dbbd0c Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Wed, 2 Sep 2015 14:33:41 +0200 Subject: [PATCH] timer test: be more tolerant in periodic test For some platforms (at least hw_zynq on Qemu), the measured time of the periodic timeout test exceeded the maximum that was previously calculated without any tolerance. Most likely, this is not a malfunction of the test subject as the error is pretty small and, of course, measuring the time produces overhead itself. Introducing a tolerance of only 0.1% fixes the problem. Fixes #1599 --- repos/os/src/test/timer/main.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/repos/os/src/test/timer/main.cc b/repos/os/src/test/timer/main.cc index 899c78a56..504755a2f 100644 --- a/repos/os/src/test/timer/main.cc +++ b/repos/os/src/test/timer/main.cc @@ -147,8 +147,10 @@ int main(int argc, char **argv) i += s.num(); } elapsed_ms = main_timer.elapsed_ms() - elapsed_ms; - unsigned const min_ms = ((i - 1) * period_us) / 1000; - unsigned const max_ms = (i * period_us) / 1000; + unsigned const min_ms = ((i - 1) * period_us) / 1000; + unsigned const max_us = i * period_us; + unsigned const max_err_us = max_us / 100; + unsigned const max_ms = (max_us + max_err_us) / 1000; if (min_ms > elapsed_ms || max_ms < elapsed_ms) { PERR("Timing %u ms period %u times failed: %u ms (min %u, max %u)", period_us / 1000, i, elapsed_ms, min_ms, max_ms);