Commit fa450567 authored by Jesper Dangaard Brouer's avatar Jesper Dangaard Brouer Committed by Daniel Borkmann

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: 1a97cf1f ("selftests/bpf: speedup test_maps")
Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/159842985651.1050885.2154399297503372406.stgit@firesoul
parent 7787b6fc
...@@ -1274,6 +1274,8 @@ static void __run_parallel(unsigned int tasks, ...@@ -1274,6 +1274,8 @@ static void __run_parallel(unsigned int tasks,
pid_t pid[tasks]; pid_t pid[tasks];
int i; int i;
fflush(stdout);
for (i = 0; i < tasks; i++) { for (i = 0; i < tasks; i++) {
pid[i] = fork(); pid[i] = fork();
if (pid[i] == 0) { if (pid[i] == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment