Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kselftest: arm64: extend toplevel skeleton Makefile

Modify KSFT arm64 toplevel Makefile to maintain arm64 kselftests organized
by subsystem, keeping them into distinct subdirectories under arm64 custom
KSFT directory: tools/testing/selftests/arm64/

Add to such toplevel Makefile a mechanism to guess the effective location
of Kernel headers as installed by KSFT framework.

Fit existing arm64 tags kselftest into this new schema moving them into
their own subdirectory (arm64/tags).

Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Cristian Marussi and committed by
Catalin Marinas
313a4db7 4f5cafb5

+92 -5
+1
tools/testing/selftests/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 TARGETS = android 3 + TARGETS += arm64 3 4 TARGETS += bpf 4 5 TARGETS += breakpoints 5 6 TARGETS += capabilities
tools/testing/selftests/arm64/.gitignore tools/testing/selftests/arm64/tags/.gitignore
+59 -5
tools/testing/selftests/arm64/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - # ARCH can be overridden by the user for cross compiling 3 + # When ARCH not overridden for crosscompiling, lookup machine 4 4 ARCH ?= $(shell uname -m 2>/dev/null || echo not) 5 5 6 6 ifneq (,$(filter $(ARCH),aarch64 arm64)) 7 - CFLAGS += -I../../../../usr/include/ 8 - TEST_GEN_PROGS := tags_test 9 - TEST_PROGS := run_tags_test.sh 7 + ARM64_SUBTARGETS ?= tags 8 + else 9 + ARM64_SUBTARGETS := 10 10 endif 11 11 12 - include ../lib.mk 12 + CFLAGS := -Wall -O2 -g 13 + 14 + # A proper top_srcdir is needed by KSFT(lib.mk) 15 + top_srcdir = $(realpath ../../../../) 16 + 17 + # Additional include paths needed by kselftest.h and local headers 18 + CFLAGS += -I$(top_srcdir)/tools/testing/selftests/ 19 + 20 + # Guessing where the Kernel headers could have been installed 21 + # depending on ENV config 22 + ifeq ($(KBUILD_OUTPUT),) 23 + khdr_dir = $(top_srcdir)/usr/include 24 + else 25 + # the KSFT preferred location when KBUILD_OUTPUT is set 26 + khdr_dir = $(KBUILD_OUTPUT)/kselftest/usr/include 27 + endif 28 + 29 + CFLAGS += -I$(khdr_dir) 30 + 31 + export CFLAGS 32 + export top_srcdir 33 + 34 + all: 35 + @for DIR in $(ARM64_SUBTARGETS); do \ 36 + BUILD_TARGET=$(OUTPUT)/$$DIR; \ 37 + mkdir -p $$BUILD_TARGET; \ 38 + make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 39 + done 40 + 41 + install: all 42 + @for DIR in $(ARM64_SUBTARGETS); do \ 43 + BUILD_TARGET=$(OUTPUT)/$$DIR; \ 44 + make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 45 + done 46 + 47 + run_tests: all 48 + @for DIR in $(ARM64_SUBTARGETS); do \ 49 + BUILD_TARGET=$(OUTPUT)/$$DIR; \ 50 + make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 51 + done 52 + 53 + # Avoid any output on non arm64 on emit_tests 54 + emit_tests: all 55 + @for DIR in $(ARM64_SUBTARGETS); do \ 56 + BUILD_TARGET=$(OUTPUT)/$$DIR; \ 57 + make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 58 + done 59 + 60 + clean: 61 + @for DIR in $(ARM64_SUBTARGETS); do \ 62 + BUILD_TARGET=$(OUTPUT)/$$DIR; \ 63 + make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 64 + done 65 + 66 + .PHONY: all clean install run_tests emit_tests
+25
tools/testing/selftests/arm64/README
··· 1 + KSelfTest ARM64 2 + =============== 3 + 4 + - These tests are arm64 specific and so not built or run but just skipped 5 + completely when env-variable ARCH is found to be different than 'arm64' 6 + and `uname -m` reports other than 'aarch64'. 7 + 8 + - Holding true the above, ARM64 KSFT tests can be run within the KSelfTest 9 + framework using standard Linux top-level-makefile targets: 10 + 11 + $ make TARGETS=arm64 kselftest-clean 12 + $ make TARGETS=arm64 kselftest 13 + 14 + or 15 + 16 + $ make -C tools/testing/selftests TARGETS=arm64 \ 17 + INSTALL_PATH=<your-installation-path> install 18 + 19 + or, alternatively, only specific arm64/ subtargets can be picked: 20 + 21 + $ make -C tools/testing/selftests TARGETS=arm64 ARM64_SUBTARGETS="tags signal" \ 22 + INSTALL_PATH=<your-installation-path> install 23 + 24 + Further details on building and running KFST can be found in: 25 + Documentation/dev-tools/kselftest.rst
tools/testing/selftests/arm64/run_tags_test.sh tools/testing/selftests/arm64/tags/run_tags_test.sh
+7
tools/testing/selftests/arm64/tags/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + CFLAGS += -I../../../../../usr/include/ 4 + TEST_GEN_PROGS := tags_test 5 + TEST_PROGS := run_tags_test.sh 6 + 7 + include ../../lib.mk
tools/testing/selftests/arm64/tags_test.c tools/testing/selftests/arm64/tags/tags_test.c