summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-21 22:17:09 (GMT)
committerGitHub <noreply@github.com>2024-03-21 22:17:09 (GMT)
commit50f9b0b1e0fb181875751cef951351ed007b6397 (patch)
treebf359d7f43e6f9acec82fef3b74f4e43275ee502
parent0907871d43bffb613cbd560224e1a9db13d06c06 (diff)
downloadcpython-50f9b0b1e0fb181875751cef951351ed007b6397.zip
cpython-50f9b0b1e0fb181875751cef951351ed007b6397.tar.gz
cpython-50f9b0b1e0fb181875751cef951351ed007b6397.tar.bz2
gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (#117126)
On RHEL9, sched_setaffinity(0, []) does not fail.
-rw-r--r--Lib/test/test_posix.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 2706d5e..1d22869 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1335,12 +1335,21 @@ class PosixTester(unittest.TestCase):
def test_sched_setaffinity(self):
mask = posix.sched_getaffinity(0)
self.addCleanup(posix.sched_setaffinity, 0, list(mask))
+
if len(mask) > 1:
# Empty masks are forbidden
mask.pop()
posix.sched_setaffinity(0, mask)
self.assertEqual(posix.sched_getaffinity(0), mask)
- self.assertRaises(OSError, posix.sched_setaffinity, 0, [])
+
+ try:
+ posix.sched_setaffinity(0, [])
+ # gh-117061: On RHEL9, sched_setaffinity(0, []) does not fail
+ except OSError:
+ # sched_setaffinity() manual page documents EINVAL error
+ # when the mask is empty.
+ pass
+
self.assertRaises(ValueError, posix.sched_setaffinity, 0, [-10])
self.assertRaises(ValueError, posix.sched_setaffinity, 0, map(int, "0X"))
self.assertRaises(OverflowError, posix.sched_setaffinity, 0, [1<<128])