From patchwork Thu Mar 17 17:51:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 8613571 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 88A6CC0553 for ; Thu, 17 Mar 2016 17:52:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECEBB202F2 for ; Thu, 17 Mar 2016 17:52:23 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 3DAC3202F0 for ; Thu, 17 Mar 2016 17:52:23 +0000 (UTC) Received: from localhost ([::1]:37148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agc5u-0000vP-N2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Mar 2016 13:52:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agc5a-0000ir-Vb for qemu-devel@nongnu.org; Thu, 17 Mar 2016 13:52:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agc5Z-0006rt-SZ for qemu-devel@nongnu.org; Thu, 17 Mar 2016 13:52:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agc5X-0006r0-Sj; Thu, 17 Mar 2016 13:51:59 -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 (Postfix) with ESMTPS id 76932711C5; Thu, 17 Mar 2016 17:51:59 +0000 (UTC) Received: from t530wlan.home.berrange.com.com (vpn1-7-40.ams2.redhat.com [10.36.7.40]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2HHpol4009388; Thu, 17 Mar 2016 13:51:58 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 17 Mar 2016 17:51:39 +0000 Message-Id: <1458237102-16204-5-git-send-email-berrange@redhat.com> In-Reply-To: <1458237102-16204-1-git-send-email-berrange@redhat.com> References: <1458237102-16204-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 17 Mar 2016 17:51:59 +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 Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org Subject: [Qemu-devel] [PATCH v5 4/7] tests: refactor python I/O tests helper main method 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The iotests.py helper provides a main() method for running tests via the python unit test framework. Not all tests will want to use this, so refactor it to split the testing of compatible formats and platforms into separate helper methods Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- tests/qemu-iotests/iotests.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5f82bbe..51e53bb 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -29,7 +29,8 @@ import qtest import struct __all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io', - 'VM', 'QMPTestCase', 'notrun', 'main'] + 'VM', 'QMPTestCase', 'notrun', 'main', 'verify_image_format', + 'verify_platform'] # This will not work if arguments contain spaces but is necessary if we # want to support the override options that ./check supports. @@ -394,17 +395,22 @@ def notrun(reason): print '%s not run: %s' % (seq, reason) sys.exit(0) -def main(supported_fmts=[], supported_oses=['linux']): - '''Run tests''' - - debug = '-d' in sys.argv - verbosity = 1 +def verify_image_format(supported_fmts=[]): if supported_fmts and (imgfmt not in supported_fmts): notrun('not suitable for this image format: %s' % imgfmt) +def verify_platform(supported_oses=['linux']): if True not in [sys.platform.startswith(x) for x in supported_oses]: notrun('not suitable for this OS: %s' % sys.platform) +def main(supported_fmts=[], supported_oses=['linux']): + '''Run tests''' + + debug = '-d' in sys.argv + verbosity = 1 + verify_image_format(supported_fmts) + verify_platform(supported_oses) + # We need to filter out the time taken from the output so that qemu-iotest # can reliably diff the results against master output. import StringIO