[Python-checkins] bpo-38692: Skip test_posix.test_pidfd_open() on EPERM (GH-17290)

Victor Stinner webhook-mailer at python.org
Thu Nov 21 06:54:58 EST 2019


https://github.com/python/cpython/commit/3ab479a2d1959923c9ab80c227dd1f39720b4e2d
commit: 3ab479a2d1959923c9ab80c227dd1f39720b4e2d
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2019-11-21T12:54:54+01:00
summary:

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).

files:
A Misc/NEWS.d/next/Tests/2019-11-20-15-42-06.bpo-38692.aqAvyF.rst
M Lib/test/test_posix.py

diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 98a39c3f04099..4df882b621085 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1476,6 +1476,8 @@ def test_pidfd_open(self):
             os.pidfd_open(-1)
         if cm.exception.errno == errno.ENOSYS:
             self.skipTest("system does not support pidfd_open")
+        if isinstance(cm.exception, PermissionError):
+            self.skipTest(f"pidfd_open syscall blocked: {cm.exception!r}")
         self.assertEqual(cm.exception.errno, errno.EINVAL)
         os.close(os.pidfd_open(os.getpid(), 0))
 
diff --git a/Misc/NEWS.d/next/Tests/2019-11-20-15-42-06.bpo-38692.aqAvyF.rst b/Misc/NEWS.d/next/Tests/2019-11-20-15-42-06.bpo-38692.aqAvyF.rst
new file mode 100644
index 0000000000000..fa2056632ba8b
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2019-11-20-15-42-06.bpo-38692.aqAvyF.rst
@@ -0,0 +1,3 @@
+Skip the test_posix.test_pidfd_open() test if ``os.pidfd_open()`` fails with a
+:exc:`PermissionError`. This situation can happen in a Linux sandbox using a
+syscall whitelist which doesn't allow the ``pidfd_open()`` syscall yet.



More information about the Python-checkins mailing list