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:
Ciro Santilli 六四事件 法轮功
2018-11-09 00:00:01 +00:00
parent 5d649377fc
commit c1f060ca65
4 changed files with 30 additions and 12 deletions

View File

@@ -11456,6 +11456,13 @@ We have some link:https://github.com/pexpect/pexpect[pexpect] automated tests fo
./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:
* link:build-test-gdb[]

View File

@@ -928,10 +928,15 @@ def setup(parser):
this_module.baremetal_build_dir,
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,
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
return args

14
run-gdb
View File

@@ -26,10 +26,10 @@ class GdbTestcase:
source_path,
test_script_path,
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
'''
self.prompt = '\(gdb\) '
@@ -42,9 +42,10 @@ class GdbTestcase:
cmd[1:],
encoding='utf-8'
)
if debug:
if verbose:
self.child.logfile = sys.stdout
self.child.setecho(False)
self.child.waitnoecho()
self.child.expect(self.prompt)
test = imp.load_source('test', test_script_path)
test.test(self)
@@ -103,6 +104,10 @@ def main(args, extra_args=None):
'-nh', 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:
break_at = ['-ex', 'break {}'.format(args.break_at), common.Newline]
else:
@@ -168,7 +173,8 @@ def main(args, extra_args=None):
GdbTestcase(
common.source_path,
test_script_path,
cmd
cmd,
verbose=args.verbose,
)
else:
# I would rather have cwd be out_rootfs_overlay_dir,

View File

@@ -3,22 +3,22 @@ set -eux
# QEMU
./run --arch arm --background --baremetal add --wait-gdb &
./run-gdb --arch arm --baremetal add --test
./run-gdb --arch arm --baremetal add --test "$@"
wait
./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
./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
# gem5
./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
./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
./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