diff --git a/README.adoc b/README.adoc index 496f45b..9525eb9 100644 --- a/README.adoc +++ b/README.adoc @@ -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[] diff --git a/common.py b/common.py index c8fd152..4ab9867 100644 --- a/common.py +++ b/common.py @@ -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 diff --git a/run-gdb b/run-gdb index 8187c94..1b88247 100755 --- a/run-gdb +++ b/run-gdb @@ -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, diff --git a/test-gdb b/test-gdb index 2a8b253..a9ae048 100755 --- a/test-gdb +++ b/test-gdb @@ -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