Add new basic kselftest that checks if the available rust sample modules
can be added and removed correctly.
Signed-off-by: Laura Nao <laura.nao@xxxxxxxxxxxxx>
Reviewed-by: Sergio Gonzalez Collado <sergio.collado@xxxxxxxxx>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>
---
Depends on:
- https://lore.kernel.org/all/20240102141528.169947-1-laura.nao@xxxxxxxxxxxxx/T/#u
- https://lore.kernel.org/all/20240131-ktap-sh-helpers-extend-v1-0-98ffb468712c@xxxxxxxxxxxxx/
Changes in v4:
- Added config file
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 +++
tools/testing/selftests/rust/config | 5 +++
.../selftests/rust/test_probe_samples.sh | 34 +++++++++++++++++++
5 files changed, 45 insertions(+)
create mode 100644 tools/testing/selftests/rust/Makefile
create mode 100644 tools/testing/selftests/rust/config
create mode 100755 tools/testing/selftests/rust/test_probe_samples.sh
diff --git a/MAINTAINERS b/MAINTAINERS
+
+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