mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-95672 skip fcntl when pipesize is smaller than pagesize (gh-102163)
This commit is contained in:
parent
c1748ed59d
commit
2f62a5da94
4 changed files with 26 additions and 3 deletions
|
@ -536,6 +536,13 @@ The :mod:`test.support` module defines the following functions:
|
||||||
:func:`doctest.testmod`.
|
:func:`doctest.testmod`.
|
||||||
|
|
||||||
|
|
||||||
|
.. function:: get_pagesize()
|
||||||
|
|
||||||
|
Get size of a page in bytes.
|
||||||
|
|
||||||
|
.. versionadded:: 3.12
|
||||||
|
|
||||||
|
|
||||||
.. function:: setswitchinterval(interval)
|
.. function:: setswitchinterval(interval)
|
||||||
|
|
||||||
Set the :func:`sys.setswitchinterval` to the given *interval*. Defines
|
Set the :func:`sys.setswitchinterval` to the given *interval*. Defines
|
||||||
|
|
|
@ -51,6 +51,8 @@ __all__ = [
|
||||||
# sys
|
# sys
|
||||||
"is_jython", "is_android", "is_emscripten", "is_wasi",
|
"is_jython", "is_android", "is_emscripten", "is_wasi",
|
||||||
"check_impl_detail", "unix_shell", "setswitchinterval",
|
"check_impl_detail", "unix_shell", "setswitchinterval",
|
||||||
|
# os
|
||||||
|
"get_pagesize",
|
||||||
# network
|
# network
|
||||||
"open_urlresource",
|
"open_urlresource",
|
||||||
# processes
|
# processes
|
||||||
|
@ -1893,6 +1895,18 @@ def setswitchinterval(interval):
|
||||||
return sys.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
|
@contextlib.contextmanager
|
||||||
def disable_faulthandler():
|
def disable_faulthandler():
|
||||||
import faulthandler
|
import faulthandler
|
||||||
|
|
|
@ -6,7 +6,7 @@ import os
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
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.import_helper import import_module
|
||||||
from test.support.os_helper import TESTFN, unlink
|
from test.support.os_helper import TESTFN, unlink
|
||||||
|
|
||||||
|
@ -201,7 +201,8 @@ class TestFcntl(unittest.TestCase):
|
||||||
# Get the default pipesize with F_GETPIPE_SZ
|
# Get the default pipesize with F_GETPIPE_SZ
|
||||||
pipesize_default = fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ)
|
pipesize_default = fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ)
|
||||||
pipesize = pipesize_default // 2 # A new value to detect change.
|
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(
|
raise unittest.SkipTest(
|
||||||
'default pipesize too small to perform test.')
|
'default pipesize too small to perform test.')
|
||||||
fcntl.fcntl(test_pipe_w, fcntl.F_SETPIPE_SZ, pipesize)
|
fcntl.fcntl(test_pipe_w, fcntl.F_SETPIPE_SZ, pipesize)
|
||||||
|
|
|
@ -717,7 +717,8 @@ class ProcessTestCase(BaseTestCase):
|
||||||
os.close(test_pipe_r)
|
os.close(test_pipe_r)
|
||||||
os.close(test_pipe_w)
|
os.close(test_pipe_w)
|
||||||
pipesize = pipesize_default // 2
|
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(
|
raise unittest.SkipTest(
|
||||||
'default pipesize too small to perform test.')
|
'default pipesize too small to perform test.')
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue