Alexandre Abadie 07f7ac5829
tests/pkg_libfixmath: refactor test and automatic script
Print the range of iterations for each subtests and catch the value in the Python script. The number of iterations is reduced on boards that are not native, this is because this test takes a lot of time on slow platforms
2019-11-20 22:27:41 +01:00

59 lines
1.7 KiB
Python
Executable File

#!/usr/bin/env python3
import sys
from testrunner import run, test_utils_interactive_sync
def expect_unary(child):
child.expect(r'COUNT: (\d+)')
count = int(child.match.group(1))
assert count > 0
for _ in range(count):
for op_name in ('abs', 'sq', 'atan', 'exp'):
child.expect(r'{}\(-?\d+\.\d+\) = -?\d+\.\d+'.format(op_name))
child.expect(r'COUNT: (\d+)')
count = int(child.match.group(1))
assert count > 0
for _ in range(count):
for op_name in ('sin', 'cos', 'tan'):
child.expect(r'{}\(-?\d+.\d+\) = -?\d+.\d+'.format(op_name))
child.expect(r'COUNT: (\d+)')
count = int(child.match.group(1))
assert count > 0
for _ in range(count):
for op_name in ('asin', 'acos'):
child.expect(r'{}\(-?\d+.\d+\) = -?\d+.\d+'.format(op_name))
child.expect(r'COUNT: (\d+)')
count = int(child.match.group(1))
assert count > 0
for _ in range(count):
for op_name in ('sqrt', 'log', 'log2', 'slog2'):
child.expect(r'{}\(-?\d+.\d+\) = -?\d+.\d+'.format(op_name))
def expect_binary(child):
child.expect(r'COUNT: (\d+)')
count = int(child.match.group(1))
assert count > 0
for _ in range(count):
for op_name in ('add', 'sub', 'mul', 'div', 'mod', 'sadd', 'ssub',
'smul', 'sdiv', 'min', 'max'):
child.expect(r'{}\(-?\d+.\d+\, -?\d+.\d+\) = -?\d+.\d+'
.format(op_name))
def testfunc(child):
test_utils_interactive_sync(child)
child.expect_exact('Unary.')
expect_unary(child)
child.expect_exact('Binary.')
expect_binary(child)
child.expect_exact('SUCCESS')
if __name__ == "__main__":
sys.exit(run(testfunc))