Skip to content

Commit

Permalink
kselftest: Support nolibc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mark Brown authored and Shuah Khan committed Apr 11, 2023
1 parent 322759f commit 9e38be7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/testing/selftests/kselftest.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
#ifndef __KSELFTEST_H
#define __KSELFTEST_H

#ifndef NOLIBC
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
#endif

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
Expand Down

0 comments on commit 9e38be7

Please sign in to comment.