On a kernel built without CONFIG_RDMA_RXE the test exits 1 instead of
skipping:

  # modprobe: FATAL: Module rdma_rxe not found in directory ...
  not ok 467 selftests: rdma: rxe_sent_rcvd_bytes.sh # exit=1

Every other test in this directory probes with modinfo and exits
$KSFT_SKIP. Apply the same guard, identical to the one in the otherwise
near-identical rxe_socket_with_netns.sh.

Fixes: c67bd973695c3 ("selftest/rxe: Add selftests for perf")
Assisted-by: kiro:claude-opus-5
Cc: [email protected]
Signed-off-by: Bjoern Doebel <[email protected]>
---
 tools/testing/selftests/rdma/rxe_sent_rcvd_bytes.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/rdma/rxe_sent_rcvd_bytes.sh 
b/tools/testing/selftests/rdma/rxe_sent_rcvd_bytes.sh
index 0e4fbfeebd228..89218ccfba4c1 100755
--- a/tools/testing/selftests/rdma/rxe_sent_rcvd_bytes.sh
+++ b/tools/testing/selftests/rdma/rxe_sent_rcvd_bytes.sh
@@ -4,6 +4,8 @@
 PORT=4791
 MODS=("tun" "rdma_rxe")
 
+source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
+
 exec > /dev/null
 
 # --- Helper: Cleanup Routine ---
@@ -24,6 +26,10 @@ if [[ $EUID -ne 0 ]]; then
 fi
 
 for m in "${MODS[@]}"; do
+    if ! modinfo "$m" >/dev/null 2>&1; then
+        echo "SKIP: Kernel module '$m' not found." >&2
+        exit $KSFT_SKIP
+    fi
     modprobe "$m" || { echo "Error: Failed to load $m"; exit 1; }
 done
 
-- 
2.50.1


Reply via email to