Commit 5d94da7f authored by Laura Nao's avatar Laura Nao Committed by Shuah Khan
Browse files

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.

Signed-off-by: default avatarLaura Nao <laura.nao@collabora.com>
Reviewed-by: default avatarSergio Gonzalez Collado <sergio.collado@gmail.com>
Reviewed-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 539cd3f4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19095,6 +19095,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)
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ TARGETS += riscv
TARGETS += rlimits
TARGETS += rseq
TARGETS += rtc
TARGETS += rust
TARGETS += seccomp
TARGETS += sgx
TARGETS += sigaltstack
+4 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
TEST_PROGS += test_probe_samples.sh

include ../lib.mk
+5 −0
Original line number Diff line number Diff line
CONFIG_RUST=y
CONFIG_SAMPLES=y
CONFIG_SAMPLES_RUST=y
CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
 No newline at end of file
+41 −0
Original line number Diff line number Diff line
#!/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")")"

KTAP_HELPERS="${DIR}/../kselftest/ktap_helpers.sh"
if [ -e "$KTAP_HELPERS" ]; then
    source "$KTAP_HELPERS"
else
    echo "$KTAP_HELPERS file not found [SKIP]"
    exit 4
fi

rust_sample_modules=("rust_minimal" "rust_print")

ktap_print_header

for sample in "${rust_sample_modules[@]}"; do
    if ! /sbin/modprobe -n -q "$sample"; then
        ktap_skip_all "module $sample is not found in /lib/modules/$(uname -r)"
        exit "$KSFT_SKIP"
    fi
done

ktap_set_plan "${#rust_sample_modules[@]}"

for sample in "${rust_sample_modules[@]}"; do
    if /sbin/modprobe -q "$sample"; then
        /sbin/modprobe -q -r "$sample"
        ktap_test_pass "$sample"
    else
        ktap_test_fail "$sample"
    fi
done

ktap_finished