From patchwork Thu Aug 1 15:17:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 11070891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3815F13A0 for ; Thu, 1 Aug 2019 15:19:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28861202A5 for ; Thu, 1 Aug 2019 15:19:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C647285FB; Thu, 1 Aug 2019 15:19:24 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 480F0202A5 for ; Thu, 1 Aug 2019 15:19:23 +0000 (UTC) Received: from localhost ([::1]:56696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htCrS-0006hn-Cf for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Aug 2019 11:19:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36083) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htCqC-0005BT-T2 for qemu-devel@nongnu.org; Thu, 01 Aug 2019 11:18:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htCqB-0000k4-3C for qemu-devel@nongnu.org; Thu, 01 Aug 2019 11:18:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34584) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1htCq7-0000i7-5w; Thu, 01 Aug 2019 11:17:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C1853002F44; Thu, 1 Aug 2019 15:17:58 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-98.ams2.redhat.com [10.36.117.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7DA062675; Thu, 1 Aug 2019 15:17:52 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 1 Aug 2019 17:17:43 +0200 Message-Id: <20190801151744.798-3-kwolf@redhat.com> In-Reply-To: <20190801151744.798-1-kwolf@redhat.com> References: <20190801151744.798-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 01 Aug 2019 15:17:58 +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: Enable -d for Python non-unittest tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@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 The part of iotests.main() that is related to the implementation of the debug option -d and enables QEMU and QMP logging is not only useful in tests that use the Python unittest framework, but also in tests that work by comparing with a reference output. Factor these parts out into iotests.init() and call it from the test cases that currently lack support for debug output. Signed-off-by: Kevin Wolf --- tests/qemu-iotests/194 | 1 + tests/qemu-iotests/202 | 1 + tests/qemu-iotests/203 | 2 ++ tests/qemu-iotests/206 | 1 + tests/qemu-iotests/207 | 1 + tests/qemu-iotests/208 | 1 + tests/qemu-iotests/210 | 1 + tests/qemu-iotests/211 | 1 + tests/qemu-iotests/212 | 1 + tests/qemu-iotests/213 | 1 + tests/qemu-iotests/216 | 2 ++ tests/qemu-iotests/218 | 1 + tests/qemu-iotests/219 | 1 + tests/qemu-iotests/222 | 1 + tests/qemu-iotests/224 | 2 ++ tests/qemu-iotests/228 | 2 ++ tests/qemu-iotests/234 | 2 ++ tests/qemu-iotests/236 | 1 + tests/qemu-iotests/237 | 1 + tests/qemu-iotests/246 | 1 + tests/qemu-iotests/255 | 1 + tests/qemu-iotests/256 | 1 + tests/qemu-iotests/iotests.py | 23 +++++++++++++++-------- 23 files changed, 42 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194 index d746ab1e21..cd6928fbd9 100755 --- a/tests/qemu-iotests/194 +++ b/tests/qemu-iotests/194 @@ -21,6 +21,7 @@ import iotests +iotests.init() iotests.verify_image_format(supported_fmts=['qcow2', 'qed', 'raw']) iotests.verify_platform(['linux']) diff --git a/tests/qemu-iotests/202 b/tests/qemu-iotests/202 index 581ca34d79..86a3b94586 100755 --- a/tests/qemu-iotests/202 +++ b/tests/qemu-iotests/202 @@ -24,6 +24,7 @@ import iotests +iotests.init() iotests.verify_image_format(supported_fmts=['qcow2']) iotests.verify_platform(['linux']) diff --git a/tests/qemu-iotests/203 b/tests/qemu-iotests/203 index 4874a1a0d8..fe25c249fb 100755 --- a/tests/qemu-iotests/203 +++ b/tests/qemu-iotests/203 @@ -27,6 +27,8 @@ import iotests iotests.verify_image_format(supported_fmts=['qcow2']) iotests.verify_platform(['linux']) +iotests.init() + with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.FilePath('disk1.img') as disk1_img_path, \ iotests.VM() as vm: diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206 index 5bb738bf23..481e4b98ea 100755 --- a/tests/qemu-iotests/206 +++ b/tests/qemu-iotests/206 @@ -23,6 +23,7 @@ import iotests from iotests import imgfmt +iotests.init() iotests.verify_image_format(supported_fmts=['qcow2']) def blockdev_create(vm, options): diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 index ec8c1d06f0..57c1e900d2 100755 --- a/tests/qemu-iotests/207 +++ b/tests/qemu-iotests/207 @@ -24,6 +24,7 @@ import iotests import subprocess import re +iotests.init() iotests.verify_image_format(supported_fmts=['raw']) iotests.verify_protocol(supported=['ssh']) diff --git a/tests/qemu-iotests/208 b/tests/qemu-iotests/208 index 1e202388dc..3b2c732cd4 100755 --- a/tests/qemu-iotests/208 +++ b/tests/qemu-iotests/208 @@ -22,6 +22,7 @@ import iotests +iotests.init() iotests.verify_image_format(supported_fmts=['generic']) with iotests.FilePath('disk.img') as disk_img_path, \ diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210 index 565e3b7b9b..a90db1c067 100755 --- a/tests/qemu-iotests/210 +++ b/tests/qemu-iotests/210 @@ -23,6 +23,7 @@ import iotests from iotests import imgfmt +iotests.init() iotests.verify_image_format(supported_fmts=['luks']) iotests.verify_protocol(supported=['file']) diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211 index 6afc894f76..e6a0bef332 100755 --- a/tests/qemu-iotests/211 +++ b/tests/qemu-iotests/211 @@ -23,6 +23,7 @@ import iotests from iotests import imgfmt +iotests.init() iotests.verify_image_format(supported_fmts=['vdi']) iotests.verify_protocol(supported=['file']) diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212 index 42b74f208b..865674191c 100755 --- a/tests/qemu-iotests/212 +++ b/tests/qemu-iotests/212 @@ -23,6 +23,7 @@ import iotests from iotests import imgfmt +iotests.init() iotests.verify_image_format(supported_fmts=['parallels']) iotests.verify_protocol(supported=['file']) diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213 index 5604f3cebb..8fb94147ff 100755 --- a/tests/qemu-iotests/213 +++ b/tests/qemu-iotests/213 @@ -23,6 +23,7 @@ import iotests from iotests import imgfmt +iotests.init() iotests.verify_image_format(supported_fmts=['vhdx']) iotests.verify_protocol(supported=['file']) diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216 index 3c0ae54b44..adcb487fb4 100755 --- a/tests/qemu-iotests/216 +++ b/tests/qemu-iotests/216 @@ -22,6 +22,8 @@ import iotests from iotests import log, qemu_img, qemu_io_silent +iotests.init() + # Need backing file support iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk']) iotests.verify_platform(['linux']) diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218 index 2554d84581..18639020ee 100755 --- a/tests/qemu-iotests/218 +++ b/tests/qemu-iotests/218 @@ -29,6 +29,7 @@ import iotests from iotests import log, qemu_img, qemu_io_silent +iotests.init() iotests.verify_image_format(supported_fmts=['qcow2', 'raw']) diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219 index e0c51662c0..c7265d12c5 100755 --- a/tests/qemu-iotests/219 +++ b/tests/qemu-iotests/219 @@ -21,6 +21,7 @@ import iotests +iotests.init() iotests.verify_image_format(supported_fmts=['qcow2']) img_size = 4 * 1024 * 1024 diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222 index 0ead56d574..bb2b8cc78a 100644 --- a/tests/qemu-iotests/222 +++ b/tests/qemu-iotests/222 @@ -24,6 +24,7 @@ import iotests from iotests import log, qemu_img, qemu_io, qemu_io_silent +iotests.init() iotests.verify_platform(['linux']) iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', 'vhdx', 'raw']) diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224 index b4dfaa639f..00013473a8 100755 --- a/tests/qemu-iotests/224 +++ b/tests/qemu-iotests/224 @@ -25,6 +25,8 @@ from iotests import log, qemu_img, qemu_io_silent, filter_qmp_testfiles, \ filter_qmp_imgfmt import json +iotests.init() + # Need backing file support (for arbitrary backing formats) iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed']) iotests.verify_platform(['linux']) diff --git a/tests/qemu-iotests/228 b/tests/qemu-iotests/228 index 9a50afd205..9b9acf8be5 100755 --- a/tests/qemu-iotests/228 +++ b/tests/qemu-iotests/228 @@ -24,6 +24,8 @@ import iotests from iotests import log, qemu_img, filter_testfiles, filter_imgfmt, \ filter_qmp_testfiles, filter_qmp_imgfmt +iotests.init() + # Need backing file and change-backing-file support iotests.verify_image_format(supported_fmts=['qcow2', 'qed']) iotests.verify_platform(['linux']) diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234 index 34c818c485..17c03d2f6a 100755 --- a/tests/qemu-iotests/234 +++ b/tests/qemu-iotests/234 @@ -26,6 +26,8 @@ import os iotests.verify_image_format(supported_fmts=['qcow2']) iotests.verify_platform(['linux']) +iotests.init() + with iotests.FilePath('img') as img_path, \ iotests.FilePath('backing') as backing_path, \ iotests.FilePath('mig_fifo_a') as fifo_a, \ diff --git a/tests/qemu-iotests/236 b/tests/qemu-iotests/236 index 79a6381f8e..15ef48f0b6 100755 --- a/tests/qemu-iotests/236 +++ b/tests/qemu-iotests/236 @@ -22,6 +22,7 @@ import iotests from iotests import log +iotests.init() iotests.verify_image_format(supported_fmts=['generic']) size = 64 * 1024 * 1024 granularity = 64 * 1024 diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237 index 06897f8c87..cbaaeed9eb 100755 --- a/tests/qemu-iotests/237 +++ b/tests/qemu-iotests/237 @@ -24,6 +24,7 @@ import math import iotests from iotests import imgfmt +iotests.init() iotests.verify_image_format(supported_fmts=['vmdk']) def blockdev_create(vm, options): diff --git a/tests/qemu-iotests/246 b/tests/qemu-iotests/246 index b0997a392f..7f6da5dced 100755 --- a/tests/qemu-iotests/246 +++ b/tests/qemu-iotests/246 @@ -22,6 +22,7 @@ import iotests from iotests import log +iotests.init() iotests.verify_image_format(supported_fmts=['qcow2']) size = 64 * 1024 * 1024 * 1024 gran_small = 32 * 1024 diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255 index 3632d507d0..099617ab59 100755 --- a/tests/qemu-iotests/255 +++ b/tests/qemu-iotests/255 @@ -23,6 +23,7 @@ import iotests from iotests import imgfmt +iotests.init() iotests.verify_image_format(supported_fmts=['qcow2']) def blockdev_create(vm, options): diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256 index c594a43205..e15f1b1a8a 100755 --- a/tests/qemu-iotests/256 +++ b/tests/qemu-iotests/256 @@ -23,6 +23,7 @@ import os import iotests from iotests import log +iotests.init() iotests.verify_image_format(supported_fmts=['qcow2']) size = 64 * 1024 * 1024 diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 91172c39a5..f2ad2b9749 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -858,10 +858,7 @@ def skip_if_unsupported(required_formats=[], read_only=False): return func_wrapper return skip_test_decorator -def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[], - unsupported_fmts=[]): - '''Run tests''' - +def init(): global debug # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to @@ -873,7 +870,19 @@ def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[], sys.exit(os.EX_USAGE) debug = '-d' in sys.argv - verbosity = 1 + if debug: + sys.argv.remove('-d') + + logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN)) + +def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[], + unsupported_fmts=[]): + '''Run tests''' + + global debug + + init() + verify_image_format(supported_fmts, unsupported_fmts) verify_platform(supported_oses) verify_cache_mode(supported_cache_modes) @@ -881,8 +890,8 @@ def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[], if debug: output = sys.stdout verbosity = 2 - sys.argv.remove('-d') else: + verbosity = 1 # We need to filter out the time taken from the output so that # qemu-iotest can reliably diff the results against master output. if sys.version_info.major >= 3: @@ -892,8 +901,6 @@ def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[], # 2.x's test runner emits. output = io.BytesIO() - logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN)) - class MyTestRunner(unittest.TextTestRunner): def __init__(self, stream=output, descriptions=True, verbosity=verbosity): unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity)