Add a --quiet option to run-tests.py so it can run without printing any
messages to the stdout.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
---
tests/guest-debug/run-test.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index e051e8947c..cf8b37b8b8 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -39,15 +39,17 @@ def get_args():
parser.add_argument("--stderr", help="A file to redirect stderr to")
parser.add_argument("--no-suspend", action="store_true",
help="Ask the binary to not wait for GDB connection")
+ parser.add_argument("--quiet", action="store_true", default=False,
+ help="Don't print any messages to stdout")
return parser.parse_args()
-def log(output, msg):
+def log(output, msg, quiet):
if output:
output.write(msg + "\n")
output.flush()
- else:
+ elif not quiet:
print(msg)
@@ -91,7 +93,7 @@ def log(output, msg):
cmd = f'{args.qemu} {args.qargs} -g {socket_name}{suspend}' \
f' {args.binary}'
- log(output, "QEMU CMD: %s" % (cmd))
+ log(output, "QEMU CMD: %s" % (cmd), args.quiet)
inferior = subprocess.Popen(shlex.split(cmd))
# Now launch gdb with our test and collect the result.
@@ -117,7 +119,7 @@ def log(output, msg):
sleep(1)
- log(output, "GDB CMD: %s" % (gdb_cmd))
+ log(output, "GDB CMD: %s" % (gdb_cmd), args.quiet)
gdb_env = dict(os.environ)
gdb_pythonpath = gdb_env.get("PYTHONPATH", "").split(os.pathsep)
--
2.34.1
On 04/09/2025 17.46, Gustavo Romero wrote:
> Add a --quiet option to run-tests.py so it can run without printing any
> messages to the stdout.
>
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> ---
> tests/guest-debug/run-test.py | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
> index e051e8947c..cf8b37b8b8 100755
> --- a/tests/guest-debug/run-test.py
> +++ b/tests/guest-debug/run-test.py
> @@ -39,15 +39,17 @@ def get_args():
> parser.add_argument("--stderr", help="A file to redirect stderr to")
> parser.add_argument("--no-suspend", action="store_true",
> help="Ask the binary to not wait for GDB connection")
> + parser.add_argument("--quiet", action="store_true", default=False,
> + help="Don't print any messages to stdout")
>
> return parser.parse_args()
>
>
> -def log(output, msg):
> +def log(output, msg, quiet):
> if output:
> output.write(msg + "\n")
> output.flush()
> - else:
> + elif not quiet:
> print(msg)
>
>
> @@ -91,7 +93,7 @@ def log(output, msg):
> cmd = f'{args.qemu} {args.qargs} -g {socket_name}{suspend}' \
> f' {args.binary}'
>
> - log(output, "QEMU CMD: %s" % (cmd))
> + log(output, "QEMU CMD: %s" % (cmd), args.quiet)
> inferior = subprocess.Popen(shlex.split(cmd))
>
> # Now launch gdb with our test and collect the result.
> @@ -117,7 +119,7 @@ def log(output, msg):
>
>
> sleep(1)
> - log(output, "GDB CMD: %s" % (gdb_cmd))
> + log(output, "GDB CMD: %s" % (gdb_cmd), args.quiet)
>
> gdb_env = dict(os.environ)
> gdb_pythonpath = gdb_env.get("PYTHONPATH", "").split(os.pathsep)
I can see two more calls to log() in that script, don't you need to change
these spots, too:
$ grep log tests/guest-debug/run-test.py
def log(output, msg):
log(output, "QEMU CMD: %s" % (cmd))
log(output, "GDB CMD: %s" % (gdb_cmd))
log(output, "GDB crashed? (%d, %d) SKIPPING" % (result, result - 128))
log(output, "GDB never connected? Killed guest")
?
Maybe you could declare the new parameter with quiet=False by default, so
that you don't have to worry?
Thomas
Gustavo Romero <gustavo.romero@linaro.org> writes:
> Add a --quiet option to run-tests.py so it can run without printing any
> messages to the stdout.
>
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> tests/guest-debug/run-test.py | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
> index e051e8947c..cf8b37b8b8 100755
> --- a/tests/guest-debug/run-test.py
> +++ b/tests/guest-debug/run-test.py
> @@ -39,15 +39,17 @@ def get_args():
> parser.add_argument("--stderr", help="A file to redirect stderr to")
> parser.add_argument("--no-suspend", action="store_true",
> help="Ask the binary to not wait for GDB connection")
> + parser.add_argument("--quiet", action="store_true", default=False,
> + help="Don't print any messages to stdout")
>
> return parser.parse_args()
>
>
> -def log(output, msg):
> +def log(output, msg, quiet):
> if output:
> output.write(msg + "\n")
> output.flush()
> - else:
> + elif not quiet:
> print(msg)
>
>
> @@ -91,7 +93,7 @@ def log(output, msg):
> cmd = f'{args.qemu} {args.qargs} -g {socket_name}{suspend}' \
> f' {args.binary}'
>
> - log(output, "QEMU CMD: %s" % (cmd))
> + log(output, "QEMU CMD: %s" % (cmd), args.quiet)
> inferior = subprocess.Popen(shlex.split(cmd))
>
> # Now launch gdb with our test and collect the result.
> @@ -117,7 +119,7 @@ def log(output, msg):
>
>
> sleep(1)
> - log(output, "GDB CMD: %s" % (gdb_cmd))
> + log(output, "GDB CMD: %s" % (gdb_cmd), args.quiet)
>
> gdb_env = dict(os.environ)
> gdb_pythonpath = gdb_env.get("PYTHONPATH", "").split(os.pathsep)
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
© 2016 - 2026 Red Hat, Inc.