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@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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);