Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
apply review
  • Loading branch information
hyeongyun0916 committed Feb 24, 2023
commit 89cc89f4484303bcb8d0ebd1c25a4e1f0ef35a0d
5 changes: 3 additions & 2 deletions Lib/test/test_fcntl.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,14 @@ def test_fcntl_f_getpath(self):
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):
resource = import_module('resource')
Copy link
Copy Markdown
Member

@corona10 corona10 Feb 24, 2023

Choose a reason for hiding this comment

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

Why not just using import resource?

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.

Oh that's right, I'll fix it.

test_pipe_r, test_pipe_w = os.pipe()
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.
minimum_pipe_size = os.sysconf('SC_PAGESIZE') # There's a check that attempts to skip the tests if the pipe capacity is 512 bytes, but that's less than the smallest page size on x86.
if pipesize < minimum_pipe_size: # the POSIX minimum
pagesize_default = resource.getpagesize()
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
5 changes: 3 additions & 2 deletions Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ def test_stdin_devnull(self):
@unittest.skipUnless(fcntl and hasattr(fcntl, 'F_GETPIPE_SZ'),
'fcntl.F_GETPIPE_SZ required for test.')
def test_pipesizes(self):
resource = import_helper.import_module('resource')
test_pipe_r, test_pipe_w = os.pipe()
try:
# Get the default pipesize with F_GETPIPE_SZ
Expand All @@ -717,8 +718,8 @@ def test_pipesizes(self):
os.close(test_pipe_r)
os.close(test_pipe_w)
pipesize = pipesize_default // 2
minimum_pipe_size = os.sysconf('SC_PAGESIZE') # There's a check that attempts to skip the tests if the pipe capacity is 512 bytes, but that's less than the smallest page size on x86.
if pipesize < minimum_pipe_size: # the POSIX minimum
pagesize_default = resource.getpagesize()
if pipesize < pagesize_default: # the POSIX minimum
raise unittest.SkipTest(
'default pipesize too small to perform test.')
p = subprocess.Popen(
Expand Down