On Fri, Oct 04, 2024 at 11:42:46AM +0200, Björn Töpel wrote:
From: Björn Töpel bjorn@rivosinc.com
Thanks a lot Björn for working on this.
The sched_ext selftests is missing proper cross-compilation support, a proper target entry, and out-of-tree build support.
When building the kselftest suite, e.g.:
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- \ SKIP_TARGETS="" O=/output/foo -C tools/testing/selftests install
The expectation is that the sched_ext is included, cross-built, and placed into /output/foo.
Add CROSS_COMPILE, OUTPUT, and TARGETS support to the sched_ext selftest.
Signed-off-by: Björn Töpel bjorn@rivosinc.com
tools/testing/selftests/Makefile | 1 + tools/testing/selftests/sched_ext/Makefile | 59 +++++++++++++++------- 2 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index b38199965f99..20ee8a0b795c 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -88,6 +88,7 @@ TARGETS += rlimits TARGETS += rseq TARGETS += rtc TARGETS += rust +TARGETS += sched_ext TARGETS += seccomp TARGETS += sgx TARGETS += sigaltstack diff --git a/tools/testing/selftests/sched_ext/Makefile b/tools/testing/selftests/sched_ext/Makefile index 0754a2c110a1..66467a99184d 100644 --- a/tools/testing/selftests/sched_ext/Makefile +++ b/tools/testing/selftests/sched_ext/Makefile @@ -13,14 +13,8 @@ LLVM_SUFFIX := $(LLVM) endif CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as -else -CC := gcc
Given that we're including ../lib.mk, can we just get rid of this whole block?
endif # LLVM -ifneq ($(CROSS_COMPILE),) -$(error CROSS_COMPILE not supported for scx selftests) -endif # CROSS_COMPILE
CURDIR := $(abspath .) REPOROOT := $(abspath ../../../..) TOOLSDIR := $(REPOROOT)/tools @@ -34,18 +28,39 @@ GENHDR := $(GENDIR)/autoconf.h SCXTOOLSDIR := $(TOOLSDIR)/sched_ext SCXTOOLSINCDIR := $(TOOLSDIR)/sched_ext/include -OUTPUT_DIR := $(CURDIR)/build +ifeq (,$(OUTPUT)) +OUTPUT := $(CURDIR)/build +RUNNER_DIR := $(CURDIR) +else +OUTPUT_DIR := $(OUTPUT)
This breaks if you use make from the selftests/sched_ext directory. AFAICT it looks like OUTPUT is always set in ../lib.mk, so we always go to the OUTPUT_DIR := $(CURDIR) branch. Because of that, running `make clean` will delete the whole sched_ext selftests directory. Also, did you mean for the first branch to be:
+OUTPUT_DIR := $(CURDIR)/build
as opposed to:
+OUTPUT := $(CURDIR)/build
[...]
Thanks, David