FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-95672 skip fcntl when pipesize is smaller than pagesize by hyeongyun0916 · Pull Request #102163 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions Doc/library/test.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,13 @@ The :mod:`test.support` module defines the following functions:
:func:`doctest.testmod`.


.. function:: get_pagesize()

Get size of a page in bytes.

Comment thread
hyeongyun0916 marked this conversation as resolved.
.. versionadded:: 3.12


.. function:: setswitchinterval(interval)

Set the :func:`sys.setswitchinterval` to the given *interval*. Defines
Expand Down
14 changes: 14 additions & 0 deletions Lib/test/support/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
# sys
"is_jython", "is_android", "is_emscripten", "is_wasi",
"check_impl_detail", "unix_shell", "setswitchinterval",
# os
"get_pagesize",
# network
"open_urlresource",
# processes
Expand Down Expand Up @@ -1893,6 +1895,18 @@ def setswitchinterval(interval):
return sys.setswitchinterval(interval)


def get_pagesize():

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Comment thread
hyeongyun0916 marked this conversation as resolved.
"""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
Comment thread
hyeongyun0916 marked this conversation as resolved.


@contextlib.contextmanager
def disable_faulthandler():
import faulthandler
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_fcntl.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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

Expand Down Expand Up @@ -201,7 +201,8 @@ def test_fcntl_f_pipesize(self):
# 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)
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_subprocess.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ def test_pipesizes(self):
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(
Expand Down

Back | FazBrowse Home | New Git URL