From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584405758; cv=none; d=zohomail.com; s=zohoarc; b=GgmZlSMkUXloBZ4G9bBP/HIy1xsEzdJ2iRY65JuczkeDbBjAicdGBUIOI0NJJJnvz8jofEfKoVRuUzXSkw2+Y/TdlNqg2+mr3T0DOk8+4z7PSTgp1NNLFmVvshmQr4SXLyBR+5CiomjE2GPeJVIKxvidLb6FLXvHSDnEcWHMmLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584405758; h=Content-Type: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; bh=TWco7/C0lTRnkqd8Rm0pU6sFt2LFRem+KeJabA6WcZU=; b=gW1zVTtojcvAhZmRf/9mHJcPokxS3I71JiXg7pMUXoBAb6gCmn4xIJmDxKUSpQuuK+RxWs8TfQHkkHNPqejCyI0H6Ab7cPZBAoJMbb0VXEcaDsoYz4DnJ4CtUpksNVbaP5ZPYZ1EryNdo7KoU6MX6ylw2/LQpA7D018Lm34gGR4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584405758590525.4339601063468; Mon, 16 Mar 2020 17:42:38 -0700 (PDT) Received: from localhost ([::1]:50832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0JZ-0005sM-61 for importer@patchew.org; Mon, 16 Mar 2020 20:42:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41410) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IG-00040B-My for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IE-0004up-JU for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:16 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:49659) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IE-0004s5-Co for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-365-urNrHlfGOY-yGY3hzsQ8Ew-1; Mon, 16 Mar 2020 20:41:09 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72F3C107ACC4; Tue, 17 Mar 2020 00:41:08 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41F6E7A411; Tue, 17 Mar 2020 00:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TWco7/C0lTRnkqd8Rm0pU6sFt2LFRem+KeJabA6WcZU=; b=UVRVZsxGpSQdduTpmRegBlF3N4QBBwUfIAuWwD7fnocZiHUny/kZYjcsmWw3BT5ZEXLtGd lrYsGgFVWRyFFfIJ9S7WgAudiUYBM42MvZZtFzDVbG949OD0bdcPRuCUmSzyNlOdsUH2X9 JsToPBYlhmEe2O1YXAM9l4E9VE07THI= X-MC-Unique: urNrHlfGOY-yGY3hzsQ8Ew-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 01/11] iotests: do a light delinting Date: Mon, 16 Mar 2020 20:40:55 -0400 Message-Id: <20200317004105.27059-2-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This doesn't fix everything in here, but it does help clean up the pylint report considerably. This should be 100% style changes only; the intent is to make pylint more useful by working on establishing a baseline for iotests that we can gate against in the future. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 83 ++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 23043baa26..c6d9ae130d 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -16,11 +16,9 @@ # along with this program. If not, see . # =20 -import errno import os import re import subprocess -import string import unittest import sys import struct @@ -34,7 +32,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qtest =20 -assert sys.version_info >=3D (3,6) +assert sys.version_info >=3D (3, 6) =20 # This will not work if arguments contain spaces but is necessary if we # want to support the override options that ./check supports. @@ -138,11 +136,11 @@ def qemu_img_log(*args): return result =20 def img_info_log(filename, filter_path=3DNone, imgopts=3DFalse, extra_args= =3D[]): - args =3D [ 'info' ] + args =3D ['info'] if imgopts: args.append('--image-opts') else: - args +=3D [ '-f', imgfmt ] + args +=3D ['-f', imgfmt] args +=3D extra_args args.append(filename) =20 @@ -221,7 +219,7 @@ def cmd(self, cmd): # quit command is in close(), '\n' is added automatically assert '\n' not in cmd cmd =3D cmd.strip() - assert cmd !=3D 'q' and cmd !=3D 'quit' + assert cmd not in ('q', 'quit') self._p.stdin.write(cmd + '\n') self._p.stdin.flush() return self._read_output() @@ -243,10 +241,8 @@ def qemu_nbd_early_pipe(*args): sys.stderr.write('qemu-nbd received signal %i: %s\n' % (-exitcode, ' '.join(qemu_nbd_args + ['--fork'] + list(args)= ))) - if exitcode =3D=3D 0: - return exitcode, '' - else: - return exitcode, subp.communicate()[0] + + return exitcode, subp.communicate()[0] if exitcode else '' =20 def qemu_nbd_popen(*args): '''Run qemu-nbd in daemon mode and return the parent's exit code''' @@ -310,7 +306,7 @@ def filter_qmp(qmsg, filter_fn): items =3D qmsg.items() =20 for k, v in items: - if isinstance(v, list) or isinstance(v, dict): + if isinstance(v, (dict, list)): qmsg[k] =3D filter_qmp(v, filter_fn) else: qmsg[k] =3D filter_fn(k, v) @@ -321,7 +317,7 @@ def filter_testfiles(msg): return msg.replace(prefix, 'TEST_DIR/PID-') =20 def filter_qmp_testfiles(qmsg): - def _filter(key, value): + def _filter(_key, value): if is_str(value): return filter_testfiles(value) return value @@ -347,7 +343,7 @@ def filter_imgfmt(msg): return msg.replace(imgfmt, 'IMGFMT') =20 def filter_qmp_imgfmt(qmsg): - def _filter(key, value): + def _filter(_key, value): if is_str(value): return filter_imgfmt(value) return value @@ -358,7 +354,7 @@ def log(msg, filters=3D[], indent=3DNone): If indent is provided, JSON serializable messages are pretty-printed.'= '' for flt in filters: msg =3D flt(msg) - if isinstance(msg, dict) or isinstance(msg, list): + if isinstance(msg, (dict, list)): # Python < 3.4 needs to know not to add whitespace when pretty-pri= nting: separators =3D (', ', ': ') if indent is None else (',', ': ') # Don't sort if it's already sorted @@ -369,14 +365,14 @@ def log(msg, filters=3D[], indent=3DNone): print(msg) =20 class Timeout: - def __init__(self, seconds, errmsg =3D "Timeout"): + def __init__(self, seconds, errmsg=3D"Timeout"): self.seconds =3D seconds self.errmsg =3D errmsg def __enter__(self): signal.signal(signal.SIGALRM, self.timeout) signal.setitimer(signal.ITIMER_REAL, self.seconds) return self - def __exit__(self, type, value, traceback): + def __exit__(self, exc_type, value, traceback): signal.setitimer(signal.ITIMER_REAL, 0) return False def timeout(self, signum, frame): @@ -385,7 +381,7 @@ def timeout(self, signum, frame): def file_pattern(name): return "{0}-{1}".format(os.getpid(), name) =20 -class FilePaths(object): +class FilePaths: """ FilePaths is an auto-generated filename that cleans itself up. =20 @@ -532,11 +528,11 @@ def pause_drive(self, drive, event=3DNone): self.pause_drive(drive, "write_aio") return self.qmp('human-monitor-command', - command_line=3D'qemu-io %s "break %s bp_%s"' % (drive,= event, drive)) + command_line=3D'qemu-io %s "break %s bp_%s"' % (drive, ev= ent, drive)) =20 def resume_drive(self, drive): self.qmp('human-monitor-command', - command_line=3D'qemu-io %s "remove_break bp_%s"' % (dr= ive, drive)) + command_line=3D'qemu-io %s "remove_break bp_%s"' % (drive= , drive)) =20 def hmp_qemu_io(self, drive, cmd): '''Write to a given drive using an HMP command''' @@ -547,8 +543,8 @@ def flatten_qmp_object(self, obj, output=3DNone, basest= r=3D''): if output is None: output =3D dict() if isinstance(obj, list): - for i in range(len(obj)): - self.flatten_qmp_object(obj[i], output, basestr + str(i) += '.') + for i, atom in enumerate(obj): + self.flatten_qmp_object(atom, output, basestr + str(i) + '= .') elif isinstance(obj, dict): for key in obj: self.flatten_qmp_object(obj[key], output, basestr + key + = '.') @@ -706,9 +702,7 @@ def get_bitmap(self, node_name, bitmap_name, recording= =3DNone, bitmaps=3DNone): =20 for bitmap in bitmaps[node_name]: if bitmap.get('name', '') =3D=3D bitmap_name: - if recording is None: - return bitmap - elif bitmap.get('recording') =3D=3D recording: + if recording is None or bitmap.get('recording') =3D=3D rec= ording: return bitmap return None =20 @@ -759,12 +753,13 @@ def assert_block_path(self, root, path, expected_node= , graph=3DNone): assert node is not None, 'Cannot follow path %s%s' % (root, pa= th) =20 try: - node_id =3D next(edge['child'] for edge in graph['edges'] \ - if edge['parent'] =3D=3D node= ['id'] and - edge['name'] =3D=3D child_= name) + node_id =3D next(edge['child'] for edge in graph['edges'] + if (edge['parent'] =3D=3D node['id'] and + edge['name'] =3D=3D child_name)) + + node =3D next(node for node in graph['nodes'] + if node['id'] =3D=3D node_id) =20 - node =3D next(node for node in graph['nodes'] \ - if node['id'] =3D=3D node_id) except StopIteration: node =3D None =20 @@ -782,6 +777,12 @@ def assert_block_path(self, root, path, expected_node,= graph=3DNone): class QMPTestCase(unittest.TestCase): '''Abstract base class for QMP test cases''' =20 + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Many users of this class set a VM property we rely on heavily + # in the methods below. + self.vm =3D None + def dictpath(self, d, path): '''Traverse a path in a nested dict''' for component in path.split('/'): @@ -827,7 +828,7 @@ def assert_qmp(self, d, path, value): else: self.assertEqual(result, value, '"%s" is "%s", expected "%s"' - % (path, str(result), str(value))) + % (path, str(result), str(value))) =20 def assert_no_active_block_jobs(self): result =3D self.vm.qmp('query-block-jobs') @@ -837,15 +838,15 @@ def assert_has_block_node(self, node_name=3DNone, fil= e_name=3DNone): """Issue a query-named-block-nodes and assert node_name and/or file_name is present in the result""" def check_equal_or_none(a, b): - return a =3D=3D None or b =3D=3D None or a =3D=3D b + return a is None or b is None or a =3D=3D b assert node_name or file_name result =3D self.vm.qmp('query-named-block-nodes') for x in result["return"]: if check_equal_or_none(x.get("node-name"), node_name) and \ check_equal_or_none(x.get("file"), file_name): return - self.assertTrue(False, "Cannot find %s %s in result:\n%s" % \ - (node_name, file_name, result)) + self.fail("Cannot find %s %s in result:\n%s" % + (node_name, file_name, result)) =20 def assert_json_filename_equal(self, json_filename, reference): '''Asserts that the given filename is a json: filename and that its @@ -894,13 +895,13 @@ def wait_until_completed(self, drive=3D'drive0', chec= k_offset=3DTrue, wait=3D60.0, self.assert_qmp(event, 'data/error', error) self.assert_no_active_block_jobs() return event - elif event['event'] =3D=3D 'JOB_STATUS_CHANGE': + if event['event'] =3D=3D 'JOB_STATUS_CHANGE': self.assert_qmp(event, 'data/id', drive) =20 def wait_ready(self, drive=3D'drive0'): - '''Wait until a block job BLOCK_JOB_READY event''' - f =3D {'data': {'type': 'mirror', 'device': drive } } - event =3D self.vm.event_wait(name=3D'BLOCK_JOB_READY', match=3Df) + """Wait until a BLOCK_JOB_READY event, and return the event.""" + f =3D {'data': {'type': 'mirror', 'device': drive}} + return self.vm.event_wait(name=3D'BLOCK_JOB_READY', match=3Df) =20 def wait_ready_and_cancel(self, drive=3D'drive0'): self.wait_ready(drive=3Ddrive) @@ -929,7 +930,7 @@ def pause_wait(self, job_id=3D'job0'): for job in result['return']: if job['device'] =3D=3D job_id: found =3D True - if job['paused'] =3D=3D True and job['busy'] =3D= =3D False: + if job['paused'] and not job['busy']: return job break assert found @@ -1026,8 +1027,8 @@ def qemu_pipe(*args): universal_newlines=3DTrue) exitcode =3D subp.wait() if exitcode < 0: - sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, - ' '.join(args))) + sys.stderr.write('qemu received signal %i: %s\n' % + (-exitcode, ' '.join(args))) return subp.communicate()[0] =20 def supported_formats(read_only=3DFalse): @@ -1059,6 +1060,7 @@ def func_wrapper(test_case: QMPTestCase, *args, **kwa= rgs): if usf_list: test_case.case_skip('{}: formats {} are not whitelisted'.f= ormat( test_case, usf_list)) + return None else: return func(test_case, *args, **kwargs) return func_wrapper @@ -1070,6 +1072,7 @@ def skip_if_user_is_root(func): def func_wrapper(*args, **kwargs): if os.getuid() =3D=3D 0: case_notrun('{}: cannot be run as root'.format(args[0])) + return None else: return func(*args, **kwargs) return func_wrapper --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584405758; cv=none; d=zohomail.com; s=zohoarc; b=crTXCzv2kd+6V7kSMtHQtUW7sFGnbjlEK73RQfPL6jDqr/vD3oAyFtFw9nQbbBvUL84FgA5wury32UM48NfzDp4LaKd7hiS1+y1Zjuyx+PxYKQoabRZRrlWmMqEpYDq8bPyJIk52ieGqCUUhMA/6ez9nvJjlfLCizYqM9fOrPdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584405758; h=Content-Type: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; bh=oLa6eitOwlPcvI4d6A5bsj3e19wXpoPcdEFbZBp//fg=; b=Ck5kPYDtSCOGOBdZhRTa0Vai46UK/O7ecvnNaMGRBSS8FMt1h/lqnk/iB9Q6PocUZVcVCkko13oOerp7EmZiXMUCw30z6BqvnZgmZclPmZfwbiS7ptJW4HldhsriOYZXzXUDaYu7IjC3IbXQEQmLtCp1kUpEMNWqmbuac+bHxUI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584405758731339.14690750754994; Mon, 16 Mar 2020 17:42:38 -0700 (PDT) Received: from localhost ([::1]:50834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0JZ-0005uA-Bn for importer@patchew.org; Mon, 16 Mar 2020 20:42:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41337) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0ID-0003wc-UU for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IC-0004mU-TR for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:13 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:52914) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IC-0004l3-Py for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-2JQSjWFLNiuMigPGz8R5Lw-1; Mon, 16 Mar 2020 20:41:10 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A31631804549; Tue, 17 Mar 2020 00:41:09 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BEC993531; Tue, 17 Mar 2020 00:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oLa6eitOwlPcvI4d6A5bsj3e19wXpoPcdEFbZBp//fg=; b=M1GAFeM7hGyNiY+znjFBngRITNF0weeGZe61uJmn2ui1U2T51F3ZyXbXyACxIV/xORvpY+ xi/uwmdWCWoR8HCtcJtsREuXps6KGNibLEzLNV1ZmMs9mIMo/lR8wBOd2SkOfM7sJ6IipJ nPidecc9y/KAf9XkDFkmZbVcYuJ2sQg= X-MC-Unique: 2JQSjWFLNiuMigPGz8R5Lw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 02/11] iotests: don't use 'format' for drive_add Date: Mon, 16 Mar 2020 20:40:56 -0400 Message-Id: <20200317004105.27059-3-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It shadows (with a different type) the built-in format. Use something else. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Max Reitz --- tests/qemu-iotests/055 | 3 ++- tests/qemu-iotests/iotests.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 index 82b9f5f47d..4175fff5e4 100755 --- a/tests/qemu-iotests/055 +++ b/tests/qemu-iotests/055 @@ -469,7 +469,8 @@ class TestDriveCompression(iotests.QMPTestCase): qemu_img('create', '-f', fmt, blockdev_target_img, str(TestDriveCompression.image_len), *args) if attach_target: - self.vm.add_drive(blockdev_target_img, format=3Dfmt, interface= =3D"none") + self.vm.add_drive(blockdev_target_img, + img_format=3Dfmt, interface=3D"none") =20 self.vm.launch() =20 diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index c6d9ae130d..a6b2889932 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -482,21 +482,21 @@ def add_drive_raw(self, opts): self._args.append(opts) return self =20 - def add_drive(self, path, opts=3D'', interface=3D'virtio', format=3Dim= gfmt): + def add_drive(self, path, opts=3D'', interface=3D'virtio', img_format= =3Dimgfmt): '''Add a virtio-blk drive to the VM''' options =3D ['if=3D%s' % interface, 'id=3Ddrive%d' % self._num_drives] =20 if path is not None: options.append('file=3D%s' % path) - options.append('format=3D%s' % format) + options.append('format=3D%s' % img_format) options.append('cache=3D%s' % cachemode) options.append('aio=3D%s' % aiomode) =20 if opts: options.append(opts) =20 - if format =3D=3D 'luks' and 'key-secret' not in opts: + if img_format =3D=3D 'luks' and 'key-secret' not in opts: # default luks support if luks_default_secret_object not in self._args: self.add_object(luks_default_secret_object) --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584405859; cv=none; d=zohomail.com; s=zohoarc; b=gKmqQ6yu2kS0WjiL5SPt0rGmAhSaCRJGOTFHkvuZTPn8nxbe3EcMP84kBdrsUMq0RzRK+T/R9c/v8mrIGAEeZyM/Rg4fVnVox6SRePbiCeose9hR0WuxCXoB50qZZhebfIK1X9lTfqA8/uf0F3yx9EP9uthkJU8FPOCqVB8iPZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584405859; h=Content-Type: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; bh=tg7R8UMMs6xG0ZD4hetM81xCnjtrpp1MvWpvCci3eF0=; b=f3s7Y1aC6pix1zcEgEl84a6bZvGVrZ9IpHjPWXCQ2NrnPa733RWMt2NpQ8I0ZW4ICQ//MEmSkFj0NSfr+g/7GZWlwS8sQ7VaqJCkrx6n76zAGloFuJ20tkwA7kEh/fYmbfU2bJk3JAQ3+A0HKushpiP41M3y+J6pwm/rGjDDziI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584405859380167.94813727369456; Mon, 16 Mar 2020 17:44:19 -0700 (PDT) Received: from localhost ([::1]:50864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0LC-000114-CN for importer@patchew.org; Mon, 16 Mar 2020 20:44:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41371) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IF-0003wv-2K for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IE-0004r2-1C for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:14 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:35748) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0ID-0004q3-Tv for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-xGPyf5hrOpCTwae3s5csWg-1; Mon, 16 Mar 2020 20:41:12 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F36821005513; Tue, 17 Mar 2020 00:41:10 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBF007A411; Tue, 17 Mar 2020 00:41:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tg7R8UMMs6xG0ZD4hetM81xCnjtrpp1MvWpvCci3eF0=; b=N34Bgip8izDICgpDQjsvoM/ttYtl32h2QctUuUDL1VRuDZ2zfGM+xWrsIx1UW2UzWlQCj5 kHbQfgmsSIloaACo7L6P0SLhjpsM/tXMX21JOBHu4eXW8/kkfBtCHGgbrdLCjQ2IvhOQ6n 9fgdgtK8VMkpgUEU5pIFIwedg8jbtpg= X-MC-Unique: xGPyf5hrOpCTwae3s5csWg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 03/11] iotests: ignore import warnings from pylint Date: Mon, 16 Mar 2020 20:40:57 -0400 Message-Id: <20200317004105.27059-4-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The right way to solve this is to come up with a virtual environment infrastructure that sets all the paths correctly, and/or to create installable python modules that can be imported normally. That's hard, so just silence this error for now. Signed-off-by: John Snow Reviewed-by: Max Reitz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qemu-iotests/iotests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index a6b2889932..cb9c2cd05d 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -29,6 +29,7 @@ import io from collections import OrderedDict =20 +# pylint: disable=3Dimport-error, wrong-import-position sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qtest =20 --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584405860; cv=none; d=zohomail.com; s=zohoarc; b=TkqVmyUwhcwPTMrFLDcSvxxBMwIN3c1J4w2Fbm1A+qQzaU3w71RG4OXDPsXJIlzUk4bctCUkucheEhxJRDI+rRXwZJqndJK/5//GaFgvB1WQZmgNvt49wWOYv/KqSO7djYEUD6e+k7ZU70bo2x70nRX8jY42iI+8tRTpJlURJCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584405860; h=Content-Type: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; bh=KQBnYkEn5mABwOQVjYOEtia36Kc/+snsuX5m5kADB2o=; b=l2wV/ZhbU48Yc+SYnm8okXwwctEERZaKuPendaEIzd1ZvoJhoTLNMcx+xdJynBBc+zwRv/uJsC1Rjl4fVv8LXtsev0Wosk+wq+lz++AJ+rFVe3n8UM126Y3EYDwqiPQnosT2G9mpCKTgaZFWp2qdQJtZFfucAIlqvhAWsWyNoZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584405860078447.4739030929803; Mon, 16 Mar 2020 17:44:20 -0700 (PDT) Received: from localhost ([::1]:50866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0LD-00012A-48 for importer@patchew.org; Mon, 16 Mar 2020 20:44:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41431) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IH-00041w-9G for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IF-0004yV-Tv for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:17 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:38671) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IF-0004xu-Pe for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-z2CnrJbxNsO4r9nOcgPXTw-1; Mon, 16 Mar 2020 20:41:13 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D355107ACC7; Tue, 17 Mar 2020 00:41:12 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23E3F7A411; Tue, 17 Mar 2020 00:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KQBnYkEn5mABwOQVjYOEtia36Kc/+snsuX5m5kADB2o=; b=T41mPmGHu3HlexyaXvccPjkL+hF0Mts08K2Mwjyiz0jSiyjOFoCUCXZRkkDqbQKxW6tlKH wVSgcA43/vJIT/zRIbTuOYHFJopmga6ZnkalNNCrv/IDRZo77v0GhVSVFZEHvmTU9PhkaW EqgUsEF70IkTA+GwjHEW5nwWKecpNxY= X-MC-Unique: z2CnrJbxNsO4r9nOcgPXTw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 04/11] iotests: replace mutable list default args Date: Mon, 16 Mar 2020 20:40:58 -0400 Message-Id: <20200317004105.27059-5-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It's bad hygiene: if we modify this list, it will be modified across all invocations. (Remaining bad usages are fixed in a subsequent patch which changes the function signature anyway.) Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index cb9c2cd05d..7cd74e7cb1 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -136,7 +136,7 @@ def qemu_img_log(*args): log(result, filters=3D[filter_testfiles]) return result =20 -def img_info_log(filename, filter_path=3DNone, imgopts=3DFalse, extra_args= =3D[]): +def img_info_log(filename, filter_path=3DNone, imgopts=3DFalse, extra_args= =3D()): args =3D ['info'] if imgopts: args.append('--image-opts') @@ -350,7 +350,7 @@ def _filter(_key, value): return value return filter_qmp(qmsg, _filter) =20 -def log(msg, filters=3D[], indent=3DNone): +def log(msg, filters=3D(), indent=3DNone): '''Logs either a string message or a JSON serializable message (like Q= MP). If indent is provided, JSON serializable messages are pretty-printed.'= '' for flt in filters: @@ -566,7 +566,7 @@ def get_qmp_events_filtered(self, wait=3D60.0): result.append(filter_qmp_event(ev)) return result =20 - def qmp_log(self, cmd, filters=3D[], indent=3DNone, **kwargs): + def qmp_log(self, cmd, filters=3D(), indent=3DNone, **kwargs): full_cmd =3D OrderedDict(( ("execute", cmd), ("arguments", ordered_qmp(kwargs)) @@ -970,7 +970,7 @@ def case_notrun(reason): open('%s/%s.casenotrun' % (output_dir, seq), 'a').write( ' [case not run] ' + reason + '\n') =20 -def verify_image_format(supported_fmts=3D[], unsupported_fmts=3D[]): +def verify_image_format(supported_fmts=3D(), unsupported_fmts=3D()): assert not (supported_fmts and unsupported_fmts) =20 if 'generic' in supported_fmts and \ @@ -984,7 +984,7 @@ def verify_image_format(supported_fmts=3D[], unsupporte= d_fmts=3D[]): if not_sup or (imgfmt in unsupported_fmts): notrun('not suitable for this image format: %s' % imgfmt) =20 -def verify_protocol(supported=3D[], unsupported=3D[]): +def verify_protocol(supported=3D(), unsupported=3D()): assert not (supported and unsupported) =20 if 'generic' in supported: @@ -1003,11 +1003,11 @@ def verify_platform(supported=3DNone, unsupported= =3DNone): if not any((sys.platform.startswith(x) for x in supported)): notrun('not suitable for this OS: %s' % sys.platform) =20 -def verify_cache_mode(supported_cache_modes=3D[]): +def verify_cache_mode(supported_cache_modes=3D()): if supported_cache_modes and (cachemode not in supported_cache_modes): notrun('not suitable for this cache mode: %s' % cachemode) =20 -def verify_aio_mode(supported_aio_modes=3D[]): +def verify_aio_mode(supported_aio_modes=3D()): if supported_aio_modes and (aiomode not in supported_aio_modes): notrun('not suitable for this aio mode: %s' % aiomode) =20 @@ -1047,7 +1047,7 @@ def supported_formats(read_only=3DFalse): =20 return supported_formats.formats[read_only] =20 -def skip_if_unsupported(required_formats=3D[], read_only=3DFalse): +def skip_if_unsupported(required_formats=3D(), read_only=3DFalse): '''Skip Test Decorator Runs the test if all the required formats are whitelisted''' def skip_test_decorator(func): @@ -1098,11 +1098,11 @@ def execute_unittest(output, verbosity, debug): sys.stderr.write(out) =20 def execute_test(test_function=3DNone, - supported_fmts=3D[], + supported_fmts=3D(), supported_platforms=3DNone, - supported_cache_modes=3D[], supported_aio_modes=3D{}, - unsupported_fmts=3D[], supported_protocols=3D[], - unsupported_protocols=3D[]): + supported_cache_modes=3D(), supported_aio_modes=3D(), + unsupported_fmts=3D(), supported_protocols=3D(), + unsupported_protocols=3D()): """Run either unittest or script-style tests.""" =20 # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584405961; cv=none; d=zohomail.com; s=zohoarc; b=WAMLDcabc0XhtfrvjvZhHPvYwobyeEJuZLQn33lAmkDZZr0yxGFj5un+0StHLMNY+7wNr0FlNJeCWgioMhI/qqxAt7fyj3iBJtbAlWGwej6Eb0tT4u3sRuKJxmTsEbdOOR5AuILN7gUeUJ31LFkLr2k3J/ICuAKGseqvM0kzn0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584405961; h=Content-Type: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; bh=S0We64aQWj81gfK4BjbGVkVQfRzyf3QTE+z185OEnM4=; b=aVVLTlyZ5b8AqOIWlF7DFzjgKEh5rrOaDqYrjkPgqG5P0B/M7XuUB/0YYAlpPB6vrmPJtb3HTooV5D4MJ59g/sjATyQ2NY87eQmtn6t1Ftb/9cgf+WPY1UMvb7dVlQ12LggTCG9uDBHZTcJ4iyZS1IFoggZ2CIjLdoU/tEY3J4Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 15844059612691006.7120900202582; Mon, 16 Mar 2020 17:46:01 -0700 (PDT) Received: from localhost ([::1]:50902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0Mq-0003RN-Ae for importer@patchew.org; Mon, 16 Mar 2020 20:46:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41504) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IL-00045y-D0 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IJ-0005A0-EL for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:21 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:27687) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0II-00056K-Tg for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-dB8CC8YvOMWg0uqXm0WI_A-1; Mon, 16 Mar 2020 20:41:14 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF1488010C7; Tue, 17 Mar 2020 00:41:13 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 523F97A411; Tue, 17 Mar 2020 00:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S0We64aQWj81gfK4BjbGVkVQfRzyf3QTE+z185OEnM4=; b=L5V6Dr5Hxq7HmwDN08mEuIml2UgSoNrDUH91KnZVOtHM47iHrJXfJ3Pq03hNvn3Njdl58H jzMUAatQnbDPyqRW4yLEWgu7ovrjkafncbQMl11V0uzfqrKcFfgOjSH9grZa5YpJnqMuh7 CFblBztJMCwn5hbS94qUUSzPhrPKAEA= X-MC-Unique: dB8CC8YvOMWg0uqXm0WI_A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 05/11] iotests: add pylintrc file Date: Mon, 16 Mar 2020 20:40:59 -0400 Message-Id: <20200317004105.27059-6-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This allows others to get repeatable results with pylint. If you run `pylint iotests.py`, you should see a 100% pass. Signed-off-by: John Snow Reviewed-by: Max Reitz --- tests/qemu-iotests/pylintrc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/qemu-iotests/pylintrc diff --git a/tests/qemu-iotests/pylintrc b/tests/qemu-iotests/pylintrc new file mode 100644 index 0000000000..8720b6a0de --- /dev/null +++ b/tests/qemu-iotests/pylintrc @@ -0,0 +1,22 @@ +[MESSAGES CONTROL] + +# Disable the message, report, category or checker with the given id(s). Y= ou +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=3Dal= l" to +# disable everything first and then reenable specific checks. For example,= if +# you want to run only the similarities checker, you can use "--disable=3D= all +# --enable=3Dsimilarities". If you want to run only the classes checker, b= ut have +# no Warning level messages displayed, use "--disable=3Dall --enable=3Dcla= sses +# --disable=3DW". +disable=3Dinvalid-name, + no-else-return, + too-many-lines, + too-few-public-methods, + too-many-arguments, + too-many-locals, + too-many-branches, + too-many-public-methods, + # These are temporary, and should be removed: + missing-docstring, + line-too-long, --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584406069; cv=none; d=zohomail.com; s=zohoarc; b=Yq+f/6Lt60jhNL/uh8tqMdySPeW6WzNfMU1slF0dEtohvFPPQjjEY3YYWnxsEhlgDKwk3p+9dv+Pj2jVRAR1yG8vCo85UY8ig8u3N6j9OnfxXDbOKI47LKmC9QL6+BVO1IDmevfNfSmR+99FTOWEZ2fq/ZTnfqVc8k99GQr6vJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584406069; h=Content-Type: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; bh=UCY8JCzM+hnfV11ZZ8UCF8U0f91cQV7idL0tWXRh6Ik=; b=Ki5PE8CFe54wNOzmSerkYG6VOtOMSc0VaqyWxO8OfocHuRolwUl4/jw/3FJzXanS5ZFsdvh00OGoRIONVImrQRzXPS6GkTkMHLjxcYxiOoQsNOS9IPL9sgv+u2/hKTi3S7UlfWnt6Aj/f6BFNIX1w/4DCxoTpMF0lcPHcQYeYS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584406069295613.7008651202566; Mon, 16 Mar 2020 17:47:49 -0700 (PDT) Received: from localhost ([::1]:50918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0OZ-0005VY-Oy for importer@patchew.org; Mon, 16 Mar 2020 20:47:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41502) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IL-00045w-CQ for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IK-0005E5-2u for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:21 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:30956) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IJ-0005Bh-VM for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-302-SG8Iu65YMzqgcGR-XFDSxQ-1; Mon, 16 Mar 2020 20:41:15 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9DF2107ACC7; Tue, 17 Mar 2020 00:41:14 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id D771393531; Tue, 17 Mar 2020 00:41:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UCY8JCzM+hnfV11ZZ8UCF8U0f91cQV7idL0tWXRh6Ik=; b=CDTBYnzspmn6tefXebH/r0DXKhgePJlD3d8P34PsbMBv1AA7Jq42hj8Ok6E9Bh4JuJF9f3 vHVywtA9iDbaa0UGTdboB1H7zpZ8xDrmPCzBEkvFI29PTqo+T+Nhod/nAnETyCcSgvtNZz flRmEkoJwK7YxlCfWS1Hwp0GJFXNqFM= X-MC-Unique: SG8Iu65YMzqgcGR-XFDSxQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 06/11] iotests: drop Python 3.4 compatibility code Date: Mon, 16 Mar 2020 20:41:00 -0400 Message-Id: <20200317004105.27059-7-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We no longer need to accommodate 3.4, drop this code. (Also, the line is over 79 characters, so drop it.) Touch up the docstring a little bit while we're here. Signed-off-by: John Snow Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 7cd74e7cb1..3d90fb157d 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -22,6 +22,7 @@ import unittest import sys import struct +from typing import Optional import json import signal import logging @@ -350,18 +351,17 @@ def _filter(_key, value): return value return filter_qmp(qmsg, _filter) =20 -def log(msg, filters=3D(), indent=3DNone): - '''Logs either a string message or a JSON serializable message (like Q= MP). - If indent is provided, JSON serializable messages are pretty-printed.'= '' +def log(msg, filters=3D(), indent: Optional[int] =3D None) -> None: + """ + Logs either a string message or a JSON serializable message (like QMP). + If indent is provided, JSON serializable messages are pretty-printed. + """ for flt in filters: msg =3D flt(msg) if isinstance(msg, (dict, list)): - # Python < 3.4 needs to know not to add whitespace when pretty-pri= nting: - 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)) + print(json.dumps(msg, sort_keys=3Ddo_sort, indent=3Dindent)) else: print(msg) =20 --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584406132; cv=none; d=zohomail.com; s=zohoarc; b=GgPxSKs4fOH58RiMFnQJMZCwQNyM56fu/NTBV/6DJngd6ZXyHCtNpg0qF89IUrR8vK+9NSIEUzGoO28CHAqyc3SMQMh3z+MPKUqdLoD7vy5wkDFc9aDW8rirJqJOIgkGT3pcIcwJw4xsh+0kXrdoBBCcQ5gXb23Ur5V1PS46MlE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584406132; h=Content-Type: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; bh=tazM/+0fZQqtchey+NZtubVXoM+HTeh++WrXhAckz6k=; b=UkgV/6Cir2f4yak6detQ+ISCndLMjH6rgXU2PqIo2q7LhKVcalMvhZSQtY6G9erkKn7eTdJBoCKU7EUoOCgphHoCQxt92rTbNyLU25knN1t8Kkqye1HhVmTZAPy6bvejPXQVmXg1pVCMZTtcCH2fQtz0je/eJJZ1ddu9ixTBXLA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584406132526544.5987751444829; Mon, 16 Mar 2020 17:48:52 -0700 (PDT) Received: from localhost ([::1]:50942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0Pb-0006ym-4Q for importer@patchew.org; Mon, 16 Mar 2020 20:48:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41589) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IP-0004DK-Bh for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IM-0005Jw-0A for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:25 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:35572) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IL-0005Ia-NN for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-161-4MouzYtRPtasq6HOzO8mqQ-1; Mon, 16 Mar 2020 20:41:17 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 876D38017CC; Tue, 17 Mar 2020 00:41:16 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E5A77A411; Tue, 17 Mar 2020 00:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tazM/+0fZQqtchey+NZtubVXoM+HTeh++WrXhAckz6k=; b=OmiNfVwZ2DUb4epq2abuxMCyUnvVXanL9YkznR+ChJ+xZ60Ph3nVtt5Z5da+Chs67IbOwI 5e4vHaHzCotTwoGDBFyuvVhzefbG10MuOUmLnpMMJgS6KK9fr4Kh36MSMguGdVJxFemXj0 z4upwy+Qn8YTzDsy7KJ5+peZHQnzOrQ= X-MC-Unique: 4MouzYtRPtasq6HOzO8mqQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 07/11] iotests: limit line length to 79 chars Date: Mon, 16 Mar 2020 20:41:01 -0400 Message-Id: <20200317004105.27059-8-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 79 is the PEP8 recommendation. This recommendation works well for reading patch diffs in TUI email clients. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qemu-iotests/iotests.py | 64 +++++++++++++++++++++++------------ tests/qemu-iotests/pylintrc | 6 +++- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 3d90fb157d..75fd697d77 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -77,9 +77,11 @@ def qemu_img(*args): '''Run qemu-img and return the exit code''' devnull =3D open('/dev/null', 'r+') - exitcode =3D subprocess.call(qemu_img_args + list(args), stdin=3Ddevnu= ll, stdout=3Ddevnull) + exitcode =3D subprocess.call(qemu_img_args + list(args), + stdin=3Ddevnull, stdout=3Ddevnull) if exitcode < 0: - sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode,= ' '.join(qemu_img_args + list(args)))) + sys.stderr.write('qemu-img received signal %i: %s\n' + % (-exitcode, ' '.join(qemu_img_args + list(args)= ))) return exitcode =20 def ordered_qmp(qmsg, conv_keys=3DTrue): @@ -118,7 +120,8 @@ def qemu_img_verbose(*args): '''Run qemu-img without suppressing its output and return the exit cod= e''' exitcode =3D subprocess.call(qemu_img_args + list(args)) if exitcode < 0: - sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode,= ' '.join(qemu_img_args + list(args)))) + sys.stderr.write('qemu-img received signal %i: %s\n' + % (-exitcode, ' '.join(qemu_img_args + list(args)= ))) return exitcode =20 def qemu_img_pipe(*args): @@ -129,7 +132,8 @@ def qemu_img_pipe(*args): universal_newlines=3DTrue) exitcode =3D subp.wait() if exitcode < 0: - sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode,= ' '.join(qemu_img_args + list(args)))) + sys.stderr.write('qemu-img received signal %i: %s\n' + % (-exitcode, ' '.join(qemu_img_args + list(args)= ))) return subp.communicate()[0] =20 def qemu_img_log(*args): @@ -159,7 +163,8 @@ def qemu_io(*args): universal_newlines=3DTrue) exitcode =3D subp.wait() if exitcode < 0: - sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, = ' '.join(args))) + sys.stderr.write('qemu-io received signal %i: %s\n' + % (-exitcode, ' '.join(args))) return subp.communicate()[0] =20 def qemu_io_log(*args): @@ -281,10 +286,13 @@ def filter_test_dir(msg): def filter_win32(msg): return win32_re.sub("", msg) =20 -qemu_io_re =3D re.compile(r"[0-9]* ops; [0-9\/:. sec]* \([0-9\/.inf]* [EPT= GMKiBbytes]*\/sec and [0-9\/.inf]* ops\/sec\)") +qemu_io_re =3D re.compile(r"[0-9]* ops; [0-9\/:. sec]* " + r"\([0-9\/.inf]* [EPTGMKiBbytes]*\/sec " + r"and [0-9\/.inf]* ops\/sec\)") def filter_qemu_io(msg): msg =3D filter_win32(msg) - return qemu_io_re.sub("X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)= ", msg) + return qemu_io_re.sub("X ops; XX:XX:XX.X " + "(XXX YYY/sec and XXX ops/sec)", msg) =20 chown_re =3D re.compile(r"chown [0-9]+:[0-9]+") def filter_chown(msg): @@ -336,7 +344,9 @@ def filter_img_info(output, filename): line =3D line.replace(filename, 'TEST_IMG') \ .replace(imgfmt, 'IMGFMT') line =3D re.sub('iters: [0-9]+', 'iters: XXX', line) - line =3D re.sub('uuid: [-a-f0-9]+', 'uuid: XXXXXXXX-XXXX-XXXX-XXXX= -XXXXXXXXXXXX', line) + line =3D re.sub('uuid: [-a-f0-9]+', + 'uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', + line) line =3D re.sub('cid: [0-9]+', 'cid: XXXXXXXXXX', line) lines.append(line) return '\n'.join(lines) @@ -529,11 +539,13 @@ def pause_drive(self, drive, event=3DNone): self.pause_drive(drive, "write_aio") return self.qmp('human-monitor-command', - command_line=3D'qemu-io %s "break %s bp_%s"' % (drive, ev= ent, drive)) + command_line=3D'qemu-io %s "break %s bp_%s"' + % (drive, event, drive)) =20 def resume_drive(self, drive): self.qmp('human-monitor-command', - command_line=3D'qemu-io %s "remove_break bp_%s"' % (drive= , drive)) + command_line=3D'qemu-io %s "remove_break bp_%s"' + % (drive, drive)) =20 def hmp_qemu_io(self, drive, cmd): '''Write to a given drive using an HMP command''' @@ -793,16 +805,18 @@ def dictpath(self, d, path): idx =3D int(idx) =20 if not isinstance(d, dict) or component not in d: - self.fail('failed path traversal for "%s" in "%s"' % (path= , str(d))) + self.fail(f'failed path traversal for "{path}" in "{d}"') d =3D d[component] =20 if m: if not isinstance(d, list): - self.fail('path component "%s" in "%s" is not a list i= n "%s"' % (component, path, str(d))) + self.fail(f'path component "{component}" in "{path}" ' + f'is not a list in "{d}"') try: d =3D d[idx] except IndexError: - self.fail('invalid index "%s" in path "%s" in "%s"' % = (idx, path, str(d))) + self.fail(f'invalid index "{idx}" in path "{path}" ' + f'in "{d}"') return d =20 def assert_qmp_absent(self, d, path): @@ -853,10 +867,13 @@ def assert_json_filename_equal(self, json_filename, r= eference): '''Asserts that the given filename is a json: filename and that its content is equal to the given reference object''' self.assertEqual(json_filename[:5], 'json:') - self.assertEqual(self.vm.flatten_qmp_object(json.loads(json_filena= me[5:])), - self.vm.flatten_qmp_object(reference)) + self.assertEqual( + self.vm.flatten_qmp_object(json.loads(json_filename[5:])), + self.vm.flatten_qmp_object(reference) + ) =20 - def cancel_and_wait(self, drive=3D'drive0', force=3DFalse, resume=3DFa= lse, wait=3D60.0): + def cancel_and_wait(self, drive=3D'drive0', force=3DFalse, + resume=3DFalse, wait=3D60.0): '''Cancel a block job and wait for it to finish, returning the eve= nt''' result =3D self.vm.qmp('block-job-cancel', device=3Ddrive, force= =3Dforce) self.assert_qmp(result, 'return', {}) @@ -880,8 +897,8 @@ def cancel_and_wait(self, drive=3D'drive0', force=3DFal= se, resume=3DFalse, wait=3D60.0): self.assert_no_active_block_jobs() return result =20 - def wait_until_completed(self, drive=3D'drive0', check_offset=3DTrue, = wait=3D60.0, - error=3DNone): + def wait_until_completed(self, drive=3D'drive0', check_offset=3DTrue, + wait=3D60.0, error=3DNone): '''Wait for a block job to finish, returning the event''' while True: for event in self.vm.get_qmp_events(wait=3Dwait): @@ -1020,8 +1037,11 @@ def verify_quorum(): notrun('quorum support missing') =20 def qemu_pipe(*args): - '''Run qemu with an option to print something and exit (e.g. a help op= tion), - and return its output''' + """ + Run qemu with an option to print something and exit (e.g. a help optio= n). + + :return: QEMU's stdout output. + """ args =3D [qemu_prog] + qemu_opts + list(args) subp =3D subprocess.Popen(args, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.STDOUT, @@ -1059,8 +1079,8 @@ def func_wrapper(test_case: QMPTestCase, *args, **kwa= rgs): =20 usf_list =3D list(set(fmts) - set(supported_formats(read_only)= )) if usf_list: - test_case.case_skip('{}: formats {} are not whitelisted'.f= ormat( - test_case, usf_list)) + msg =3D f'{test_case}: formats {usf_list} are not whitelis= ted' + test_case.case_skip(msg) return None else: return func(test_case, *args, **kwargs) diff --git a/tests/qemu-iotests/pylintrc b/tests/qemu-iotests/pylintrc index 8720b6a0de..8d02f00607 100644 --- a/tests/qemu-iotests/pylintrc +++ b/tests/qemu-iotests/pylintrc @@ -19,4 +19,8 @@ disable=3Dinvalid-name, too-many-public-methods, # These are temporary, and should be removed: missing-docstring, - line-too-long, + +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=3D79 --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584406079; cv=none; d=zohomail.com; s=zohoarc; b=ng+Xto7XooXLVL2GbYOwrTORKvVEQ2KvfvmYwgPC96D1S0x/lJPqxfcTYA8CKjZ//Zo7Q7Pebg0hHrr7lSW8BzoDHt/pOybRaniIuZRsjomcV/Jw7HcIzNXPo1BRCPKQrJSEQGeUaqRgMb0SjCmke+YSpVkxALxnXtEriNU7EI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584406079; h=Content-Type: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; bh=Eo87ZVke7npPJQdiTkfldgbjn+Sst1Yy6liUhZtqdtA=; b=fixb7nnyW70nqwI1M/uP4l8Vqw2t80g7odyWfJYUfu75Ni50dTspD7x9pPkYLYzsGuh+5mWCrY+OZ//dOv3WBYyP7ysIuZ8ppAdkuko4tHV5NsSxMXiN8urq+cEoAM+coLDm8t/tyH/zVYTivyyjtPg+mJ1N7qJrd0gWIemINTc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584406079429986.8157448524051; Mon, 16 Mar 2020 17:47:59 -0700 (PDT) Received: from localhost ([::1]:50920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0Ok-0005jJ-6l for importer@patchew.org; Mon, 16 Mar 2020 20:47:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41666) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IR-0004Jo-M8 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IN-0005Lo-UU for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:27 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:51353) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IM-0005Jf-64 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-bIOtN2vrN4itgyVCC02Dmg-1; Mon, 16 Mar 2020 20:41:19 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6F0813EA; Tue, 17 Mar 2020 00:41:18 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id B029A9353C; Tue, 17 Mar 2020 00:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Eo87ZVke7npPJQdiTkfldgbjn+Sst1Yy6liUhZtqdtA=; b=fWrNddrAL5T5TW0yBOGaZjoRNWcNTFd6gBfJGLdF0ClgsuRzTHF9E6k/U+cewJzGgqQ1J/ Z0R8o+YuA5rtc5ifVxVlMl0wYtILGp3ct1Z0pxKApr3WocqcUO+Rb1giDD+j1KcK76Adj3 N6nWpCCGF+5ZsSzi1gAfqxlmA4HYrP4= X-MC-Unique: bIOtN2vrN4itgyVCC02Dmg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 08/11] iotests: add script_initialize Date: Mon, 16 Mar 2020 20:41:02 -0400 Message-Id: <20200317004105.27059-9-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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. Signed-off-by: John Snow Reviewed-by: Max Reitz --- tests/qemu-iotests/149 | 3 +- tests/qemu-iotests/194 | 4 +- tests/qemu-iotests/202 | 4 +- tests/qemu-iotests/203 | 4 +- tests/qemu-iotests/206 | 2 +- tests/qemu-iotests/207 | 6 ++- tests/qemu-iotests/208 | 2 +- tests/qemu-iotests/209 | 2 +- tests/qemu-iotests/210 | 6 ++- tests/qemu-iotests/211 | 6 ++- tests/qemu-iotests/212 | 6 ++- tests/qemu-iotests/213 | 6 ++- tests/qemu-iotests/216 | 4 +- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/219 | 2 +- tests/qemu-iotests/222 | 7 ++-- tests/qemu-iotests/224 | 4 +- tests/qemu-iotests/228 | 6 ++- tests/qemu-iotests/234 | 4 +- 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/258 | 7 ++-- tests/qemu-iotests/260 | 4 +- tests/qemu-iotests/262 | 4 +- tests/qemu-iotests/264 | 4 +- tests/qemu-iotests/277 | 2 + tests/qemu-iotests/280 | 8 ++-- tests/qemu-iotests/283 | 4 +- tests/qemu-iotests/iotests.py | 73 +++++++++++++++++++++++------------ 37 files changed, 128 insertions(+), 80 deletions(-) diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149 index b4a21bf7b7..852768f80a 100755 --- a/tests/qemu-iotests/149 +++ b/tests/qemu-iotests/149 @@ -382,8 +382,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 9dc1bd3510..8b1f720af4 100755 --- a/tests/qemu-iotests/194 +++ b/tests/qemu-iotests/194 @@ -21,8 +21,8 @@ =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'], + supported_platforms=3D['linux']) =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 920a8683ef..e3900a44d1 100755 --- a/tests/qemu-iotests/202 +++ b/tests/qemu-iotests/202 @@ -24,8 +24,8 @@ =20 import iotests =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2'], + supported_platforms=3D['linux']) =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 49eff5d405..4b4bd3307d 100755 --- a/tests/qemu-iotests/203 +++ b/tests/qemu-iotests/203 @@ -24,8 +24,8 @@ =20 import iotests =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2'], + supported_platforms=3D['linux']) =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 e2b50ae24d..f42432a838 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 with iotests.FilePath('t.qcow2') as disk_path, \ iotests.FilePath('t.qcow2.base') as backing_path, \ diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 index 3d9c1208ca..a6621410da 100755 --- a/tests/qemu-iotests/207 +++ b/tests/qemu-iotests/207 @@ -24,8 +24,10 @@ import iotests import subprocess import re =20 -iotests.verify_image_format(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/208 b/tests/qemu-iotests/208 index 1c3fc8c7fd..6cb642f821 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 65c1a1e70a..8c804f4a30 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 =3D file_path('disk') nbd_sock =3D file_path('nbd-sock', base_dir=3Diotests.sock_dir) diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210 index e49896e23d..7bf591f313 100755 --- a/tests/qemu-iotests/210 +++ b/tests/qemu-iotests/210 @@ -23,8 +23,10 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['luks']) -iotests.verify_protocol(supported=3D['file']) +iotests.script_initialize( + supported_fmts=3D['luks'], + supported_protocols=3D['file'], +) =20 with iotests.FilePath('t.luks') as disk_path, \ iotests.VM() as vm: diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211 index 163994d559..4969edb00c 100755 --- a/tests/qemu-iotests/211 +++ b/tests/qemu-iotests/211 @@ -23,8 +23,10 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(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): error =3D vm.blockdev_create(options) diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212 index 800f92dd84..45d08842bb 100755 --- a/tests/qemu-iotests/212 +++ b/tests/qemu-iotests/212 @@ -23,8 +23,10 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['parallels']) -iotests.verify_protocol(supported=3D['file']) +iotests.script_initialize( + supported_fmts=3D['parallels'], + supported_protocols=3D['file'], +) =20 with iotests.FilePath('t.parallels') as disk_path, \ iotests.VM() as vm: diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213 index 1eee45276a..cf638eb927 100755 --- a/tests/qemu-iotests/213 +++ b/tests/qemu-iotests/213 @@ -23,8 +23,10 @@ import iotests from iotests import imgfmt =20 -iotests.verify_image_format(supported_fmts=3D['vhdx']) -iotests.verify_protocol(supported=3D['file']) +iotests.script_initialize( + supported_fmts=3D['vhdx'], + supported_protocols=3D['file'], +) =20 with iotests.FilePath('t.vhdx') as disk_path, \ iotests.VM() as vm: diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216 index 372f042d3e..de11d85b5d 100755 --- a/tests/qemu-iotests/216 +++ b/tests/qemu-iotests/216 @@ -23,8 +23,8 @@ 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'= ], + supported_platforms=3D['linux']) =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 1325ba9eaa..5586870456 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 b8774770c4..db272c5249 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 bf1718e179..6602f6b4ba 100755 --- a/tests/qemu-iotests/222 +++ b/tests/qemu-iotests/222 @@ -24,9 +24,10 @@ 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'], + supported_platforms=3D['linux'], +) =20 patterns =3D [("0x5d", "0", "64k"), ("0xd5", "1M", "64k"), diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224 index e91fb26fd8..81ca1e4898 100755 --- a/tests/qemu-iotests/224 +++ b/tests/qemu-iotests/224 @@ -26,8 +26,8 @@ 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'], + supported_platforms=3D['linux']) =20 =20 # There are two variations of this test: diff --git a/tests/qemu-iotests/228 b/tests/qemu-iotests/228 index 64bc82ee23..da0900fb82 100755 --- a/tests/qemu-iotests/228 +++ b/tests/qemu-iotests/228 @@ -25,8 +25,10 @@ from iotests import log, qemu_img, filter_testfiles, fil= ter_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'], + supported_platforms=3D['linux'], +) =20 =20 def log_node_info(node): diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234 index 324c1549fd..73c899ddae 100755 --- a/tests/qemu-iotests/234 +++ b/tests/qemu-iotests/234 @@ -23,8 +23,8 @@ import iotests import os =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2'], + supported_platforms=3D['linux']) =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 760826128e..d1b10ac36b 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 8ce927a16c..6f5cee2444 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 50ba364a3e..5b21ad3509 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 with iotests.FilePath('t.vmdk') as disk_path, \ iotests.FilePath('t.vmdk.1') as extent1_path, \ diff --git a/tests/qemu-iotests/238 b/tests/qemu-iotests/238 index d4e060228c..b8fcf15a1f 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 97617876bc..64f1bd95e4 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 59a216a839..58a479cc1f 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 68c374692e..18ba03467e 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 ee66c986db..150e58be8e 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 4a4818bafb..8f08f741da 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 iotests.log('Finishing a commit job with background reads') iotests.log('=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D') diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256 index e34074c83e..db8d6f31cf 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/258 b/tests/qemu-iotests/258 index 091755a45c..a65151dda6 100755 --- a/tests/qemu-iotests/258 +++ b/tests/qemu-iotests/258 @@ -24,9 +24,10 @@ 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']) - +iotests.script_initialize( + supported_fmts=3D['qcow2', 'qed'], + supported_platforms=3D['linux'], +) =20 # Returns a node for blockdev-add def node(node_name, path, backing=3DNone, fmt=3DNone, throttle=3DNone): diff --git a/tests/qemu-iotests/260 b/tests/qemu-iotests/260 index 30c0de380d..804a7addb9 100755 --- a/tests/qemu-iotests/260 +++ b/tests/qemu-iotests/260 @@ -21,7 +21,9 @@ import iotests from iotests import qemu_img_create, file_path, log, filter_qmp_event =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize( + supported_fmts=3D['qcow2'] +) =20 base, top =3D file_path('base', 'top') size =3D 64 * 1024 * 3 diff --git a/tests/qemu-iotests/262 b/tests/qemu-iotests/262 index 8835dce7be..03af061f94 100755 --- a/tests/qemu-iotests/262 +++ b/tests/qemu-iotests/262 @@ -23,8 +23,8 @@ import iotests import os =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=3D['qcow2'], + supported_platforms=3D['linux']) =20 with iotests.FilePath('img') as img_path, \ iotests.FilePath('mig_fifo') as fifo, \ diff --git a/tests/qemu-iotests/264 b/tests/qemu-iotests/264 index 879123a343..304a7443d7 100755 --- a/tests/qemu-iotests/264 +++ b/tests/qemu-iotests/264 @@ -24,7 +24,9 @@ import iotests from iotests import qemu_img_create, qemu_io_silent_check, file_path, \ qemu_nbd_popen, log =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize( + supported_fmts=3D['qcow2'], +) =20 disk_a, disk_b, nbd_sock =3D file_path('disk_a', 'disk_b', 'nbd-sock') nbd_uri =3D 'nbd+unix:///?socket=3D' + nbd_sock diff --git a/tests/qemu-iotests/277 b/tests/qemu-iotests/277 index 04aa15a3d5..d34f87021f 100755 --- a/tests/qemu-iotests/277 +++ b/tests/qemu-iotests/277 @@ -23,6 +23,8 @@ import subprocess import iotests from iotests import file_path, log =20 +iotests.script_initialize() + =20 nbd_sock, conf_file =3D file_path('nbd-sock', 'nbd-fault-injector.conf') =20 diff --git a/tests/qemu-iotests/280 b/tests/qemu-iotests/280 index 69288fdd0e..f594bb9ed2 100755 --- a/tests/qemu-iotests/280 +++ b/tests/qemu-iotests/280 @@ -22,9 +22,11 @@ import iotests import os =20 -iotests.verify_image_format(supported_fmts=3D['qcow2']) -iotests.verify_protocol(supported=3D['file']) -iotests.verify_platform(['linux']) +iotests.script_initialize( + supported_fmts=3D['qcow2'], + supported_protocols=3D['file'], + supported_platforms=3D['linux'], +) =20 with iotests.FilePath('base') as base_path , \ iotests.FilePath('top') as top_path, \ diff --git a/tests/qemu-iotests/283 b/tests/qemu-iotests/283 index 55b7cff953..e17b953333 100644 --- a/tests/qemu-iotests/283 +++ b/tests/qemu-iotests/283 @@ -21,7 +21,9 @@ import iotests =20 # The test is unrelated to formats, restrict it to qcow2 to avoid extra ru= ns -iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.script_initialize( + supported_fmts=3D['qcow2'], +) =20 size =3D 1024 * 1024 =20 diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 75fd697d77..ec7aa42a70 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -29,6 +29,7 @@ import atexit import io from collections import OrderedDict +from typing import Collection =20 # pylint: disable=3Dimport-error, wrong-import-position sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) @@ -1011,12 +1012,11 @@ def verify_protocol(supported=3D(), unsupported=3D(= )): if not_sup or (imgproto in unsupported): notrun('not suitable for this protocol: %s' % imgproto) =20 -def verify_platform(supported=3DNone, unsupported=3DNone): - if unsupported is not None: - if any((sys.platform.startswith(x) for x in unsupported)): - notrun('not suitable for this OS: %s' % sys.platform) +def verify_platform(supported=3D(), unsupported=3D()): + if any((sys.platform.startswith(x) for x in unsupported)): + notrun('not suitable for this OS: %s' % sys.platform) =20 - if supported is not None: + if supported: if not any((sys.platform.startswith(x) for x in supported)): notrun('not suitable for this OS: %s' % sys.platform) =20 @@ -1098,7 +1098,18 @@ def func_wrapper(*args, **kwargs): return func(*args, **kwargs) return func_wrapper =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 + else: + # We need to filter out the time taken from the output so that + # qemu-iotest can reliably diff the results against master output. + output =3D io.StringIO() + runner =3D unittest.TextTestRunner(stream=3Doutput, descriptions=3DTru= e, verbosity=3Dverbosity) try: @@ -1106,6 +1117,8 @@ 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: out =3D output.getvalue() out =3D re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests'= , out) @@ -1117,13 +1130,18 @@ def execute_unittest(output, verbosity, debug): =20 sys.stderr.write(out) =20 -def execute_test(test_function=3DNone, - supported_fmts=3D(), - supported_platforms=3DNone, - supported_cache_modes=3D(), supported_aio_modes=3D(), - unsupported_fmts=3D(), supported_protocols=3D(), - unsupported_protocols=3D()): - """Run either unittest or script-style tests.""" +def execute_setup_common(supported_fmts: Collection[str] =3D (), + supported_platforms: Collection[str] =3D (), + supported_cache_modes: Collection[str] =3D (), + supported_aio_modes: Collection[str] =3D (), + unsupported_fmts: Collection[str] =3D (), + supported_protocols: Collection[str] =3D (), + unsupported_protocols: Collection[str] =3D ()) ->= bool: + """ + Perform necessary setup for either script-style or unittest-style test= s. + + :return: Bool; Whether or not debug mode has been requested via the CL= I. + """ =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 @@ -1133,34 +1151,39 @@ 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_protocol(supported_protocols, unsupported_protocols) verify_platform(supported=3Dsupported_platforms) verify_cache_mode(supported_cache_modes) verify_aio_mode(supported_aio_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. - output =3D io.StringIO() - logging.basicConfig(level=3D(logging.DEBUG if debug else logging.WARN)) =20 + return debug + +def execute_test(*args, test_function=3DNone, **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) + execute_test(*args, test_function=3Dtest_function, **kwargs) =20 +# This is called from unittest style iotests def main(*args, **kwargs): """Run tests using the unittest framework""" - execute_test(None, *args, **kwargs) + execute_test(*args, **kwargs) --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584405776; cv=none; d=zohomail.com; s=zohoarc; b=eVAhK3B/A/yRoxQPcWM4gMqQB5g17TNRunPBhxVRi/RCl/kZzkCLchsDdgkA/HGhwkasnEP4S0haSWdC1fXKof2Ed+MB+QZczsopYEZwuQ0rul2Zc2cXLHCIWOI7YODHsIaaYLjmqTSmKHyA1K/ka03jZtcZE66DXbotgdRoOQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584405776; h=Content-Type: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; bh=Xv6o6f8b1Q4FefHhXsxFTjQdb4skVJt1N5hqGDVXzJE=; b=RQvO0iHVu3z64raMoJcINT+CSIVqyt8QtUlJ2fZ5f9RCAF+pMTelamGaRMs4rrd2YaEYGTHTJTYVIJKrp71a4+eLBEbDt49bbfcsZ8i28P0vVK+WvKcmEfUrASeAke33QuIFIxIjFsuSWgRsz/lNsdqHgLGffenbf6R8Dw5cpsI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584405776864483.88361824688013; Mon, 16 Mar 2020 17:42:56 -0700 (PDT) Received: from localhost ([::1]:50836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0Jr-0006Hh-Rj for importer@patchew.org; Mon, 16 Mar 2020 20:42:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41582) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IP-0004D1-8P for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IO-0005N5-3n for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:25 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:39674) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IN-0005LL-VE for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-BNL_UadkPCCIAjFGade3EA-1; Mon, 16 Mar 2020 20:41:21 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 325A1800D53; Tue, 17 Mar 2020 00:41:20 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06F0B7A411; Tue, 17 Mar 2020 00:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xv6o6f8b1Q4FefHhXsxFTjQdb4skVJt1N5hqGDVXzJE=; b=M0FTqgkhzeXUC0BlygI8EcpzZfwXHDkMi86iuCGtwnLR4MKYmH+p6phlPcF8KgMiHO7xc8 maU1XknwlzczAzGbzIti5bEZgP3kYz4KhbwVDROSgftFArvDWXa2WZx5j2BDkbV4WrhAwY vZJ79dqHLoNpmlywZH7zKFXxmItcPwA= X-MC-Unique: BNL_UadkPCCIAjFGade3EA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 09/11] iotest 258: use script_main Date: Mon, 16 Mar 2020 20:41:03 -0400 Message-Id: <20200317004105.27059-10-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Max Reitz --- tests/qemu-iotests/258 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258 index a65151dda6..e305a1502f 100755 --- a/tests/qemu-iotests/258 +++ b/tests/qemu-iotests/258 @@ -23,12 +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.script_initialize( - supported_fmts=3D['qcow2', 'qed'], - supported_platforms=3D['linux'], -) - # Returns a node for blockdev-add def node(node_name, path, backing=3DNone, fmt=3DNone, throttle=3DNone): if fmt is None: @@ -161,4 +155,7 @@ 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'], + supported_platforms=3D['linux']) --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584405962; cv=none; d=zohomail.com; s=zohoarc; b=WFqyMxAXZOdGqBP2MtspvdB/vmE7meqWuEhp8WFdXBe10bouvybEwzFdbLbzL5mcJg4Ic4d8rhm1FP3pXoxQKOzx2Np6myGx4NLNW9WJBfm4jcwopy1oXwsSIyGxtRFqlFJcKIOxddBYIAuI34H6jQsDMneJKyv2yyKusmQ1M5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584405962; h=Content-Type: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; bh=Y7jRjEibibgckQjO9NFz+8/WOaFK+Qeu2Tf4flFKXow=; b=QrOkwk67lasgIedA29qghUAZJhWQXQRNnpApSLeLpco+B2wfQzrTKUTDQyrUZzMkFGhbL33CKkgVbycOng1VD1iupbLq12cAy8oLJPzXTfUjE7hsorV5/rsSuZh0y32ZbF9zxbRThUZfAGSa+P7uoEfiOINMGQhVWGAWicNxIEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 15844059627801009.0339462397167; Mon, 16 Mar 2020 17:46:02 -0700 (PDT) Received: from localhost ([::1]:50904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0Mr-0003SQ-Q9 for importer@patchew.org; Mon, 16 Mar 2020 20:46:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41615) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IQ-0004FO-3y for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IO-0005Qt-N5 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:26 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:47015) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IO-0005Oj-Hv for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-jqn__ZfAN-C7o3YXMeWBeQ-1; Mon, 16 Mar 2020 20:41:22 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F26E100550D; Tue, 17 Mar 2020 00:41:21 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ACCF7A411; Tue, 17 Mar 2020 00:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y7jRjEibibgckQjO9NFz+8/WOaFK+Qeu2Tf4flFKXow=; b=Z0c5L2nMutKOhnw4f5wdk7emyZznxmLWgfpvWss06GXw5lvA5K4TTpKQ49PMqxC0YL4Z8W Tb+z7AE78I3CxRQXp7JW3KbwSCj//KFnENDuwrj8nCGdtE83M81cGenQdLGR4uEjHLqhAY k/2Qm8GsGFsk8Y28IIfXR5wLoLcQMzM= X-MC-Unique: jqn__ZfAN-C7o3YXMeWBeQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 10/11] iotests: Mark verify functions as private Date: Mon, 16 Mar 2020 20:41:04 -0400 Message-Id: <20200317004105.27059-11-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Mark the verify functions as "private" with a leading underscore, to discourage their use. (Also, make pending patches not yet using the new entry points fail in a very obvious way.) Signed-off-by: John Snow Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index ec7aa42a70..7d6cc430a4 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -988,7 +988,7 @@ def case_notrun(reason): open('%s/%s.casenotrun' % (output_dir, seq), 'a').write( ' [case not run] ' + reason + '\n') =20 -def verify_image_format(supported_fmts=3D(), unsupported_fmts=3D()): +def _verify_image_format(supported_fmts=3D(), unsupported_fmts=3D()): assert not (supported_fmts and unsupported_fmts) =20 if 'generic' in supported_fmts and \ @@ -1002,7 +1002,7 @@ def verify_image_format(supported_fmts=3D(), unsuppor= ted_fmts=3D()): if not_sup or (imgfmt in unsupported_fmts): notrun('not suitable for this image format: %s' % imgfmt) =20 -def verify_protocol(supported=3D(), unsupported=3D()): +def _verify_protocol(supported=3D(), unsupported=3D()): assert not (supported and unsupported) =20 if 'generic' in supported: @@ -1012,7 +1012,7 @@ def verify_protocol(supported=3D(), unsupported=3D()): if not_sup or (imgproto in unsupported): notrun('not suitable for this protocol: %s' % imgproto) =20 -def verify_platform(supported=3D(), unsupported=3D()): +def _verify_platform(supported=3D(), unsupported=3D()): if any((sys.platform.startswith(x) for x in unsupported)): notrun('not suitable for this OS: %s' % sys.platform) =20 @@ -1020,11 +1020,11 @@ def verify_platform(supported=3D(), unsupported=3D(= )): if not any((sys.platform.startswith(x) for x in supported)): notrun('not suitable for this OS: %s' % sys.platform) =20 -def verify_cache_mode(supported_cache_modes=3D()): +def _verify_cache_mode(supported_cache_modes=3D()): if supported_cache_modes and (cachemode not in supported_cache_modes): notrun('not suitable for this cache mode: %s' % cachemode) =20 -def verify_aio_mode(supported_aio_modes=3D()): +def _verify_aio_mode(supported_aio_modes=3D()): if supported_aio_modes and (aiomode not in supported_aio_modes): notrun('not suitable for this aio mode: %s' % aiomode) =20 @@ -1151,11 +1151,11 @@ def execute_setup_common(supported_fmts: Collection= [str] =3D (), sys.stderr.write('Please run this test via the "check" script\n') sys.exit(os.EX_USAGE) =20 - verify_image_format(supported_fmts, unsupported_fmts) - verify_protocol(supported_protocols, unsupported_protocols) - verify_platform(supported=3Dsupported_platforms) - verify_cache_mode(supported_cache_modes) - verify_aio_mode(supported_aio_modes) + _verify_image_format(supported_fmts, unsupported_fmts) + _verify_protocol(supported_protocols, unsupported_protocols) + _verify_platform(supported=3Dsupported_platforms) + _verify_cache_mode(supported_cache_modes) + _verify_aio_mode(supported_aio_modes) =20 debug =3D '-d' in sys.argv if debug: --=20 2.21.1 From nobody Sun May 5 16:34:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584405868; cv=none; d=zohomail.com; s=zohoarc; b=ECF41AkCCBPMMJykU/qiOMQ42RUGzyhVTYgufuuETosuPlihRO6AOk+omyOXjvDwc2L9gVhfCQjjxzJJsFYC6dLU+QxH1WjmTrJOI17vWUqHp5khkmsmcjRTZdJYj5qaFbjQPCeRgaBbba4JB2cBDZcXPoKLF/qys1B10+R6KZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584405868; h=Content-Type: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; bh=6nCWGGcvDINr8VvhdiD2z/JaMCRwOkULtz4107dv8BA=; b=nuzKLootGSVbA0/yb2Zd8GOcBgKzPM7ffx4Bd8tsCukG9lArzQa4HfABoxlvxlDKFyl7Zy3BHGLQ3OmoZz/ENaHpFSgxQIaHQB2gIuRN3/S8eY1d6qQBTrgUA1V5wAYblRO4b52XszRWku+6VRd6h9mtIFkdoEi5SwcGW5Sd8gM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1584405868544782.9594273251173; Mon, 16 Mar 2020 17:44:28 -0700 (PDT) Received: from localhost ([::1]:50868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0LL-0001KB-EI for importer@patchew.org; Mon, 16 Mar 2020 20:44:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41706) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE0IT-0004PG-PI for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE0IR-0005cm-Bc for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:29 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:50622) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE0IR-0005br-54 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 20:41:27 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-5CK2m5-kNx2cJ3Y-vI1w6A-1; Mon, 16 Mar 2020 20:41:23 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1C60800D53; Tue, 17 Mar 2020 00:41:22 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FADC93531; Tue, 17 Mar 2020 00:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584405686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6nCWGGcvDINr8VvhdiD2z/JaMCRwOkULtz4107dv8BA=; b=QPUvcg9thsazxLTAQK/yD0YWRknsAv8xLD8Gq6Mw3951+/nrD8VBNoUaXSDk8TDl4O578D dy4rorLXKB0MfimVQ24juUZ0AQtYdIj6w3SQ58JMiuroIRLw5Y7CBmX+mh2xRFxWDGJdEV PZ9bc38RHWrJvRLeOfxE3B2DKlo49L4= X-MC-Unique: 5CK2m5-kNx2cJ3Y-vI1w6A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v8 11/11] iotests: use python logging for iotests.log() Date: Mon, 16 Mar 2020 20:41:05 -0400 Message-Id: <20200317004105.27059-12-jsnow@redhat.com> In-Reply-To: <20200317004105.27059-1-jsnow@redhat.com> References: <20200317004105.27059-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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 , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, armbru@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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. An extended note on python logging: A NullHandler is added to `qemu.iotests` to stop output from being generated if this code is used as a library without configuring logging. A NullHandler is only needed at the root, so a duplicate handler is not needed for `qemu.iotests.diff_io`. When logging is not configured, messages at the 'WARNING' levels or above are printed with default settings. The NullHandler stops this from occurring, which is considered good hygiene for code used as a library. See https://docs.python.org/3/howto/logging.html#library-config When logging is actually enabled (always at the behest of an explicit call by a client script), a root logger is implicitly created at the root, which allows messages to propagate upwards and be handled/emitted from the root logger with default settings. When we want iotest logging, we attach a handler to the qemu.iotests.diff_io logger and disable propagation to avoid possible double-printing. For more information on python logging infrastructure, I highly recommend downloading the pip package `logging_tree`, which provides convenient visualizations of the hierarchical logging configuration under different circumstances. See https://pypi.org/project/logging_tree/ for more information. Signed-off-by: John Snow Reviewed-by: Max Reitz --- tests/qemu-iotests/030 | 4 +-- tests/qemu-iotests/155 | 2 +- tests/qemu-iotests/245 | 1 + tests/qemu-iotests/245.out | 24 ++++++++-------- tests/qemu-iotests/iotests.py | 53 ++++++++++++++++++++--------------- 5 files changed, 46 insertions(+), 38 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index aa911d266a..104e3cee1b 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/155 b/tests/qemu-iotests/155 index 571bce9de4..cb371d4649 100755 --- a/tests/qemu-iotests/155 +++ b/tests/qemu-iotests/155 @@ -188,7 +188,7 @@ class MirrorBaseClass(BaseClass): =20 self.assert_qmp(result, 'return', {}) =20 - self.vm.run_job('mirror-job', use_log=3DFalse, auto_finalize=3DFal= se, + self.vm.run_job('mirror-job', auto_finalize=3DFalse, pre_finalize=3Dself.openBacking, auto_dismiss=3DTr= ue) =20 def testFull(self): diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 index 1001275a44..4f5f0bb901 100755 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -1027,5 +1027,6 @@ class TestBlockdevReopen(iotests.QMPTestCase): self.run_test_iothreads(None, 'iothread0') =20 if __name__ =3D=3D '__main__': + iotests.activate_logging() iotests.main(supported_fmts=3D["qcow2"], supported_protocols=3D["file"]) diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out index 682b93394d..4b33dcaf5c 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 21 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 7d6cc430a4..9304066471 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -37,6 +37,14 @@ =20 assert sys.version_info >=3D (3, 6) =20 +# Use this logger for logging messages directly from the iotests module +logger =3D logging.getLogger('qemu.iotests') +logger.addHandler(logging.NullHandler()) + +# Use this logger for messages that ought to be used for diff output. +test_logger =3D logging.getLogger('qemu.iotests.diff_io') + + # This will not work if arguments contain spaces but is necessary if we # want to support the override options that ./check supports. qemu_img_args =3D [os.environ.get('QEMU_IMG_PROG', 'qemu-img')] @@ -372,9 +380,9 @@ def log(msg, filters=3D(), indent: Optional[int] =3D No= ne) -> None: if isinstance(msg, (dict, list)): # 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)) + test_logger.info(json.dumps(msg, sort_keys=3Ddo_sort, indent=3Dind= ent)) else: - print(msg) + test_logger.info(msg) =20 class Timeout: def __init__(self, seconds, errmsg=3D"Timeout"): @@ -591,7 +599,7 @@ def qmp_log(self, cmd, filters=3D(), indent=3DNone, **k= wargs): =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 @@ -604,7 +612,6 @@ def run_job(self, job, auto_finalize=3DTrue, auto_dismi= ss=3DFalse, 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. """ @@ -622,8 +629,7 @@ def run_job(self, job, auto_finalize=3DTrue, auto_dismi= ss=3DFalse, while True: ev =3D filter_qmp_event(self.events_wait(events, timeout=3Dwai= t)) 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': @@ -631,29 +637,18 @@ def run_job(self, job, auto_finalize=3DTrue, auto_dis= miss=3DFalse, 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 'ready': - if use_log: - self.qmp_log('job-complete', id=3Djob) - else: - self.qmp('job-complete', id=3Djob) + self.qmp_log('job-complete', id=3Djob) 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 @@ -973,7 +968,7 @@ def notrun(reason): seq =3D os.path.basename(sys.argv[0]) =20 open('%s/%s.notrun' % (output_dir, seq), 'w').write(reason + '\n') - print('%s not run: %s' % (seq, reason)) + logger.warning("%s not run: %s", seq, reason) sys.exit(0) =20 def case_notrun(reason): @@ -1161,6 +1156,7 @@ def execute_setup_common(supported_fmts: Collection[s= tr] =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 @@ -1173,14 +1169,25 @@ def execute_test(*args, test_function=3DNone, **kwa= rgs): 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(*args, test_function=3Dtest_function, **kwargs) =20 # This is called from unittest style iotests --=20 2.21.1