mirror of
https://gitee.com/openharmony/kernel_linux
synced 2025-04-15 13:50:42 +00:00
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>
This commit is contained in:
parent
c31d02d129
commit
b2d35fa5fc
14
Makefile
14
Makefile
@ -299,19 +299,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
|
|||||||
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
|
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
|
||||||
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
|
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
|
||||||
|
|
||||||
# SUBARCH tells the usermode build what the underlying arch is. That is set
|
include scripts/subarch.include
|
||||||
# first, and if a usermode build is happening, the "ARCH=um" on the command
|
|
||||||
# line overrides the setting of ARCH below. If a native build is happening,
|
|
||||||
# then ARCH is assigned, getting whatever value it gets normally, and
|
|
||||||
# SUBARCH is subsequently ignored.
|
|
||||||
|
|
||||||
SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
|
|
||||||
-e s/sun4u/sparc64/ \
|
|
||||||
-e s/arm.*/arm/ -e s/sa110/arm/ \
|
|
||||||
-e s/s390x/s390/ -e s/parisc64/parisc/ \
|
|
||||||
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
|
|
||||||
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
|
|
||||||
-e s/riscv.*/riscv/)
|
|
||||||
|
|
||||||
# Cross compiling and selecting different set of gcc/bin-utils
|
# Cross compiling and selecting different set of gcc/bin-utils
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
13
scripts/subarch.include
Normal file
13
scripts/subarch.include
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# SUBARCH tells the usermode build what the underlying arch is. That is set
|
||||||
|
# first, and if a usermode build is happening, the "ARCH=um" on the command
|
||||||
|
# line overrides the setting of ARCH below. If a native build is happening,
|
||||||
|
# then ARCH is assigned, getting whatever value it gets normally, and
|
||||||
|
# SUBARCH is subsequently ignored.
|
||||||
|
|
||||||
|
SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
|
||||||
|
-e s/sun4u/sparc64/ \
|
||||||
|
-e s/arm.*/arm/ -e s/sa110/arm/ \
|
||||||
|
-e s/s390x/s390/ -e s/parisc64/parisc/ \
|
||||||
|
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
|
||||||
|
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
|
||||||
|
-e s/riscv.*/riscv/)
|
@ -6,7 +6,7 @@ TEST_PROGS := run.sh
|
|||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
all:
|
all: khdr
|
||||||
@for DIR in $(SUBDIRS); do \
|
@for DIR in $(SUBDIRS); do \
|
||||||
BUILD_TARGET=$(OUTPUT)/$$DIR; \
|
BUILD_TARGET=$(OUTPUT)/$$DIR; \
|
||||||
mkdir $$BUILD_TARGET -p; \
|
mkdir $$BUILD_TARGET -p; \
|
||||||
|
@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c
|
|||||||
|
|
||||||
TEST_PROGS := ion_test.sh
|
TEST_PROGS := ion_test.sh
|
||||||
|
|
||||||
|
KSFT_KHDR_INSTALL := 1
|
||||||
|
top_srcdir = ../../../../..
|
||||||
include ../../lib.mk
|
include ../../lib.mk
|
||||||
|
|
||||||
$(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c
|
$(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c
|
||||||
|
@ -18,6 +18,7 @@ TEST_GEN_FILES := \
|
|||||||
|
|
||||||
TEST_PROGS := run.sh
|
TEST_PROGS := run.sh
|
||||||
|
|
||||||
|
top_srcdir = ../../../../..
|
||||||
include ../../lib.mk
|
include ../../lib.mk
|
||||||
|
|
||||||
$(TEST_GEN_FILES): $(HEADERS)
|
$(TEST_GEN_FILES): $(HEADERS)
|
||||||
|
@ -21,11 +21,8 @@ endef
|
|||||||
CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
|
CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
|
||||||
LDLIBS += -lmount -I/usr/include/libmount
|
LDLIBS += -lmount -I/usr/include/libmount
|
||||||
|
|
||||||
$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
|
$(BINARIES):| khdr
|
||||||
|
$(BINARIES): ../../../gpio/gpio-utils.o
|
||||||
|
|
||||||
../../../gpio/gpio-utils.o:
|
../../../gpio/gpio-utils.o:
|
||||||
make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
|
make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
|
||||||
|
|
||||||
../../../../usr/include/linux/gpio.h:
|
|
||||||
make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/
|
|
||||||
|
|
||||||
|
@ -37,9 +37,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c
|
|||||||
$(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
|
$(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
|
||||||
$(AR) crs $@ $^
|
$(AR) crs $@ $^
|
||||||
|
|
||||||
$(LINUX_HDR_PATH):
|
all: $(STATIC_LIBS)
|
||||||
make -C $(top_srcdir) headers_install
|
|
||||||
|
|
||||||
all: $(STATIC_LIBS) $(LINUX_HDR_PATH)
|
|
||||||
$(TEST_GEN_PROGS): $(STATIC_LIBS)
|
$(TEST_GEN_PROGS): $(STATIC_LIBS)
|
||||||
$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH)
|
$(STATIC_LIBS):| khdr
|
||||||
|
@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
|
|||||||
TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
|
TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
|
||||||
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
|
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
|
||||||
|
|
||||||
|
top_srcdir ?= ../../../..
|
||||||
|
include $(top_srcdir)/scripts/subarch.include
|
||||||
|
ARCH ?= $(SUBARCH)
|
||||||
|
|
||||||
all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
|
all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
|
||||||
|
|
||||||
|
.PHONY: khdr
|
||||||
|
khdr:
|
||||||
|
make ARCH=$(ARCH) -C $(top_srcdir) headers_install
|
||||||
|
|
||||||
|
ifdef KSFT_KHDR_INSTALL
|
||||||
|
$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr
|
||||||
|
endif
|
||||||
|
|
||||||
.ONESHELL:
|
.ONESHELL:
|
||||||
define RUN_TEST_PRINT_RESULT
|
define RUN_TEST_PRINT_RESULT
|
||||||
TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \
|
TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \
|
||||||
|
@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx
|
|||||||
TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
|
TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
|
||||||
TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls
|
TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls
|
||||||
|
|
||||||
|
KSFT_KHDR_INSTALL := 1
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
$(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma
|
$(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma
|
||||||
|
@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp
|
|||||||
|
|
||||||
all: $(TEST_PROGS)
|
all: $(TEST_PROGS)
|
||||||
|
|
||||||
|
top_srcdir = ../../../../..
|
||||||
include ../../lib.mk
|
include ../../lib.mk
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -26,10 +26,6 @@ TEST_PROGS := run_vmtests
|
|||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h
|
|
||||||
$(OUTPUT)/userfaultfd: LDLIBS += -lpthread
|
$(OUTPUT)/userfaultfd: LDLIBS += -lpthread
|
||||||
|
|
||||||
$(OUTPUT)/mlock-random-test: LDLIBS += -lcap
|
$(OUTPUT)/mlock-random-test: LDLIBS += -lcap
|
||||||
|
|
||||||
../../../../usr/include/linux/kernel.h:
|
|
||||||
make -C ../../../.. headers_install
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user