From a06356b455f00d5e92f1dead2ea67f5458d6c231 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Wed, 6 Mar 2019 20:31:10 +1100 Subject: testsuite: Add rexclude, rinclude and cflags to test config files. --- testsuites/rtems-test-check.py | 94 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 11 deletions(-) (limited to 'testsuites/rtems-test-check.py') diff --git a/testsuites/rtems-test-check.py b/testsuites/rtems-test-check.py index 8eef1a01c1..8af841957f 100755 --- a/testsuites/rtems-test-check.py +++ b/testsuites/rtems-test-check.py @@ -37,6 +37,8 @@ from __future__ import print_function import os import os.path +import re +import sre_constants import sys def eprint(*args, **kwargs): @@ -82,7 +84,7 @@ if verbose: # if mode == 'exclude': pass -elif mode == 'flags': +elif mode == 'cflags': if len(tests) != 1: eprint('error: test count not 1 for mode: %s' % (mode)) print('INVALID-TEST-DATA') @@ -103,13 +105,19 @@ states = ['exclude', 'expected-fail', 'user-input', 'indeterminate', - 'benchmark'] + 'benchmark', + 'rexclude', + 'rinclude'] +flags = ['cflags'] defines = { 'expected-fail' : '-DTEST_STATE_EXPECTED_FAIL=1', 'user-input' : '-DTEST_STATE_USER_INPUT=1', 'indeterminate' : '-DTEST_STATE_INDETERMINATE=1', 'benchmark' : '-DTEST_STATE_BENCHMARK=1' } output = [] -testdata = {} +testdata = { 'flags': {} } + +for f in flags: + testdata['flags'][f] = {} if verbose: eprint('mode: %s' % (mode)) @@ -145,9 +153,9 @@ while len(testconfig): lc = 0 for line in tdata: lc += 1 - ls = [s.strip() for s in line.split(':')] if len(line) == 0: continue + ls = [s.strip() for s in line.split(':', 1)] if verbose: eprint('%4d: %s' % (lc, line)) if len(ls) != 2: @@ -161,27 +169,91 @@ while len(testconfig): if td is None: eprint('error: include not found: %s:%d' % (tc, lc)) print('INVALID-TEST-DATA') + sys.exit(1) testconfig.insert(0, td) if verbose: eprint('include: %s' % (', '.join(testconfig))) + elif state in flags: + fs = test.split(':', 1) + if len(fs) != 2: + eprint('error: syntax error: %s:%d' % (tc, lc)) + print('INVALID-TEST-DATA') + sys.exit(1) + ftests = [t.strip() for t in fs[0].split(',')] + if verbose: + eprint('%4d: %r : %s' % (lc, ftests, fs[1])) + for test in ftests: + if test not in testdata['flags'][state]: + testdata['flags'][state][test] = [fs[1]] + else: + testdata['flags'][state][test] += [fs[1]] elif state in states: + stests = [t.strip() for t in test.split(',')] if state not in testdata: - testdata[state] = [test] + testdata[state] = stests else: - testdata[state] += [test] + testdata[state] += stests else: eprint('error: invalid test state: %s in %s:%d' % (state, tc, lc)) print('INVALID-TEST-DATA') sys.exit(1) +if mode in flags: + for state in ['exclude', 'rexclude', 'rinclude']: + states.remove(state) + for test in tests: if mode == 'exclude': - if 'exclude' not in testdata or test not in testdata['exclude']: + # + # Exclude is the highest priority, do this first + # + if 'exclude' in testdata and test in testdata['exclude']: + exclude = True + else: + # + # Regx exclude then regx include so you can filter a whole + # group and add back some. + # + exclude = False + if 'rexclude' in testdata: + for e in testdata['rexclude']: + try: + m = re.compile(e).match(test) + except sre_constants.error as ree: + eprint('error: invalid rexclude regx: %s: %s' % (e, ree)) + print('INVALID-TEST-DATA') + sys.exit(1) + if m: + exclude = True + if 'rinclude' in testdata: + for i in testdata['rinclude']: + try: + m = re.compile(i).match(test) + except sre_constants.error as ree: + eprint('error: invalid rinclude regx: %s: %s' % (i, ree)) + print('INVALID-TEST-DATA') + sys.exit(1) + if m: + exclude = False + # + # If not excluded add the test to the output + # + if not exclude: output += [test] - elif mode == 'flags': - for state in states: - if state != 'exclude' and state in testdata and test in testdata[state]: - output += [defines[state]] + elif mode in flags: + if mode == 'cflags': + for state in states: + if state in testdata and test in testdata[state]: + output += [defines[state]] + for ftest in testdata['flags'][mode]: + try: + m = re.compile(ftest).match(test) + except sre_constants.error as ref: + eprint('error: invalid flags test regx: %s: %s' % (ftest, ref)) + print('INVALID-TEST-DATA') + sys.exit(1) + if m: + output += testdata['flags'][mode][ftest] print(' '.join(sorted(set(output)))) -- cgit v1.2.3