[PATCH 2/2] selftests: bpf: test_kmod.sh: use modprobe on target device

From: naresh . kamboju
Date: Tue Sep 05 2017 - 05:55:09 EST


From: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>

on ARM and ARM64 devices kernel source tree is not available so
insmod "$SRC_TREE/lib/test_bpf.ko" is not working.

on these target devices the test_bpf.ko is installed under
/lib/modules/`uname -r`/kernel/lib/
so use modprobe dry run to check for missing test_bpf.ko module and
insert for testing.

Signed-off-by: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>
---
tools/testing/selftests/bpf/test_kmod.sh | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
index a53eb1cb54ef..4a827b4c4b60 100755
--- a/tools/testing/selftests/bpf/test_kmod.sh
+++ b/tools/testing/selftests/bpf/test_kmod.sh
@@ -13,6 +13,16 @@ test_run()
insmod $SRC_TREE/lib/test_bpf.ko 2> /dev/null
if [ $? -ne 0 ]; then
rc=1
+ elif
+ # Use modprobe dry run to check for missing test_bpf module
+ if ! /sbin/modprobe -q -n test_bpf; then
+ echo "test_bpf: [SKIP]"
+ fi
+ if /sbin/modprobe -q test_bpf; then
+ echo "test_bpf: ok"
+ else
+ echo "test_bpf: [FAIL]"
+ rc=1
fi
fi
rmmod test_bpf 2> /dev/null
--
2.13.0