Skip to content

Commit 035d808

Browse files
Naresh Kambojuborkmann
authored andcommitted
selftests: bpf: test_kmod.sh: check the module path before insmod
test_kmod.sh reported false failure when module not present. Check test_bpf.ko is present in the path before loading it. Two cases to be addressed here, In the development process of test_bpf.c unit testing will be done by developers by using "insmod $SRC_TREE/lib/test_bpf.ko" On the other hand testers run full tests by installing modules on device under test (DUT) and followed by modprobe to insert the modules accordingly. Signed-off-by: Naresh Kamboju <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 41b0530 commit 035d808

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tools/testing/selftests/bpf/test_kmod.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@ test_run()
1010

1111
echo "[ JIT enabled:$1 hardened:$2 ]"
1212
dmesg -C
13-
insmod $SRC_TREE/lib/test_bpf.ko 2> /dev/null
14-
if [ $? -ne 0 ]; then
15-
rc=1
13+
if [ -f ${SRC_TREE}/lib/test_bpf.ko ]; then
14+
insmod ${SRC_TREE}/lib/test_bpf.ko 2> /dev/null
15+
if [ $? -ne 0 ]; then
16+
rc=1
17+
fi
18+
else
19+
# Use modprobe dry run to check for missing test_bpf module
20+
if ! /sbin/modprobe -q -n test_bpf; then
21+
echo "test_bpf: [SKIP]"
22+
elif /sbin/modprobe -q test_bpf; then
23+
echo "test_bpf: ok"
24+
else
25+
echo "test_bpf: [FAIL]"
26+
rc=1
27+
fi
1628
fi
1729
rmmod test_bpf 2> /dev/null
1830
dmesg | grep FAIL

0 commit comments

Comments
 (0)