linux/tools/include/nolibc
Ryan Roberts 58e2847ad2 selftests: line buffer test program's stdout
Patch series "selftests/mm fixes for arm64", v3.

Given my on-going work on large anon folios and contpte mappings, I
decided it would be a good idea to start running mm selftests to help
guard against regressions.  However, it soon became clear that I
couldn't get the suite to run cleanly on arm64 with a vanilla v6.5-rc1
kernel (perhaps I'm just doing it wrong??), so got stuck in a rabbit
hole trying to debug and fix all the issues.  Some were down to
misconfigurations, but I also found a number of issues with the tests
and even a couple of issues with the kernel.


This patch (of 8):

The selftests runner pipes the test program's stdout to tap_prefix.  The
presence of the pipe means that the test program sets its stdout to be
fully buffered (as aposed to line buffered when directly connected to the
terminal).  The block buffering means that there is often content in the
buffer at fork() time, which causes the output to end up duplicated.  This
was causing problems for mm:cow where test results were duplicated 20-30x.

Solve this by using `stdbuf`, when available to force the test program to
use line buffered mode.  This means previously printf'ed results are
flushed out of the program before any fork().

Additionally, explicitly set line buffer mode in ksft_print_header(),
which means that all test programs that use the ksft framework will
benefit even if stdbuf is not present on the system.

[ryan.roberts@arm.com: add setvbuf() to set buffering mode]
  Link: https://lkml.kernel.org/r/20230726070655.2713530-1-ryan.roberts@arm.com
Link: https://lkml.kernel.org/r/20230724082522.1202616-1-ryan.roberts@arm.com
Link: https://lkml.kernel.org/r/20230724082522.1202616-2-ryan.roberts@arm.com
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Florent Revest <revest@chromium.org>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-08-18 10:12:42 -07:00
..
.gitignore tools/nolibc: Add gitignore to avoid git complaints about sysroot 2023-03-20 08:45:21 -07:00
Makefile tools/nolibc: add autodetection for stackprotector support 2023-06-09 11:46:08 -07:00
arch-aarch64.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
arch-arm.h tools/nolibc: arm: add missing my_syscall6 2023-06-09 11:46:09 -07:00
arch-i386.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
arch-loongarch.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
arch-mips.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
arch-riscv.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
arch-s390.h tools/nolibc: s390: disable stackprotector in _start 2023-06-09 11:46:09 -07:00
arch-x86_64.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
arch.h tools/nolibc: fix typo pint -> point 2023-06-09 11:46:08 -07:00
compiler.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
ctype.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
errno.h tools/nolibc: make errno a weak symbol instead of a static one 2023-01-10 13:33:55 -08:00
nolibc.h tools/nolibc: Fix build of stdio.h due to header ordering 2023-06-09 11:45:34 -07:00
signal.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
stackprotector.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
std.h tools/nolibc: add stdint.h 2023-03-20 08:45:21 -07:00
stdint.h selftests/nolibc: not include limits.h for nolibc 2023-06-09 11:46:09 -07:00
stdio.h selftests: line buffer test program's stdout 2023-08-18 10:12:42 -07:00
stdlib.h tools/nolibc: use __inline__ syntax 2023-06-09 11:46:07 -07:00
string.h tools/nolibc: use standard __asm__ statements 2023-06-09 11:46:07 -07:00
sys.h tools/nolibc: open: fix up compile warning for arm 2023-06-09 11:46:10 -07:00
time.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
types.h tools/nolibc: support nanoseconds in stat() 2023-06-09 11:46:09 -07:00
unistd.h tools/nolibc/unistd: add syscall() 2023-06-09 11:46:07 -07:00