2024-03-28 03:34:54

by John Hubbard

[permalink] [raw]
Subject: [PATCH 1/2] selftests: break the dependency upon local header files

Use tools/include/uapi/ files instead. These are obtained by taking a
snapshot: run "make headers" at the top level, then copy the desired
header file into the appropriate subdir in tools/uapi/.

This was discussed and solved in [1].

However, even before copying any additional files there, there are
already quite a few in tools/include/uapi already. And these will
immediately fix a number of selftests/mm build failures.

So this patch:

a) Adds TOOLS_INCLUDES to selftests/lib.mk, so that all selftests can
immediately and easily include the snapshotted header files.

b) Uses $(TOOLS_INCLUDES) in the selftests/mm build. On today's Arch
Linux, this already fixes all build errors except for a few
userfaultfd.h (those will be addressed in a subsequent patch).

[1] https://lore.kernel.org/all/[email protected]/

Cc: David Hildenbrand <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Muhammad Usama Anjum <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Signed-off-by: John Hubbard <[email protected]>
---
tools/testing/selftests/lib.mk | 9 +++++++++
tools/testing/selftests/mm/Makefile | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index da2cade3bab0..1dae4a02957f 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -48,6 +48,15 @@ ifeq ($(KHDR_INCLUDES),)
KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
endif

+# In order to use newer items that haven't yet been added to the user's system
+# header files, add $(TOOLS_INCLUDES) to the compiler invocation in each
+# each selftest.
+# You may need to add files to that location, or to refresh an existing file. In
+# order to do that, run "make headers" from $(top_srcdir), then copy the
+# header file that you want from $(top_srcdir)/usr/include/... , to the matching
+# subdir in $(TOOLS_INCLUDE).
+TOOLS_INCLUDES := -isystem $(top_srcdir)/tools/include/uapi
+
# The following are built by lib.mk common compile rules.
# TEST_CUSTOM_PROGS should be used by tests that require
# custom build rule and prevent common build rule use.
diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index eb5f39a2668b..7ca9186a0639 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -32,7 +32,7 @@ endif
# LDLIBS.
MAKEFLAGS += --no-builtin-rules

-CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
+CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
LDLIBS = -lrt -lpthread -lm

TEST_GEN_FILES = cow
--
2.44.0



2024-04-04 18:45:54

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH 1/2] selftests: break the dependency upon local header files

On 28.03.24 04:34, John Hubbard wrote:
> Use tools/include/uapi/ files instead. These are obtained by taking a
> snapshot: run "make headers" at the top level, then copy the desired
> header file into the appropriate subdir in tools/uapi/.
>
> This was discussed and solved in [1].
>
> However, even before copying any additional files there, there are
> already quite a few in tools/include/uapi already. And these will
> immediately fix a number of selftests/mm build failures.
>
> So this patch:
>
> a) Adds TOOLS_INCLUDES to selftests/lib.mk, so that all selftests can
> immediately and easily include the snapshotted header files.
>
> b) Uses $(TOOLS_INCLUDES) in the selftests/mm build. On today's Arch
> Linux, this already fixes all build errors except for a few
> userfaultfd.h (those will be addressed in a subsequent patch).
>
> [1] https://lore.kernel.org/all/[email protected]/
>
> Cc: David Hildenbrand <[email protected]>
> Cc: Mark Brown <[email protected]>
> Cc: Muhammad Usama Anjum <[email protected]>
> Cc: Suren Baghdasaryan <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Signed-off-by: John Hubbard <[email protected]>
> ---
>

Acked-by: David Hildenbrand <[email protected]>

--
Cheers,

David / dhildenb