test-userland: allow selecting just a few tests

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-01-22 00:00:00 +00:00
parent 38ca239ad2
commit d79771aa21

View File

@@ -5,32 +5,47 @@ import os
import common import common
class Main(common.LkmcCliFunction): class Main(common.LkmcCliFunction):
def __init__(self):
super().__init__()
self.add_argument(
'tests',
metavar='tests',
nargs='*',
help='''\
If given, run only the given tests. Otherwise, run all tests.
'''
)
def timed_main(self): def timed_main(self):
run = self.import_path('run').Main() run = self.import_path('run').Main()
sources = [
'add.c',
'hello.c',
'hello_cpp.cpp',
'print_argv.c',
]
if self.env['emulator'] == 'gem5': if self.env['emulator'] == 'gem5':
extra_args = { extra_args = {
'userland_build_id': 'static', 'userland_build_id': 'static',
} }
else: else:
extra_args = {} extra_args = {}
if self.env['arch'] == 'x86_64': if self.env['tests'] == []:
arch_sources = [ sources = [
'asm_hello' 'add.c',
] 'hello.c',
elif self.env['arch'] == 'aarch64': 'hello_cpp.cpp',
arch_sources = [ 'print_argv.c',
'asm_hello'
] ]
if self.env['arch'] == 'x86_64':
arch_sources = [
'asm_hello'
]
elif self.env['arch'] == 'aarch64':
arch_sources = [
'asm_hello'
]
else:
arch_sources = []
arch_sources[:] = [os.path.join('arch', self.env['arch'], arch_source) for arch_source in arch_sources]
sources.extend(arch_sources)
else: else:
arch_sources = [] sources = self.env['tests']
arch_sources[:] = [os.path.join('arch', self.env['arch'], arch_source) for arch_source in arch_sources] for source in sources:
for source in sources + arch_sources:
exit_status = run( exit_status = run(
archs=[self.env['arch']], archs=[self.env['arch']],
dry_run=self.env['dry_run'], dry_run=self.env['dry_run'],