From nobody Mon Feb 9 23:00:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1657580714; cv=none; d=zohomail.com; s=zohoarc; b=geJsaNbnHND7ei66tJ3GIl2xTpZbWi7ej+UrzNHZg+Ru/uad9hoJ/6dr3/NSUylqsHuYtst0Jx6zNd3DeHYZl+1FstaJbv9/Fn5es4k/lfFPp9gboMxe9n1ZVVugMHu5FYGcSUJgZIXaVJtEdYZLSnVDmQqTP+ShSIkkynph+N4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657580714; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=62eiebJ4CRcXipkHxKOY6aVMeIBXkh9jFMURuOSkro4=; b=Af5Y9w7NshLgxxl/5iYokJzZaxHPujNxiBQ/zSq6CfqLDNW2w1kd/zZWXiRpr3RVeAOd4oEwE64sVaVdXiYgkn09AoWZznZgwNikXMUHaESRngE3uHThNZiIQuKwWhTba9awr7/mnruv0mu47XTw+5gTOchstTwWZpskDuynv5E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657580714691807.3493293336693; Mon, 11 Jul 2022 16:05:14 -0700 (PDT) Received: from localhost ([::1]:56590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oB2Sm-0003Fj-OT for importer@patchew.org; Mon, 11 Jul 2022 19:05:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oB2Pr-0000hL-17 for qemu-devel@nongnu.org; Mon, 11 Jul 2022 19:02:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oB2Pn-00023B-MB for qemu-devel@nongnu.org; Mon, 11 Jul 2022 19:02:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-202-Gu9El7cbNWWaaJF3JEaEzg-1; Mon, 11 Jul 2022 19:02:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C022F802D2C; Mon, 11 Jul 2022 23:02:00 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 299AD2166B26; Mon, 11 Jul 2022 23:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657580524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=62eiebJ4CRcXipkHxKOY6aVMeIBXkh9jFMURuOSkro4=; b=ZCPQSIpkurk2sqtZkLGICFXV2T2Kf6KX4BpMbI8+WepS5uJtlYc0JYsEy9PqWxVBdj3AfG +jQaPc1ruf+F9gd2TzvzBHouOVUJ3zRwZyOP5J6WJLjvEItORXez2854N/Mmxjjq2C/B8x fih71RWAL9dB4ZWH9ikzarg48ChQiBQ= X-MC-Unique: Gu9El7cbNWWaaJF3JEaEzg-1 From: John Snow To: qemu-devel@nongnu.org Cc: Daniel Berrange , Kevin Wolf , Beraldo Leal , John Snow , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Wainer dos Santos Moschetta , Kyle Evans , Warner Losh , qemu-block@nongnu.org, Paolo Bonzini , Cleber Rosa , Michael Tsirkin , Ani Sinha , Hanna Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH v3 6/7] iotests: use tests/venv for running tests Date: Mon, 11 Jul 2022 19:01:54 -0400 Message-Id: <20220711230155.953788-7-jsnow@redhat.com> In-Reply-To: <20220711230155.953788-1-jsnow@redhat.com> References: <20220711230155.953788-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1657580716835100001 Content-Type: text/plain; charset="utf-8" Essentially, the changes to testenv.py here mimic the changes that occur wh= en you "source venv/bin/activate.fish" or similar. (1) update iotest's internal notion of which python binary to use, (2) export the VIRTUAL_ENV variable, (3) front-load the venv/bin directory to PATH. If the venv directory isn't found, raise a friendly exception that tries to give the human operator a friendly clue as to what's gone wrong. The subsequent commit attempts to address this shortcoming by teaching iotests how to invoke the venv bootstrapper in this circumstance instead. Signed-off-by: John Snow --- tests/qemu-iotests/testenv.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index a864c74b123..29404ac94be 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -65,8 +65,9 @@ class TestEnv(ContextManager['TestEnv']): # lot of them. Silence pylint: # pylint: disable=3Dtoo-many-instance-attributes =20 - env_variables =3D ['PYTHONPATH', 'TEST_DIR', 'SOCK_DIR', 'SAMPLE_IMG_D= IR', - 'PYTHON', 'QEMU_PROG', 'QEMU_IMG_PROG', + env_variables =3D ['PYTHONPATH', 'VIRTUAL_ENV', 'PYTHON', 'PATH', + 'TEST_DIR', 'SOCK_DIR', 'SAMPLE_IMG_DIR', + 'QEMU_PROG', 'QEMU_IMG_PROG', 'QEMU_IO_PROG', 'QEMU_NBD_PROG', 'QSD_PROG', 'QEMU_OPTIONS', 'QEMU_IMG_OPTIONS', 'QEMU_IO_OPTIONS', 'QEMU_IO_OPTIONS_NO_FMT', @@ -102,18 +103,29 @@ def get_env(self) -> Dict[str, str]: =20 def init_directories(self) -> None: """Init directory variables: + VIRTUAL_ENV + PATH PYTHONPATH TEST_DIR SOCK_DIR SAMPLE_IMG_DIR """ + venv_path =3D Path(self.build_root, 'tests/venv/') + if not venv_path.exists(): + raise FileNotFoundError( + f"Virtual environment \"{venv_path!s}\" isn't found." + " (Maybe you need to run 'make check-venv'" + " from the build dir?)" + ) + self.virtual_env: str =3D str(venv_path) =20 - # Path where qemu goodies live in this source tree. - qemu_srctree_path =3D Path(__file__, '../../../python').resolve() + self.path =3D os.pathsep.join(( + str(venv_path / 'bin'), + os.environ['PATH'], + )) =20 self.pythonpath =3D os.pathsep.join(filter(None, ( self.source_iotests, - str(qemu_srctree_path), os.getenv('PYTHONPATH'), ))) =20 @@ -138,7 +150,7 @@ def init_binaries(self) -> None: PYTHON (for bash tests) QEMU_PROG, QEMU_IMG_PROG, QEMU_IO_PROG, QEMU_NBD_PROG, QSD_PR= OG """ - self.python =3D sys.executable + self.python: str =3D os.path.join(self.virtual_env, 'bin', 'python= 3') =20 def root(*names: str) -> str: return os.path.join(self.build_root, *names) @@ -300,6 +312,7 @@ def print_env(self, prefix: str =3D '') -> None: {prefix}GDB_OPTIONS -- {GDB_OPTIONS} {prefix}VALGRIND_QEMU -- {VALGRIND_QEMU} {prefix}PRINT_QEMU_OUTPUT -- {PRINT_QEMU} +{prefix}VIRTUAL_ENV -- {VIRTUAL_ENV} {prefix}""" =20 args =3D collections.defaultdict(str, self.get_env()) --=20 2.34.3