diff mbox series

[02/67] iotests.py: Add @skip_for_imgopts()

Message ID 20191001194715.2796-3-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series iotests: Honor $IMGOPTS in Python tests | expand

Commit Message

Max Reitz Oct. 1, 2019, 7:46 p.m. UTC
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

John Snow Oct. 1, 2019, 10:16 p.m. UTC | #1
On 10/1/19 3:46 PM, Max Reitz wrote:
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/iotests.py | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 7030900807..cdcb62c4ac 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -950,6 +950,19 @@ def skip_if_unsupported(required_formats=[], read_only=False):
>          return func_wrapper
>      return skip_test_decorator
>  
> +def skip_for_imgopts(unsupported_opts=[]):
> +    '''Skip Test Decorator
> +       Skips the test if imgopts contains any of the given options'''
> +    def skip_test_decorator(func):
> +        def func_wrapper(test_case: QMPTestCase, *args, **kwargs):

:D

> +            for opt in imgopts:
> +                if any(unsupported in opt for unsupported in unsupported_opts):
> +                    test_case.case_skip('{}: Option {} is unsupported'.format(
> +                                        test_case, opt))
> +            return func(test_case, *args, **kwargs)
> +        return func_wrapper
> +    return skip_test_decorator
> +
>  def execute_unittest(debug=False):
>      """Executes unittests within the calling module."""
>  
> 

Reviewed-by: John Snow <jsnow@redhat.com>
Vladimir Sementsov-Ogievskiy Oct. 3, 2019, 3:19 p.m. UTC | #2
01.10.2019 22:46, Max Reitz wrote:
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>   tests/qemu-iotests/iotests.py | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 7030900807..cdcb62c4ac 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -950,6 +950,19 @@ def skip_if_unsupported(required_formats=[], read_only=False):
>           return func_wrapper
>       return skip_test_decorator
>   
> +def skip_for_imgopts(unsupported_opts=[]):
> +    '''Skip Test Decorator
> +       Skips the test if imgopts contains any of the given options'''
> +    def skip_test_decorator(func):
> +        def func_wrapper(test_case: QMPTestCase, *args, **kwargs):

how about

unsup = set(imgopts) & set(unsupported_opts)
if unsup:
    test_case.case_skip('... Options {} are ...', format(..., ', '.join(map(str, unsup)))

> +            for opt in imgopts:
> +                if any(unsupported in opt for unsupported in unsupported_opts):
> +                    test_case.case_skip('{}: Option {} is unsupported'.format(
> +                                        test_case, opt))
> +            return func(test_case, *args, **kwargs)
> +        return func_wrapper
> +    return skip_test_decorator
> +
>   def execute_unittest(debug=False):
>       """Executes unittests within the calling module."""
>   
>
Max Reitz Oct. 4, 2019, 12:55 p.m. UTC | #3
On 03.10.19 17:19, Vladimir Sementsov-Ogievskiy wrote:
> 01.10.2019 22:46, Max Reitz wrote:
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   tests/qemu-iotests/iotests.py | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
>> index 7030900807..cdcb62c4ac 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
>> @@ -950,6 +950,19 @@ def skip_if_unsupported(required_formats=[], read_only=False):
>>           return func_wrapper
>>       return skip_test_decorator
>>   
>> +def skip_for_imgopts(unsupported_opts=[]):
>> +    '''Skip Test Decorator
>> +       Skips the test if imgopts contains any of the given options'''
>> +    def skip_test_decorator(func):
>> +        def func_wrapper(test_case: QMPTestCase, *args, **kwargs):
> 
> how about
> 
> unsup = set(imgopts) & set(unsupported_opts)
> if unsup:
>     test_case.case_skip('... Options {} are ...', format(..., ', '.join(map(str, unsup)))

Sure.

Max
diff mbox series

Patch

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 7030900807..cdcb62c4ac 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -950,6 +950,19 @@  def skip_if_unsupported(required_formats=[], read_only=False):
         return func_wrapper
     return skip_test_decorator
 
+def skip_for_imgopts(unsupported_opts=[]):
+    '''Skip Test Decorator
+       Skips the test if imgopts contains any of the given options'''
+    def skip_test_decorator(func):
+        def func_wrapper(test_case: QMPTestCase, *args, **kwargs):
+            for opt in imgopts:
+                if any(unsupported in opt for unsupported in unsupported_opts):
+                    test_case.case_skip('{}: Option {} is unsupported'.format(
+                                        test_case, opt))
+            return func(test_case, *args, **kwargs)
+        return func_wrapper
+    return skip_test_decorator
+
 def execute_unittest(debug=False):
     """Executes unittests within the calling module."""