[PATCH 2/5] iotests: allow test discovery before building

Daniel P. Berrangé posted 5 patches 2 years, 11 months ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
There is a newer version of this series
[PATCH 2/5] iotests: allow test discovery before building
Posted by Daniel P. Berrangé 2 years, 11 months ago
The 'check' script can be invoked in "dry run" mode, in which case it
merely does test discovery and prints out all their names. Despite only
doing test discovery it still validates that the various QEMU binaries
can be found. This makes it impossible todo test discovery prior to
building QEMU. This is a desirable feature to support, because it will
let meson discover tests.

Fortunately the code in the TestEnv constructor is ordered in a way
that makes this fairly trivial to achieve. We can just short circuit
the constructor after the basic directory paths have been set.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/qemu-iotests/check      | 1 +
 tests/qemu-iotests/testenv.py | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 806abc21d6..7e287a79a3 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -129,6 +129,7 @@ if __name__ == '__main__':
                   imgopts=args.imgopts, misalign=args.misalign,
                   debug=args.debug, valgrind=args.valgrind,
                   gdb=args.gdb, qprint=args.print,
+                  dry_run=args.dry_run,
                   source_dir=args.source_dir,
                   build_dir=args.build_dir)
 
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index 9bf37cd381..952efa0e63 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -178,6 +178,7 @@ def __init__(self, imgfmt: str, imgproto: str, aiomode: str,
                  valgrind: bool = False,
                  gdb: bool = False,
                  qprint: bool = False,
+                 dry_run: bool = False,
                  source_dir: Optional[str] = None,
                  build_dir: Optional[str] = None) -> None:
         self.imgfmt = imgfmt
@@ -232,6 +233,10 @@ def __init__(self, imgfmt: str, imgproto: str, aiomode: str,
         self.build_root = os.path.join(self.build_iotests, '..', '..')
 
         self.init_directories()
+
+        if dry_run:
+            return
+
         self.init_binaries()
 
         self.malloc_perturb_ = os.getenv('MALLOC_PERTURB_',
-- 
2.39.2


Re: [PATCH 2/5] iotests: allow test discovery before building
Posted by Alex Bennée 2 years, 11 months ago
Daniel P. Berrangé <berrange@redhat.com> writes:

> The 'check' script can be invoked in "dry run" mode, in which case it
> merely does test discovery and prints out all their names. Despite only
> doing test discovery it still validates that the various QEMU binaries
> can be found. This makes it impossible todo test discovery prior to
> building QEMU. This is a desirable feature to support, because it will
> let meson discover tests.
>
> Fortunately the code in the TestEnv constructor is ordered in a way
> that makes this fairly trivial to achieve. We can just short circuit
> the constructor after the basic directory paths have been set.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH 2/5] iotests: allow test discovery before building
Posted by Thomas Huth 2 years, 11 months ago
On 02/03/2023 19.46, Daniel P. Berrangé wrote:
> The 'check' script can be invoked in "dry run" mode, in which case it
> merely does test discovery and prints out all their names. Despite only
> doing test discovery it still validates that the various QEMU binaries
> can be found. This makes it impossible todo test discovery prior to
> building QEMU. This is a desirable feature to support, because it will
> let meson discover tests.
> 
> Fortunately the code in the TestEnv constructor is ordered in a way
> that makes this fairly trivial to achieve. We can just short circuit
> the constructor after the basic directory paths have been set.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/qemu-iotests/check      | 1 +
>   tests/qemu-iotests/testenv.py | 5 +++++
>   2 files changed, 6 insertions(+)
> 
> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
> index 806abc21d6..7e287a79a3 100755
> --- a/tests/qemu-iotests/check
> +++ b/tests/qemu-iotests/check
> @@ -129,6 +129,7 @@ if __name__ == '__main__':
>                     imgopts=args.imgopts, misalign=args.misalign,
>                     debug=args.debug, valgrind=args.valgrind,
>                     gdb=args.gdb, qprint=args.print,
> +                  dry_run=args.dry_run,
>                     source_dir=args.source_dir,
>                     build_dir=args.build_dir)
>   
> diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
> index 9bf37cd381..952efa0e63 100644
> --- a/tests/qemu-iotests/testenv.py
> +++ b/tests/qemu-iotests/testenv.py
> @@ -178,6 +178,7 @@ def __init__(self, imgfmt: str, imgproto: str, aiomode: str,
>                    valgrind: bool = False,
>                    gdb: bool = False,
>                    qprint: bool = False,
> +                 dry_run: bool = False,
>                    source_dir: Optional[str] = None,
>                    build_dir: Optional[str] = None) -> None:
>           self.imgfmt = imgfmt
> @@ -232,6 +233,10 @@ def __init__(self, imgfmt: str, imgproto: str, aiomode: str,
>           self.build_root = os.path.join(self.build_iotests, '..', '..')
>   
>           self.init_directories()
> +
> +        if dry_run:
> +            return
> +
>           self.init_binaries()
>   
>           self.malloc_perturb_ = os.getenv('MALLOC_PERTURB_',

This gives me a feeling of Deja-Vu:

  https://lore.kernel.org/all/20220209101530.3442837-5-thuth@redhat.com/

... to bad that I never got that merged ;-)

Anyway:
Reviewed-by: Thomas Huth <thuth@redhat.com>