Skip to content

Commit 3ab479a

Browse files
authored
bpo-38692: Skip test_posix.test_pidfd_open() on EPERM (GH-17290)
Skip the test_posix.test_pidfd_open() test if os.pidfd_open() fails with a PermissionError. This situation can happen in a Linux sandbox using a syscall whitelist which doesn't allow the pidfd_open() syscall yet (like systemd-nspawn).
1 parent 0127bb1 commit 3ab479a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Lib/test/test_posix.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,8 @@ def test_pidfd_open(self):
14761476
os.pidfd_open(-1)
14771477
if cm.exception.errno == errno.ENOSYS:
14781478
self.skipTest("system does not support pidfd_open")
1479+
if isinstance(cm.exception, PermissionError):
1480+
self.skipTest(f"pidfd_open syscall blocked: {cm.exception!r}")
14791481
self.assertEqual(cm.exception.errno, errno.EINVAL)
14801482
os.close(os.pidfd_open(os.getpid(), 0))
14811483

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Skip the test_posix.test_pidfd_open() test if ``os.pidfd_open()`` fails with a
2+
:exc:`PermissionError`. This situation can happen in a Linux sandbox using a
3+
syscall whitelist which doesn't allow the ``pidfd_open()`` syscall yet.

0 commit comments

Comments
 (0)