[PATCH v2 3/5] tests/guest-debug: Add quiet option to run-tests.py

Gustavo Romero posted 5 patches 1 day, 22 hours ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Zhao Liu <zhao1.liu@intel.com>
[PATCH v2 3/5] tests/guest-debug: Add quiet option to run-tests.py
Posted by Gustavo Romero 1 day, 22 hours ago
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
Re: [PATCH v2 3/5] tests/guest-debug: Add quiet option to run-tests.py
Posted by Alex Bennée 1 day, 7 hours ago
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