From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWfG-0001HN-Dy for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfWfA-0004ko-QR for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWfA-0004kR-Hy for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:08 -0400 From: Kevin Wolf Date: Fri, 15 Jun 2012 15:33:18 +0200 Message-Id: <1339767219-24297-19-git-send-email-kwolf@redhat.com> In-Reply-To: <1339767219-24297-1-git-send-email-kwolf@redhat.com> References: <1339767219-24297-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 18/39] qemu-iotests: fill streaming test image with data List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Paolo Bonzini The TestStreamStop test case is racy; if the job completes before we can cancel it, it fails. If we remove the sleep the job will be canceled before it has even started, and the test succeeds but it is also not testing anything interesting. But if the image is left sparse, then the job has really nothing to do. For qcow2 it will read one L2-table, for raw it will issue a bunch of ioctls. This also falls under "not testing anything interesting", and this may be happening right now (depending on the filesystem) since the file protocol got an is_allocated method. Filling the test image with data ensures that the test covers the intended case. It also slows down the test, which will be particularly important after the next patch. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- tests/qemu-iotests/030 | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index eb7bf99..4ab7d62 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -21,6 +21,7 @@ import os import iotests from iotests import qemu_img, qemu_io +import struct backing_img = os.path.join(iotests.test_dir, 'backing.img') mid_img = os.path.join(iotests.test_dir, 'mid.img') @@ -48,11 +49,21 @@ class ImageStreamingTestCase(iotests.QMPTestCase): self.assert_no_active_streams() + def create_image(self, name, size): + file = open(name, 'w') + i = 0 + while i < size: + sector = struct.pack('>l504xl', i / 512, i / 512) + file.write(sector) + i = i + 512 + file.close() + + class TestSingleDrive(ImageStreamingTestCase): image_len = 1 * 1024 * 1024 # MB def setUp(self): - qemu_img('create', backing_img, str(TestSingleDrive.image_len)) + self.create_image(backing_img, TestSingleDrive.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) self.vm = iotests.VM().add_drive(test_img) -- 1.7.6.5