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

selftests: bpf: test_kmod.sh: Fix running out of srctree

When running out of srctree, relative path to lib/test_bpf.ko is
different than when running in srctree. Check $building_out_of_srctree
environment variable and use a different relative path if needed.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200717165326.6786-2-iii@linux.ibm.com

authored by

Ilya Leoshkevich and committed by
Alexei Starovoitov
2ea48598 c576b9c7

+9 -3
+9 -3
tools/testing/selftests/bpf/test_kmod.sh
··· 10 10 exit $ksft_skip 11 11 fi 12 12 13 - SRC_TREE=../../../../ 13 + if [ "$building_out_of_srctree" ]; then 14 + # We are in linux-build/kselftest/bpf 15 + OUTPUT=../../ 16 + else 17 + # We are in linux/tools/testing/selftests/bpf 18 + OUTPUT=../../../../ 19 + fi 14 20 15 21 test_run() 16 22 { ··· 25 19 26 20 echo "[ JIT enabled:$1 hardened:$2 ]" 27 21 dmesg -C 28 - if [ -f ${SRC_TREE}/lib/test_bpf.ko ]; then 29 - insmod ${SRC_TREE}/lib/test_bpf.ko 2> /dev/null 22 + if [ -f ${OUTPUT}/lib/test_bpf.ko ]; then 23 + insmod ${OUTPUT}/lib/test_bpf.ko 2> /dev/null 30 24 if [ $? -ne 0 ]; then 31 25 rc=1 32 26 fi