[PATCH 03/15] perf test: Drain pipe after child finishes to avoid losing output
From: Ian Rogers
Date: Sun May 31 2026 - 20:06:48 EST
When running tests in parallel, the parent process reads output from
the child's pipe. However, it might exit the loop as soon as the
child is detected as finished, potentially missing data that arrived
in the pipe just after the last poll or before the loop terminated.
Address this by draining the pipe after the main loop in finish_test.
Assisted-by: Gemini-CLI:Google Gemini 3
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/tests/builtin-test.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index f2c135891477..7946878195b7 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -483,6 +483,16 @@ static void finish_test(struct child_test **child_tests, int running_test, int c
if (err_done)
err_done = check_if_command_finished(&child_test->process);
}
+ /* Drain any remaining data from the pipe. */
+ if (err > 0) {
+ char buf[512];
+ ssize_t len;
+
+ while ((len = read(err, buf, sizeof(buf) - 1)) > 0) {
+ buf[len] = '\0';
+ strbuf_addstr(&err_output, buf);
+ }
+ }
if (perf_use_color_default && last_running != -1) {
/* Erase "Running (.. active)" line printed before poll/sleep. */
fprintf(debug_file(), PERF_COLOR_DELETE_LINE);
--
2.54.0.823.g6e5bcc1fc9-goog