| Message ID | 20260307103516.2584088-1-richard.purdie@linuxfoundation.org |
|---|---|
| State | New |
| Headers | show |
| Series | [ptest-runner] utils: Ensure output buffers are always line based | expand |
Applied!, Thanks! On Sat, Mar 7, 2026 at 4:35 AM Richard Purdie < richard.purdie@linuxfoundation.org> wrote: > When running slow ptests, we can see an issue where the tests are writing > output > but it doesn't make it to the process (e.g. ssh connection) running > ptest-runner. > > The issue is that the standard buffering for non-interactive terminals is > 8kb and > some ptests don't output enough data to trigger a write. This can lead to > the controlling connection timing out. > > This change forces the output streams to be line buffered in all cases. > Most > ptest output would contain newlines so this should work well. stderr can be > unbuffered by default but making it consistent here seems the best > approach. > > Testing with this change on slow ptest runs (e.g. qemu emulated) showed > much > more consistent data with this change. > > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> > --- > utils.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/utils.c b/utils.c > index 6cfa26f..192d3d0 100644 > --- a/utils.c > +++ b/utils.c > @@ -434,11 +434,13 @@ run_ptests(struct ptest_list *head, const struct > ptest_options opts, > set_nonblocking(pipefd_stdout[PIPE_READ]); > pfds[0].fd = pipefd_stdout[PIPE_READ]; > pfds[0].events = POLLIN; > + setlinebuf(fp); > dest_fps[0] = fp; > > set_nonblocking(pipefd_stderr[PIPE_READ]); > pfds[1].fd = pipefd_stderr[PIPE_READ]; > pfds[1].events = POLLIN; > + setlinebuf(fp_stderr); > dest_fps[1] = fp_stderr; > > while (true) { >
diff --git a/utils.c b/utils.c index 6cfa26f..192d3d0 100644 --- a/utils.c +++ b/utils.c @@ -434,11 +434,13 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts, set_nonblocking(pipefd_stdout[PIPE_READ]); pfds[0].fd = pipefd_stdout[PIPE_READ]; pfds[0].events = POLLIN; + setlinebuf(fp); dest_fps[0] = fp; set_nonblocking(pipefd_stderr[PIPE_READ]); pfds[1].fd = pipefd_stderr[PIPE_READ]; pfds[1].events = POLLIN; + setlinebuf(fp_stderr); dest_fps[1] = fp_stderr; while (true) {
When running slow ptests, we can see an issue where the tests are writing output but it doesn't make it to the process (e.g. ssh connection) running ptest-runner. The issue is that the standard buffering for non-interactive terminals is 8kb and some ptests don't output enough data to trigger a write. This can lead to the controlling connection timing out. This change forces the output streams to be line buffered in all cases. Most ptest output would contain newlines so this should work well. stderr can be unbuffered by default but making it consistent here seems the best approach. Testing with this change on slow ptest runs (e.g. qemu emulated) showed much more consistent data with this change. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- utils.c | 2 ++ 1 file changed, 2 insertions(+)