commit: e882b1e956d50808a0143875a8ca35f2fc21f368
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 28 06:25:45 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Feb 28 06:25:45 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e882b1e9
UnshareNetTestCase: Initialize ABILITY_TO_UNSHARE in setUp
Initialize ABILITY_TO_UNSHARE in setUp so that _unshare_validate
uses the correct PORTAGE_MULTIPROCESSING_START_METHOD setup
from super().setUp(), eliminating messages like this from CI
runs for the multiprocessing start method spawn:
/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/multiprocessing/popen_fork.py:66:
DeprecationWarning: This process (pid=2886) is multi-threaded, use of
fork() may lead to deadlocks in the child.
The cause of these messages can be traced by patching python's
multiprocessing popen_fork.py like this:
--- /usr/lib/python3.12/multiprocessing/popen_fork.py
+++ /usr/lib/python3.12/multiprocessing/popen_fork.py
@@ -2,2 +2,3 @@
import signal
+import traceback
@@ -62,2 +63,3 @@
def _launch(self, process_obj):
+ traceback.print_stack()
code = 1
Fixes: 3110ec376cbc ("actions: Fix interaction between start-method and
pytest-xdist")
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/tests/process/test_unshare_net.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/lib/portage/tests/process/test_unshare_net.py
b/lib/portage/tests/process/test_unshare_net.py
index dabf15585f..ad3b288ef4 100644
--- a/lib/portage/tests/process/test_unshare_net.py
+++ b/lib/portage/tests/process/test_unshare_net.py
@@ -20,19 +20,27 @@ ping -c 1 -W 1 10.0.0.1 || exit 1
ping -c 1 -W 1 ::1 || exit 1
ping -c 1 -W 1 fd::1 || exit 1
"""
-ABILITY_TO_UNSHARE = portage.process._unshare_validate(CLONE_NEWNET)
class UnshareNetTestCase(TestCase):
- @pytest.mark.skipif(
- ABILITY_TO_UNSHARE != 0,
- reason=f"Unable to unshare: {errno.errorcode.get(ABILITY_TO_UNSHARE,
'?')}",
- )
+ def setUp(self):
+ """
+ Initialize ABILITY_TO_UNSHARE in setUp so that _unshare_validate
+ uses the correct PORTAGE_MULTIPROCESSING_START_METHOD setup
+ from super().setUp().
+ """
+ super().setUp()
+ self.ABILITY_TO_UNSHARE =
portage.process._unshare_validate(CLONE_NEWNET)
+
@pytest.mark.skipif(
portage.process.find_binary("ping") is None, reason="ping not found"
)
@pytest.mark.skipif(platform.system() != "Linux", reason="not Linux")
def testUnshareNet(self):
+ if self.ABILITY_TO_UNSHARE != 0:
+ pytest.skip(
+ f"Unable to unshare:
{errno.errorcode.get(self.ABILITY_TO_UNSHARE, '?')}"
+ )
env = os.environ.copy()
env["IPV6"] = "1" if portage.process._has_ipv6() else ""
self.assertEqual(