Skip to content

Commit b2d35fa

Browse files
roxellShuah Khan (Samsung OSG)
authored andcommitted
selftests: add headers_install to lib.mk
If the kernel headers aren't installed we can't build all the tests. Add a new make target rule 'khdr' in the file lib.mk to generate the kernel headers and that gets include for every test-dir Makefile that includes lib.mk If the testdir in turn have its own sub-dirs the top_srcdir needs to be set to the linux-rootdir to be able to generate the kernel headers. Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
1 parent c31d02d commit b2d35fa

File tree

11 files changed

+36
-28
lines changed

11 files changed

+36
-28
lines changed

Makefile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
299299
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
300300
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
301301

302-
# SUBARCH tells the usermode build what the underlying arch is. That is set
303-
# first, and if a usermode build is happening, the "ARCH=um" on the command
304-
# line overrides the setting of ARCH below. If a native build is happening,
305-
# then ARCH is assigned, getting whatever value it gets normally, and
306-
# SUBARCH is subsequently ignored.
307-
308-
SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
309-
-e s/sun4u/sparc64/ \
310-
-e s/arm.*/arm/ -e s/sa110/arm/ \
311-
-e s/s390x/s390/ -e s/parisc64/parisc/ \
312-
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
313-
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
314-
-e s/riscv.*/riscv/)
302+
include scripts/subarch.include
315303

316304
# Cross compiling and selecting different set of gcc/bin-utils
317305
# ---------------------------------------------------------------------------

scripts/subarch.include

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SUBARCH tells the usermode build what the underlying arch is. That is set
2+
# first, and if a usermode build is happening, the "ARCH=um" on the command
3+
# line overrides the setting of ARCH below. If a native build is happening,
4+
# then ARCH is assigned, getting whatever value it gets normally, and
5+
# SUBARCH is subsequently ignored.
6+
7+
SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
8+
-e s/sun4u/sparc64/ \
9+
-e s/arm.*/arm/ -e s/sa110/arm/ \
10+
-e s/s390x/s390/ -e s/parisc64/parisc/ \
11+
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
12+
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
13+
-e s/riscv.*/riscv/)

tools/testing/selftests/android/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TEST_PROGS := run.sh
66

77
include ../lib.mk
88

9-
all:
9+
all: khdr
1010
@for DIR in $(SUBDIRS); do \
1111
BUILD_TARGET=$(OUTPUT)/$$DIR; \
1212
mkdir $$BUILD_TARGET -p; \

tools/testing/selftests/android/ion/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c
1010

1111
TEST_PROGS := ion_test.sh
1212

13+
KSFT_KHDR_INSTALL := 1
14+
top_srcdir = ../../../../..
1315
include ../../lib.mk
1416

1517
$(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c

tools/testing/selftests/futex/functional/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ TEST_GEN_FILES := \
1818

1919
TEST_PROGS := run.sh
2020

21+
top_srcdir = ../../../../..
2122
include ../../lib.mk
2223

2324
$(TEST_GEN_FILES): $(HEADERS)

tools/testing/selftests/gpio/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ endef
2121
CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
2222
LDLIBS += -lmount -I/usr/include/libmount
2323

24-
$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
24+
$(BINARIES):| khdr
25+
$(BINARIES): ../../../gpio/gpio-utils.o
2526

2627
../../../gpio/gpio-utils.o:
2728
make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
28-
29-
../../../../usr/include/linux/gpio.h:
30-
make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/
31-

tools/testing/selftests/kvm/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c
3737
$(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
3838
$(AR) crs $@ $^
3939

40-
$(LINUX_HDR_PATH):
41-
make -C $(top_srcdir) headers_install
42-
43-
all: $(STATIC_LIBS) $(LINUX_HDR_PATH)
40+
all: $(STATIC_LIBS)
4441
$(TEST_GEN_PROGS): $(STATIC_LIBS)
45-
$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH)
42+
$(STATIC_LIBS):| khdr

tools/testing/selftests/lib.mk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
1616
TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
1717
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
1818

19+
top_srcdir ?= ../../../..
20+
include $(top_srcdir)/scripts/subarch.include
21+
ARCH ?= $(SUBARCH)
22+
1923
all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
2024

25+
.PHONY: khdr
26+
khdr:
27+
make ARCH=$(ARCH) -C $(top_srcdir) headers_install
28+
29+
ifdef KSFT_KHDR_INSTALL
30+
$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr
31+
endif
32+
2133
.ONESHELL:
2234
define RUN_TEST_PRINT_RESULT
2335
TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \

tools/testing/selftests/net/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx
1515
TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
1616
TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls
1717

18+
KSFT_KHDR_INSTALL := 1
1819
include ../lib.mk
1920

2021
$(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma

tools/testing/selftests/networking/timestamping/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp
55

66
all: $(TEST_PROGS)
77

8+
top_srcdir = ../../../../..
89
include ../../lib.mk
910

1011
clean:

tools/testing/selftests/vm/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ TEST_PROGS := run_vmtests
2626

2727
include ../lib.mk
2828

29-
$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h
3029
$(OUTPUT)/userfaultfd: LDLIBS += -lpthread
3130

3231
$(OUTPUT)/mlock-random-test: LDLIBS += -lcap
33-
34-
../../../../usr/include/linux/kernel.h:
35-
make -C ../../../.. headers_install

0 commit comments

Comments
 (0)