[PATCH 03/19] iotests/common.rc: Add _require_working_luks

Max Reitz posted 19 patches 5 years, 7 months ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>
[PATCH 03/19] iotests/common.rc: Add _require_working_luks
Posted by Max Reitz 5 years, 7 months ago
That the luks driver is present is little indication on whether it is
actually working.  Without the crypto libraries linked in, it does not
work.  So add this function, which tries to create a luks image to see
whether that actually works.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/common.rc | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index ba912555ca..f3667f48ab 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -740,6 +740,33 @@ _unsupported_imgopts()
     done
 }
 
+# Caution: Overwrites $TEST_DIR/t.luks
+_require_working_luks()
+{
+    file="$TEST_DIR/t.luks"
+
+    output=$(
+        $QEMU_IMG create -f luks \
+            --object secret,id=sec0,data=hunter0 \
+            -o key-secret=sec0 \
+            -o iter-time=10 \
+            "$file" \
+            1M \
+            2>&1
+    )
+    status=$?
+
+    IMGFMT='luks' _rm_test_img "$file"
+
+    if [ $status != 0 ]; then
+        reason=$(echo "$output" | grep "$file:" | $SED -e "s#.*$file: *##")
+        if [ -z "$reason" ]; then
+            reason="Failed to create a LUKS image"
+        fi
+        _notrun "$reason"
+    fi
+}
+
 # this test requires that a specified command (executable) exists
 #
 _require_command()
-- 
2.26.2


Re: [PATCH 03/19] iotests/common.rc: Add _require_working_luks
Posted by Maxim Levitsky 5 years, 7 months ago
On Thu, 2020-06-25 at 14:55 +0200, Max Reitz wrote:
> That the luks driver is present is little indication on whether it is
> actually working.  Without the crypto libraries linked in, it does not
> work.  So add this function, which tries to create a luks image to see
> whether that actually works.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/common.rc | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
> index ba912555ca..f3667f48ab 100644
> --- a/tests/qemu-iotests/common.rc
> +++ b/tests/qemu-iotests/common.rc
> @@ -740,6 +740,33 @@ _unsupported_imgopts()
>      done
>  }
>  
> +# Caution: Overwrites $TEST_DIR/t.luks
> +_require_working_luks()
> +{
> +    file="$TEST_DIR/t.luks"
> +
> +    output=$(
> +        $QEMU_IMG create -f luks \
> +            --object secret,id=sec0,data=hunter0 \
> +            -o key-secret=sec0 \
> +            -o iter-time=10 \
> +            "$file" \
> +            1M \
> +            2>&1
> +    )
> +    status=$?
> +
> +    IMGFMT='luks' _rm_test_img "$file"
> +
> +    if [ $status != 0 ]; then
> +        reason=$(echo "$output" | grep "$file:" | $SED -e "s#.*$file: *##")
> +        if [ -z "$reason" ]; then
> +            reason="Failed to create a LUKS image"
> +        fi
> +        _notrun "$reason"
> +    fi
> +}
> +
>  # this test requires that a specified command (executable) exists
>  #
>  _require_command()


Look OK. I also tested this by building the qemu with all the patches applied,a
and with --disable-nettle --disable-gcrypt

And now all my tests are skipped with this nice message:
"No crypto library supporting PBKDF in this build: Function not implemented"

Thank you very very much for implementing this!

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


Best regards,
	Maxim Levitsky