From 6a570f3a82240f6892f89eb9ff63dfbcfede9f43 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie <alexandre.abadie@inria.fr> Date: Mon, 28 Jan 2019 22:17:54 +0100 Subject: [PATCH] tests/periph_rtt: add automatic testing script --- tests/periph_rtt/tests/01-run.py | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 tests/periph_rtt/tests/01-run.py diff --git a/tests/periph_rtt/tests/01-run.py b/tests/periph_rtt/tests/01-run.py new file mode 100755 index 0000000000..653ad1d4ce --- /dev/null +++ b/tests/periph_rtt/tests/01-run.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2019 Inria +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +import sys +import time +from testrunner import run + + +PRECISION = 0.05 # 5% +MAX_HELLOS = 5 + + +def testfunc(child): + child.expect(r'This test will display \'Hello\' every (\d+) seconds') + period = int(child.match[1]) + child.expect_exact('Initializing the RTT driver') + child.expect(r'RTT now: \d+') + child.expect(r'Setting initial alarm to now \+ {} s \(\d+\)' + .format(period)) + child.expect_exact('Done setting up the RTT, wait for many Hellos') + start = time.time() + for _ in range(MAX_HELLOS): + child.expect_exact('Hello\r\n', timeout=period + 1) + + # Verify timings + elapsed = time.time() - start + assert elapsed > (MAX_HELLOS * period * (1 - PRECISION)) + assert elapsed < (MAX_HELLOS * period * (1 + PRECISION)) + + +if __name__ == "__main__": + sys.exit(run(testfunc)) -- GitLab