From ae8187922d8de2bc739519da3bd40cf5f03f5e4f Mon Sep 17 00:00:00 2001 From: Petri Latvala Date: Wed, 19 Sep 2018 14:49:10 +0300 Subject: runner: Flush igt_runner outputs before forking If the output of igt_runner is piped or redirected, buffered prints could be left lingering and read as test executable output if execv() fails. This can happen easily if CI for example generates a testlist with an incorrect binary name, or an optional test binary (say, kms_chamelium) is not built for the deployment in question. Signed-off-by: Petri Latvala Cc: Tomi Sarvela Cc: Arkadiusz Hiler Reviewed-by: Arkadiusz Hiler --- runner/executor.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runner') diff --git a/runner/executor.c b/runner/executor.c index 701ca80d..fd262eb4 100644 --- a/runner/executor.c +++ b/runner/executor.c @@ -780,6 +780,14 @@ static int execute_entry(size_t idx, printf("\n"); } + /* + * Flush outputs before forking so our (buffered) output won't + * end up in the test outputs. + */ + + fflush(stdout); + fflush(stderr); + if ((child = fork())) { int outfd = outpipe[0]; int errfd = errpipe[0]; -- cgit v1.2.3