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

kselftest: Support nolibc

Rather than providing headers for inclusion which replace any offered by
the system nolibc is provided in the form of a header which should be added
to the build via the compiler command line. In order to build with nolibc
we need to not include the standard C headers, especially not stdio.h where
the definitions of stdout, stdin and stderr will actively conflict with
nolibc.

Add an include guard which suppresses the inclusion of the standard headers
when building with nolibc, allowing us to build tests using the nolibc
headers. This allows us to avoid open coding of KTAP output for
selftests that need to use nolibc in order to test interfaces that are
controlled by libc.

Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Mark Brown and committed by
Shuah Khan
9e38be73 322759f9

+2
+2
tools/testing/selftests/kselftest.h
··· 43 43 #ifndef __KSELFTEST_H 44 44 #define __KSELFTEST_H 45 45 46 + #ifndef NOLIBC 46 47 #include <errno.h> 47 48 #include <stdlib.h> 48 49 #include <unistd.h> 49 50 #include <stdarg.h> 50 51 #include <stdio.h> 52 + #endif 51 53 52 54 #ifndef ARRAY_SIZE 53 55 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))