qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/4] tests/guest-debug: Support passing arguments to the GDB


From: Alex Bennée
Subject: Re: [PATCH 3/4] tests/guest-debug: Support passing arguments to the GDB test script
Date: Thu, 25 Jul 2024 21:38:01 +0100

Gustavo Romero <gustavo.romero@linaro.org> writes:

> This commit adds a new option to run-test.py, --test-args, which can
> be used to pass arguments to the GDB test script specified by the --test
> option. The arguments passed are in the key=value form, and multiple
> pairs can be passed, separated by a space. For example:
>
> run-test.py [...] --test <GDB_TEST_SCRIPT> --test-args v0="string" v1=10
>
> The 'v0' and 'v1' variables will then be available in the GDB test
> script, like this:
>
> print(v0)
> print(v1)
>
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> ---
>  tests/guest-debug/run-test.py | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
> index 368ff8a890..63b55fb8bd 100755
> --- a/tests/guest-debug/run-test.py
> +++ b/tests/guest-debug/run-test.py
> @@ -27,6 +27,7 @@ def get_args():
>      parser.add_argument("--binary", help="Binary to debug",
>                          required=True)
>      parser.add_argument("--test", help="GDB test script")
> +    parser.add_argument("--test-args", help="Arguments to GDB test script")
>      parser.add_argument("--gdb", help="The gdb binary to use",
>                          default=None)
>      parser.add_argument("--gdb-args", help="Additional gdb
> arguments")

I might be easier to do:

    parser.add_argument('test_args', nargs='*',
                        help="Additional args for test. "
                        "You should precede with -- "
                        "to avoid confusion with flags for runner script")


> @@ -91,6 +92,9 @@ def log(output, msg):
>      gdb_cmd += " -ex 'target remote %s'" % (socket_name)
>      # finally the test script itself
>      if args.test:
> +        if args.test_args:
> +            test_args = args.test_args.replace(" ",";")
> +            gdb_cmd += f" -ex 'py {test_args}'"
>          gdb_cmd += " -x %s" % (args.test)

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro



reply via email to

[Prev in Thread] Current Thread [Next in Thread]