diff mbox series

[bpf-next] selftests: bpf: test_kmod.sh: pass parameter to the module

Message ID 20220905072219.56361-1-ykaliuta@redhat.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] selftests: bpf: test_kmod.sh: pass parameter to the module | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 11 maintainers not CCed: shuah@kernel.org john.fastabend@gmail.com linux-kselftest@vger.kernel.org jolsa@kernel.org song@kernel.org yhs@fb.com haoluo@google.com martin.lau@linux.dev mykolal@fb.com kpsingh@kernel.org sdf@google.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with llvm-16

Commit Message

Yauheni Kaliuta Sept. 5, 2022, 7:22 a.m. UTC
It's possible to specify particular tests for test_bpf.ko with
module parameters. Make it possible to pass a module parameter as
the first test_kmod.sh argument, 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>
---
 tools/testing/selftests/bpf/test_kmod.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Song Liu Sept. 6, 2022, 4:51 p.m. UTC | #1
On Mon, Sep 5, 2022 at 12:25 AM Yauheni Kaliuta <ykaliuta@redhat.com> wrote:
>
> It's possible to specify particular tests for test_bpf.ko with
> module parameters. Make it possible to pass a module parameter as
> the first test_kmod.sh argument, 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>
> ---
>  tools/testing/selftests/bpf/test_kmod.sh | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
> index 4f6444bcd53f..3cb52ba20db8 100755
> --- a/tools/testing/selftests/bpf/test_kmod.sh
> +++ b/tools/testing/selftests/bpf/test_kmod.sh
> @@ -4,6 +4,8 @@
>  # Kselftest framework requirement - SKIP code is 4.
>  ksft_skip=4
>
> +MOD_PARAM="$1"

Shall we use $@ to pass all remaining arguments to insmod/modprobe?
Otherwise, users may get confused when some parameters don't get
passed.

We should also add a help/usage message or at least a comment in the
script.

Thanks,
Song

> +
>  msg="skip all tests:"
>  if [ "$(id -u)" != "0" ]; then
>         echo $msg please run this as root >&2
> @@ -26,15 +28,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 $MOD_PARAM 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 $MOD_PARAM; then
>                         echo "test_bpf: [SKIP]"
> -               elif /sbin/modprobe -q test_bpf; then
> +               elif /sbin/modprobe -q test_bpf $MOD_PARAM; then
>                         echo "test_bpf: ok"
>                 else
>                         echo "test_bpf: [FAIL]"
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
index 4f6444bcd53f..3cb52ba20db8 100755
--- a/tools/testing/selftests/bpf/test_kmod.sh
+++ b/tools/testing/selftests/bpf/test_kmod.sh
@@ -4,6 +4,8 @@ 
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
 
+MOD_PARAM="$1"
+
 msg="skip all tests:"
 if [ "$(id -u)" != "0" ]; then
 	echo $msg please run this as root >&2
@@ -26,15 +28,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 $MOD_PARAM 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 $MOD_PARAM; then
 			echo "test_bpf: [SKIP]"
-		elif /sbin/modprobe -q test_bpf; then
+		elif /sbin/modprobe -q test_bpf $MOD_PARAM; then
 			echo "test_bpf: ok"
 		else
 			echo "test_bpf: [FAIL]"