mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
test-gdb: find source path correctly
Previously was relying on glob order, and which could pick up the .py instead of the .c / .S.
This commit is contained in:
@@ -11456,6 +11456,13 @@ We have some link:https://github.com/pexpect/pexpect[pexpect] automated tests fo
|
|||||||
./test-gdb
|
./test-gdb
|
||||||
....
|
....
|
||||||
|
|
||||||
|
If something goes wrong, re-run the test commands manually and use `--verbose` to understand what happened:
|
||||||
|
|
||||||
|
....
|
||||||
|
./run --arch arm --background --baremetal add --wait-gdb &
|
||||||
|
./run-gdb --arch arm --baremetal add --test --verbose
|
||||||
|
....
|
||||||
|
|
||||||
Sources:
|
Sources:
|
||||||
|
|
||||||
* link:build-test-gdb[]
|
* link:build-test-gdb[]
|
||||||
|
|||||||
@@ -928,10 +928,15 @@ def setup(parser):
|
|||||||
this_module.baremetal_build_dir,
|
this_module.baremetal_build_dir,
|
||||||
this_module.baremetal_build_ext,
|
this_module.baremetal_build_ext,
|
||||||
)
|
)
|
||||||
this_module.source_path = glob.glob(os.path.splitext(os.path.join(
|
source_path_noext = os.path.splitext(os.path.join(
|
||||||
this_module.baremetal_src_dir,
|
this_module.baremetal_src_dir,
|
||||||
os.path.relpath(path, this_module.baremetal_build_dir)
|
os.path.relpath(path, this_module.baremetal_build_dir)
|
||||||
))[0] + '.*')[0]
|
))[0]
|
||||||
|
for ext in [c_ext, asm_ext]:
|
||||||
|
source_path = source_path_noext + ext
|
||||||
|
if os.path.exists(source_path):
|
||||||
|
this_module.source_path = source_path
|
||||||
|
break
|
||||||
this_module.image = path
|
this_module.image = path
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|||||||
14
run-gdb
14
run-gdb
@@ -26,10 +26,10 @@ class GdbTestcase:
|
|||||||
source_path,
|
source_path,
|
||||||
test_script_path,
|
test_script_path,
|
||||||
cmd,
|
cmd,
|
||||||
debug=False
|
verbose=False
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
:param debug: if True, print extra debug information to help understand
|
:param verbose: if True, print extra debug information to help understand
|
||||||
why a test is not working
|
why a test is not working
|
||||||
'''
|
'''
|
||||||
self.prompt = '\(gdb\) '
|
self.prompt = '\(gdb\) '
|
||||||
@@ -42,9 +42,10 @@ class GdbTestcase:
|
|||||||
cmd[1:],
|
cmd[1:],
|
||||||
encoding='utf-8'
|
encoding='utf-8'
|
||||||
)
|
)
|
||||||
if debug:
|
if verbose:
|
||||||
self.child.logfile = sys.stdout
|
self.child.logfile = sys.stdout
|
||||||
self.child.setecho(False)
|
self.child.setecho(False)
|
||||||
|
self.child.waitnoecho()
|
||||||
self.child.expect(self.prompt)
|
self.child.expect(self.prompt)
|
||||||
test = imp.load_source('test', test_script_path)
|
test = imp.load_source('test', test_script_path)
|
||||||
test.test(self)
|
test.test(self)
|
||||||
@@ -103,6 +104,10 @@ def main(args, extra_args=None):
|
|||||||
'-nh', common.Newline,
|
'-nh', common.Newline,
|
||||||
'-ex', 'set confirm off', common.Newline
|
'-ex', 'set confirm off', common.Newline
|
||||||
])
|
])
|
||||||
|
elif args.verbose:
|
||||||
|
# The output of this would affect the tests.
|
||||||
|
# https://stackoverflow.com/questions/13496389/gdb-remote-protocol-how-to-analyse-packets
|
||||||
|
before.extend(['-ex', 'set debug remote 1', common.Newline])
|
||||||
if args.break_at is not None:
|
if args.break_at is not None:
|
||||||
break_at = ['-ex', 'break {}'.format(args.break_at), common.Newline]
|
break_at = ['-ex', 'break {}'.format(args.break_at), common.Newline]
|
||||||
else:
|
else:
|
||||||
@@ -168,7 +173,8 @@ def main(args, extra_args=None):
|
|||||||
GdbTestcase(
|
GdbTestcase(
|
||||||
common.source_path,
|
common.source_path,
|
||||||
test_script_path,
|
test_script_path,
|
||||||
cmd
|
cmd,
|
||||||
|
verbose=args.verbose,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# I would rather have cwd be out_rootfs_overlay_dir,
|
# I would rather have cwd be out_rootfs_overlay_dir,
|
||||||
|
|||||||
12
test-gdb
12
test-gdb
@@ -3,22 +3,22 @@ set -eux
|
|||||||
|
|
||||||
# QEMU
|
# QEMU
|
||||||
./run --arch arm --background --baremetal add --wait-gdb &
|
./run --arch arm --background --baremetal add --wait-gdb &
|
||||||
./run-gdb --arch arm --baremetal add --test
|
./run-gdb --arch arm --baremetal add --test "$@"
|
||||||
wait
|
wait
|
||||||
./run --arch arm --background --baremetal arch/arm/add --wait-gdb &
|
./run --arch arm --background --baremetal arch/arm/add --wait-gdb &
|
||||||
./run-gdb --arch arm --baremetal arch/arm/add --test
|
./run-gdb --arch arm --baremetal arch/arm/add --test "$@"
|
||||||
wait
|
wait
|
||||||
./run --arch aarch64 --background --baremetal arch/aarch64/add --wait-gdb &
|
./run --arch aarch64 --background --baremetal arch/aarch64/add --wait-gdb &
|
||||||
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --test
|
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --test "$@"
|
||||||
wait
|
wait
|
||||||
|
|
||||||
# gem5
|
# gem5
|
||||||
./run --arch arm --background --baremetal add --gem5 --wait-gdb &
|
./run --arch arm --background --baremetal add --gem5 --wait-gdb &
|
||||||
./run-gdb --arch arm --baremetal add --gem5 --test
|
./run-gdb --arch arm --baremetal add --gem5 --test "$@"
|
||||||
wait
|
wait
|
||||||
./run --arch arm --background --baremetal arch/arm/add --gem5 --wait-gdb &
|
./run --arch arm --background --baremetal arch/arm/add --gem5 --wait-gdb &
|
||||||
./run-gdb --arch arm --baremetal arch/arm/add --gem5 --test
|
./run-gdb --arch arm --baremetal arch/arm/add --gem5 --test "$@"
|
||||||
wait
|
wait
|
||||||
./run --arch aarch64 --background --baremetal arch/aarch64/add --gem5 --wait-gdb &
|
./run --arch aarch64 --background --baremetal arch/aarch64/add --gem5 --wait-gdb &
|
||||||
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --gem5 --test
|
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --gem5 --test "$@"
|
||||||
wait
|
wait
|
||||||
|
|||||||
Reference in New Issue
Block a user