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
This commit is contained in:
Martin Stein 2015-09-02 14:33:41 +02:00 committed by Christian Helmuth
parent be994641ef
commit 349c15dfe4
1 changed files with 4 additions and 2 deletions

View File

@ -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);