From f73fcf4f07cef8c144ea9e6f27bfb679a11df392 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie <alexandre.abadie@inria.fr> Date: Thu, 9 Nov 2017 21:54:53 +0100 Subject: [PATCH] tests/libfixmath: migrate to testrunner --- tests/libfixmath/Makefile | 3 +++ tests/libfixmath/main.c | 2 +- tests/libfixmath/tests/01-run.py | 44 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100755 tests/libfixmath/tests/01-run.py diff --git a/tests/libfixmath/Makefile b/tests/libfixmath/Makefile index 5032a53897..16073e73cf 100644 --- a/tests/libfixmath/Makefile +++ b/tests/libfixmath/Makefile @@ -5,3 +5,6 @@ USEPKG += libfixmath USEMODULE += libfixmath include $(RIOTBASE)/Makefile.include + +test: + tests/01-run.py diff --git a/tests/libfixmath/main.c b/tests/libfixmath/main.c index dd6763e073..a5ec3de2a4 100644 --- a/tests/libfixmath/main.c +++ b/tests/libfixmath/main.c @@ -190,6 +190,6 @@ int main(void) puts("Binary."); binary_ops(); - puts("Done."); + puts("SUCCESS"); return 0; } diff --git a/tests/libfixmath/tests/01-run.py b/tests/libfixmath/tests/01-run.py new file mode 100755 index 0000000000..92e5f4544e --- /dev/null +++ b/tests/libfixmath/tests/01-run.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +import os +import sys + +sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner')) +import testrunner + + +def expect_unary(child): + for _ in range(20): + for op_name in ('abs', 'sq', 'atan', 'exp'): + child.expect('{}\(-?\d+\.\d+\) = -?\d+\.\d+'.format(op_name)) + + for _ in range(20): + for op_name in ('sin', 'cos', 'tan'): + child.expect('{}\(-?\d+.\d+\) = -?\d+.\d+'.format(op_name)) + + for _ in range(20): + for op_name in ('asin', 'acos'): + child.expect('{}\(-?\d+.\d+\) = -?\d+.\d+'.format(op_name)) + + for _ in range(20): + for op_name in ('sqrt', 'log', 'log2', 'slog2'): + child.expect('{}\(-?\d+.\d+\) = -?\d+.\d+'.format(op_name)) + + +def expect_binary(child): + for _ in range(20): + for op_name in ('add', 'sub', 'mul', 'div', 'mod', 'sadd', 'ssub', + 'smul', 'sdiv', 'min', 'max'): + child.expect('{}\(-?\d+.\d+\, -?\d+.\d+\) = -?\d+.\d+' + .format(op_name)) + + +def testfunc(child): + child.expect_exact('Unary.') + expect_unary(child) + child.expect_exact('Binary.') + expect_binary(child) + child.expect_exact('SUCCESS') + +if __name__ == "__main__": + sys.exit(testrunner.run(testfunc)) -- GitLab