From nobody Mon Feb 9 07:55:39 2026 Delivered-To: importer@patchew.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632420879329616.6135741538417; Thu, 23 Sep 2021 11:14:39 -0700 (PDT) Received: from localhost ([::1]:51866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTTEz-0005yM-VN for importer@patchew.org; Thu, 23 Sep 2021 14:14:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTT8J-0005Q4-Ky for qemu-devel@nongnu.org; Thu, 23 Sep 2021 14:07:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTT89-0003Un-ES for qemu-devel@nongnu.org; Thu, 23 Sep 2021 14:07:42 -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-560-ATqZj1YDOXettLNuJJTLrw-1; Thu, 23 Sep 2021 14:07:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1ACF61084683; Thu, 23 Sep 2021 18:07:26 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id F14A060BE5; Thu, 23 Sep 2021 18:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632420450; 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=SZ4cC/7v/qxYlGzLlH72C5MQYwtyyCkS4n6qF7epGOk=; b=JtWxMxLEjVrlO7L6EDnZZS8SpUgsr+TCu3mJo0ZgwTNOKdN5AJIFgQMrM9UaRw/vpY3XNu JQi88Vc9jyk9gaGthloQbR9puKABsp3+tphQrXh1FGLeaxFtYkq8PqRwWiCAq6sGTCIEo+ MTOb+E0NbDq6QybaDaZuVpnbxENf+mk= X-MC-Unique: ATqZj1YDOXettLNuJJTLrw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 1/6] iotests: add 'qemu' package location to PYTHONPATH in testenv Date: Thu, 23 Sep 2021 14:07:10 -0400 Message-Id: <20210923180715.4168522-2-jsnow@redhat.com> In-Reply-To: <20210923180715.4168522-1-jsnow@redhat.com> References: <20210923180715.4168522-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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 , Vladimir Sementsov-Ogievskiy , Daniel Berrange , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hanna 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) X-ZM-MESSAGEID: 1632420880226100001 We can drop the sys.path hacking in various places by doing this. Additionally, by doing it in one place right up top, we can print interesting warnings in case the environment does not look correct. (See next commit.) If we ever decide to change how the environment is crafted, all of the "help me find my python packages" goop is all in one place, right in one function. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf --- tests/qemu-iotests/235 | 2 -- tests/qemu-iotests/297 | 6 ------ tests/qemu-iotests/300 | 7 +++---- tests/qemu-iotests/iotests.py | 2 -- tests/qemu-iotests/testenv.py | 15 +++++++++------ tests/qemu-iotests/tests/mirror-top-perms | 7 +++---- 6 files changed, 15 insertions(+), 24 deletions(-) diff --git a/tests/qemu-iotests/235 b/tests/qemu-iotests/235 index 8aed45f9a76..4de920c3801 100755 --- a/tests/qemu-iotests/235 +++ b/tests/qemu-iotests/235 @@ -24,8 +24,6 @@ import os import iotests from iotests import qemu_img_create, qemu_io, file_path, log =20 -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) - from qemu.machine import QEMUMachine =20 iotests.script_initialize(supported_fmts=3D['qcow2']) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index b04cba53667..467b712280e 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -68,12 +68,6 @@ def run_linters(): # Todo notes are fine, but fixme's or xxx's should probably just be # fixed (in tests, at least) env =3D os.environ.copy() - qemu_module_path =3D os.path.join(os.path.dirname(__file__), - '..', '..', 'python') - try: - env['PYTHONPATH'] +=3D os.pathsep + qemu_module_path - except KeyError: - env['PYTHONPATH'] =3D qemu_module_path subprocess.run(('pylint-3', '--score=3Dn', '--notes=3DFIXME,XXX', *fil= es), env=3Denv, check=3DFalse) =20 diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300 index fe94de84edd..10f9f2a8da6 100755 --- a/tests/qemu-iotests/300 +++ b/tests/qemu-iotests/300 @@ -24,12 +24,11 @@ import random import re from typing import Dict, List, Optional =20 -import iotests - -# Import qemu after iotests.py has amended sys.path -# pylint: disable=3Dwrong-import-order from qemu.machine import machine =20 +import iotests + + BlockBitmapMapping =3D List[Dict[str, object]] =20 mig_sock =3D os.path.join(iotests.sock_dir, 'mig_sock') diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index ce06cf56304..b06ad76e0c5 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -36,8 +36,6 @@ =20 from contextlib import contextmanager =20 -# pylint: disable=3Dimport-error, wrong-import-position -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu.machine import qtest from qemu.qmp import QMPMessage =20 diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index 70da0d60c80..99a57a69f3a 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -108,12 +108,15 @@ def init_directories(self) -> None: SAMPLE_IMG_DIR OUTPUT_DIR """ - self.pythonpath =3D os.getenv('PYTHONPATH') - if self.pythonpath: - self.pythonpath =3D self.source_iotests + os.pathsep + \ - self.pythonpath - else: - self.pythonpath =3D self.source_iotests + + # Path where qemu goodies live in this source tree. + qemu_srctree_path =3D Path(__file__, '../../../python').resolve() + + self.pythonpath =3D os.pathsep.join(filter(None, ( + self.source_iotests, + str(qemu_srctree_path), + os.getenv('PYTHONPATH'), + ))) =20 self.test_dir =3D os.getenv('TEST_DIR', os.path.join(os.getcwd(), 'scratch')) diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests= /tests/mirror-top-perms index 2fc8dd66e0a..73138a0ef91 100755 --- a/tests/qemu-iotests/tests/mirror-top-perms +++ b/tests/qemu-iotests/tests/mirror-top-perms @@ -20,13 +20,12 @@ # =20 import os + +import qemu + import iotests from iotests import qemu_img =20 -# Import qemu after iotests.py has amended sys.path -# pylint: disable=3Dwrong-import-order -import qemu - =20 image_size =3D 1 * 1024 * 1024 source =3D os.path.join(iotests.test_dir, 'source.img') --=20 2.31.1