[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/14] iotests: make img_info_log() call qemu_img_log()
From: |
John Snow |
Subject: |
[PATCH 14/14] iotests: make img_info_log() call qemu_img_log() |
Date: |
Tue, 8 Mar 2022 22:54:07 -0500 |
Add configurable filters to qemu_img_log(), and re-write img_info_log()
to call into qemu_img_log() with a custom filter instead.
After this patch, every last call to qemu_img() is now guaranteed to
either have its return code checked for zero, OR have its output
actually visibly logged somewhere.
Signed-off-by: John Snow <jsnow@redhat.com>
---
tests/qemu-iotests/iotests.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 6af503058f..0c69327c00 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -317,10 +317,14 @@ def qemu_img_info(*args: str) -> Any:
def qemu_img_map(*args: str) -> Any:
return qemu_img_json('map', "--output", "json", *args)
-def qemu_img_log(*args: str) -> subprocess.CompletedProcess[str]:
+def qemu_img_log(
+ *args: str,
+ filters: Iterable[Callable[[str], str]] = (),
+) -> subprocess.CompletedProcess[str]:
"""
Logged, unchecked variant of qemu_img() that allows non-zero exit codes.
+ By default, output will be filtered through filter_testfiles().
If logging is perceived to be disabled, this function will fall back
to prohibiting non-zero return codes.
@@ -331,7 +335,7 @@ def qemu_img_log(*args: str) ->
subprocess.CompletedProcess[str]:
:return: a CompletedProcess instance with returncode and console output.
"""
result = qemu_img(*args, check=not logging_enabled())
- log(result.stdout, filters=[filter_testfiles])
+ log(result.stdout, filters=filters or [filter_testfiles])
return result
def img_info_log(filename: str, filter_path: Optional[str] = None,
@@ -345,10 +349,11 @@ def img_info_log(filename: str, filter_path:
Optional[str] = None,
args += extra_args
args.append(filename)
- output = qemu_img(*args, check=False).stdout
if not filter_path:
filter_path = filename
- log(filter_img_info(output, filter_path))
+ qemu_img_log(
+ *args,
+ filters=[lambda output: filter_img_info(output, filter_path)])
def qemu_io_wrap_args(args: Sequence[str]) -> List[str]:
if '-f' in args or '--image-opts' in args:
--
2.34.1
- Re: [PATCH 09/14] iotests: remove remaining calls to qemu_img_pipe(), (continued)
[PATCH 14/14] iotests: make img_info_log() call qemu_img_log(),
John Snow <=
[PATCH 13/14] iotests: make qemu_img_log() check log level, John Snow, 2022/03/08