mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 20:14:27 +01:00
test-baremetal: create
This commit is contained in:
64
test-baremetal
Executable file
64
test-baremetal
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import common
|
||||
|
||||
class Main(common.LkmcCliFunction):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
defaults={
|
||||
'print_time': False,
|
||||
},
|
||||
supported_archs=common.consts['crosstool_ng_supported_archs'],
|
||||
)
|
||||
self.add_argument(
|
||||
'tests',
|
||||
nargs='*',
|
||||
help='''\
|
||||
If given, run only the given tests. Otherwise, run all tests.
|
||||
'''
|
||||
)
|
||||
|
||||
def timed_main(self):
|
||||
run = self.import_path_main('run')
|
||||
run_args = self.get_common_args()
|
||||
if self.env['emulator'] == 'gem5':
|
||||
run_args['userland_build_id'] = 'static'
|
||||
if self.env['tests'] == []:
|
||||
baremetal_source_exts = (self.env['c_ext'], self.env['asm_ext'])
|
||||
paths = []
|
||||
for f in os.listdir(self.env['baremetal_source_dir']):
|
||||
path = os.path.join(self.env['baremetal_source_dir'], f)
|
||||
if os.path.isfile(path) and os.path.splitext(path)[1] in baremetal_source_exts:
|
||||
paths.append(path)
|
||||
for root, dirs, files in os.walk(self.env['baremetal_source_arch_dir'], topdown=True):
|
||||
dirs[:] = [d for d in dirs if d != 'interactive']
|
||||
for file in files:
|
||||
path = os.path.join(root, file)
|
||||
if os.path.splitext(path)[1] in baremetal_source_exts:
|
||||
paths.append(path)
|
||||
sources = []
|
||||
for path in paths:
|
||||
if not (
|
||||
self.env['emulator'] == 'gem5' and os.path.basename(path).startswith('semihost_') or
|
||||
self.env['emulator'] == 'qemu' and os.path.basename(path).startswith('gem5_')
|
||||
):
|
||||
sources.append(os.path.relpath(path, self.env['baremetal_source_dir']))
|
||||
else:
|
||||
sources = self.env['tests']
|
||||
for source in sources:
|
||||
run_args['baremetal'] = source
|
||||
run_args['background'] = True
|
||||
test_id_string = self.test_setup(run_args, source)
|
||||
if os.path.splitext(os.path.basename(source))[0] == 'multicore':
|
||||
run_args['cpus'] = 2
|
||||
exit_status = run(**run_args)
|
||||
self.test_teardown(run)
|
||||
if exit_status != 0:
|
||||
self.log_error('test failed, program exit status: {} test id: {}'.format(exit_status, test_id_string))
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Main().cli()
|
||||
Reference in New Issue
Block a user