diff mbox series

[06/19] iotests: Check whether luks works

Message ID 20200625125548.870061-7-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: LUKS encryption slot management + iotest tweaks | expand

Commit Message

Max Reitz June 25, 2020, 12:55 p.m. UTC
Whenever running an iotest for the luks format, we should check whether
luks actually really works.

Tests that try to create luks-encrypted qcow2 images should do the same.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/087        | 1 +
 tests/qemu-iotests/178        | 1 +
 tests/qemu-iotests/188        | 1 +
 tests/qemu-iotests/189        | 1 +
 tests/qemu-iotests/198        | 1 +
 tests/qemu-iotests/206        | 1 +
 tests/qemu-iotests/263        | 1 +
 tests/qemu-iotests/284        | 1 +
 tests/qemu-iotests/common.rc  | 3 +++
 tests/qemu-iotests/iotests.py | 5 +++++
 10 files changed, 16 insertions(+)

Comments

Maxim Levitsky June 29, 2020, 12:03 p.m. UTC | #1
On Thu, 2020-06-25 at 14:55 +0200, Max Reitz wrote:
> Whenever running an iotest for the luks format, we should check whether
> luks actually really works.
> 
> Tests that try to create luks-encrypted qcow2 images should do the same.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/087        | 1 +
>  tests/qemu-iotests/178        | 1 +
>  tests/qemu-iotests/188        | 1 +
>  tests/qemu-iotests/189        | 1 +
>  tests/qemu-iotests/198        | 1 +
>  tests/qemu-iotests/206        | 1 +
>  tests/qemu-iotests/263        | 1 +
>  tests/qemu-iotests/284        | 1 +
>  tests/qemu-iotests/common.rc  | 3 +++
>  tests/qemu-iotests/iotests.py | 5 +++++
>  10 files changed, 16 insertions(+)
> 
> diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087
> index bdfdad3454..678e748c58 100755
> --- a/tests/qemu-iotests/087
> +++ b/tests/qemu-iotests/087
> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  _supported_fmt qcow2
>  _supported_proto file
>  _supported_os Linux
> +_require_working_luks
>  
>  do_run_qemu()
>  {
> diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178
> index 7cf0e27154..f09b27caac 100755
> --- a/tests/qemu-iotests/178
> +++ b/tests/qemu-iotests/178
> @@ -41,6 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  _supported_fmt raw qcow2
>  _supported_proto file
>  _supported_os Linux
> +_require_working_luks
>  
>  echo "== Input validation =="
>  echo
> diff --git a/tests/qemu-iotests/188 b/tests/qemu-iotests/188
> index 09b9b6083a..13b225fded 100755
> --- a/tests/qemu-iotests/188
> +++ b/tests/qemu-iotests/188
> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  _supported_fmt qcow2
>  _supported_proto generic
>  _supported_os Linux
> +_require_working_luks
>  
>  
>  size=16M
> diff --git a/tests/qemu-iotests/189 b/tests/qemu-iotests/189
> index c9ce9d3bed..e6a84b8a3b 100755
> --- a/tests/qemu-iotests/189
> +++ b/tests/qemu-iotests/189
> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  _supported_fmt qcow2
>  _supported_proto generic
>  _supported_os Linux
> +_require_working_luks
>  
>  
>  size=16M
> diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198
> index fb0d5a29d3..aeb059d5ea 100755
> --- a/tests/qemu-iotests/198
> +++ b/tests/qemu-iotests/198
> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  _supported_fmt qcow2
>  _supported_proto generic
>  _supported_os Linux
> +_require_working_luks
>  
>  
>  size=16M
> diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
> index f42432a838..11bc51f256 100755
> --- a/tests/qemu-iotests/206
> +++ b/tests/qemu-iotests/206
> @@ -24,6 +24,7 @@ import iotests
>  from iotests import imgfmt
>  
>  iotests.script_initialize(supported_fmts=['qcow2'])
> +iotests.verify_working_luks()
>  
>  with iotests.FilePath('t.qcow2') as disk_path, \
>       iotests.FilePath('t.qcow2.base') as backing_path, \
> diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263
> index d2c030fae9..f598a12899 100755
> --- a/tests/qemu-iotests/263
> +++ b/tests/qemu-iotests/263
> @@ -40,6 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  _supported_fmt qcow2
>  _supported_proto generic
>  _supported_os Linux
> +_require_working_luks
>  
>  
>  size=1M
> diff --git a/tests/qemu-iotests/284 b/tests/qemu-iotests/284
> index 071e89b33e..9f6c29a79c 100755
> --- a/tests/qemu-iotests/284
> +++ b/tests/qemu-iotests/284
> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  _supported_fmt qcow2
>  _supported_proto generic
>  _supported_os Linux
> +_require_working_luks
>  
>  
>  size=1M
> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
> index f3667f48ab..7ac46edc1f 100644
> --- a/tests/qemu-iotests/common.rc
> +++ b/tests/qemu-iotests/common.rc
> @@ -605,6 +605,9 @@ _supported_fmt()
>      # setting IMGFMT_GENERIC to false.
>      for f; do
>          if [ "$f" = "$IMGFMT" -o "$f" = "generic" -a "$IMGFMT_GENERIC" = "true" ]; then
> +            if [ "$IMGFMT" = "luks" ]; then
> +                _require_working_luks
> +            fi
>              return
>          fi
>      done
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 039170a8a3..e1ddfcb662 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -1010,12 +1010,17 @@ def _verify_image_format(supported_fmts: Sequence[str] = (),
>          # similar to
>          #   _supported_fmt generic
>          # for bash tests
> +        if imgfmt == 'luks':
> +            verify_working_luks()
>          return
>  
>      not_sup = supported_fmts and (imgfmt not in supported_fmts)
>      if not_sup or (imgfmt in unsupported_fmts):
>          notrun('not suitable for this image format: %s' % imgfmt)
>  
> +    if imgfmt == 'luks':
> +        verify_working_luks()
> +
>  def _verify_protocol(supported: Sequence[str] = (),
>                       unsupported: Sequence[str] = ()) -> None:
>      assert not (supported and unsupported)


If I understand correctly all raw luks tests are now under the condition that
luks works, and qcow2 tests are added to this manually for the tests that
use encryption. Seems fair to me.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>


PS: I also run the iotests with luks and qcow2, and it works fine.

Note that iotest 051 is broken (regardless of these patches)

051      fail       [14:18:42] [14:18:49]                    output mismatch (see 051.out.bad)
--- /home/mlevitsk/UPSTREAM/qemu/src/tests/qemu-iotests/051.pc.out	2020-06-07 12:50:28.037624714 +0300
+++ /home/mlevitsk/UPSTREAM/qemu/build_luks/tests/qemu-iotests/051.out.bad	2020-06-29 14:18:49.372420624 +0300
@@ -142,7 +142,7 @@
 
 Testing: -drive if=ide
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: Initialization of device ide-hd failed: Device needs media, but drive is empty
+(qemu) QEMU_PROG: Device needs media, but drive is empty
 
 Testing: -drive if=virtio
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -214,7 +214,7 @@
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: Initialization of device ide-hd failed: Block node is read-only
+(qemu) QEMU_PROG: Block node is read-only
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
 QEMU X.Y.Z monitor - type 'help' for more information
Failures: 051
Failed 1 of 1 iotests


It seem to use an pc machine type specific 'out' file, thus I might have something wrong in my enviroment.

Best regards,
	Maxim Levitsky
Max Reitz June 30, 2020, 8:53 a.m. UTC | #2
On 29.06.20 14:03, Maxim Levitsky wrote:
> On Thu, 2020-06-25 at 14:55 +0200, Max Reitz wrote:
>> Whenever running an iotest for the luks format, we should check whether
>> luks actually really works.
>>
>> Tests that try to create luks-encrypted qcow2 images should do the same.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>  tests/qemu-iotests/087        | 1 +
>>  tests/qemu-iotests/178        | 1 +
>>  tests/qemu-iotests/188        | 1 +
>>  tests/qemu-iotests/189        | 1 +
>>  tests/qemu-iotests/198        | 1 +
>>  tests/qemu-iotests/206        | 1 +
>>  tests/qemu-iotests/263        | 1 +
>>  tests/qemu-iotests/284        | 1 +
>>  tests/qemu-iotests/common.rc  | 3 +++
>>  tests/qemu-iotests/iotests.py | 5 +++++
>>  10 files changed, 16 insertions(+)
>>
>> diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087
>> index bdfdad3454..678e748c58 100755
>> --- a/tests/qemu-iotests/087
>> +++ b/tests/qemu-iotests/087
>> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>>  _supported_fmt qcow2
>>  _supported_proto file
>>  _supported_os Linux
>> +_require_working_luks
>>  
>>  do_run_qemu()
>>  {
>> diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178
>> index 7cf0e27154..f09b27caac 100755
>> --- a/tests/qemu-iotests/178
>> +++ b/tests/qemu-iotests/178
>> @@ -41,6 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>>  _supported_fmt raw qcow2
>>  _supported_proto file
>>  _supported_os Linux
>> +_require_working_luks
>>  
>>  echo "== Input validation =="
>>  echo
>> diff --git a/tests/qemu-iotests/188 b/tests/qemu-iotests/188
>> index 09b9b6083a..13b225fded 100755
>> --- a/tests/qemu-iotests/188
>> +++ b/tests/qemu-iotests/188
>> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>>  _supported_fmt qcow2
>>  _supported_proto generic
>>  _supported_os Linux
>> +_require_working_luks
>>  
>>  
>>  size=16M
>> diff --git a/tests/qemu-iotests/189 b/tests/qemu-iotests/189
>> index c9ce9d3bed..e6a84b8a3b 100755
>> --- a/tests/qemu-iotests/189
>> +++ b/tests/qemu-iotests/189
>> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>>  _supported_fmt qcow2
>>  _supported_proto generic
>>  _supported_os Linux
>> +_require_working_luks
>>  
>>  
>>  size=16M
>> diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198
>> index fb0d5a29d3..aeb059d5ea 100755
>> --- a/tests/qemu-iotests/198
>> +++ b/tests/qemu-iotests/198
>> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>>  _supported_fmt qcow2
>>  _supported_proto generic
>>  _supported_os Linux
>> +_require_working_luks
>>  
>>  
>>  size=16M
>> diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
>> index f42432a838..11bc51f256 100755
>> --- a/tests/qemu-iotests/206
>> +++ b/tests/qemu-iotests/206
>> @@ -24,6 +24,7 @@ import iotests
>>  from iotests import imgfmt
>>  
>>  iotests.script_initialize(supported_fmts=['qcow2'])
>> +iotests.verify_working_luks()
>>  
>>  with iotests.FilePath('t.qcow2') as disk_path, \
>>       iotests.FilePath('t.qcow2.base') as backing_path, \
>> diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263
>> index d2c030fae9..f598a12899 100755
>> --- a/tests/qemu-iotests/263
>> +++ b/tests/qemu-iotests/263
>> @@ -40,6 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>>  _supported_fmt qcow2
>>  _supported_proto generic
>>  _supported_os Linux
>> +_require_working_luks
>>  
>>  
>>  size=1M
>> diff --git a/tests/qemu-iotests/284 b/tests/qemu-iotests/284
>> index 071e89b33e..9f6c29a79c 100755
>> --- a/tests/qemu-iotests/284
>> +++ b/tests/qemu-iotests/284
>> @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>>  _supported_fmt qcow2
>>  _supported_proto generic
>>  _supported_os Linux
>> +_require_working_luks
>>  
>>  
>>  size=1M
>> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
>> index f3667f48ab..7ac46edc1f 100644
>> --- a/tests/qemu-iotests/common.rc
>> +++ b/tests/qemu-iotests/common.rc
>> @@ -605,6 +605,9 @@ _supported_fmt()
>>      # setting IMGFMT_GENERIC to false.
>>      for f; do
>>          if [ "$f" = "$IMGFMT" -o "$f" = "generic" -a "$IMGFMT_GENERIC" = "true" ]; then
>> +            if [ "$IMGFMT" = "luks" ]; then
>> +                _require_working_luks
>> +            fi
>>              return
>>          fi
>>      done
>> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
>> index 039170a8a3..e1ddfcb662 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
>> @@ -1010,12 +1010,17 @@ def _verify_image_format(supported_fmts: Sequence[str] = (),
>>          # similar to
>>          #   _supported_fmt generic
>>          # for bash tests
>> +        if imgfmt == 'luks':
>> +            verify_working_luks()
>>          return
>>  
>>      not_sup = supported_fmts and (imgfmt not in supported_fmts)
>>      if not_sup or (imgfmt in unsupported_fmts):
>>          notrun('not suitable for this image format: %s' % imgfmt)
>>  
>> +    if imgfmt == 'luks':
>> +        verify_working_luks()
>> +
>>  def _verify_protocol(supported: Sequence[str] = (),
>>                       unsupported: Sequence[str] = ()) -> None:
>>      assert not (supported and unsupported)
> 
> 
> If I understand correctly all raw luks tests are now under the condition that
> luks works, and qcow2 tests are added to this manually for the tests that
> use encryption. Seems fair to me.
> 
> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
> 
> 
> PS: I also run the iotests with luks and qcow2, and it works fine.
> 
> Note that iotest 051 is broken (regardless of these patches)
> 
> 051      fail       [14:18:42] [14:18:49]                    output mismatch (see 051.out.bad)
> --- /home/mlevitsk/UPSTREAM/qemu/src/tests/qemu-iotests/051.pc.out	2020-06-07 12:50:28.037624714 +0300
> +++ /home/mlevitsk/UPSTREAM/qemu/build_luks/tests/qemu-iotests/051.out.bad	2020-06-29 14:18:49.372420624 +0300
> @@ -142,7 +142,7 @@
>  
>  Testing: -drive if=ide
>  QEMU X.Y.Z monitor - type 'help' for more information
> -(qemu) QEMU_PROG: Initialization of device ide-hd failed: Device needs media, but drive is empty
> +(qemu) QEMU_PROG: Device needs media, but drive is empty
>  
>  Testing: -drive if=virtio
>  QEMU X.Y.Z monitor - type 'help' for more information
> @@ -214,7 +214,7 @@
>  
>  Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
>  QEMU X.Y.Z monitor - type 'help' for more information
> -(qemu) QEMU_PROG: Initialization of device ide-hd failed: Block node is read-only
> +(qemu) QEMU_PROG: Block node is read-only
>  
>  Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
>  QEMU X.Y.Z monitor - type 'help' for more information
> Failures: 051
> Failed 1 of 1 iotests
> 
> 
> It seem to use an pc machine type specific 'out' file, thus I might have something wrong in my enviroment.

No, it isn’t just you.  The patch to fix that is in my pull request:

https://lists.nongnu.org/archive/html/qemu-block/2020-06/msg01159.html

Max
diff mbox series

Patch

diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087
index bdfdad3454..678e748c58 100755
--- a/tests/qemu-iotests/087
+++ b/tests/qemu-iotests/087
@@ -39,6 +39,7 @@  trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto file
 _supported_os Linux
+_require_working_luks
 
 do_run_qemu()
 {
diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178
index 7cf0e27154..f09b27caac 100755
--- a/tests/qemu-iotests/178
+++ b/tests/qemu-iotests/178
@@ -41,6 +41,7 @@  trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt raw qcow2
 _supported_proto file
 _supported_os Linux
+_require_working_luks
 
 echo "== Input validation =="
 echo
diff --git a/tests/qemu-iotests/188 b/tests/qemu-iotests/188
index 09b9b6083a..13b225fded 100755
--- a/tests/qemu-iotests/188
+++ b/tests/qemu-iotests/188
@@ -39,6 +39,7 @@  trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto generic
 _supported_os Linux
+_require_working_luks
 
 
 size=16M
diff --git a/tests/qemu-iotests/189 b/tests/qemu-iotests/189
index c9ce9d3bed..e6a84b8a3b 100755
--- a/tests/qemu-iotests/189
+++ b/tests/qemu-iotests/189
@@ -39,6 +39,7 @@  trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto generic
 _supported_os Linux
+_require_working_luks
 
 
 size=16M
diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198
index fb0d5a29d3..aeb059d5ea 100755
--- a/tests/qemu-iotests/198
+++ b/tests/qemu-iotests/198
@@ -39,6 +39,7 @@  trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto generic
 _supported_os Linux
+_require_working_luks
 
 
 size=16M
diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
index f42432a838..11bc51f256 100755
--- a/tests/qemu-iotests/206
+++ b/tests/qemu-iotests/206
@@ -24,6 +24,7 @@  import iotests
 from iotests import imgfmt
 
 iotests.script_initialize(supported_fmts=['qcow2'])
+iotests.verify_working_luks()
 
 with iotests.FilePath('t.qcow2') as disk_path, \
      iotests.FilePath('t.qcow2.base') as backing_path, \
diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263
index d2c030fae9..f598a12899 100755
--- a/tests/qemu-iotests/263
+++ b/tests/qemu-iotests/263
@@ -40,6 +40,7 @@  trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto generic
 _supported_os Linux
+_require_working_luks
 
 
 size=1M
diff --git a/tests/qemu-iotests/284 b/tests/qemu-iotests/284
index 071e89b33e..9f6c29a79c 100755
--- a/tests/qemu-iotests/284
+++ b/tests/qemu-iotests/284
@@ -39,6 +39,7 @@  trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto generic
 _supported_os Linux
+_require_working_luks
 
 
 size=1M
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index f3667f48ab..7ac46edc1f 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -605,6 +605,9 @@  _supported_fmt()
     # setting IMGFMT_GENERIC to false.
     for f; do
         if [ "$f" = "$IMGFMT" -o "$f" = "generic" -a "$IMGFMT_GENERIC" = "true" ]; then
+            if [ "$IMGFMT" = "luks" ]; then
+                _require_working_luks
+            fi
             return
         fi
     done
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 039170a8a3..e1ddfcb662 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -1010,12 +1010,17 @@  def _verify_image_format(supported_fmts: Sequence[str] = (),
         # similar to
         #   _supported_fmt generic
         # for bash tests
+        if imgfmt == 'luks':
+            verify_working_luks()
         return
 
     not_sup = supported_fmts and (imgfmt not in supported_fmts)
     if not_sup or (imgfmt in unsupported_fmts):
         notrun('not suitable for this image format: %s' % imgfmt)
 
+    if imgfmt == 'luks':
+        verify_working_luks()
+
 def _verify_protocol(supported: Sequence[str] = (),
                      unsupported: Sequence[str] = ()) -> None:
     assert not (supported and unsupported)