From patchwork Wed Oct 30 09:23:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 287172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E9B902C0366 for ; Wed, 30 Oct 2013 20:24:32 +1100 (EST) Received: from localhost ([::1]:51130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbS0s-0007lI-BC for incoming@patchwork.ozlabs.org; Wed, 30 Oct 2013 05:24:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbS0W-0007l1-VE for qemu-devel@nongnu.org; Wed, 30 Oct 2013 05:24:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbS0M-0002pW-HU for qemu-devel@nongnu.org; Wed, 30 Oct 2013 05:24:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbS0M-0002pB-9x for qemu-devel@nongnu.org; Wed, 30 Oct 2013 05:23:58 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9U9Nu9t031096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 30 Oct 2013 05:23:57 -0400 Received: from T430s.nay.redhat.com ([10.66.4.130]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9U9Nsc0004298; Wed, 30 Oct 2013 05:23:55 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 30 Oct 2013 17:23:54 +0800 Message-Id: <1383125034-32669-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH] qemu-iotests: drop duplicated "create_image" 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 There's a same common function in iotests.py Signed-off-by: Fam Zheng --- tests/qemu-iotests/040 | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index aad535a..a2e18c5 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -54,22 +54,12 @@ class ImageCommitTestCase(iotests.QMPTestCase): self.assert_no_active_commit() - 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(ImageCommitTestCase): image_len = 1 * 1024 * 1024 test_len = 1 * 1024 * 256 def setUp(self): - self.create_image(backing_img, TestSingleDrive.image_len) + iotests.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) qemu_io('-c', 'write -P 0xab 0 524288', backing_img) @@ -167,7 +157,7 @@ class TestRelativePaths(ImageCommitTestCase): except OSError as exception: if exception.errno != errno.EEXIST: raise - self.create_image(self.backing_img_abs, TestRelativePaths.image_len) + iotests.create_image(self.backing_img_abs, TestRelativePaths.image_len) qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.backing_img_abs, self.mid_img_abs) qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.mid_img_abs, self.test_img) qemu_img('rebase', '-u', '-b', self.backing_img, self.mid_img_abs)