[PATCH 06/32] selftests: harness: Guard includes on nolibc

From: Thomas Weißschuh
Date: Tue Mar 04 2025 - 02:12:15 EST


Nolibc doesn't provide all normal header files.

Don't try to include these non-existent header files, as the symbols are
available unconditionally anyways.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
---
tools/testing/selftests/kselftest_harness.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 222a4f51a8d704c41597e09a241ad887ef787139..6659c10f4d8fc7c750bc5e8a36ebcbcacda5de60 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -53,19 +53,23 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
-#include <asm/types.h>
-#include <ctype.h>
-#include <errno.h>
+
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
+#ifndef NOLIBC
+#include <asm/types.h>
+#include <ctype.h>
+#include <errno.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <unistd.h>
#include <setjmp.h>
+#endif

#include "kselftest.h"


--
2.48.1