diff mbox series

[v4,4/7] iotests: Let skip_if_unsupported accept a function

Message ID 20190917092004.999-5-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series iotests: Selfish patches | expand

Commit Message

Max Reitz Sept. 17, 2019, 9:20 a.m. UTC
This lets tests use skip_if_unsupported() with a potentially variable
list of required formats.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Andrey Shinkevich Sept. 17, 2019, 1:40 p.m. UTC | #1
On 17/09/2019 12:20, Max Reitz wrote:
> This lets tests use skip_if_unsupported() with a potentially variable
> list of required formats.
> 
> Suggested-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>   tests/qemu-iotests/iotests.py | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 427c34697a..a42702b6b9 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -894,8 +894,12 @@ def skip_if_unsupported(required_formats=[], read_only=False):
>          Runs the test if all the required formats are whitelisted'''
>       def skip_test_decorator(func):
>           def func_wrapper(test_case: QMPTestCase, *args, **kwargs):
> -            usf_list = list(set(required_formats) -
> -                            set(supported_formats(read_only)))
> +            if callable(required_formats):
> +                fmts = required_formats(test_case)
> +            else:
> +                fmts = required_formats
> +
> +            usf_list = list(set(fmts) - set(supported_formats(read_only)))
>               if usf_list:
>                   test_case.case_skip('{}: formats {} are not whitelisted'.format(
>                       test_case, usf_list))
> 

Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
diff mbox series

Patch

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 427c34697a..a42702b6b9 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -894,8 +894,12 @@  def skip_if_unsupported(required_formats=[], read_only=False):
        Runs the test if all the required formats are whitelisted'''
     def skip_test_decorator(func):
         def func_wrapper(test_case: QMPTestCase, *args, **kwargs):
-            usf_list = list(set(required_formats) -
-                            set(supported_formats(read_only)))
+            if callable(required_formats):
+                fmts = required_formats(test_case)
+            else:
+                fmts = required_formats
+
+            usf_list = list(set(fmts) - set(supported_formats(read_only)))
             if usf_list:
                 test_case.case_skip('{}: formats {} are not whitelisted'.format(
                     test_case, usf_list))