[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 18/18] iotests: make qemu_img_log and img_info_log raise on er
From: |
John Snow |
Subject: |
[PATCH v4 18/18] iotests: make qemu_img_log and img_info_log raise on error |
Date: |
Thu, 17 Mar 2022 19:49:37 -0400 |
Add a `check: bool = True` parameter to both functions and make their
qemu_img() invocations raise on error by default.
users of img_info_log:
206, 207, 210, 211, 212, 213, 237, 242, 266, 274, 302
users of qemu_img_log:
044, 209, 274, 302, 304
iotests 242 and 266 need to use check=False for their negative tests.
iotests 206, 210, 211, 212, 213, 237, 274 and 302 continue working
normally.
As of this commit, all calls to QEMU_IMG made from iotests enforce a
return code of zero by default unless explicitly disabled or suppressed
by passing check=False or with an exception handler.
Signed-off-by: John Snow <jsnow@redhat.com>
---
tests/qemu-iotests/242 | 2 +-
tests/qemu-iotests/266 | 2 +-
tests/qemu-iotests/iotests.py | 8 +++++---
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
index 547bf382e3..b3afd36d72 100755
--- a/tests/qemu-iotests/242
+++ b/tests/qemu-iotests/242
@@ -100,7 +100,7 @@ add_bitmap(1, True, False)
log('Write an unknown bitmap flag \'{}\' into a new QCOW2 image at offset {}'
.format(hex(bitmap_flag_unknown), flag_offset))
toggle_flag(flag_offset)
-img_info_log(disk)
+img_info_log(disk, check=False)
toggle_flag(flag_offset)
log('Unset the unknown bitmap flag \'{}\' in the bitmap directory entry:\n'
.format(hex(bitmap_flag_unknown)))
diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266
index 71ce81d0df..8fc3807ac5 100755
--- a/tests/qemu-iotests/266
+++ b/tests/qemu-iotests/266
@@ -137,7 +137,7 @@ def main():
iotests.log('')
vm.shutdown()
- iotests.img_info_log(file_path)
+ iotests.img_info_log(file_path, check=False)
iotests.script_main(main,
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index c75c7470e2..6cd8374c81 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -311,13 +311,15 @@ 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]:
- result = qemu_img(*args, check=False)
+def qemu_img_log(*args: str, check: bool = True
+ ) -> subprocess.CompletedProcess[str]:
+ result = qemu_img(*args, check=check)
log(result.stdout, filters=[filter_testfiles])
return result
def img_info_log(filename: str, filter_path: Optional[str] = None,
use_image_opts: bool = False, extra_args: Sequence[str] = (),
+ check: bool = True,
) -> None:
args = ['info']
if use_image_opts:
@@ -327,7 +329,7 @@ def img_info_log(filename: str, filter_path: Optional[str]
= None,
args += extra_args
args.append(filename)
- output = qemu_img(*args, check=False).stdout
+ output = qemu_img(*args, check=check).stdout
if not filter_path:
filter_path = filename
log(filter_img_info(output, filter_path))
--
2.34.1
- [PATCH v4 02/18] python/utils: add VerboseProcessError, (continued)
- [PATCH v4 02/18] python/utils: add VerboseProcessError, John Snow, 2022/03/17
- [PATCH v4 05/18] iotests: fortify compare_images() against crashes, John Snow, 2022/03/17
- [PATCH v4 06/18] iotests: add qemu_img_json(), John Snow, 2022/03/17
- [PATCH v4 08/18] iotests: add qemu_img_info(), John Snow, 2022/03/17
- [PATCH v4 07/18] iotests: use qemu_img_json() when applicable, John Snow, 2022/03/17
- [PATCH v4 10/18] iotests: add qemu_img_map() function, John Snow, 2022/03/17
- [PATCH v4 15/18] iotests: use qemu_img() in has_working_luks(), John Snow, 2022/03/17
- [PATCH v4 01/18] python/utils: add add_visual_margin() text decoration utility, John Snow, 2022/03/17
- [PATCH v4 09/18] iotests/remove-bitmap-from-backing: use qemu_img_info(), John Snow, 2022/03/17
- [PATCH v4 12/18] iotests: replace unchecked calls to qemu_img_pipe(), John Snow, 2022/03/17
- [PATCH v4 18/18] iotests: make qemu_img_log and img_info_log raise on error,
John Snow <=
- [PATCH v4 04/18] iotests: make qemu_img raise on non-zero rc by default, John Snow, 2022/03/17
- [PATCH v4 17/18] iotests: remove qemu_img_pipe_and_status(), John Snow, 2022/03/17
- [PATCH v4 16/18] iotests: replace qemu_img_log('create', ...) calls, John Snow, 2022/03/17
- [PATCH v4 11/18] iotests: change supports_quorum to use qemu_img, John Snow, 2022/03/17
- [PATCH v4 13/18] iotests/149: Remove qemu_img_pipe() call, John Snow, 2022/03/17
- [PATCH v4 14/18] iotests: remove remaining calls to qemu_img_pipe(), John Snow, 2022/03/17
- Re: [PATCH v4 00/18] iotests: add enhanced debugging info to qemu-img failures, Hanna Reitz, 2022/03/18