[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/31] iotests.py: Add (verify|has)_working_luks()
From: |
Max Reitz |
Subject: |
[PULL 07/31] iotests.py: Add (verify|has)_working_luks() |
Date: |
Mon, 6 Jul 2020 12:04:08 +0200 |
Similar to _require_working_luks for bash tests, these functions can be
used to check whether our luks driver can actually create images.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200625125548.870061-6-mreitz@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
---
tests/qemu-iotests/iotests.py | 39 +++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 423974d3f6..1d8a45c02e 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -1052,6 +1052,45 @@ def verify_quorum():
if not supports_quorum():
notrun('quorum support missing')
+def has_working_luks() -> Tuple[bool, str]:
+ """
+ Check whether our LUKS driver can actually create images
+ (this extends to LUKS encryption for qcow2).
+
+ If not, return the reason why.
+ """
+
+ img_file = f'{test_dir}/luks-test.luks'
+ (output, status) = \
+ qemu_img_pipe_and_status('create', '-f', 'luks',
+ '--object', luks_default_secret_object,
+ '-o', luks_default_key_secret_opt,
+ '-o', 'iter-time=10',
+ img_file, '1G')
+ try:
+ os.remove(img_file)
+ except OSError:
+ pass
+
+ if status != 0:
+ reason = output
+ for line in output.splitlines():
+ if img_file + ':' in line:
+ reason = line.split(img_file + ':', 1)[1].strip()
+ break
+
+ return (False, reason)
+ else:
+ return (True, '')
+
+def verify_working_luks():
+ """
+ Skip test suite if LUKS does not work
+ """
+ (working, reason) = has_working_luks()
+ if not working:
+ notrun(reason)
+
def qemu_pipe(*args):
"""
Run qemu with an option to print something and exit (e.g. a help option).
--
2.26.2
- [PULL 00/31] Block patches, Max Reitz, 2020/07/06
- [PULL 01/31] block/block-copy: block_copy_dirty_clusters: fix failure check, Max Reitz, 2020/07/06
- [PULL 02/31] qcow2: Fix preallocation on images with unaligned sizes, Max Reitz, 2020/07/06
- [PULL 03/31] iotests: Make _filter_img_create more active, Max Reitz, 2020/07/06
- [PULL 05/31] iotests/common.rc: Add _require_working_luks, Max Reitz, 2020/07/06
- [PULL 04/31] iotests: filter few more luks specific create options, Max Reitz, 2020/07/06
- [PULL 07/31] iotests.py: Add (verify|has)_working_luks(),
Max Reitz <=
- [PULL 08/31] iotests: Check whether luks works, Max Reitz, 2020/07/06
- [PULL 06/31] iotests.py: Add qemu_img_pipe_and_status(), Max Reitz, 2020/07/06
- [PULL 09/31] qcrypto/core: add generic infrastructure for crypto options amendment, Max Reitz, 2020/07/06
- [PULL 10/31] qcrypto/luks: implement encryption key management, Max Reitz, 2020/07/06
- [PULL 11/31] block/amend: add 'force' option, Max Reitz, 2020/07/06
- [PULL 12/31] block/amend: separate amend and create options for qemu-img, Max Reitz, 2020/07/06
- [PULL 14/31] block/crypto: rename two functions, Max Reitz, 2020/07/06
- [PULL 13/31] block/amend: refactor qcow2 amend options, Max Reitz, 2020/07/06
- [PULL 15/31] block/crypto: implement the encryption key management, Max Reitz, 2020/07/06
- [PULL 16/31] block/qcow2: extend qemu-img amend interface with crypto options, Max Reitz, 2020/07/06