From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6AFD6158089 for ; Mon, 30 Oct 2023 05:09:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 857CA2BC018; Mon, 30 Oct 2023 05:09:45 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 60BA12BC018 for ; Mon, 30 Oct 2023 05:09:45 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6229B335C2A for ; Mon, 30 Oct 2023 05:09:44 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E60F911BA for ; Mon, 30 Oct 2023 05:09:42 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1698641275.6a7297abca88c5d86ac299e51a52547baac791f1.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/ebuild/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/tests/ebuild/test_doebuild_fd_pipes.py X-VCS-Directories: lib/portage/tests/ebuild/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 6a7297abca88c5d86ac299e51a52547baac791f1 X-VCS-Branch: master Date: Mon, 30 Oct 2023 05:09:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c8e15a44-32bb-4097-bfa6-c3a8c17d25dd X-Archives-Hash: 4da11a0fa2d16323eb51da5b80d02c34 commit: 6a7297abca88c5d86ac299e51a52547baac791f1 Author: Zac Medico gentoo org> AuthorDate: Mon Oct 30 04:43:42 2023 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Oct 30 04:47:55 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6a7297ab test_doebuild_fd_pipes.py: multiprocessing spawn compat Use multiprocessing.Pipe for compatibility with the spawn start method. Also pass QueryCommand._db to the child process, like MergeProcess does. Bug: https://bugs.gentoo.org/916247 Signed-off-by: Zac Medico gentoo.org> lib/portage/tests/ebuild/test_doebuild_fd_pipes.py | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py b/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py index 51ddc23908..678486ed16 100644 --- a/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py +++ b/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py @@ -1,6 +1,8 @@ # Copyright 2013-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +import multiprocessing + import portage from portage import os from portage.tests import TestCase @@ -13,6 +15,8 @@ from _emerge.PipeReader import PipeReader class DoebuildFdPipesTestCase(TestCase): + output_fd = 200 + def testDoebuild(self): """ Invoke portage.doebuild() with the fd_pipes parameter, and @@ -21,7 +25,7 @@ class DoebuildFdPipesTestCase(TestCase): supported for API consumers (see bug #475812). """ - output_fd = 200 + output_fd = self.output_fd ebuild_body = ["S=${WORKDIR}"] for phase_func in ( "pkg_info", @@ -117,21 +121,19 @@ class DoebuildFdPipesTestCase(TestCase): "clean", "merge", ): - pr, pw = os.pipe() + pr, pw = multiprocessing.Pipe(duplex=False) producer = ForkProcess( - target=portage.doebuild, - args=(ebuildpath, phase), + target=self._doebuild, + fd_pipes={ + 1: dev_null.fileno(), + }, + args=(QueryCommand._db, pw, ebuildpath, phase), kwargs={ "settings": settings, "mydbapi": portdb, "tree": "porttree", "vartree": root_config.trees["vartree"], - "fd_pipes": { - 1: dev_null.fileno(), - 2: dev_null.fileno(), - output_fd: pw, - }, "prev_mtimes": {}, }, ) @@ -144,7 +146,7 @@ class DoebuildFdPipesTestCase(TestCase): task_scheduler.start() finally: # PipeReader closes pr - os.close(pw) + pw.close() task_scheduler.wait() output = portage._unicode_decode(consumer.getvalue()).rstrip("\n") @@ -161,3 +163,11 @@ class DoebuildFdPipesTestCase(TestCase): dev_null.close() playground.cleanup() QueryCommand._db = None + + @staticmethod + def _doebuild(db, pw, *args, **kwargs): + QueryCommand._db = db + kwargs["fd_pipes"] = { + DoebuildFdPipesTestCase.output_fd: pw.fileno(), + } + return portage.doebuild(*args, **kwargs)