diff options
author | Hyunkyun Moon <hyunkyun.moon@linecorp.com> | 2023-03-01 14:56:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 14:56:19 (GMT) |
commit | 2f62a5da949cd368a9498e6a03e700f4629fa97f (patch) | |
tree | 50b136092f68e0a97b7280c79bad168f8af77f08 /Lib/test | |
parent | c1748ed59dc30ab99fe69c22bdbab54f93baa57c (diff) | |
download | cpython-2f62a5da949cd368a9498e6a03e700f4629fa97f.zip cpython-2f62a5da949cd368a9498e6a03e700f4629fa97f.tar.gz cpython-2f62a5da949cd368a9498e6a03e700f4629fa97f.tar.bz2 |
gh-95672 skip fcntl when pipesize is smaller than pagesize (gh-102163)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/support/__init__.py | 14 | ||||
-rw-r--r-- | Lib/test/test_fcntl.py | 5 | ||||
-rw-r--r-- | Lib/test/test_subprocess.py | 3 |
3 files changed, 19 insertions, 3 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 4a22ccd..c309fd7 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -51,6 +51,8 @@ __all__ = [ # sys "is_jython", "is_android", "is_emscripten", "is_wasi", "check_impl_detail", "unix_shell", "setswitchinterval", + # os + "get_pagesize", # network "open_urlresource", # processes @@ -1893,6 +1895,18 @@ def setswitchinterval(interval): return sys.setswitchinterval(interval) +def get_pagesize(): + """Get size of a page in bytes.""" + try: + page_size = os.sysconf('SC_PAGESIZE') + except (ValueError, AttributeError): + try: + page_size = os.sysconf('SC_PAGE_SIZE') + except (ValueError, AttributeError): + page_size = 4096 + return page_size + + @contextlib.contextmanager def disable_faulthandler(): import faulthandler diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index 26de67d..5da7561 100644 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -6,7 +6,7 @@ import os import struct import sys import unittest -from test.support import verbose, cpython_only +from test.support import verbose, cpython_only, get_pagesize from test.support.import_helper import import_module from test.support.os_helper import TESTFN, unlink @@ -201,7 +201,8 @@ class TestFcntl(unittest.TestCase): # 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 + pagesize_default = get_pagesize() + if pipesize < pagesize_default: # the POSIX minimum raise unittest.SkipTest( 'default pipesize too small to perform test.') fcntl.fcntl(test_pipe_w, fcntl.F_SETPIPE_SZ, pipesize) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 727b0e6..3880125 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -717,7 +717,8 @@ class ProcessTestCase(BaseTestCase): os.close(test_pipe_r) os.close(test_pipe_w) pipesize = pipesize_default // 2 - if pipesize < 512: # the POSIX minimum + pagesize_default = support.get_pagesize() + if pipesize < pagesize_default: # the POSIX minimum raise unittest.SkipTest( 'default pipesize too small to perform test.') p = subprocess.Popen( |