selftests/sched_ext: flush stdout before test to avoid log spam

The sched_ext selftests runner runs each test in the same process,
with each test possibly forking multiple times. When the main runner
has not flushed its stdout, the children inherit the buffered output
for previous tests and emit it during exit. This causes log spam.

Make sure stdout/stderr is fully flushed before each test.

Cc: Ihor Solodrai <ihor.solodrai@linux.dev>
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
pull/1354/merge
Emil Tsalapatis 2025-12-05 13:23:14 -08:00 committed by Tejun Heo
parent f5e1e5ec20
commit 579a3297b2
1 changed files with 8 additions and 0 deletions

View File

@ -46,6 +46,14 @@ static void print_test_preamble(const struct scx_test *test, bool quiet)
if (!quiet) if (!quiet)
printf("DESCRIPTION: %s\n", test->description); printf("DESCRIPTION: %s\n", test->description);
printf("OUTPUT:\n"); printf("OUTPUT:\n");
/*
* The tests may fork with the preamble buffered
* in the children's stdout. Flush before the test
* to avoid printing the message multiple times.
*/
fflush(stdout);
fflush(stderr);
} }
static const char *status_to_result(enum scx_test_status status) static const char *status_to_result(enum scx_test_status status)