mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
test-gdb: bring back to life
Well factored with ./test-baremetal, allowing for target selection.
This commit is contained in:
@@ -15303,6 +15303,7 @@ We have some link:https://github.com/pexpect/pexpect[pexpect] automated tests fo
|
||||
Sources:
|
||||
|
||||
* link:test-gdb[]
|
||||
* link:userland/gdb_tests/[]
|
||||
* link:userland/arch/arm/gdb_tests/[]
|
||||
* link:userland/arch/aarch64/gdb_tests/[]
|
||||
|
||||
|
||||
@@ -419,6 +419,7 @@ path_properties_tuples = (
|
||||
'openmp.c': {'cc_flags': ['-fopenmp', LF]},
|
||||
}
|
||||
),
|
||||
'gdb_tests': {'baremetal': True},
|
||||
'kernel_modules': {**gnu_extension_properties, **{'requires_kernel_modules': True}},
|
||||
'libs': (
|
||||
{'requires_dynamic_library': True},
|
||||
|
||||
59
test-gdb
59
test-gdb
@@ -5,13 +5,15 @@ import os
|
||||
|
||||
import common
|
||||
import lkmc.import_path
|
||||
import path_properties
|
||||
|
||||
class Main(common.TestCliFunction):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
description='''\
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#test-gdb
|
||||
'''
|
||||
''',
|
||||
supported_archs=common.consts['crosstool_ng_supported_archs'],
|
||||
)
|
||||
self.add_argument(
|
||||
'tests',
|
||||
@@ -22,45 +24,36 @@ 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):
|
||||
run = lkmc.import_path.import_path_main('run')
|
||||
run_gdb = lkmc.import_path.import_path_main('run-gdb')
|
||||
if self.env['arch'] in self.env['crosstool_ng_supported_archs']:
|
||||
test_sources = []
|
||||
if self.env['tests'] == []:
|
||||
source_paths = []
|
||||
for filename in sorted(os.listdir(self.env['baremetal_source_dir'])):
|
||||
base, ext = os.path.splitext(filename)
|
||||
if ext in self.env['build_in_exts']:
|
||||
test_sources.append(
|
||||
os.path.join(
|
||||
self.env['baremetal_source_dir'],
|
||||
filename
|
||||
)
|
||||
)
|
||||
for root, dirnames, filenames in os.walk(
|
||||
os.path.join(
|
||||
self.env['baremetal_source_dir'],
|
||||
'arch',
|
||||
self.env['arch']
|
||||
)
|
||||
):
|
||||
for filename in filenames:
|
||||
base, ext = os.path.splitext(filename)
|
||||
if ext in self.env['build_in_exts']:
|
||||
test_sources.append(os.path.join(root, filename))
|
||||
else:
|
||||
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'])
|
||||
rootdir_abs_len = len(self.env['root_dir'])
|
||||
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:
|
||||
in_file_abs = os.path.join(path_abs, in_filename)
|
||||
path_relative_root = os.path.join(dirpath_relative_root, in_filename)
|
||||
path_relative_root_base, ext = os.path.splitext(path_relative_root)
|
||||
if ext in self.env['baremetal_build_in_exts'] and os.path.exists(path_relative_root_base + '.py'):
|
||||
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()
|
||||
common_args['baremetal'] = test_source_base + ext
|
||||
common_args['baremetal'] = path_relative_root
|
||||
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)
|
||||
test_id_string = self.test_setup(run_args, path_relative_root)
|
||||
run_thread = threading.Thread(target=lambda: run(**run_args))
|
||||
run_thread.start()
|
||||
gdb_args = common_args.copy()
|
||||
|
||||
1
userland/gdb_tests/README.adoc
Normal file
1
userland/gdb_tests/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#gdb-tests
|
||||
Reference in New Issue
Block a user