qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 4/4] iotests: Skip read and write in 040 for length=


From: Max Reitz
Subject: [Qemu-devel] [PATCH 4/4] iotests: Skip read and write in 040 for length=0
Date: Sat, 12 Jul 2014 00:23:07 +0200

Do not prevent to actually do a meaningful comparison after the commit
in case the backing image has a length of zero: The reason qemu-io does
not return "verification failed" in these tests is simply that it
returns "I/O error" instead. Therefore, it's better to skip these
comparisons instead of pretending they'd be useful.

Furthermore, do not write anything to the backing file in case its
length should be zero: As of "block: Correct bs->growable", raw images
are growable which means the backing file will no longer have a length
of zero after something has been written to it. Thus the write operation
should be skipped in order to actually test a commit operation on a
zero-length backing file.

Signed-off-by: Max Reitz <address@hidden>
---
 tests/qemu-iotests/040 | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
index f1e16c1..4accd3e 100755
--- a/tests/qemu-iotests/040
+++ b/tests/qemu-iotests/040
@@ -78,7 +78,8 @@ class TestSingleDrive(ImageCommitTestCase):
         iotests.create_image(backing_img, self.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % 
backing_img, mid_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % 
mid_img, test_img)
-        qemu_io('-c', 'write -P 0xab 0 524288', backing_img)
+        if self.image_len > 0:
+            qemu_io('-c', 'write -P 0xab 0 524288', backing_img)
         qemu_io('-c', 'write -P 0xef 524288 524288', mid_img)
         self.vm = iotests.VM().add_drive(test_img)
         self.vm.launch()
@@ -91,8 +92,9 @@ class TestSingleDrive(ImageCommitTestCase):
 
     def test_commit(self):
         self.run_commit_test(mid_img, backing_img)
-        self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', 
backing_img).find("verification failed"))
-        self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', 
backing_img).find("verification failed"))
+        if self.image_len > 0:
+            self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', 
backing_img).find("verification failed"))
+            self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', 
backing_img).find("verification failed"))
 
     def test_device_not_found(self):
         result = self.vm.qmp('block-commit', device='nonexistent', top='%s' % 
mid_img)
@@ -118,13 +120,15 @@ 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('-c', 'read -P 0xab 0 524288', 
backing_img).find("verification failed"))
-        self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', 
backing_img).find("verification failed"))
+        if self.image_len > 0:
+            self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', 
backing_img).find("verification failed"))
+            self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', 
backing_img).find("verification failed"))
 
     def test_top_is_default_active(self):
         self.run_default_commit_test()
-        self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', 
backing_img).find("verification failed"))
-        self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', 
backing_img).find("verification failed"))
+        if self.image_len > 0:
+            self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', 
backing_img).find("verification failed"))
+            self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', 
backing_img).find("verification failed"))
 
     def test_top_and_base_reversed(self):
         self.assert_no_active_block_jobs()
-- 
2.0.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]