From patchwork Mon Jul 11 19:50:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: clord@redhat.com X-Patchwork-Id: 9224033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8364060760 for ; Mon, 11 Jul 2016 19:51:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71B0A27D76 for ; Mon, 11 Jul 2016 19:51:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6649927E66; Mon, 11 Jul 2016 19:51:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1EF4527D76 for ; Mon, 11 Jul 2016 19:51:17 +0000 (UTC) Received: from localhost ([::1]:35803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMhEa-0002PI-4G for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Jul 2016 15:51:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMhE5-0002LF-Od for qemu-devel@nongnu.org; Mon, 11 Jul 2016 15:50:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMhE4-00040P-VH for qemu-devel@nongnu.org; Mon, 11 Jul 2016 15:50:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMhE0-0003z9-Oi; Mon, 11 Jul 2016 15:50:40 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4DCF063E28; Mon, 11 Jul 2016 19:50:40 +0000 (UTC) Received: from dhcp-17-138.bos.redhat.com (dhcp-17-130.bos.redhat.com [10.18.17.130]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6BJobLF008248; Mon, 11 Jul 2016 15:50:39 -0400 From: Colin Lord To: qemu-devel@nongnu.org Date: Mon, 11 Jul 2016 15:50:35 -0400 Message-Id: <1468266636-16861-3-git-send-email-clord@redhat.com> In-Reply-To: <1468266636-16861-1-git-send-email-clord@redhat.com> References: <1468266636-16861-1-git-send-email-clord@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 11 Jul 2016 19:50:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] iotests: Add python functions for using sample images X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Colin Lord , qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This adds a python equivalent of the _use_sample_img and _rm_sample_img testing functions. Signed-off-by: Colin Lord --- tests/qemu-iotests/iotests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 1687c33..3ba0de2 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -29,6 +29,7 @@ import qmp import qtest import struct import json +import bz2 # This will not work if arguments contain spaces but is necessary if we @@ -53,6 +54,20 @@ cachemode = os.environ.get('CACHEMODE') qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') +sample_img_dir = os.environ.get('SAMPLE_IMG_DIR') + +def use_sample_image(sample_image_file): + sample_img_path = os.path.join(sample_img_dir, sample_image_file + '.bz2') + sample_img_file = bz2.BZ2File(sample_img_path) + output_img_path = os.path.join(test_dir, sample_image_file) + output_img = open(output_img_path, 'wb') + output_img.write(sample_img_file.read()) + sample_img_file.close() + output_img.close() + return output_img_path + +def rm_test_image(test_image): + os.remove(test_image) def qemu_img(*args): '''Run qemu-img and return the exit code'''