Files
linux-kernel-module-cheat/test-baremetal
Ciro Santilli 六四事件 法轮功 3d83206461 baremetal: ah, actually nope, it didn't work :-(
Workaround for now. Works on asserts, but not on exit 1.

Some other day, maybe.

https://github.com/cirosantilli/linux-kernel-module-cheat/issues/59
2019-05-07 00:00:00 +00:00

77 lines
3.2 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import sys
import common
import path_properties
from thread_pool import ThreadPool
class Main(common.TestCliFunction):
def __init__(self):
super().__init__(
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 setup_one(self):
self.env['tests'] = self.resolve_targets(
self.env['baremetal_source_dir'],
self.env['tests']
)
def timed_main(self):
run_args = self.get_common_args()
rootdir_abs_len = len(self.env['root_dir'])
with ThreadPool(
self.run_test,
nthreads=self.env['nproc'],
thread_id_arg='thread_id',
) as thread_pool:
try:
for test in self.env['tests']:
for path, in_dirnames, in_filenames in self.sh.walk(test):
path_abs = os.path.abspath(path)
dirpath_relative_root = path_abs[rootdir_abs_len + 1:]
for in_filename in in_filenames:
if os.path.splitext(in_filename)[1] in (self.env['c_ext'], self.env['asm_ext']):
path_relative_root = os.path.join(dirpath_relative_root, in_filename)
my_path_properties = path_properties.get(path_relative_root)
if my_path_properties.should_be_tested(self.env):
cur_run_args = run_args.copy()
cur_run_args.update({
'baremetal': os.path.relpath(os.path.join(path_abs, in_filename), os.getcwd()),
})
cur_run_args.update(my_path_properties['test_run_args'])
test_args = {
'expected_exit_status': my_path_properties['exit_status'],
'run_args': cur_run_args,
'run_obj': self.import_path_main('run'),
'test_id': path_relative_root,
}
if path_relative_root != os.path.join('baremetal', 'assert_fail.c'):
# Workaround fro: https://github.com/cirosantilli/linux-kernel-module-cheat/issues/59
test_args['expected_exit_status'] = 0
error = thread_pool.submit(test_args)
if error is not None:
if self.env['quit_on_fail']:
raise common.ExitLoop()
except common.ExitLoop:
pass
error = thread_pool.get_error()
if error is not None:
print(error)
return 1
else:
return 0
if __name__ == '__main__':
Main().cli()