All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
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	[thread overview]
Message-ID: <1405117387-25539-5-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1405117387-25539-1-git-send-email-mreitz@redhat.com>

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 <mreitz@redhat.com>
---
 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

  parent reply	other threads:[~2014-07-11 22:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11 22:23 [Qemu-devel] [PATCH 0/4] block: Warn about usage of growing formats over non-growable protocols Max Reitz
2014-07-11 22:23 ` [Qemu-devel] [PATCH 1/4] block: Correct bs->growable Max Reitz
2014-08-20 11:40   ` Kevin Wolf
2014-08-20 19:13     ` Max Reitz
2014-08-21  8:19       ` Kevin Wolf
2014-08-22 13:26         ` Max Reitz
2014-09-04 20:01     ` Max Reitz
2014-09-05 10:01       ` Kevin Wolf
2014-09-05 12:46         ` Max Reitz
2014-09-05 13:13           ` Kevin Wolf
2014-07-11 22:23 ` [Qemu-devel] [PATCH 2/4] block: Introduce requires_growing_file Max Reitz
2014-07-11 22:23 ` [Qemu-devel] [PATCH 3/4] iotests: Make some qemu-io commands read-only Max Reitz
2014-07-11 22:23 ` Max Reitz [this message]
2014-08-15 15:23 ` [Qemu-devel] [PATCH 0/4] block: Warn about usage of growing formats over non-growable protocols Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405117387-25539-5-git-send-email-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.