summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fcntl.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2020-10-21 00:37:20 (GMT)
committerGitHub <noreply@github.com>2020-10-21 00:37:20 (GMT)
commit786addd9d07b6c712b8ea9ee06e1f9f41c1b67a1 (patch)
treeb1f3e58c5af49910708aeacaf4e419644a4c497c /Lib/test/test_fcntl.py
parent7cdf30fff39ea97f403b5472096349998d190e30 (diff)
downloadcpython-786addd9d07b6c712b8ea9ee06e1f9f41c1b67a1.zip
cpython-786addd9d07b6c712b8ea9ee06e1f9f41c1b67a1.tar.gz
cpython-786addd9d07b6c712b8ea9ee06e1f9f41c1b67a1.tar.bz2
bpo-41586: Attempt to make the pipesize tests more robust. (GH-22839)
Several buildbots are failing on these, likely due to an inability to set the pipe size to the desired test value.
Diffstat (limited to 'Lib/test/test_fcntl.py')
-rw-r--r--Lib/test/test_fcntl.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
index 8d6e9ff..83ee7a5 100644
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -190,17 +190,24 @@ class TestFcntl(unittest.TestCase):
res = fcntl.fcntl(self.f.fileno(), fcntl.F_GETPATH, bytes(len(expected)))
self.assertEqual(expected, res)
- @unittest.skipIf(not (hasattr(fcntl, "F_SETPIPE_SZ") and hasattr(fcntl, "F_GETPIPE_SZ")),
- "F_SETPIPE_SZ and F_GETPIPE_SZ are not available on all unix platforms.")
+ @unittest.skipUnless(
+ hasattr(fcntl, "F_SETPIPE_SZ") and hasattr(fcntl, "F_GETPIPE_SZ"),
+ "F_SETPIPE_SZ and F_GETPIPE_SZ are not available on all platforms.")
def test_fcntl_f_pipesize(self):
test_pipe_r, test_pipe_w = os.pipe()
- # Get the default pipesize with F_GETPIPE_SZ
- pipesize_default = fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ)
- # Multiply the default with 2 to get a new value.
- fcntl.fcntl(test_pipe_w, fcntl.F_SETPIPE_SZ, pipesize_default * 2)
- self.assertEqual(fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ), pipesize_default * 2)
- os.close(test_pipe_r)
- os.close(test_pipe_w)
+ try:
+ # Get the default pipesize with F_GETPIPE_SZ
+ pipesize_default = fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ)
+ pipesize = pipesize_default // 2 # A new value to detect change.
+ if pipesize < 512: # the POSIX minimum
+ raise unittest.SkitTest(
+ 'default pipesize too small to perform test.')
+ fcntl.fcntl(test_pipe_w, fcntl.F_SETPIPE_SZ, pipesize)
+ self.assertEqual(fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ),
+ pipesize)
+ finally:
+ os.close(test_pipe_r)
+ os.close(test_pipe_w)
def test_main():