[PATCH] iotests: add --quiet arg to hide env variable dump

Daniel P. Berrangé posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260623160611.2347282-1-berrange@redhat.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
tests/qemu-iotests/check         | 4 +++-
tests/qemu-iotests/testrunner.py | 7 ++++---
2 files changed, 7 insertions(+), 4 deletions(-)
[PATCH] iotests: add --quiet arg to hide env variable dump
Posted by Daniel P. Berrangé 1 month ago
Every test run dumps a long list of environment variable settings.
While this is often useful, if you are trying to reproduce a bug
while repeatedly running a single test it can be quiet noisy. Add
a --quiet flag to 'check' which allows the env variable dump to
be hidden.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/qemu-iotests/check         | 4 +++-
 tests/qemu-iotests/testrunner.py | 7 ++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 3941eac8e2..c8ba536970 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -46,6 +46,8 @@ def make_argparser() -> argparse.ArgumentParser:
         description="Test run options",
         formatter_class=argparse.ArgumentDefaultsHelpFormatter)
 
+    p.add_argument('-q', '--quiet', action='store_true',
+                   help='reduce output verbosity to only test results')
     p.add_argument('-n', '--dry-run', action='store_true',
                    help='show me, do not run tests')
     p.add_argument('-j', dest='jobs', type=int, default=1,
@@ -230,6 +232,6 @@ if __name__ == '__main__':
         with TestRunner(env, tap=args.tap,
                         color=args.color) as tr:
             paths = [os.path.join(env.source_iotests, t) for t in tests]
-            ok = tr.run_tests(paths, args.jobs)
+            ok = tr.run_tests(paths, args.jobs, args.quiet)
             if not ok:
                 sys.exit(1)
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
index dbe2dddc32..0eb7f144df 100644
--- a/tests/qemu-iotests/testrunner.py
+++ b/tests/qemu-iotests/testrunner.py
@@ -376,7 +376,7 @@ def run_test(self, test: str,
         sys.stdout.flush()
         return res
 
-    def run_tests(self, tests: List[str], jobs: int = 1) -> bool:
+    def run_tests(self, tests: List[str], jobs: int = 1, quiet: bool = False) -> bool:
         n_run = 0
         failed = []
         notrun = []
@@ -384,9 +384,10 @@ def run_tests(self, tests: List[str], jobs: int = 1) -> bool:
 
         if self.tap:
             print('TAP version 13')
-            self.env.print_env('# ')
+            if not quiet:
+                self.env.print_env('# ')
             print('1..%d' % len(tests))
-        else:
+        elif not quiet:
             self.env.print_env()
 
         test_field_width = max(len(os.path.basename(t)) for t in tests) + 2
-- 
2.54.0


Re: [PATCH] iotests: add --quiet arg to hide env variable dump
Posted by Daniel P. Berrangé 2 weeks, 4 days ago
Ping: anyone have any thoughts on this proposal

On Tue, Jun 23, 2026 at 05:06:11PM +0100, Daniel P. Berrangé wrote:
> Every test run dumps a long list of environment variable settings.
> While this is often useful, if you are trying to reproduce a bug
> while repeatedly running a single test it can be quiet noisy. Add
> a --quiet flag to 'check' which allows the env variable dump to
> be hidden.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  tests/qemu-iotests/check         | 4 +++-
>  tests/qemu-iotests/testrunner.py | 7 ++++---
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
> index 3941eac8e2..c8ba536970 100755
> --- a/tests/qemu-iotests/check
> +++ b/tests/qemu-iotests/check
> @@ -46,6 +46,8 @@ def make_argparser() -> argparse.ArgumentParser:
>          description="Test run options",
>          formatter_class=argparse.ArgumentDefaultsHelpFormatter)
>  
> +    p.add_argument('-q', '--quiet', action='store_true',
> +                   help='reduce output verbosity to only test results')
>      p.add_argument('-n', '--dry-run', action='store_true',
>                     help='show me, do not run tests')
>      p.add_argument('-j', dest='jobs', type=int, default=1,
> @@ -230,6 +232,6 @@ if __name__ == '__main__':
>          with TestRunner(env, tap=args.tap,
>                          color=args.color) as tr:
>              paths = [os.path.join(env.source_iotests, t) for t in tests]
> -            ok = tr.run_tests(paths, args.jobs)
> +            ok = tr.run_tests(paths, args.jobs, args.quiet)
>              if not ok:
>                  sys.exit(1)
> diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
> index dbe2dddc32..0eb7f144df 100644
> --- a/tests/qemu-iotests/testrunner.py
> +++ b/tests/qemu-iotests/testrunner.py
> @@ -376,7 +376,7 @@ def run_test(self, test: str,
>          sys.stdout.flush()
>          return res
>  
> -    def run_tests(self, tests: List[str], jobs: int = 1) -> bool:
> +    def run_tests(self, tests: List[str], jobs: int = 1, quiet: bool = False) -> bool:
>          n_run = 0
>          failed = []
>          notrun = []
> @@ -384,9 +384,10 @@ def run_tests(self, tests: List[str], jobs: int = 1) -> bool:
>  
>          if self.tap:
>              print('TAP version 13')
> -            self.env.print_env('# ')
> +            if not quiet:
> +                self.env.print_env('# ')
>              print('1..%d' % len(tests))
> -        else:
> +        elif not quiet:
>              self.env.print_env()
>  
>          test_field_width = max(len(os.path.basename(t)) for t in tests) + 2
> -- 
> 2.54.0
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|