Currently, when testing a certain target in selftests, executing the command 'make TARGETS=XX -C tools/testing/selftests' succeeds for non-BPF, but a similar command fails for BPF: ''' make TARGETS=bpf -C tools/testing/selftests
make: Entering directory '/linux-kselftest/tools/testing/selftests' make: *** [Makefile:197: all] Error 1 make: Leaving directory '/linux-kselftest/tools/testing/selftests' '''
The reason is that the previous commit: commit 7a6eb7c34a78 ("selftests: Skip BPF seftests by default") led to the default filtering of bpf in TARGETS which make TARGETS empty. That commit also mentioned that building BPF tests requires external commands to run. This caused target like 'bpf' or 'sched_ext' defined in SKIP_TARGETS to need an additional specification of SKIP_TARGETS as empty to avoid skipping it, for example: ''' make TARGETS=bpf SKIP_TARGETS="" -C tools/testing/selftests '''
If special steps are required to execute certain test, it is extremely unfair. We need a fairer way to treat different test targets.
This commit provider a way: If a user has specified a single TARGETS, it indicates an expectation to run the specified target, and thus the object should not be skipped.
Another way is to change TARGETS to DEFAULT_TARGETS in the Makefile and then check if the user specified TARGETS and decide whether filter or not, though this approach requires too many modifications. Signed-off-by: Jiayuan Chen mrpre@163.com --- tools/testing/selftests/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 363d031a16f7..d76c1781ec09 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -116,7 +116,7 @@ TARGETS += vDSO TARGETS += mm TARGETS += x86 TARGETS += zram -#Please keep the TARGETS list alphabetically sorted +# Please keep the TARGETS list alphabetically sorted # Run "make quicktest=1 run_tests" or # "make quicktest=1 kselftest" from top level Makefile
@@ -132,12 +132,15 @@ endif
# User can optionally provide a TARGETS skiplist. By default we skip # targets using BPF since it has cutting edge build time dependencies -# which require more effort to install. +# If user provide custom TARGETS, we just ignore SKIP_TARGETS so that +# user can easy to test single target which defined in SKIP_TARGETS SKIP_TARGETS ?= bpf sched_ext ifneq ($(SKIP_TARGETS),) +ifneq ($(words $(TARGETS)), 1) TMP := $(filter-out $(SKIP_TARGETS), $(TARGETS)) override TARGETS := $(TMP) endif +endif
# User can set FORCE_TARGETS to 1 to require all targets to be successfully # built; make will fail if any of the targets cannot be built. If
base-commit: 67b6d342fb6d5abfbeb71e0f23141b9b96cf7bb1
On 11/18/24 07:06, Jiayuan Chen wrote:
Currently, when testing a certain target in selftests, executing the command 'make TARGETS=XX -C tools/testing/selftests' succeeds for non-BPF, but a similar command fails for BPF: ''' make TARGETS=bpf -C tools/testing/selftests
make: Entering directory '/linux-kselftest/tools/testing/selftests' make: *** [Makefile:197: all] Error 1 make: Leaving directory '/linux-kselftest/tools/testing/selftests' '''
The reason is that the previous commit: commit 7a6eb7c34a78 ("selftests: Skip BPF seftests by default") led to the default filtering of bpf in TARGETS which make TARGETS empty. That commit also mentioned that building BPF tests requires external commands to run. This caused target like 'bpf' or 'sched_ext' defined in SKIP_TARGETS to need an additional specification of SKIP_TARGETS as empty to avoid skipping it, for example: ''' make TARGETS=bpf SKIP_TARGETS="" -C tools/testing/selftests '''
If special steps are required to execute certain test, it is extremely unfair. We need a fairer way to treat different test targets.
Note: Adding Mark, author for commit 7a6eb7c34a78 to the thread
The reason we did this was bpf test depends on newer versions of LLVM tool chain.
A better solution would be to check for compile time dependencies in bpf Makefile and check run-time dependencies from bpf test or a wrapper script invoked from run_tests to the skip the test if test can't run.
I would like to see us go that route over addressing this problem with SKIP_TARGETS solution.
The commit 7a6eb7c34a78 went in 4 years ago? DO we have a better story for the LLVM tool chain to get rid of skipping bpf and sched_ext?
Running make -C tools/testing/selftests/bpf/ gave me the following error. Does this mean we still can't include bpf in default run?
make -C tools/testing/selftests/bpf/ make: Entering directory '/linux/linux_6.12/tools/testing/selftests/bpf'
Auto-detecting system features: ... llvm: [ OFF ]
GEN /linux/linux_6.12/tools/testing/selftests/bpf/tools/build/bpftool/vmlinux.h libbpf: failed to find '.BTF' ELF section in /linux/linux_6.12/vmlinux Error: failed to load BTF from /linux/linux_6.12/vmlinux: No data available make[1]: *** [Makefile:209: /linux/linux_6.12/tools/testing/selftests/bpf/tools/build/bpftool/vmlinux.h] Error 195 make[1]: *** Deleting file '/linux/linux_6.12/tools/testing/selftests/bpf/tools/build/bpftool/vmlinux.h' make: *** [Makefile:369: /linux/linux_6.12/tools/testing/selftests/bpf/tools/sbin/bpftool] Error 2 make: Leaving directory '/linux/linux_6.12/tools/testing/selftests/bpf'
This commit provider a way: If a user has specified a single TARGETS, it indicates an expectation to run the specified target, and thus the object should not be skipped.
Another way is to change TARGETS to DEFAULT_TARGETS in the Makefile and then check if the user specified TARGETS and decide whether filter or not, though this approach requires too many modifications. Signed-off-by: Jiayuan Chen mrpre@163.com
tools/testing/selftests/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 363d031a16f7..d76c1781ec09 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -116,7 +116,7 @@ TARGETS += vDSO TARGETS += mm TARGETS += x86 TARGETS += zram -#Please keep the TARGETS list alphabetically sorted +# Please keep the TARGETS list alphabetically sorted # Run "make quicktest=1 run_tests" or # "make quicktest=1 kselftest" from top level Makefile @@ -132,12 +132,15 @@ endif # User can optionally provide a TARGETS skiplist. By default we skip # targets using BPF since it has cutting edge build time dependencies -# which require more effort to install. +# If user provide custom TARGETS, we just ignore SKIP_TARGETS so that +# user can easy to test single target which defined in SKIP_TARGETS SKIP_TARGETS ?= bpf sched_ext ifneq ($(SKIP_TARGETS),) +ifneq ($(words $(TARGETS)), 1) TMP := $(filter-out $(SKIP_TARGETS), $(TARGETS)) override TARGETS := $(TMP) endif +endif # User can set FORCE_TARGETS to 1 to require all targets to be successfully # built; make will fail if any of the targets cannot be built. If
base-commit: 67b6d342fb6d5abfbeb71e0f23141b9b96cf7bb1
thanks, -- Shuah
On Fri, Nov 22, 2024 at 08:14:58AM -0700, Shuah Khan wrote:
The commit 7a6eb7c34a78 went in 4 years ago? DO we have a better story for the LLVM tool chain to get rid of skipping bpf and sched_ext?
Running make -C tools/testing/selftests/bpf/ gave me the following error. Does this mean we still can't include bpf in default run?
make -C tools/testing/selftests/bpf/ make: Entering directory '/linux/linux_6.12/tools/testing/selftests/bpf'
Auto-detecting system features: ... llvm: [ OFF ]
The toolchain is in a better place now and we can run with released LLVM versions. The detection above is still needed since the LLVM version needed is a bit newer than the version needed for the kernel itself, it's LLVM 18 for BPF, and not everyone has LLVM.
GEN /linux/linux_6.12/tools/testing/selftests/bpf/tools/build/bpftool/vmlinux.h libbpf: failed to find '.BTF' ELF section in /linux/linux_6.12/vmlinux Error: failed to load BTF from /linux/linux_6.12/vmlinux: No data available make[1]: *** [Makefile:209: /linux/linux_6.12/tools/testing/selftests/bpf/tools/build/bpftool/vmlinux.h] Error 195 make[1]: *** Deleting file '/linux/linux_6.12/tools/testing/selftests/bpf/tools/build/bpftool/vmlinux.h' make: *** [Makefile:369: /linux/linux_6.12/tools/testing/selftests/bpf/tools/sbin/bpftool] Error 2 make: Leaving directory '/linux/linux_6.12/tools/testing/selftests/bpf'
This bit still needs some attention - the build needs a kernel binary with BTF information built in via CONFIG_DEBUG_INFO_BTF. That is enabled by the config fragment for BTF tests but it's not compatible with the arm64 defconfig since that sets CONFIG_DEBUG_INFO_REDUCED which isn't compatible with _BTF, and in general having it missing should be handled a bit more gracefully. I believe some of the tests would run happily without the BTF information.
TBH I'm a bit surprised we even tried to do this bit with LLVM not available...
linux-kselftest-mirror@lists.linaro.org