2 # SPDX-License-Identifier: GPL-2.0
5 # ./test_kmod.sh [module_param]...
6 # Ex.: ./test_kmod.sh test_range=1,3
7 # All the parameters are passed to the kernel module.
9 # Kselftest framework requirement - SKIP code is 4.
13 if [ "$(id -u)" != "0" ]; then
14 echo $msg please run this as root >&2
18 if [ "$building_out_of_srctree" ]; then
19 # We are in linux-build/kselftest/bpf
22 # We are in linux/tools/testing/selftests/bpf
28 sysctl -w net.core.bpf_jit_enable=$1 2>&1 > /dev/null
29 sysctl -w net.core.bpf_jit_harden=$2 2>&1 > /dev/null
31 echo "[ JIT enabled:$1 hardened:$2 ]"
34 if [ -f ${OUTPUT}/lib/test_bpf.ko ]; then
35 insmod ${OUTPUT}/lib/test_bpf.ko "$@" 2> /dev/null
40 # Use modprobe dry run to check for missing test_bpf module
41 if ! /sbin/modprobe -q -n test_bpf "$@"; then
42 echo "test_bpf: [SKIP]"
43 elif /sbin/modprobe -q test_bpf "$@"; then
46 echo "test_bpf: [FAIL]"
50 rmmod test_bpf 2> /dev/null
56 JE=`sysctl -n net.core.bpf_jit_enable`
57 JH=`sysctl -n net.core.bpf_jit_harden`
62 sysctl -w net.core.bpf_jit_enable=$JE 2>&1 > /dev/null
63 sysctl -w net.core.bpf_jit_harden=$JH 2>&1 > /dev/null