]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38692: Skip test_posix.test_pidfd_open() on EPERM (GH-17290)
authorVictor Stinner <vstinner@python.org>
Thu, 21 Nov 2019 11:54:54 +0000 (12:54 +0100)
committerGitHub <noreply@github.com>
Thu, 21 Nov 2019 11:54:54 +0000 (12:54 +0100)
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).

Lib/test/test_posix.py
Misc/NEWS.d/next/Tests/2019-11-20-15-42-06.bpo-38692.aqAvyF.rst [new file with mode: 0644]

index 98a39c3f040992b9f1910a0901f571bc8657be12..4df882b621085a5e1e9b995e27b25bdc611adbc2 100644 (file)
@@ -1476,6 +1476,8 @@ class PosixTester(unittest.TestCase):
             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 (file)
index 0000000..fa20566
--- /dev/null
@@ -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.