diff mbox series

[1/2] iotests/065: Check for zstd support

Message ID 20220221170845.628429-2-hreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series iotests: Check for zstd support | expand

Commit Message

Hanna Czenczek Feb. 21, 2022, 5:08 p.m. UTC
Some test cases run in iotest 065 require zstd support.  Skip them if
qemu-img reports it not to be available.

Reported-by: Thomas Huth <thuth@redhat.com>
Fixes: 12a936171d71f839dc907ff ("iotest 065: explicit compression type")
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
 tests/qemu-iotests/065 | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Thomas Huth Feb. 21, 2022, 5:20 p.m. UTC | #1
On 21/02/2022 18.08, Hanna Reitz wrote:
> Some test cases run in iotest 065 require zstd support.  Skip them if
> qemu-img reports it not to be available.
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Fixes: 12a936171d71f839dc907ff ("iotest 065: explicit compression type")
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> ---
>   tests/qemu-iotests/065 | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
> index f7c1b68dad..b68df84642 100755
> --- a/tests/qemu-iotests/065
> +++ b/tests/qemu-iotests/065
> @@ -24,7 +24,7 @@ import os
>   import re
>   import json
>   import iotests
> -from iotests import qemu_img, qemu_img_pipe
> +from iotests import qemu_img_pipe, qemu_img_pipe_and_status
>   import unittest
>   
>   test_img = os.path.join(iotests.test_dir, 'test.img')
> @@ -35,8 +35,13 @@ class TestImageInfoSpecific(iotests.QMPTestCase):
>       def setUp(self):
>           if self.img_options is None:
>               self.skipTest('Skipping abstract test class')
> -        qemu_img('create', '-f', iotests.imgfmt, '-o', self.img_options,
> -                 test_img, '128K')
> +        output, status = qemu_img_pipe_and_status('create',
> +                                                  '-f', iotests.imgfmt,
> +                                                  '-o', self.img_options,
> +                                                  test_img, '128K')
> +        if status == 1 and \
> +                "'compression-type' does not accept value 'zstd'" in output:
> +            self.case_skip('zstd compression not supported')
>   
>       def tearDown(self):
>           os.remove(test_img)

Thanks, that fixes 065 for me!

Tested-by: Thomas Huth <thuth@redhat.com>
Vladimir Sementsov-Ogievskiy Feb. 22, 2022, 3:44 p.m. UTC | #2
21.02.2022 20:08, Hanna Reitz wrote:
> Some test cases run in iotest 065 require zstd support.  Skip them if
> qemu-img reports it not to be available.
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Fixes: 12a936171d71f839dc907ff ("iotest 065: explicit compression type")
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> ---
>   tests/qemu-iotests/065 | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
> index f7c1b68dad..b68df84642 100755
> --- a/tests/qemu-iotests/065
> +++ b/tests/qemu-iotests/065
> @@ -24,7 +24,7 @@ import os
>   import re
>   import json
>   import iotests
> -from iotests import qemu_img, qemu_img_pipe
> +from iotests import qemu_img_pipe, qemu_img_pipe_and_status
>   import unittest
>   
>   test_img = os.path.join(iotests.test_dir, 'test.img')
> @@ -35,8 +35,13 @@ class TestImageInfoSpecific(iotests.QMPTestCase):
>       def setUp(self):
>           if self.img_options is None:
>               self.skipTest('Skipping abstract test class')
> -        qemu_img('create', '-f', iotests.imgfmt, '-o', self.img_options,
> -                 test_img, '128K')
> +        output, status = qemu_img_pipe_and_status('create',
> +                                                  '-f', iotests.imgfmt,
> +                                                  '-o', self.img_options,
> +                                                  test_img, '128K')
> +        if status == 1 and \
> +                "'compression-type' does not accept value 'zstd'" in output:
> +            self.case_skip('zstd compression not supported')
>   
>       def tearDown(self):
>           os.remove(test_img)


Hmm. Actually you fix the commit 12a936171d71f in a meaning that test passes now. But that only stresses the fact that 12a936171d71f brings a degradation in test-count for no-zstd builds. Is it bad?
The simplest solution is to duplicate TestQCow3NotLazy and TestQCow3LazyQMP with s/zstd/zlib/.. More complicated is to add generic function to detect is zstd supported or not, and use zstd in TestQCow3NotLazy and TestQCow3NotLazy only if zstd is supported (and otherwise use zlib).
Hanna Czenczek March 2, 2022, 11:14 a.m. UTC | #3
On 22.02.22 16:44, Vladimir Sementsov-Ogievskiy wrote:
> 21.02.2022 20:08, Hanna Reitz wrote:
>> Some test cases run in iotest 065 require zstd support.  Skip them if
>> qemu-img reports it not to be available.
>>
>> Reported-by: Thomas Huth <thuth@redhat.com>
>> Fixes: 12a936171d71f839dc907ff ("iotest 065: explicit compression type")
>> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
>> ---
>>   tests/qemu-iotests/065 | 11 ++++++++---
>>   1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
>> index f7c1b68dad..b68df84642 100755
>> --- a/tests/qemu-iotests/065
>> +++ b/tests/qemu-iotests/065
>> @@ -24,7 +24,7 @@ import os
>>   import re
>>   import json
>>   import iotests
>> -from iotests import qemu_img, qemu_img_pipe
>> +from iotests import qemu_img_pipe, qemu_img_pipe_and_status
>>   import unittest
>>     test_img = os.path.join(iotests.test_dir, 'test.img')
>> @@ -35,8 +35,13 @@ class TestImageInfoSpecific(iotests.QMPTestCase):
>>       def setUp(self):
>>           if self.img_options is None:
>>               self.skipTest('Skipping abstract test class')
>> -        qemu_img('create', '-f', iotests.imgfmt, '-o', 
>> self.img_options,
>> -                 test_img, '128K')
>> +        output, status = qemu_img_pipe_and_status('create',
>> +                                                  '-f', iotests.imgfmt,
>> +                                                  '-o', 
>> self.img_options,
>> +                                                  test_img, '128K')
>> +        if status == 1 and \
>> +                "'compression-type' does not accept value 'zstd'" in 
>> output:
>> +            self.case_skip('zstd compression not supported')
>>         def tearDown(self):
>>           os.remove(test_img)
>
>
> Hmm. Actually you fix the commit 12a936171d71f in a meaning that test 
> passes now. But that only stresses the fact that 12a936171d71f brings 
> a degradation in test-count for no-zstd builds. Is it bad?

Probably not really, considering that no-zstd builds shouldn’t be 
happening very often.  But since it’s something that can absolutely be 
worked around, it should be worked around. :)

> The simplest solution is to duplicate TestQCow3NotLazy and 
> TestQCow3LazyQMP with s/zstd/zlib/.. More complicated is to add 
> generic function to detect is zstd supported or not, and use zstd in 
> TestQCow3NotLazy and TestQCow3NotLazy only if zstd is supported (and 
> otherwise use zlib).

I think using zstd only if zstd is supported makes the most sense so we 
don’t increase the number of test cases for the more common case where 
zstd is compiled in.

Hanna
diff mbox series

Patch

diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
index f7c1b68dad..b68df84642 100755
--- a/tests/qemu-iotests/065
+++ b/tests/qemu-iotests/065
@@ -24,7 +24,7 @@  import os
 import re
 import json
 import iotests
-from iotests import qemu_img, qemu_img_pipe
+from iotests import qemu_img_pipe, qemu_img_pipe_and_status
 import unittest
 
 test_img = os.path.join(iotests.test_dir, 'test.img')
@@ -35,8 +35,13 @@  class TestImageInfoSpecific(iotests.QMPTestCase):
     def setUp(self):
         if self.img_options is None:
             self.skipTest('Skipping abstract test class')
-        qemu_img('create', '-f', iotests.imgfmt, '-o', self.img_options,
-                 test_img, '128K')
+        output, status = qemu_img_pipe_and_status('create',
+                                                  '-f', iotests.imgfmt,
+                                                  '-o', self.img_options,
+                                                  test_img, '128K')
+        if status == 1 and \
+                "'compression-type' does not accept value 'zstd'" in output:
+            self.case_skip('zstd compression not supported')
 
     def tearDown(self):
         os.remove(test_img)