diff options
| author | Anders Roxell <anders.roxell@linaro.org> | 2018-09-04 06:47:21 -0400 |
|---|---|---|
| committer | Shuah Khan (Samsung OSG) <shuah@kernel.org> | 2018-09-05 10:12:09 -0400 |
| commit | b2d35fa5fc80c27e868e393dcab4c94a0d71737f (patch) | |
| tree | 1ff2d280109a4b5b43cc5ec6a4e70ff23131ca78 | |
| parent | c31d02d1290e1e82a08015199e408228e152991f (diff) | |
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>
| -rw-r--r-- | Makefile | 14 | ||||
| -rw-r--r-- | scripts/subarch.include | 13 | ||||
| -rw-r--r-- | tools/testing/selftests/android/Makefile | 2 | ||||
| -rw-r--r-- | tools/testing/selftests/android/ion/Makefile | 2 | ||||
| -rw-r--r-- | tools/testing/selftests/futex/functional/Makefile | 1 | ||||
| -rw-r--r-- | tools/testing/selftests/gpio/Makefile | 7 | ||||
| -rw-r--r-- | tools/testing/selftests/kvm/Makefile | 7 | ||||
| -rw-r--r-- | tools/testing/selftests/lib.mk | 12 | ||||
| -rw-r--r-- | tools/testing/selftests/net/Makefile | 1 | ||||
| -rw-r--r-- | tools/testing/selftests/networking/timestamping/Makefile | 1 | ||||
| -rw-r--r-- | tools/testing/selftests/vm/Makefile | 4 |
11 files changed, 36 insertions, 28 deletions
| @@ -299,19 +299,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) | |||
| 299 | KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) | 299 | KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) |
| 300 | export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION | 300 | export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION |
| 301 | 301 | ||
| 302 | # SUBARCH tells the usermode build what the underlying arch is. That is set | 302 | include scripts/subarch.include |
| 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/) | ||
| 315 | 303 | ||
| 316 | # Cross compiling and selecting different set of gcc/bin-utils | 304 | # Cross compiling and selecting different set of gcc/bin-utils |
| 317 | # --------------------------------------------------------------------------- | 305 | # --------------------------------------------------------------------------- |
diff --git a/scripts/subarch.include b/scripts/subarch.include new file mode 100644 index 000000000000..650682821126 --- /dev/null +++ b/scripts/subarch.include | |||
| @@ -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/) | ||
diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index 72c25a3cb658..d9a725478375 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile | |||
| @@ -6,7 +6,7 @@ TEST_PROGS := run.sh | |||
| 6 | 6 | ||
| 7 | include ../lib.mk | 7 | include ../lib.mk |
| 8 | 8 | ||
| 9 | all: | 9 | all: khdr |
| 10 | @for DIR in $(SUBDIRS); do \ | 10 | @for DIR in $(SUBDIRS); do \ |
| 11 | BUILD_TARGET=$(OUTPUT)/$$DIR; \ | 11 | BUILD_TARGET=$(OUTPUT)/$$DIR; \ |
| 12 | mkdir $$BUILD_TARGET -p; \ | 12 | mkdir $$BUILD_TARGET -p; \ |
diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile index e03695287f76..88cfe88e466f 100644 --- a/tools/testing/selftests/android/ion/Makefile +++ b/tools/testing/selftests/android/ion/Makefile | |||
| @@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c | |||
| 10 | 10 | ||
| 11 | TEST_PROGS := ion_test.sh | 11 | TEST_PROGS := ion_test.sh |
| 12 | 12 | ||
| 13 | KSFT_KHDR_INSTALL := 1 | ||
| 14 | top_srcdir = ../../../../.. | ||
| 13 | include ../../lib.mk | 15 | include ../../lib.mk |
| 14 | 16 | ||
| 15 | $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c | 17 | $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c |
diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile index ff8feca49746..ad1eeb14fda7 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile | |||
| @@ -18,6 +18,7 @@ TEST_GEN_FILES := \ | |||
| 18 | 18 | ||
| 19 | TEST_PROGS := run.sh | 19 | TEST_PROGS := run.sh |
| 20 | 20 | ||
| 21 | top_srcdir = ../../../../.. | ||
| 21 | include ../../lib.mk | 22 | include ../../lib.mk |
| 22 | 23 | ||
| 23 | $(TEST_GEN_FILES): $(HEADERS) | 24 | $(TEST_GEN_FILES): $(HEADERS) |
diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 1bbb47565c55..4665cdbf1a8d 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile | |||
| @@ -21,11 +21,8 @@ endef | |||
| 21 | CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ | 21 | CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ |
| 22 | LDLIBS += -lmount -I/usr/include/libmount | 22 | LDLIBS += -lmount -I/usr/include/libmount |
| 23 | 23 | ||
| 24 | $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h | 24 | $(BINARIES):| khdr |
| 25 | $(BINARIES): ../../../gpio/gpio-utils.o | ||
| 25 | 26 | ||
| 26 | ../../../gpio/gpio-utils.o: | 27 | ../../../gpio/gpio-utils.o: |
| 27 | make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio | 28 | 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 | |||
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 03b0f551bedf..87d1a8488af8 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile | |||
| @@ -37,9 +37,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c | |||
| 37 | $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) | 37 | $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) |
| 38 | $(AR) crs $@ $^ | 38 | $(AR) crs $@ $^ |
| 39 | 39 | ||
| 40 | $(LINUX_HDR_PATH): | 40 | all: $(STATIC_LIBS) |
| 41 | make -C $(top_srcdir) headers_install | ||
| 42 | |||
| 43 | all: $(STATIC_LIBS) $(LINUX_HDR_PATH) | ||
| 44 | $(TEST_GEN_PROGS): $(STATIC_LIBS) | 41 | $(TEST_GEN_PROGS): $(STATIC_LIBS) |
| 45 | $(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) | 42 | $(STATIC_LIBS):| khdr |
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 17ab36605a8e..0a8e75886224 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk | |||
| @@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) | |||
| 16 | TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) | 16 | TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) |
| 17 | TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) | 17 | TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) |
| 18 | 18 | ||
| 19 | top_srcdir ?= ../../../.. | ||
| 20 | include $(top_srcdir)/scripts/subarch.include | ||
| 21 | ARCH ?= $(SUBARCH) | ||
| 22 | |||
| 19 | all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) | 23 | all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) |
| 20 | 24 | ||
| 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 | |||
| 21 | .ONESHELL: | 33 | .ONESHELL: |
| 22 | define RUN_TEST_PRINT_RESULT | 34 | define RUN_TEST_PRINT_RESULT |
| 23 | TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ | 35 | TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ |
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 9cca68e440a0..919aa2ac00af 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile | |||
| @@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx | |||
| 15 | TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa | 15 | TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa |
| 16 | TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls | 16 | TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls |
| 17 | 17 | ||
| 18 | KSFT_KHDR_INSTALL := 1 | ||
| 18 | include ../lib.mk | 19 | include ../lib.mk |
| 19 | 20 | ||
| 20 | $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma | 21 | $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma |
diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile index a728040edbe1..14cfcf006936 100644 --- a/tools/testing/selftests/networking/timestamping/Makefile +++ b/tools/testing/selftests/networking/timestamping/Makefile | |||
| @@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp | |||
| 5 | 5 | ||
| 6 | all: $(TEST_PROGS) | 6 | all: $(TEST_PROGS) |
| 7 | 7 | ||
| 8 | top_srcdir = ../../../../.. | ||
| 8 | include ../../lib.mk | 9 | include ../../lib.mk |
| 9 | 10 | ||
| 10 | clean: | 11 | clean: |
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 9881876d2aa0..e94b7b14bcb2 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile | |||
| @@ -26,10 +26,6 @@ TEST_PROGS := run_vmtests | |||
| 26 | 26 | ||
| 27 | include ../lib.mk | 27 | include ../lib.mk |
| 28 | 28 | ||
| 29 | $(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h | ||
| 30 | $(OUTPUT)/userfaultfd: LDLIBS += -lpthread | 29 | $(OUTPUT)/userfaultfd: LDLIBS += -lpthread |
| 31 | 30 | ||
| 32 | $(OUTPUT)/mlock-random-test: LDLIBS += -lcap | 31 | $(OUTPUT)/mlock-random-test: LDLIBS += -lcap |
| 33 | |||
| 34 | ../../../../usr/include/linux/kernel.h: | ||
| 35 | make -C ../../../.. headers_install | ||
