Skip to content

Commit cb496e3

Browse files
committed
Have vfork specific tests disable posix_spawn.
1 parent 55790a1 commit cb496e3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/test/test_subprocess.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,6 +3348,7 @@ def exit_handler():
33483348
@unittest.skipIf(not sysconfig.get_config_var("HAVE_VFORK"),
33493349
"vfork() not enabled by configure.")
33503350
@mock.patch("subprocess._fork_exec")
3351+
@mock.patch("subprocess._USE_POSIX_SPAWN", new=False)
33513352
def test__use_vfork(self, mock_fork_exec):
33523353
self.assertTrue(subprocess._USE_VFORK) # The default value regardless.
33533354
mock_fork_exec.side_effect = RuntimeError("just testing args")
@@ -3366,9 +3367,13 @@ def test__use_vfork(self, mock_fork_exec):
33663367
@unittest.skipIf(not sysconfig.get_config_var("HAVE_VFORK"),
33673368
"vfork() not enabled by configure.")
33683369
@unittest.skipIf(sys.platform != "linux", "Linux only, requires strace.")
3370+
@mock.patch("subprocess._USE_POSIX_SPAWN", new=False)
33693371
def test_vfork_used_when_expected(self):
33703372
# This is a performance regression test to ensure we default to using
33713373
# vfork() when possible.
3374+
# Technically this test could pass when posix_spawn is used as well
3375+
# because libc tends to implement that internally using vfork. But
3376+
# that'd just be testing a libc+kernel implementation detail.
33723377
strace_binary = "/usr/bin/strace"
33733378
# The only system calls we are interested in.
33743379
strace_filter = "--trace=clone,clone2,clone3,fork,vfork,exit,exit_group"

0 commit comments

Comments
 (0)