From ca26a8fe6a54d59997e01f821f072b28a7c8a3f9 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 10 Feb 2021 18:20:46 +0100 Subject: [PATCH 1/2] tests/periph_timer_periodic: add error tolerance in timings On a lot of platforms the peripheral timer fires in advance, adding a precision factor of 15% makes the test more reliable --- tests/periph_timer_periodic/tests/01-run.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/periph_timer_periodic/tests/01-run.py b/tests/periph_timer_periodic/tests/01-run.py index ac28e2f79780..653914f86e32 100755 --- a/tests/periph_timer_periodic/tests/01-run.py +++ b/tests/periph_timer_periodic/tests/01-run.py @@ -6,19 +6,24 @@ # General Public License v2.1. See the file LICENSE in the top level # directory for more details. +import os import sys import time from testrunner import run +PRECISION = float(os.getenv("TEST_PERIPH_TIMER_PERIODIC_PRECISION", "0")) + + def testfunc(child): child.expect_exact('TEST START') start = time.time() child.expect_exact('TEST SUCCEEDED') end = time.time() # test should run 10 cycles with 25ms each - assert (end - start) > 0.25 - assert (end - start) < 0.40 + elapsed = end - start + assert elapsed > 0.25 * (1 - PRECISION), "=< 0.25s ({})".format(elapsed) + assert elapsed < 0.40 * (1 + PRECISION), "=> 0.40s ({})".format(elapsed) if __name__ == "__main__": From fa32f8a4b1575c3e2752e677b7f1ba5ec0c0cd12 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 23 Feb 2021 12:32:41 +0100 Subject: [PATCH 2/2] ci/test-on-iotlab: set error precision to periph_timer_periodic --- .github/workflows/test-on-iotlab.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-on-iotlab.yml b/.github/workflows/test-on-iotlab.yml index 99249fe94df1..6932408d1007 100644 --- a/.github/workflows/test-on-iotlab.yml +++ b/.github/workflows/test-on-iotlab.yml @@ -82,6 +82,10 @@ jobs: # but flashing at a specific offset is not (yet) supported on IoT-LAB # so it will always fail because of that limitation APPLICATIONS_EXCLUDE: tests/periph_timer_short_relative_set tests/riotboot + # Increase tolerance error with `tests/periph_timer_periodic` because + # of timing issues with the test script when running in the github + # actions environment + TEST_PERIPH_TIMER_PERIODIC_PRECISION: 0.30 steps: - name: Set up Python 3.8 uses: actions/setup-python@v2