tests: Make run-tests.py process test case selection arguments

This allows a list of matching test cases to be produced without having
to run the test cases. Previously, -L output included all defined test
cases regardless of what else was included on the command line.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-11-19 00:34:36 +02:00
parent 38cb0a2db6
commit 5e3c0b02a7

View file

@ -240,8 +240,29 @@ def main():
if conn: if conn:
run = int(time.time()) run = int(time.time())
# read the modules from the modules file
if args.mfile:
args.testmodules = []
with open(args.mfile) as f:
for line in f.readlines():
line = line.strip()
if not line or line.startswith('#'):
continue
args.testmodules.append(line)
tests_to_run = []
for t in tests:
name = t.__name__.replace('test_', '', 1)
if args.tests:
if not name in args.tests:
continue
if args.testmodules:
if not t.__module__.replace('test_', '', 1) in args.testmodules:
continue
tests_to_run.append(t)
if args.update_tests_db: if args.update_tests_db:
for t in tests: for t in tests_to_run:
name = t.__name__.replace('test_', '', 1) name = t.__name__.replace('test_', '', 1)
if t.__doc__ is None: if t.__doc__ is None:
print name + " - MISSING DESCRIPTION" print name + " - MISSING DESCRIPTION"
@ -292,27 +313,6 @@ def main():
if args.dmesg: if args.dmesg:
subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w')) subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w'))
# read the modules from the modules file
if args.mfile:
args.testmodules = []
with open(args.mfile) as f:
for line in f.readlines():
line = line.strip()
if not line or line.startswith('#'):
continue
args.testmodules.append(line)
tests_to_run = []
for t in tests:
name = t.__name__.replace('test_', '', 1)
if args.tests:
if not name in args.tests:
continue
if args.testmodules:
if not t.__module__.replace('test_', '', 1) in args.testmodules:
continue
tests_to_run.append(t)
if conn and args.prefill: if conn and args.prefill:
for t in tests_to_run: for t in tests_to_run:
name = t.__name__.replace('test_', '', 1) name = t.__name__.replace('test_', '', 1)