aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/subcmd
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2020-09-17 14:15:19 +1000
committerShuah Khan <skhan@linuxfoundation.org>2020-09-17 17:33:39 -0600
commitc8bd596f9388bceda6cf008d554cbb1a4f2244e7 (patch)
treee5fe5c96f76c88c0b27a215b300d5da8f2996ef3 /tools/lib/subcmd
parentselftests/timers: Turn off timeout setting (diff)
downloadlinux-dev-c8bd596f9388bceda6cf008d554cbb1a4f2244e7.tar.xz
linux-dev-c8bd596f9388bceda6cf008d554cbb1a4f2244e7.zip
selftests/harness: Flush stdout before forking
The test harness forks() a child to run each test. Both the parent and the child print to stdout using libc functions. That can lead to duplicated (or more) output if the libc buffers are not flushed before forking. It's generally not seen when running programs directly, because stdout will usually be line buffered when it's pointing to a terminal. This was noticed when running the seccomp_bpf test, eg: $ ./seccomp_bpf | tee test.log $ grep -c "TAP version 13" test.log 2 But we only expect the TAP header to appear once. It can be exacerbated using stdbuf to increase the buffer size: $ stdbuf -o 1MB ./seccomp_bpf > test.log $ grep -c "TAP version 13" test.log 13 The fix is simple, we just flush stdout & stderr before fork. Usually stderr is unbuffered, but that can be changed, so flush it as well just to be safe. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Tested-by: Max Filippov <jcmvbkbc@gmail.com> Acked-by: Shuah Khan <skhan@linuxfoundation.org> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/lib/subcmd')
0 files changed, 0 insertions, 0 deletions