From patchwork Wed Jun 6 14:23:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 163385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 34116B6F77 for ; Thu, 7 Jun 2012 00:24:06 +1000 (EST) Received: from localhost ([::1]:60626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScH9X-00089Z-UY for incoming@patchwork.ozlabs.org; Wed, 06 Jun 2012 10:24:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScH9G-0007qv-A9 for qemu-devel@nongnu.org; Wed, 06 Jun 2012 10:23:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScH9A-0003gF-Jj for qemu-devel@nongnu.org; Wed, 06 Jun 2012 10:23:45 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:45173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScH9A-0003fn-AN for qemu-devel@nongnu.org; Wed, 06 Jun 2012 10:23:40 -0400 Received: by dadv2 with SMTP id v2so9621096dad.4 for ; Wed, 06 Jun 2012 07:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=gSwtPvlZbguvmhLG1MCbGhZ3xX8+4TuahXm6fXMUPvU=; b=LleZaul0HGhm0UzeuWzcArLFm9SSWg8lci7Gb6t3wP9lKunIi+D6nNwpnPFOeDaXM1 FyB0+/xj6yUZ/hkTrJBsrhOiTsFHB8IFp8a8qKiCu4TK73n04HYzmzIFgrZ9jvhz1PjQ OMOtbs2nAH1ajOk4YkuLcd4FOo1nNtR4X+IDWMYacP/Bpkqm6KoMo9ZAJIcxaQeiEIPz nyNl+VrBC00jsn1JiwWWUrnhPTFi5cuDosn1dszPBq2DuM7+tatfh9WM8isa3x3A/JE2 ViILvDWd6acZJ/20IZ4z+BbFWyRcMmPg7z6FXXUckM+X4pgqthmu3msAoQVRaQPvKLKV RsJQ== Received: by 10.68.228.136 with SMTP id si8mr46790515pbc.159.1338992618079; Wed, 06 Jun 2012 07:23:38 -0700 (PDT) Received: from yakj.usersys.redhat.com (222-151-096-013.jp.fiberbit.net. [222.151.96.13]) by mx.google.com with ESMTPS id rv5sm537631pbc.56.2012.06.06.07.23.34 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 06 Jun 2012 07:23:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 6 Jun 2012 16:23:26 +0200 Message-Id: <1338992607-12388-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1338992607-12388-1-git-send-email-pbonzini@redhat.com> References: <1338992607-12388-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH v2 1/2] qemu-iotests: fill streaming test image with data X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- tests/qemu-iotests/030 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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)