From nobody Tue May 7 09:58:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566345314; cv=none; d=zoho.com; s=zohoarc; b=hnW57GUNgW9yzCSR4acUScv4FK3vdrUn0HvECjU5o4vyxAwEtsPATz0T2rkDFKLLiDWu3i0BizTUTo8AXKw0gZSKpy9ekeupQ5nNwQD778IIAb2pGuFQ7dLk7qZusOPxP23WYtafAMjcoMgZmkuSra8Cdsc2IjSylPXTUqsdcQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566345314; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=THpoCOQa+RryFahrTUyPpVhNSIw2jA+zM3jQ6i9cdhw=; b=aBB0BEp6yn8y7yFsRrvSby2RcVwzui9FdJqPRSD+g0ZJiQ282AasFGDgM+RDnlHcpj43suMURM1kSL2uSZNjuJxzYrYdytVzHFvLa9L0L74PC3U4LLTfFwCgHD7JmiY551bZ6+xqZSWlvVGX1/ra8IB66gCMSRVsCiv1Ev468Z8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566345314506159.9195280126944; Tue, 20 Aug 2019 16:55:14 -0700 (PDT) Received: from localhost ([::1]:42850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Dxz-0004sJ-Ql for importer@patchew.org; Tue, 20 Aug 2019 19:55:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48799) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Dvu-0002ax-QI for qemu-devel@nongnu.org; Tue, 20 Aug 2019 19:53:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0Dvq-00055W-In for qemu-devel@nongnu.org; Tue, 20 Aug 2019 19:52:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i0Dvk-0004zV-Vs; Tue, 20 Aug 2019 19:52:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D6A14E925; Tue, 20 Aug 2019 23:52:48 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8389A57990; Tue, 20 Aug 2019 23:52:47 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Tue, 20 Aug 2019 19:52:40 -0400 Message-Id: <20190820235243.26092-2-jsnow@redhat.com> In-Reply-To: <20190820235243.26092-1-jsnow@redhat.com> References: <20190820235243.26092-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 20 Aug 2019 23:52:48 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v3 1/4] iotests: add script_initialize 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: Kevin Wolf , John Snow , ehabkost@redhat.com, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Like script_main, but doesn't require a single point of entry. Replace all existing initialization sections with this drop-in replacement. This brings debug support to all existing script-style iotests. Note: supported_oses=3D['linux'] was omitted, as it is a default argument. --- tests/qemu-iotests/149 | 3 +- tests/qemu-iotests/194 | 3 +- tests/qemu-iotests/202 | 3 +- tests/qemu-iotests/203 | 3 +- tests/qemu-iotests/206 | 2 +- tests/qemu-iotests/207 | 2 +- tests/qemu-iotests/208 | 2 +- tests/qemu-iotests/209 | 2 +- tests/qemu-iotests/210 | 2 +- tests/qemu-iotests/211 | 2 +- tests/qemu-iotests/212 | 2 +- tests/qemu-iotests/213 | 2 +- tests/qemu-iotests/216 | 3 +- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/219 | 2 +- tests/qemu-iotests/222 | 5 ++- tests/qemu-iotests/224 | 3 +- tests/qemu-iotests/228 | 3 +- tests/qemu-iotests/234 | 3 +- tests/qemu-iotests/235 | 4 +-- tests/qemu-iotests/236 | 2 +- tests/qemu-iotests/237 | 2 +- tests/qemu-iotests/238 | 2 ++ tests/qemu-iotests/242 | 2 +- tests/qemu-iotests/246 | 2 +- tests/qemu-iotests/248 | 2 +- tests/qemu-iotests/254 | 2 +- tests/qemu-iotests/255 | 2 +- tests/qemu-iotests/256 | 2 +- tests/qemu-iotests/262 | 3 +- tests/qemu-iotests/iotests.py | 58 +++++++++++++++++++++++------------ 31 files changed, 71 insertions(+), 61 deletions(-) diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149 index 4f363f295f..9fa97966c5 100755 --- a/tests/qemu-iotests/149 +++ b/tests/qemu-iotests/149 @@ -383,8 +383,7 @@ def test_once(config, qemu_img=3DFalse): =20 =20 # Obviously we only work with the luks image format -iotests.verify_image_format(supported_fmts=3D['luks']) -iotests.verify_platform() +iotests.script_initialize(supported_fmts=3D['luks']) =20 # We need sudo in order to run cryptsetup to create # dm-crypt devices. This is safe to use on any diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194 index d746ab1e21..c8aeb6d0e4 100755 --- a/tests/qemu-iotests/194 +++ b/tests/qemu-iotests/194 @@ -21,8 +21,7 @@ =20 import iotests =20 -iotests.verify_image_format(supported_fmts=3D['qcow2', 'qed', 'raw']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2', 'qed', 'raw']) =20 with iotests.FilePath('source.img') as source_img_path, \ iotests.FilePath('dest.img') as dest_img_path, \ diff --git a/tests/qemu-iotests/202 b/tests/qemu-iotests/202 index 581ca34d79..1271ac9459 100755 --- a/tests/qemu-iotests/202 +++ b/tests/qemu-iotests/202 @@ -24,8 +24,7 @@ =20 import iotests =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.FilePath('disk1.img') as disk1_img_path, \ diff --git a/tests/qemu-iotests/203 b/tests/qemu-iotests/203 index 4874a1a0d8..c40fe231ea 100755 --- a/tests/qemu-iotests/203 +++ b/tests/qemu-iotests/203 @@ -24,8 +24,7 @@ =20 import iotests =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.FilePath('disk1.img') as disk1_img_path, \ diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206 index 5bb738bf23..23ff2f624b 100755 --- a/tests/qemu-iotests/206 +++ b/tests/qemu-iotests/206 @@ -23,7 +23,7 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 def blockdev_create(vm, options): result =3D vm.qmp_log('blockdev-create', diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 index ec8c1d06f0..ab9e3b6747 100755 --- a/tests/qemu-iotests/207 +++ b/tests/qemu-iotests/207 @@ -24,7 +24,7 @@ import iotests import subprocess import re =20 -iotests.verify_image_format(supported_fmts=3D['raw']) +iotests.script_initialize(supported_fmts=3D['raw']) iotests.verify_protocol(supported=3D['ssh']) =20 def filter_hash(qmsg): diff --git a/tests/qemu-iotests/208 b/tests/qemu-iotests/208 index 1e202388dc..dfce6f9fe4 100755 --- a/tests/qemu-iotests/208 +++ b/tests/qemu-iotests/208 @@ -22,7 +22,7 @@ =20 import iotests =20 -iotests.verify_image_format(supported_fmts=3D['generic']) +iotests.script_initialize(supported_fmts=3D['generic']) =20 with iotests.FilePath('disk.img') as disk_img_path, \ iotests.FilePath('disk-snapshot.img') as disk_snapshot_img_path, \ diff --git a/tests/qemu-iotests/209 b/tests/qemu-iotests/209 index 259e991ec6..a77f884166 100755 --- a/tests/qemu-iotests/209 +++ b/tests/qemu-iotests/209 @@ -22,7 +22,7 @@ import iotests from iotests import qemu_img_create, qemu_io, qemu_img_verbose, qemu_nbd, \ file_path =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 disk, nbd_sock =3D file_path('disk', 'nbd-sock') nbd_uri =3D 'nbd+unix:///exp?socket=3D' + nbd_sock diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210 index 565e3b7b9b..5a7013cd34 100755 --- a/tests/qemu-iotests/210 +++ b/tests/qemu-iotests/210 @@ -23,7 +23,7 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['luks']) +iotests.script_initialize(supported_fmts=3D['luks']) iotests.verify_protocol(supported=3D['file']) =20 def blockdev_create(vm, options): diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211 index 6afc894f76..4d6aac497f 100755 --- a/tests/qemu-iotests/211 +++ b/tests/qemu-iotests/211 @@ -23,7 +23,7 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['vdi']) +iotests.script_initialize(supported_fmts=3D['vdi']) iotests.verify_protocol(supported=3D['file']) =20 def blockdev_create(vm, options): diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212 index 42b74f208b..ec35bceb11 100755 --- a/tests/qemu-iotests/212 +++ b/tests/qemu-iotests/212 @@ -23,7 +23,7 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['parallels']) +iotests.script_initialize(supported_fmts=3D['parallels']) iotests.verify_protocol(supported=3D['file']) =20 def blockdev_create(vm, options): diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213 index 5604f3cebb..3d2c024375 100755 --- a/tests/qemu-iotests/213 +++ b/tests/qemu-iotests/213 @@ -23,7 +23,7 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['vhdx']) +iotests.script_initialize(supported_fmts=3D['vhdx']) iotests.verify_protocol(supported=3D['file']) =20 def blockdev_create(vm, options): diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216 index 3c0ae54b44..7574bcc09f 100755 --- a/tests/qemu-iotests/216 +++ b/tests/qemu-iotests/216 @@ -23,8 +23,7 @@ import iotests from iotests import log, qemu_img, qemu_io_silent =20 # Need backing file support -iotests.verify_image_format(supported_fmts=3D['qcow2', 'qcow', 'qed', 'vmd= k']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2', 'qcow', 'qed', 'vmdk'= ]) =20 log('') log('=3D=3D=3D Copy-on-read across nodes =3D=3D=3D') diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218 index 2554d84581..e18e31076b 100755 --- a/tests/qemu-iotests/218 +++ b/tests/qemu-iotests/218 @@ -29,7 +29,7 @@ import iotests from iotests import log, qemu_img, qemu_io_silent =20 -iotests.verify_image_format(supported_fmts=3D['qcow2', 'raw']) +iotests.script_initialize(supported_fmts=3D['qcow2', 'raw']) =20 =20 # Launches the VM, adds two null-co nodes (source and target), and diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219 index e0c51662c0..9ae27cb04e 100755 --- a/tests/qemu-iotests/219 +++ b/tests/qemu-iotests/219 @@ -21,7 +21,7 @@ =20 import iotests =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 img_size =3D 4 * 1024 * 1024 =20 diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222 index 0ead56d574..6788979ed3 100644 --- a/tests/qemu-iotests/222 +++ b/tests/qemu-iotests/222 @@ -24,9 +24,8 @@ import iotests from iotests import log, qemu_img, qemu_io, qemu_io_silent =20 -iotests.verify_platform(['linux']) -iotests.verify_image_format(supported_fmts=3D['qcow2', 'qcow', 'qed', 'vmd= k', - 'vhdx', 'raw']) +iotests.script_initialize(supported_fmts=3D['qcow2', 'qcow', 'qed', 'vmdk', + 'vhdx', 'raw']) =20 patterns =3D [("0x5d", "0", "64k"), ("0xd5", "1M", "64k"), diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224 index b4dfaa639f..d0d0c44104 100755 --- a/tests/qemu-iotests/224 +++ b/tests/qemu-iotests/224 @@ -26,8 +26,7 @@ from iotests import log, qemu_img, qemu_io_silent, filter= _qmp_testfiles, \ import json =20 # Need backing file support (for arbitrary backing formats) -iotests.verify_image_format(supported_fmts=3D['qcow2', 'qcow', 'qed']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2', 'qcow', 'qed']) =20 =20 # There are two variations of this test: diff --git a/tests/qemu-iotests/228 b/tests/qemu-iotests/228 index 9a50afd205..9785868ab3 100755 --- a/tests/qemu-iotests/228 +++ b/tests/qemu-iotests/228 @@ -25,8 +25,7 @@ from iotests import log, qemu_img, filter_testfiles, filt= er_imgfmt, \ filter_qmp_testfiles, filter_qmp_imgfmt =20 # Need backing file and change-backing-file support -iotests.verify_image_format(supported_fmts=3D['qcow2', 'qed']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2', 'qed']) =20 =20 def log_node_info(node): diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234 index 34c818c485..3de6ab2341 100755 --- a/tests/qemu-iotests/234 +++ b/tests/qemu-iotests/234 @@ -23,8 +23,7 @@ import iotests import os =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 with iotests.FilePath('img') as img_path, \ iotests.FilePath('backing') as backing_path, \ diff --git a/tests/qemu-iotests/235 b/tests/qemu-iotests/235 index fedd111fd4..9e88c65b93 100755 --- a/tests/qemu-iotests/235 +++ b/tests/qemu-iotests/235 @@ -27,6 +27,8 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '= ..', '..', 'python')) =20 from qemu.machine import QEMUMachine =20 +iotests.script_initialize(supported_fmts=3D['qcow2']) + # Note: # This test was added to check that mirror dead-lock was fixed (see previo= us # commit before this test addition). @@ -40,8 +42,6 @@ from qemu.machine import QEMUMachine =20 size =3D 1 * 1024 * 1024 * 1024 =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) - disk =3D file_path('disk') =20 # prepare source image diff --git a/tests/qemu-iotests/236 b/tests/qemu-iotests/236 index 79a6381f8e..b88779eb0b 100755 --- a/tests/qemu-iotests/236 +++ b/tests/qemu-iotests/236 @@ -22,7 +22,7 @@ import iotests from iotests import log =20 -iotests.verify_image_format(supported_fmts=3D['generic']) +iotests.script_initialize(supported_fmts=3D['generic']) size =3D 64 * 1024 * 1024 granularity =3D 64 * 1024 =20 diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237 index 06897f8c87..3758ace0bc 100755 --- a/tests/qemu-iotests/237 +++ b/tests/qemu-iotests/237 @@ -24,7 +24,7 @@ import math import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['vmdk']) +iotests.script_initialize(supported_fmts=3D['vmdk']) =20 def blockdev_create(vm, options): result =3D vm.qmp_log('blockdev-create', job_id=3D'job0', options=3Dop= tions, diff --git a/tests/qemu-iotests/238 b/tests/qemu-iotests/238 index e5ac2b2ff8..6e27fb40c2 100755 --- a/tests/qemu-iotests/238 +++ b/tests/qemu-iotests/238 @@ -23,6 +23,8 @@ import os import iotests from iotests import log =20 +iotests.script_initialize() + virtio_scsi_device =3D iotests.get_virtio_scsi_device() =20 vm =3D iotests.VM() diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242 index c176e92da6..7c2685b4cc 100755 --- a/tests/qemu-iotests/242 +++ b/tests/qemu-iotests/242 @@ -24,7 +24,7 @@ import struct from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \ file_path, img_info_log, log, filter_qemu_io =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 disk =3D file_path('disk') chunk =3D 256 * 1024 diff --git a/tests/qemu-iotests/246 b/tests/qemu-iotests/246 index b0997a392f..1d7747d62d 100755 --- a/tests/qemu-iotests/246 +++ b/tests/qemu-iotests/246 @@ -22,7 +22,7 @@ import iotests from iotests import log =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) size =3D 64 * 1024 * 1024 * 1024 gran_small =3D 32 * 1024 gran_large =3D 128 * 1024 diff --git a/tests/qemu-iotests/248 b/tests/qemu-iotests/248 index f26b4bb2aa..781b21b227 100755 --- a/tests/qemu-iotests/248 +++ b/tests/qemu-iotests/248 @@ -21,7 +21,7 @@ import iotests from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfi= les =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 source, target =3D file_path('source', 'target') size =3D 5 * 1024 * 1024 diff --git a/tests/qemu-iotests/254 b/tests/qemu-iotests/254 index 09584f3f7d..43b40f4f71 100755 --- a/tests/qemu-iotests/254 +++ b/tests/qemu-iotests/254 @@ -21,7 +21,7 @@ import iotests from iotests import qemu_img_create, file_path, log =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 disk, top =3D file_path('disk', 'top') size =3D 1024 * 1024 diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255 index 3632d507d0..ff16402268 100755 --- a/tests/qemu-iotests/255 +++ b/tests/qemu-iotests/255 @@ -23,7 +23,7 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 def blockdev_create(vm, options): result =3D vm.qmp_log('blockdev-create', diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256 index c594a43205..d2f9212e5a 100755 --- a/tests/qemu-iotests/256 +++ b/tests/qemu-iotests/256 @@ -23,7 +23,7 @@ import os import iotests from iotests import log =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2']) size =3D 64 * 1024 * 1024 =20 with iotests.FilePath('img0') as img0_path, \ diff --git a/tests/qemu-iotests/262 b/tests/qemu-iotests/262 index 398f63587e..f0e9d0f8ac 100755 --- a/tests/qemu-iotests/262 +++ b/tests/qemu-iotests/262 @@ -23,8 +23,7 @@ import iotests import os =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2']) =20 with iotests.FilePath('img') as img_path, \ iotests.FilePath('mig_fifo') as fifo, \ diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 84438e837c..2970d7304a 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -895,7 +895,20 @@ def skip_if_unsupported(required_formats=3D[], read_on= ly=3DFalse): return func_wrapper return skip_test_decorator =20 -def execute_unittest(output, verbosity, debug): +def execute_unittest(debug=3DFalse): + """Executes unittests within the calling module.""" + + verbosity =3D 2 if debug else 1 + + if debug: + output =3D sys.stdout + elif sys.version_info.major >=3D 3: + output =3D io.StringIO() + else: + # io.StringIO is for unicode strings, which is not what + # 2.x's test runner emits. + output =3D io.BytesIO() + runner =3D unittest.TextTestRunner(stream=3Doutput, descriptions=3DTru= e, verbosity=3Dverbosity) try: @@ -903,14 +916,19 @@ def execute_unittest(output, verbosity, debug): # exception unittest.main(testRunner=3Drunner) finally: + # We need to filter out the time taken from the output so that + # qemu-iotest can reliably diff the results against master output. if not debug: sys.stderr.write(re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', output.getvalue())) =20 -def execute_test(test_function=3DNone, - supported_fmts=3D[], supported_oses=3D['linux'], - supported_cache_modes=3D[], unsupported_fmts=3D[]): - """Run either unittest or script-style tests.""" +def execute_setup_common(supported_fmts=3D[], + supported_oses=3D['linux'], + supported_cache_modes=3D[], + unsupported_fmts=3D[]): + """ + Perform necessary setup for either script-style or unittest-style test= s. + """ =20 # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to # indicate that we're not being run via "check". There may be @@ -920,37 +938,37 @@ def execute_test(test_function=3DNone, sys.stderr.write('Please run this test via the "check" script\n') sys.exit(os.EX_USAGE) =20 - debug =3D '-d' in sys.argv - verbosity =3D 1 verify_image_format(supported_fmts, unsupported_fmts) verify_platform(supported_oses) verify_cache_mode(supported_cache_modes) =20 + debug =3D '-d' in sys.argv if debug: - output =3D sys.stdout - verbosity =3D 2 sys.argv.remove('-d') - else: - # 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 >=3D 3: - output =3D io.StringIO() - else: - # io.StringIO is for unicode strings, which is not what - # 2.x's test runner emits. - output =3D io.BytesIO() - logging.basicConfig(level=3D(logging.DEBUG if debug else logging.WARN)) =20 + return debug + +def execute_test(test_function=3DNone, *args, **kwargs): + """Run either unittest or script-style tests.""" + + debug =3D execute_setup_common(*args, **kwargs) if not test_function: - execute_unittest(output, verbosity, debug) + execute_unittest(debug) else: test_function() =20 +# This is called from script-style iotests without a single point of entry +def script_initialize(*args, **kwargs): + """Initialize script-style tests without running any tests.""" + execute_setup_common(*args, **kwargs) + +# This is called from script-style iotests with a single point of entry def script_main(test_function, *args, **kwargs): """Run script-style tests outside of the unittest framework""" execute_test(test_function, *args, **kwargs) =20 +# This is called from unittest style iotests def main(*args, **kwargs): """Run tests using the unittest framework""" execute_test(None, *args, **kwargs) --=20 2.21.0 From nobody Tue May 7 09:58:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566345313; cv=none; d=zoho.com; s=zohoarc; b=F72nTJdGa0kacyXWQ1AzjPatHlRJp1jyJMXiSaRtsqQ8drq1C9/LDOjAIRWsCohruyqbtROMG6aOIpdg2sNM7eo9ml1ORFLGLk+AOKvJAQtlM4v/d3cQbLdDohe8oztUig1cXtCgvZAUeqPf3V8yxYvOTgnv1WtNP53bwRMjiGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566345313; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uvN0UfPYzEbhWo8ZNlFMjykON5wEGPnoTcy3cGw0JMU=; b=mothNlaEHtb02s+dHTdgEVpHTV80DFfI3CP7tsCkccNbg0Kb90+BYg7OOFXGB5Lt9wJZH01K1wjfOu6KoLMMUTUw3f0uTV7rtpcx872+fkqav1gZPTrzceT1vmcH2OOn+LhvxXVyvZmadGTgCJUOKWZgIau0oS5YN5Q6oonH+js= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566345313917859.589270808014; Tue, 20 Aug 2019 16:55:13 -0700 (PDT) Received: from localhost ([::1]:42852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Dy4-00050B-0K for importer@patchew.org; Tue, 20 Aug 2019 19:55:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48750) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Dvo-0002SU-Tn for qemu-devel@nongnu.org; Tue, 20 Aug 2019 19:52:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0Dvn-00052W-Q9 for qemu-devel@nongnu.org; Tue, 20 Aug 2019 19:52:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i0Dvl-00050F-R3; Tue, 20 Aug 2019 19:52:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 221493083391; Tue, 20 Aug 2019 23:52:49 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DE432C8D2; Tue, 20 Aug 2019 23:52:48 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Tue, 20 Aug 2019 19:52:41 -0400 Message-Id: <20190820235243.26092-3-jsnow@redhat.com> In-Reply-To: <20190820235243.26092-1-jsnow@redhat.com> References: <20190820235243.26092-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 20 Aug 2019 23:52:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v3 2/4] iotest 258: use script_main 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: Kevin Wolf , John Snow , ehabkost@redhat.com, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since this one is nicely factored to use a single entry point, use script_main to run the tests. Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qemu-iotests/258 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258 index b84cf02254..1372522c7a 100755 --- a/tests/qemu-iotests/258 +++ b/tests/qemu-iotests/258 @@ -23,11 +23,6 @@ import iotests from iotests import log, qemu_img, qemu_io_silent, \ filter_qmp_testfiles, filter_qmp_imgfmt =20 -# Need backing file and change-backing-file support -iotests.verify_image_format(supported_fmts=3D['qcow2', 'qed']) -iotests.verify_platform(['linux']) - - # Returns a node for blockdev-add def node(node_name, path, backing=3DNone, fmt=3DNone, throttle=3DNone): if fmt is None: @@ -160,4 +155,5 @@ def main(): test_concurrent_finish(False) =20 if __name__ =3D=3D '__main__': - main() + # Need backing file and change-backing-file support + iotests.script_main(main, supported_fmts=3D['qcow2', 'qed']) --=20 2.21.0 From nobody Tue May 7 09:58:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566345310; cv=none; d=zoho.com; s=zohoarc; b=IM3Gyionpk67+ShQ9DTBcIN/vJKVniuMJ/BjfM5+k1e1ryQez1dQ4r33+e6T61N3OPD37VE92Ms2YBJwvP7tPeWdib836TIXFphMFg8KFd+2+qBsSmqzXxZ8xP0vMhw6Jx4aC8g03mKa17JltvCrc81rQ594PsbV7LFwiGhKGbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566345310; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Eo+OS5MJ1TfozC29gQcqz13q42zsnafsT0MHI6rJda4=; b=gEYNGg8YpQhFi1EZuIniDAq2KpqEF39cssADGjY1lW841IFNHuZwXwigrI9Gj1ZYuyfB5hpWBXxTDBeT1Zwx25GAHVmlyEWtSkplCem0/MUjgYDnJRKDNceWU7uXNlK+kwwdMxgWvO2cpGGXkRGBZw+VZYyH2O8V0gnmUKxMe6Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566345310591430.66825743906315; Tue, 20 Aug 2019 16:55:10 -0700 (PDT) Received: from localhost ([::1]:42848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Dxv-0004k3-EX for importer@patchew.org; Tue, 20 Aug 2019 19:55:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48776) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Dvq-0002XP-Vp for qemu-devel@nongnu.org; Tue, 20 Aug 2019 19:52:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0Dvp-00054v-Pz for qemu-devel@nongnu.org; Tue, 20 Aug 2019 19:52:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40542) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i0Dvm-00050n-KO; Tue, 20 Aug 2019 19:52:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA9D37F747; Tue, 20 Aug 2019 23:52:49 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 443B657990; Tue, 20 Aug 2019 23:52:49 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Tue, 20 Aug 2019 19:52:42 -0400 Message-Id: <20190820235243.26092-4-jsnow@redhat.com> In-Reply-To: <20190820235243.26092-1-jsnow@redhat.com> References: <20190820235243.26092-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Tue, 20 Aug 2019 23:52:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v3 3/4] iotests: add protocol support to initialization info 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: Kevin Wolf , John Snow , ehabkost@redhat.com, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This will add supported_protocols and unsupported_protocols to all of iotests.main, iotests.script_main, and iotests.script_initialize. Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qemu-iotests/207 | 4 ++-- tests/qemu-iotests/210 | 4 ++-- tests/qemu-iotests/211 | 4 ++-- tests/qemu-iotests/212 | 4 ++-- tests/qemu-iotests/213 | 4 ++-- tests/qemu-iotests/iotests.py | 5 ++++- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 index ab9e3b6747..35d98f2736 100755 --- a/tests/qemu-iotests/207 +++ b/tests/qemu-iotests/207 @@ -24,8 +24,8 @@ import iotests import subprocess import re =20 -iotests.script_initialize(supported_fmts=3D['raw']) -iotests.verify_protocol(supported=3D['ssh']) +iotests.script_initialize(supported_fmts=3D['raw'], + supported_protocols=3D['ssh']) =20 def filter_hash(qmsg): def _filter(key, value): diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210 index 5a7013cd34..d9fe780c07 100755 --- a/tests/qemu-iotests/210 +++ b/tests/qemu-iotests/210 @@ -23,8 +23,8 @@ import iotests from iotests import imgfmt =20 -iotests.script_initialize(supported_fmts=3D['luks']) -iotests.verify_protocol(supported=3D['file']) +iotests.script_initialize(supported_fmts=3D['luks'], + supported_protocols=3D['file']) =20 def blockdev_create(vm, options): result =3D vm.qmp_log('blockdev-create', job_id=3D'job0', options=3Dop= tions, diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211 index 4d6aac497f..155fac4e87 100755 --- a/tests/qemu-iotests/211 +++ b/tests/qemu-iotests/211 @@ -23,8 +23,8 @@ import iotests from iotests import imgfmt =20 -iotests.script_initialize(supported_fmts=3D['vdi']) -iotests.verify_protocol(supported=3D['file']) +iotests.script_initialize(supported_fmts=3D['vdi'], + supported_protocols=3D['file']) =20 def blockdev_create(vm, options): result =3D vm.qmp_log('blockdev-create', job_id=3D'job0', options=3Dop= tions, diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212 index ec35bceb11..67e5a1dbb5 100755 --- a/tests/qemu-iotests/212 +++ b/tests/qemu-iotests/212 @@ -23,8 +23,8 @@ import iotests from iotests import imgfmt =20 -iotests.script_initialize(supported_fmts=3D['parallels']) -iotests.verify_protocol(supported=3D['file']) +iotests.script_initialize(supported_fmts=3D['parallels'], + supported_protocols=3D['file']) =20 def blockdev_create(vm, options): result =3D vm.qmp_log('blockdev-create', job_id=3D'job0', options=3Dop= tions, diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213 index 3d2c024375..23f387ab63 100755 --- a/tests/qemu-iotests/213 +++ b/tests/qemu-iotests/213 @@ -23,8 +23,8 @@ import iotests from iotests import imgfmt =20 -iotests.script_initialize(supported_fmts=3D['vhdx']) -iotests.verify_protocol(supported=3D['file']) +iotests.script_initialize(supported_fmts=3D['vhdx'], + supported_protocols=3D['file']) =20 def blockdev_create(vm, options): result =3D vm.qmp_log('blockdev-create', job_id=3D'job0', options=3Dop= tions, diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 2970d7304a..661d7f93bf 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -925,7 +925,9 @@ def execute_unittest(debug=3DFalse): def execute_setup_common(supported_fmts=3D[], supported_oses=3D['linux'], supported_cache_modes=3D[], - unsupported_fmts=3D[]): + unsupported_fmts=3D[], + supported_protocols=3D[], + unsupported_protocols=3D[]): """ Perform necessary setup for either script-style or unittest-style test= s. """ @@ -941,6 +943,7 @@ def execute_setup_common(supported_fmts=3D[], verify_image_format(supported_fmts, unsupported_fmts) verify_platform(supported_oses) verify_cache_mode(supported_cache_modes) + verify_protocol(supported_protocols, unsupported_protocols) =20 debug =3D '-d' in sys.argv if debug: --=20 2.21.0 From nobody Tue May 7 09:58:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566345461; cv=none; d=zoho.com; s=zohoarc; b=A8CvIBmvGoevT8OG7CeyKdNS3HBEUZW1YhehMpaTXN/kCDLBJk365zRasGw9MQ9ZtRKIFx7HAsMslbCDhRZ+ix4uxSvJwR0yCxwNCI+tMcAHzVwqMfKoOqxrZHzXK953vpydXhG9GAmKHQDStBZ4l38dMX7bcNiOlxhB1zPnUbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566345461; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mVXBYylarxChKZ6ZXKlT6BxooPgolDIhSfRJt850x6g=; b=U5NaMUzY9wR2575cr6UTmRjErbYYE2wvJi65U+E0aGz1e7N5e89izWnwWB+VZylt2n8oDkFNnwaItq7A37Dk+8QzwWQO0E6A+x4ibDxpLmpowVjab+LjlNi15jufohSkiuEnJW/YTrRGhGjiEgN5pqHOYWwhXAagOOJacES5BA0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566345461415530.33853673436; Tue, 20 Aug 2019 16:57:41 -0700 (PDT) Received: from localhost ([::1]:42902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0E0Q-0000Uo-BG for importer@patchew.org; Tue, 20 Aug 2019 19:57:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48800) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Dvu-0002az-Pu for qemu-devel@nongnu.org; Tue, 20 Aug 2019 19:53:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0Dvs-00058s-QU for qemu-devel@nongnu.org; Tue, 20 Aug 2019 19:52:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47510) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i0Dvn-00051k-Dr; Tue, 20 Aug 2019 19:52:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C01BC8980E3; Tue, 20 Aug 2019 23:52:50 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1959757990; Tue, 20 Aug 2019 23:52:50 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Tue, 20 Aug 2019 19:52:43 -0400 Message-Id: <20190820235243.26092-5-jsnow@redhat.com> In-Reply-To: <20190820235243.26092-1-jsnow@redhat.com> References: <20190820235243.26092-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Tue, 20 Aug 2019 23:52:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v3 4/4] iotests: use python logging for iotests.log() 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: Kevin Wolf , John Snow , ehabkost@redhat.com, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can turn logging on/off globally instead of per-function. Remove use_log from run_job, and use python logging to turn on diffable output when we run through a script entry point. iotest 245 changes output order due to buffering reasons. --- tests/qemu-iotests/030 | 4 +-- tests/qemu-iotests/245 | 1 + tests/qemu-iotests/245.out | 24 +++++++++--------- tests/qemu-iotests/iotests.py | 47 +++++++++++++++++++++-------------- 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 1b69f318c6..a382cb430b 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -411,8 +411,8 @@ class TestParallelOps(iotests.QMPTestCase): result =3D self.vm.qmp('block-job-set-speed', device=3D'drive0', s= peed=3D0) self.assert_qmp(result, 'return', {}) =20 - self.vm.run_job(job=3D'drive0', auto_dismiss=3DTrue, use_log=3DFal= se) - self.vm.run_job(job=3D'node4', auto_dismiss=3DTrue, use_log=3DFals= e) + self.vm.run_job(job=3D'drive0', auto_dismiss=3DTrue) + self.vm.run_job(job=3D'node4', auto_dismiss=3DTrue) self.assert_no_active_block_jobs() =20 # Test a block-stream and a block-commit job in parallel diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 index bc1ceb9792..3bc29acb33 100644 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -1000,4 +1000,5 @@ class TestBlockdevReopen(iotests.QMPTestCase): self.reopen(opts, {'backing': 'hd2'}) =20 if __name__ =3D=3D '__main__': + iotests.activate_logging() iotests.main(supported_fmts=3D["qcow2"]) diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out index a19de5214d..15c3630e92 100644 --- a/tests/qemu-iotests/245.out +++ b/tests/qemu-iotests/245.out @@ -1,17 +1,17 @@ +{"execute": "job-finalize", "arguments": {"id": "commit0"}} +{"return": {}} +{"data": {"id": "commit0", "type": "commit"}, "event": "BLOCK_JOB_PENDING"= , "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "commit0", "len": 3145728, "offset": 3145728, "speed":= 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micro= seconds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "stream0"}} +{"return": {}} +{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING"= , "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed":= 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micro= seconds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "stream0"}} +{"return": {}} +{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING"= , "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed":= 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micro= seconds": "USECS", "seconds": "SECS"}} .................. ---------------------------------------------------------------------- Ran 18 tests =20 OK -{"execute": "job-finalize", "arguments": {"id": "commit0"}} -{"return": {}} -{"data": {"id": "commit0", "type": "commit"}, "event": "BLOCK_JOB_PENDING"= , "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "commit0", "len": 3145728, "offset": 3145728, "speed":= 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micro= seconds": "USECS", "seconds": "SECS"}} -{"execute": "job-finalize", "arguments": {"id": "stream0"}} -{"return": {}} -{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING"= , "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed":= 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micro= seconds": "USECS", "seconds": "SECS"}} -{"execute": "job-finalize", "arguments": {"id": "stream0"}} -{"return": {}} -{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING"= , "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed":= 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micro= seconds": "USECS", "seconds": "SECS"}} diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 661d7f93bf..b97cc2fab2 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -35,6 +35,13 @@ from collections import OrderedDict sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qtest =20 +# Use this logger for logging messages directly from the iotests module +logger =3D logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) + +# Use this logger for messages that ought to be used for diff output. +test_logger =3D logging.getLogger('.'.join((__name__, 'iotest'))) +test_logger.addHandler(logging.NullHandler()) =20 # This will not work if arguments contain spaces but is necessary if we # want to support the override options that ./check supports. @@ -343,10 +350,10 @@ def log(msg, filters=3D[], indent=3DNone): separators =3D (', ', ': ') if indent is None else (',', ': ') # Don't sort if it's already sorted do_sort =3D not isinstance(msg, OrderedDict) - print(json.dumps(msg, sort_keys=3Ddo_sort, - indent=3Dindent, separators=3Dseparators)) + test_logger.info(json.dumps(msg, sort_keys=3Ddo_sort, + indent=3Dindent, separators=3Dseparato= rs)) else: - print(msg) + test_logger.info(msg) =20 class Timeout: def __init__(self, seconds, errmsg =3D "Timeout"): @@ -559,7 +566,7 @@ class VM(qtest.QEMUQtestMachine): =20 # Returns None on success, and an error string on failure def run_job(self, job, auto_finalize=3DTrue, auto_dismiss=3DFalse, - pre_finalize=3DNone, cancel=3DFalse, use_log=3DTrue, wait= =3D60.0): + pre_finalize=3DNone, cancel=3DFalse, wait=3D60.0): """ run_job moves a job from creation through to dismissal. =20 @@ -572,7 +579,6 @@ class VM(qtest.QEMUQtestMachine): invoked prior to issuing job-finalize, if any. :param cancel: Bool. When true, cancels the job after the pre_fina= lize callback. - :param use_log: Bool. When false, does not log QMP messages. :param wait: Float. Timeout value specifying how long to wait for = any event, in seconds. Defaults to 60.0. """ @@ -590,8 +596,7 @@ class VM(qtest.QEMUQtestMachine): while True: ev =3D filter_qmp_event(self.events_wait(events)) if ev['event'] !=3D 'JOB_STATUS_CHANGE': - if use_log: - log(ev) + log(ev) continue status =3D ev['data']['status'] if status =3D=3D 'aborting': @@ -599,24 +604,16 @@ class VM(qtest.QEMUQtestMachine): for j in result['return']: if j['id'] =3D=3D job: error =3D j['error'] - if use_log: - log('Job failed: %s' % (j['error'])) + log('Job failed: %s' % (j['error'])) elif status =3D=3D 'pending' and not auto_finalize: if pre_finalize: pre_finalize() - if cancel and use_log: + if cancel: self.qmp_log('job-cancel', id=3Djob) - elif cancel: - self.qmp('job-cancel', id=3Djob) - elif use_log: + else: self.qmp_log('job-finalize', id=3Djob) - else: - self.qmp('job-finalize', id=3Djob) elif status =3D=3D 'concluded' and not auto_dismiss: - if use_log: - self.qmp_log('job-dismiss', id=3Djob) - else: - self.qmp('job-dismiss', id=3Djob) + self.qmp_log('job-dismiss', id=3Djob) elif status =3D=3D 'null': return error =20 @@ -949,6 +946,7 @@ def execute_setup_common(supported_fmts=3D[], if debug: sys.argv.remove('-d') logging.basicConfig(level=3D(logging.DEBUG if debug else logging.WARN)) + logger.debug("iotests debugging messages active") =20 return debug =20 @@ -961,14 +959,25 @@ def execute_test(test_function=3DNone, *args, **kwarg= s): else: test_function() =20 +def activate_logging(): + """Activate iotests.log() output to stdout for script-style tests.""" + handler =3D logging.StreamHandler(stream=3Dsys.stdout) + formatter =3D logging.Formatter('%(message)s') + handler.setFormatter(formatter) + test_logger.addHandler(handler) + test_logger.setLevel(logging.INFO) + test_logger.propagate =3D False + # This is called from script-style iotests without a single point of entry def script_initialize(*args, **kwargs): """Initialize script-style tests without running any tests.""" + activate_logging() execute_setup_common(*args, **kwargs) =20 # This is called from script-style iotests with a single point of entry def script_main(test_function, *args, **kwargs): """Run script-style tests outside of the unittest framework""" + activate_logging() execute_test(test_function, *args, **kwargs) =20 # This is called from unittest style iotests --=20 2.21.0