Skip to content

Commit

Permalink
selftests: bpf: test_kmod.sh: Fix running out of srctree
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ilya Leoshkevich authored and Alexei Starovoitov committed Jul 21, 2020
1 parent c576b9c commit 2ea4859
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tools/testing/selftests/bpf/test_kmod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ if [ "$(id -u)" != "0" ]; then
exit $ksft_skip
fi

SRC_TREE=../../../../
if [ "$building_out_of_srctree" ]; then
# We are in linux-build/kselftest/bpf
OUTPUT=../../
else
# We are in linux/tools/testing/selftests/bpf
OUTPUT=../../../../
fi

test_run()
{
Expand All @@ -19,8 +25,8 @@ test_run()

echo "[ JIT enabled:$1 hardened:$2 ]"
dmesg -C
if [ -f ${SRC_TREE}/lib/test_bpf.ko ]; then
insmod ${SRC_TREE}/lib/test_bpf.ko 2> /dev/null
if [ -f ${OUTPUT}/lib/test_bpf.ko ]; then
insmod ${OUTPUT}/lib/test_bpf.ko 2> /dev/null
if [ $? -ne 0 ]; then
rc=1
fi
Expand Down

0 comments on commit 2ea4859

Please sign in to comment.