Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Fix massive output from test_maps

When stdout output from the selftests tool 'test_maps' gets redirected
into e.g file or pipe, then the output lines increase a lot (from 21
to 33949 lines). This is caused by the printf that happens before the
fork() call, and there are user-space buffered printf data that seems
to be duplicated into the forked process.

To fix this fflush() stdout before the fork loop in __run_parallel().

Fixes: 1a97cf1fe503 ("selftests/bpf: speedup test_maps")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/159842985651.1050885.2154399297503372406.stgit@firesoul

authored by

Jesper Dangaard Brouer and committed by
Daniel Borkmann
fa450567 7787b6fc

+2
+2
tools/testing/selftests/bpf/test_maps.c
··· 1274 1274 pid_t pid[tasks]; 1275 1275 int i; 1276 1276 1277 + fflush(stdout); 1278 + 1277 1279 for (i = 0; i < tasks; i++) { 1278 1280 pid[i] = fork(); 1279 1281 if (pid[i] == 0) {