test-gdb: bring back to life

Well factored with ./test-baremetal, allowing for target selection.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-27 00:00:05 +00:00
parent 24b75f92d8
commit cc1d8d08d0
6 changed files with 40 additions and 44 deletions

View File

@@ -15303,6 +15303,7 @@ We have some link:https://github.com/pexpect/pexpect[pexpect] automated tests fo
Sources: Sources:
* link:test-gdb[] * link:test-gdb[]
* link:userland/gdb_tests/[]
* link:userland/arch/arm/gdb_tests/[] * link:userland/arch/arm/gdb_tests/[]
* link:userland/arch/aarch64/gdb_tests/[] * link:userland/arch/aarch64/gdb_tests/[]

View File

@@ -419,6 +419,7 @@ path_properties_tuples = (
'openmp.c': {'cc_flags': ['-fopenmp', LF]}, 'openmp.c': {'cc_flags': ['-fopenmp', LF]},
} }
), ),
'gdb_tests': {'baremetal': True},
'kernel_modules': {**gnu_extension_properties, **{'requires_kernel_modules': True}}, 'kernel_modules': {**gnu_extension_properties, **{'requires_kernel_modules': True}},
'libs': ( 'libs': (
{'requires_dynamic_library': True}, {'requires_dynamic_library': True},

View File

@@ -5,13 +5,15 @@ import os
import common import common
import lkmc.import_path import lkmc.import_path
import path_properties
class Main(common.TestCliFunction): class Main(common.TestCliFunction):
def __init__(self): def __init__(self):
super().__init__( super().__init__(
description='''\ description='''\
https://github.com/cirosantilli/linux-kernel-module-cheat#test-gdb https://github.com/cirosantilli/linux-kernel-module-cheat#test-gdb
''' ''',
supported_archs=common.consts['crosstool_ng_supported_archs'],
) )
self.add_argument( self.add_argument(
'tests', 'tests',
@@ -22,52 +24,43 @@ found by searching for the Python test files.
''' '''
) )
def setup_one(self):
self.env['tests'] = self.resolve_targets(
[
self.env['baremetal_source_dir'],
self.env['userland_source_dir']
],
self.env['tests']
)
def timed_main(self): def timed_main(self):
run = lkmc.import_path.import_path_main('run') run = lkmc.import_path.import_path_main('run')
run_gdb = lkmc.import_path.import_path_main('run-gdb') run_gdb = lkmc.import_path.import_path_main('run-gdb')
if self.env['arch'] in self.env['crosstool_ng_supported_archs']: rootdir_abs_len = len(self.env['root_dir'])
test_sources = [] for test in self.env['tests']:
if self.env['tests'] == []: for path, in_dirnames, in_filenames in self.sh.walk(test):
source_paths = [] path_abs = os.path.abspath(path)
for filename in sorted(os.listdir(self.env['baremetal_source_dir'])): dirpath_relative_root = path_abs[rootdir_abs_len + 1:]
base, ext = os.path.splitext(filename) for in_filename in in_filenames:
if ext in self.env['build_in_exts']: in_file_abs = os.path.join(path_abs, in_filename)
test_sources.append( path_relative_root = os.path.join(dirpath_relative_root, in_filename)
os.path.join( path_relative_root_base, ext = os.path.splitext(path_relative_root)
self.env['baremetal_source_dir'], if ext in self.env['baremetal_build_in_exts'] and os.path.exists(path_relative_root_base + '.py'):
filename my_path_properties = path_properties.get(path_relative_root)
) if my_path_properties.should_be_tested(self.env, is_baremetal=True):
) common_args = self.get_common_args()
for root, dirnames, filenames in os.walk( common_args['baremetal'] = path_relative_root
os.path.join( run_args = common_args.copy()
self.env['baremetal_source_dir'], run_args['gdb_wait'] = True
'arch', run_args['background'] = True
self.env['arch'] test_id_string = self.test_setup(run_args, path_relative_root)
) run_thread = threading.Thread(target=lambda: run(**run_args))
): run_thread.start()
for filename in filenames: gdb_args = common_args.copy()
base, ext = os.path.splitext(filename) gdb_args['test'] = True
if ext in self.env['build_in_exts']: run_gdb(**gdb_args)
test_sources.append(os.path.join(root, filename)) run_thread.join()
else: self.test_teardown(run, 0, test_id_string)
test_sources = self.env['tests']
for test_source_full in test_sources:
base, ext = os.path.splitext(test_source_full)
if os.path.exists(base + '.py'):
test_source_base = os.path.relpath(base, self.env['root_dir'])
common_args = self.get_common_args()
common_args['baremetal'] = test_source_base + ext
run_args = common_args.copy()
run_args['gdb_wait'] = True
run_args['background'] = True
test_id_string = self.test_setup(run_args, test_source_base)
run_thread = threading.Thread(target=lambda: run(**run_args))
run_thread.start()
gdb_args = common_args.copy()
gdb_args['test'] = True
run_gdb(**gdb_args)
run_thread.join()
self.test_teardown(run, 0, test_id_string)
if __name__ == '__main__': if __name__ == '__main__':
Main().cli() Main().cli()

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#gdb-tests