Skip to content

Commit

Permalink
selftests: bpf: test_kmod.sh: Pass parameters to the module
Browse files Browse the repository at this point in the history
It's possible to specify particular tests for test_bpf.ko with
module parameters. Make it possible to pass the module parameters,
example:

test_kmod.sh test_range=1,3

Since magnitude tests take long time it can be reasonable to skip
them.

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220908120146.381218-1-ykaliuta@redhat.com
  • Loading branch information
Yauheni Kaliuta authored and Andrii Nakryiko committed Sep 22, 2022
1 parent 9f2f5d7 commit 272d1f4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/testing/selftests/bpf/test_kmod.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0

# Usage:
# ./test_kmod.sh [module_param]...
# Ex.: ./test_kmod.sh test_range=1,3
# All the parameters are passed to the kernel module.

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

Expand All @@ -26,15 +31,15 @@ test_run()
echo "[ JIT enabled:$1 hardened:$2 ]"
dmesg -C
if [ -f ${OUTPUT}/lib/test_bpf.ko ]; then
insmod ${OUTPUT}/lib/test_bpf.ko 2> /dev/null
insmod ${OUTPUT}/lib/test_bpf.ko "$@" 2> /dev/null
if [ $? -ne 0 ]; then
rc=1
fi
else
# Use modprobe dry run to check for missing test_bpf module
if ! /sbin/modprobe -q -n test_bpf; then
if ! /sbin/modprobe -q -n test_bpf "$@"; then
echo "test_bpf: [SKIP]"
elif /sbin/modprobe -q test_bpf; then
elif /sbin/modprobe -q test_bpf "$@"; then
echo "test_bpf: ok"
else
echo "test_bpf: [FAIL]"
Expand Down

0 comments on commit 272d1f4

Please sign in to comment.