From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5jDx-0005Q2-P6 for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X5jDr-0002W9-K8 for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17957) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5jDr-0002Vc-Bv for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:19 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6BMNHh8012926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 11 Jul 2014 18:23:18 -0400 From: Max Reitz Date: Sat, 12 Jul 2014 00:23:07 +0200 Message-Id: <1405117387-25539-5-git-send-email-mreitz@redhat.com> In-Reply-To: <1405117387-25539-1-git-send-email-mreitz@redhat.com> References: <1405117387-25539-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 4/4] iotests: Skip read and write in 040 for length=0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz 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 --- 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