[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/14] iotests: Don't check qemu_io() output for specific error st
From: |
Hanna Reitz |
Subject: |
[PULL 04/14] iotests: Don't check qemu_io() output for specific error strings |
Date: |
Mon, 25 Apr 2022 16:08:11 +0200 |
From: John Snow <jsnow@redhat.com>
A forthcoming commit updates qemu_io() to raise an exception on non-zero
return by default, and changes its return type.
In preparation, simplify some calls to qemu_io() that assert that
specific error message strings do not appear in qemu-io's
output. Asserting that all of these calls return a status code of zero
will be a more robust way to guard against failure.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220418211504.943969-4-jsnow@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
tests/qemu-iotests/040 | 33 ++++++++++++++++-----------------
tests/qemu-iotests/056 | 2 +-
2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
index 0e1cfd7e49..adf5815781 100755
--- a/tests/qemu-iotests/040
+++ b/tests/qemu-iotests/040
@@ -101,13 +101,13 @@ class TestSingleDrive(ImageCommitTestCase):
def test_commit(self):
self.run_commit_test(mid_img, backing_img)
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0
524288', backing_img).find("verification failed"))
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288
524288', backing_img).find("verification failed"))
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
def test_commit_node(self):
self.run_commit_test("mid", "base", node_names=True)
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0
524288', backing_img).find("verification failed"))
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288
524288', backing_img).find("verification failed"))
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
@iotests.skip_if_unsupported(['throttle'])
def test_commit_with_filter_and_quit(self):
@@ -192,13 +192,13 @@ class TestSingleDrive(ImageCommitTestCase):
def test_top_is_active(self):
self.run_commit_test(test_img, backing_img, need_ready=True)
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0
524288', backing_img).find("verification failed"))
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288
524288', backing_img).find("verification failed"))
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
def test_top_is_default_active(self):
self.run_default_commit_test()
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0
524288', backing_img).find("verification failed"))
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288
524288', backing_img).find("verification failed"))
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
def test_top_and_base_reversed(self):
self.assert_no_active_block_jobs()
@@ -334,8 +334,8 @@ class TestRelativePaths(ImageCommitTestCase):
def test_commit(self):
self.run_commit_test(self.mid_img, self.backing_img)
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0
524288', self.backing_img_abs).find("verification failed"))
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288
524288', self.backing_img_abs).find("verification failed"))
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288',
self.backing_img_abs)
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288',
self.backing_img_abs)
def test_device_not_found(self):
result = self.vm.qmp('block-commit', device='nonexistent', top='%s' %
self.mid_img)
@@ -361,8 +361,8 @@ class TestRelativePaths(ImageCommitTestCase):
def test_top_is_active(self):
self.run_commit_test(self.test_img, self.backing_img)
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0
524288', self.backing_img_abs).find("verification failed"))
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288
524288', self.backing_img_abs).find("verification failed"))
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288',
self.backing_img_abs)
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288',
self.backing_img_abs)
def test_top_and_base_reversed(self):
self.assert_no_active_block_jobs()
@@ -738,11 +738,10 @@ class TestCommitWithFilters(iotests.QMPTestCase):
def do_test_io(self, read_or_write):
for index, pattern_file in enumerate(self.pattern_files):
- result = qemu_io('-f', iotests.imgfmt,
- '-c',
- f'{read_or_write} -P {index + 1} {index}M 1M',
- pattern_file)
- self.assertFalse('Pattern verification failed' in result)
+ qemu_io('-f', iotests.imgfmt,
+ '-c',
+ f'{read_or_write} -P {index + 1} {index}M 1M',
+ pattern_file)
@iotests.skip_if_unsupported(['throttle'])
def setUp(self):
diff --git a/tests/qemu-iotests/056 b/tests/qemu-iotests/056
index b459a3f1e8..bef865eec4 100755
--- a/tests/qemu-iotests/056
+++ b/tests/qemu-iotests/056
@@ -102,7 +102,7 @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase):
self.vm.shutdown()
time.sleep(1)
- self.assertEqual(-1, qemu_io('-c', 'read -P0x41 0 512',
target_img).find("verification failed"))
+ qemu_io('-c', 'read -P0x41 0 512', target_img)
class TestBeforeWriteNotifier(iotests.QMPTestCase):
def setUp(self):
--
2.35.1
- [PULL 00/14] Block patches, Hanna Reitz, 2022/04/25
- [PULL 01/14] block: add 'force' parameter to 'blockdev-change-medium' command, Hanna Reitz, 2022/04/25
- [PULL 02/14] iotests: replace calls to log(qemu_io(...)) with qemu_io_log(), Hanna Reitz, 2022/04/25
- [PULL 03/14] iotests/163: Fix broken qemu-io invocation, Hanna Reitz, 2022/04/25
- [PULL 04/14] iotests: Don't check qemu_io() output for specific error strings,
Hanna Reitz <=
- [PULL 05/14] iotests/040: Don't check image pattern on zero-length image, Hanna Reitz, 2022/04/25
- [PULL 06/14] iotests/040: Fix TestCommitWithFilters test, Hanna Reitz, 2022/04/25
- [PULL 07/14] iotests: create generic qemu_tool() function, Hanna Reitz, 2022/04/25
- [PULL 09/14] iotests/migration-permissions: use assertRaises() for qemu_io() negative test, Hanna Reitz, 2022/04/25
- [PULL 08/14] iotests: rebase qemu_io() on top of qemu_tool(), Hanna Reitz, 2022/04/25
- [PULL 10/14] iotests/image-fleecing: switch to qemu_io(), Hanna Reitz, 2022/04/25
- [PULL 12/14] iotests: remove qemu_io_silent() and qemu_io_silent_check()., Hanna Reitz, 2022/04/25
- [PULL 13/14] iotests: make qemu_io_log() check return codes by default, Hanna Reitz, 2022/04/25
- [PULL 11/14] iotests: remove qemu_io_pipe_and_status(), Hanna Reitz, 2022/04/25
- [PULL 14/14] iotests/108: Fix when missing user_allow_other, Hanna Reitz, 2022/04/25