Skip to content

Commit 70217f0

Browse files
traylenatorclaudetleonhardt
authored
test: size job-control output from page size (#1828)
On ppc64le, test_pipeline_stops_with_cmd2_and_returns_terminal[interrupt-busy-producer] times out waiting for cmd2 to hand the terminal to the pager: foreground process group: 605 605 ... Sl+ hrtime application.py 633 ... S poll_s pager.py The busy producers write 256 KiB, meant to be more than a pipe holds so that the write blocks and cmd2 lends the terminal. Linux sizes a pipe in pages, 16 by default, and ppc64le uses 64 KiB pages, so a pipe holds 1 MiB there. The write completes without blocking and the terminal is never lent. Write 64 pages instead: unchanged at 256 KiB with 4 KiB pages, 4 MiB with 64 KiB pages. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Todd Leonhardt <2812720+tleonhardt@users.noreply.github.com>
1 parent a59d895 commit 70217f0

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎tests/test_pipeline_job_control.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="POSIX job control")
2020

21+
# More output than a pipe and the relay's pipe hold, so a producer blocks until the consumer reads. Linux sizes a pipe
22+
# in pages, 16 by default, so follow the page size: 256 KiB with 4 KiB pages, 4 MiB with the 64 KiB pages of ppc64le.
23+
PIPE_FILL = 64 * (os.sysconf("SC_PAGE_SIZE") if hasattr(os, "sysconf") else 4096)
24+
2125

2226
def describe_processes(root: int, master: int) -> str:
2327
"""Report the terminal's foreground group and every descendant of root, for a timeout.
@@ -154,13 +158,13 @@ def test_pipeline_stops_with_cmd2_and_returns_terminal(
154158
"class App(Cmd):\n"
155159
" def do_busy(self, statement):\n"
156160
" os.write(2, b'BUSY_READY\\n')\n"
157-
" self.stdout.write('x' * 262144)\n"
161+
f" self.stdout.write('x' * {PIPE_FILL})\n"
158162
" self.stdout.flush()\n"
159163
" time.sleep(30)\n"
160164
" def do_ask(self, statement):\n"
161165
" self.poutput(self.read_input('INPUT> '))\n"
162166
" def do_direct(self, statement):\n"
163-
" self.stdout.buffer.write(b'x' * 262144)\n"
167+
f" self.stdout.buffer.write(b'x' * {PIPE_FILL})\n"
164168
" self.stdout.flush()\n"
165169
" assert self.select('first second', 'SELECT> ') == 'first'\n"
166170
" assert input('PLAIN> ') == 'answer'\n"
@@ -305,7 +309,7 @@ def running(*pids: int) -> bool:
305309
"import os, signal, sys, time\n"
306310
"signal.signal(signal.SIGINT, signal.SIG_DFL)\n"
307311
"os.write(2, b'BUSY_READY\\n')\n"
308-
"sys.stdout.write('x' * 262144)\n"
312+
f"sys.stdout.write('x' * {PIPE_FILL})\n"
309313
"sys.stdout.flush()\n"
310314
"time.sleep(30)\n",
311315
encoding="utf-8",

0 commit comments

Comments
 (0)