kselftest: Add basic test for probing the rust sample modules
PATCH v3 1/1 kselftest: Add basic test for probing the rust sample modules
Add new basic kselftest that checks if the available rust sample modules can be added and removed correctly.
---
Changes in v3:
- Removed useless KSFT_PASS, KSFT_FAIL, KSFT_SKIP constants
- Used ktap_finished to print the results summary and handle the return code Changes in v2:
- Added missing SPDX line
- Edited test_probe_samples.sh script to use the common KTAP helpers file
--- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rust/Makefile | 4 +++ .../selftests/rust/test_probe_samples.sh | 34 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 tools/testing/selftests/rust/Makefile create mode 100755 tools/testing/selftests/rust/test_probe_samples.sh
MAINTAINERS +1 -0
@@ -19207,6 +19207,7 @@ F: Documentation/rust/ F: rust/ F: samples/rust/ F: scripts/*rust* +F: tools/testing/selftests/rust/ K: \b(?i:rust)\b RXRPC SOCKETS (AF_RXRPC)
tools/testing/selftests/Makefile +1 -0
@@ -80,6 +80,7 @@ TARGETS += riscv TARGETS += rlimits TARGETS += rseq TARGETS += rtc +TARGETS += rust TARGETS += seccomp TARGETS += sgx TARGETS += sigaltstack
tools/testing/selftests/rust/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 +TEST_PROGS += test_probe_samples.sh + +include ../lib.mk
tools/testing/selftests/rust/test_probe_samples.sh new file +34 -0
@@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (c) 2023 Collabora Ltd +# +# This script tests whether the rust sample modules can +# be added and removed correctly. +# + +DIR="$(dirname "$(readlink -f "$0")")" + +source "${DIR}"/../kselftest/ktap_helpers.sh + +rust_sample_modules=("rust_minimal" "rust_print") + +ktap_print_header + +ktap_set_plan "${#rust_sample_modules[@]}" + +for sample in "${rust_sample_modules[@]}"; do + if ! /sbin/modprobe -n -q "$sample"; then + ktap_test_skip "module $sample is not found in /lib/modules/$(uname -r)" + continue + fi + + if /sbin/modprobe -q "$sample"; then + /sbin/modprobe -q -r "$sample" + ktap_test_pass "$sample" + else + ktap_test_fail "$sample" + fi +done + +ktap_finished
Signature · 1 line
2.30.2
Shuah Khan
maintainerQuoted 13 lines · Laura Nao
Add new basic kselftest that checks if the available rust sample modules can be added and removed correctly.
Signed-off-by Laura Nao <[email protected]>Reviewed-by Sergio Gonzalez Collado <[email protected]>Reviewed-by Muhammad Usama Anjum <[email protected]>---
Changes in v3:
- Removed uselessKSFT_PASS,KSFT_FAIL,KSFT_SKIPconstants
- Usedktap_finishedto print the results summary and handle the return code Changes in v2:
- Added missing SPDX line
- Editedtest_probe_samples.shscript to use the common KTAP helpers file
Quoted 9 lines
--- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rust/Makefile | 4 +++ .../selftests/rust/test_probe_samples.sh | 34 +++++++++++++++++++ 4 files changed, 40 insertions(+)create mode 100644
tools/testing/selftests/rust/Makefilecreate mode 100755tools/testing/selftests/rust/test_probe_samples.sh
Looks good to me. Don't you need a config file for this test? Refer to config files for existing tests as a reference.
thanks,
-- Shuah
Shuah Khan
maintainerQuoted 24 lines · Shuah Khan
Quoted 18 lines · Laura Nao
Add new basic kselftest that checks if the available rust sample modules can be added and removed correctly.
Signed-off-by Laura Nao <[email protected]>Reviewed-by Sergio Gonzalez Collado <[email protected]>Reviewed-by Muhammad Usama Anjum <[email protected]>---
Changes in v3:
- Removed uselessKSFT_PASS,KSFT_FAIL,KSFT_SKIPconstants
- Usedktap_finishedto print the results summary and handle the return code Changes in v2:
- Added missing SPDX line
- Editedtest_probe_samples.shscript to use the common KTAP helpers file
---
MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rust/Makefile | 4 +++ .../selftests/rust/test_probe_samples.sh | 34 +++++++++++++++++++Quoted 4 lines
4 files changed, 40 insertions(+)create mode 100644
tools/testing/selftests/rust/Makefilecreate mode 100755tools/testing/selftests/rust/test_probe_samples.sh
Quoted 3 lines
Looks good to me. Don't you need a config file for this test? Refer to config files for existing tests as a reference.
make kselftest TARGETS=rust
or
make run_tests
On Linux 6.8-rc5 give the following? Doesn't look right.
TAP version 13
1..1
# timeout set to 45 # selftests: rust: test_probe_samples.sh # ./test_probe_samples.sh: line 12: /linux/linux_6.8/tools/testing/selftests/rust/../kselftest/ktap_helpers.sh: No such file or directory # ./test_probe_samples.sh: line 16: ktap_print_header: command not found # ./test_probe_samples.sh: line 18: ktap_set_plan: command not found # ./test_probe_samples.sh: line 22: ktap_test_skip: command not found # ./test_probe_samples.sh: line 22: ktap_test_skip: command not found # ./test_probe_samples.sh: line 34: ktap_finished: command not found not ok 1 selftests: rust: test_probe_samples.sh # exit=127
thanks,
-- Shuah
Hi Shuah,
Quoted 27 lines · Shuah Khan
Quoted 26 lines · Shuah Khan
Quoted 24 lines · Laura Nao
Add new basic kselftest that checks if the available rust sample modules can be added and removed correctly.
Signed-off-by Laura Nao <[email protected]>Reviewed-by Sergio Gonzalez Collado <[email protected]>Reviewed-by Muhammad Usama Anjum <[email protected]>---
Changes in v3:
- Removed uselessKSFT_PASS,KSFT_FAIL,KSFT_SKIPconstants
- Usedktap_finishedto print the results summary and handle the return code
Changes in v2:
- Added missing SPDX line
- Editedtest_probe_samples.shscript to use the common KTAP helpers file--- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rust/Makefile | 4 +++ .../selftests/rust/test_probe_samples.sh | 34 +++++++++++++++++++ 4 files changed, 40 insertions(+)create mode 100644
tools/testing/selftests/rust/Makefilecreate mode 100755tools/testing/selftests/rust/test_probe_samples.sh
Quoted 3 lines
Quoted 3 lines
Looks good to me. Don't you need a config file for this test? Refer to config files for existing tests as a reference.
Right, in order for the tests to not be skipped support for rust and its sample modules need to be enabled.
I added the config file in v4: https://lore.kernel.org/linux-kselftest/[email protected]/T/#u
Quoted 8 lines
make kselftest TARGETS=rust
or
makerun_testsOn Linux 6.8-rc5 give the following? Doesn't look right.
TAP version 13
1..1
Quoted 11 lines
# timeout set to 45 # selftests: rust: test_probe_samples.sh # ./test_probe_samples.sh: line 12: /linux/linux_6.8/tools/testing/selftests/rust/../kselftest/ktap_helpers.sh: No such file or directory # ./test_probe_samples.sh: line 16: ktap_print_header: command not found # ./test_probe_samples.sh: line 18: ktap_set_plan: command not found # ./test_probe_samples.sh: line 22: ktap_test_skip: command not found # ./test_probe_samples.sh: line 22: ktap_test_skip: command not found # ./test_probe_samples.sh: line 34: ktap_finished: command not found not ok 1 selftests: rust: test_probe_samples.sh # exit=127
This patch requires
https://lore.kernel.org/all/[email protected]/T/#u
and
https://lore.kernel.org/all/[email protected]/
, which are both scheduled for 6.9-rc1. Sorry I didn't mention it above!
Thanks,
Laura