From nobody Thu Nov 6 12:14:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540946896805462.95522695797763; Tue, 30 Oct 2018 17:48:16 -0700 (PDT) Received: from localhost ([::1]:56341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHegB-0001nA-Ka for importer@patchew.org; Tue, 30 Oct 2018 20:48:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHeQY-0002Kf-4r for qemu-devel@nongnu.org; Tue, 30 Oct 2018 20:32:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHeQU-00040j-TN for qemu-devel@nongnu.org; Tue, 30 Oct 2018 20:32:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55088) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHeQS-0003xZ-Bz; Tue, 30 Oct 2018 20:32:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BFA7558E20; Wed, 31 Oct 2018 00:31:58 +0000 (UTC) Received: from localhost (ovpn-116-56.gru2.redhat.com [10.97.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABF24100195E; Wed, 31 Oct 2018 00:31:55 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 21:31:14 -0300 Message-Id: <20181031003120.26771-10-ehabkost@redhat.com> In-Reply-To: <20181031003120.26771-1-ehabkost@redhat.com> References: <20181031003120.26771-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 Oct 2018 00:31:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/15] iotests: Modify imports for Python 3 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Max Reitz , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz There are two imports that need to be modified when running the iotests under Python 3: One is StringIO, which no longer exists; instead, the StringIO class comes from the io module, so import it from there (and use the BytesIO class for Python 2). The other is the ConfigParser, which has just been renamed to configparser. Signed-off-by: Max Reitz Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Message-Id: <20181022135307.14398-9-mreitz@redhat.com> Signed-off-by: Eduardo Habkost --- tests/qemu-iotests/iotests.py | 13 +++++++++---- tests/qemu-iotests/nbd-fault-injector.py | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 7ca94e9278..a0f35e4b68 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -29,6 +29,7 @@ import json import signal import logging import atexit +import io =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'scrip= ts')) import qtest @@ -681,15 +682,19 @@ def main(supported_fmts=3D[], supported_oses=3D['linu= x'], supported_cache_modes=3D[], verify_platform(supported_oses) verify_cache_mode(supported_cache_modes) =20 - # We need to filter out the time taken from the output so that qemu-io= test - # can reliably diff the results against master output. - import StringIO if debug: output =3D sys.stdout verbosity =3D 2 sys.argv.remove('-d') else: - output =3D StringIO.StringIO() + # We need to filter out the time taken from the output so that + # qemu-iotest can reliably diff the results against master output. + if sys.version_info.major >=3D 3: + output =3D io.StringIO() + else: + # io.StringIO is for unicode strings, which is not what + # 2.x's test runner emits. + output =3D io.BytesIO() =20 logging.basicConfig(level=3D(logging.DEBUG if debug else logging.WARN)) =20 diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/= nbd-fault-injector.py index d45e2e0a6a..6b2d659dee 100755 --- a/tests/qemu-iotests/nbd-fault-injector.py +++ b/tests/qemu-iotests/nbd-fault-injector.py @@ -48,7 +48,10 @@ import sys import socket import struct import collections -import ConfigParser +if sys.version_info.major >=3D 3: + import configparser +else: + import ConfigParser as configparser =20 FAKE_DISK_SIZE =3D 8 * 1024 * 1024 * 1024 # 8 GB =20 @@ -225,7 +228,7 @@ def parse_config(config): return rules =20 def load_rules(filename): - config =3D ConfigParser.RawConfigParser() + config =3D configparser.RawConfigParser() with open(filename, 'rt') as f: config.readfp(f, filename) return parse_config(config) --=20 2.18.0.rc1.1.g3f1ff2140