Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / tools / testing / selftests / bpf / test_kmod.sh
blob35669ccd4d23b26c7505e8829bcf3876e3bcb3e1
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
4 SRC_TREE=../../../../
6 test_run()
8 sysctl -w net.core.bpf_jit_enable=$1 2>&1 > /dev/null
9 sysctl -w net.core.bpf_jit_harden=$2 2>&1 > /dev/null
11 echo "[ JIT enabled:$1 hardened:$2 ]"
12 dmesg -C
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
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
29 rmmod test_bpf 2> /dev/null
30 dmesg | grep FAIL
33 test_save()
35 JE=`sysctl -n net.core.bpf_jit_enable`
36 JH=`sysctl -n net.core.bpf_jit_harden`
39 test_restore()
41 sysctl -w net.core.bpf_jit_enable=$JE 2>&1 > /dev/null
42 sysctl -w net.core.bpf_jit_harden=$JH 2>&1 > /dev/null
45 rc=0
46 test_save
47 test_run 0 0
48 test_run 1 0
49 test_run 1 1
50 test_run 1 2
51 test_restore
52 exit $rc