[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 06/12] iotests: create generic qemu_tool() function
From: |
John Snow |
Subject: |
[PATCH v3 06/12] iotests: create generic qemu_tool() function |
Date: |
Mon, 18 Apr 2022 17:14:58 -0400 |
reimplement qemu_img() in terms of qemu_tool() in preparation for doing
the same with qemu_io().
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
---
tests/qemu-iotests/iotests.py | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index fcec3e51e51..e4e18a5889d 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -207,15 +207,13 @@ def qemu_img_create_prepare_args(args: List[str]) ->
List[str]:
return result
-def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
- ) -> 'subprocess.CompletedProcess[str]':
+
+def qemu_tool(*args: str, check: bool = True, combine_stdio: bool = True
+ ) -> 'subprocess.CompletedProcess[str]':
"""
- Run qemu_img and return the status code and console output.
+ Run a qemu tool and return its status code and console output.
- This function always prepends QEMU_IMG_OPTIONS and may further alter
- the args for 'create' commands.
-
- :param args: command-line arguments to qemu-img.
+ :param args: full command line to run.
:param check: Enforce a return code of zero.
:param combine_stdio: set to False to keep stdout/stderr separated.
@@ -232,10 +230,8 @@ def qemu_img(*args: str, check: bool = True,
combine_stdio: bool = True
properties. If streams are not combined, it will also have a
stderr property.
"""
- full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
-
subp = subprocess.run(
- full_args,
+ args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT if combine_stdio else subprocess.PIPE,
universal_newlines=True,
@@ -244,7 +240,7 @@ def qemu_img(*args: str, check: bool = True, combine_stdio:
bool = True
if check and subp.returncode or (subp.returncode < 0):
raise VerboseProcessError(
- subp.returncode, full_args,
+ subp.returncode, args,
output=subp.stdout,
stderr=subp.stderr,
)
@@ -252,6 +248,20 @@ def qemu_img(*args: str, check: bool = True,
combine_stdio: bool = True
return subp
+def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
+ ) -> 'subprocess.CompletedProcess[str]':
+ """
+ Run QEMU_IMG_PROG and return its status code and console output.
+
+ This function always prepends QEMU_IMG_OPTIONS and may further alter
+ the args for 'create' commands.
+
+ See `qemu_tool()` for greater detail.
+ """
+ full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
+ return qemu_tool(*full_args, check=check, combine_stdio=combine_stdio)
+
+
def ordered_qmp(qmsg, conv_keys=True):
# Dictionaries are not ordered prior to 3.6, therefore:
if isinstance(qmsg, list):
--
2.34.1
- [PATCH v3 00/12] iotests: add enhanced debugging info to qemu-io failures, John Snow, 2022/04/18
- [PATCH v3 01/12] iotests: replace calls to log(qemu_io(...)) with qemu_io_log(), John Snow, 2022/04/18
- [PATCH v3 09/12] iotests/image-fleecing: switch to qemu_io(), John Snow, 2022/04/18
- [PATCH v3 02/12] iotests/163: Fix broken qemu-io invocation, John Snow, 2022/04/18
- [PATCH v3 04/12] iotests/040: Don't check image pattern on zero-length image, John Snow, 2022/04/18
- [PATCH v3 06/12] iotests: create generic qemu_tool() function,
John Snow <=
- [PATCH v3 07/12] iotests: rebase qemu_io() on top of qemu_tool(), John Snow, 2022/04/18
- [PATCH v3 05/12] iotests/040: Fix TestCommitWithFilters test, John Snow, 2022/04/18
- [PATCH v3 11/12] iotests: remove qemu_io_silent() and qemu_io_silent_check()., John Snow, 2022/04/18
- [PATCH v3 03/12] iotests: Don't check qemu_io() output for specific error strings, John Snow, 2022/04/18
- [PATCH v3 10/12] iotests: remove qemu_io_pipe_and_status(), John Snow, 2022/04/18
- [PATCH v3 12/12] iotests: make qemu_io_log() check return codes by default, John Snow, 2022/04/18
- [PATCH v3 08/12] iotests/migration-permissions: use assertRaises() for qemu_io() negative test, John Snow, 2022/04/18
- Re: [PATCH v3 00/12] iotests: add enhanced debugging info to qemu-io failures, Hanna Reitz, 2022/04/25