Skip to content

Commit 0bf1b4d

Browse files
laifryieerleon
authored andcommitted
selftests/rdma: explicitly skip tests when required modules are missing
Currently, the rdma rxe selftests fail with an exit code of 1 when required kernel modules are not present. This causes spurious failures in environments where these modules might not be compiled or available. Include the standard kselftest 'ktap_helpers.sh' and replace the hardcoded error exits with '$KSFT_SKIP'. This ensures the tests are properly marked as skipped rather than failed. Fixes: e01027c ("RDMA/rxe: Add testcase for net namespace rxe") Signed-off-by: Yi Lai <yi1.lai@intel.com> Link: https://patch.msgid.link/20260507125106.3114167-1-yi1.lai@intel.com Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 0b28000 commit 0bf1b4d

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

tools/testing/selftests/rdma/rxe_ipv6.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ RXE_NAME="rxe6"
88
PORT=4791
99
IP6_ADDR="2001:db8::1/64"
1010

11+
source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
12+
1113
exec > /dev/null
1214

1315
# Cleanup function to run on exit (even on failure)
@@ -21,8 +23,8 @@ trap cleanup EXIT
2123
# 1. Prerequisites check
2224
for mod in tun veth rdma_rxe; do
2325
if ! modinfo "$mod" >/dev/null 2>&1; then
24-
echo "Error: Kernel module '$mod' not found."
25-
exit 1
26+
echo "SKIP: Kernel module '$mod' not found." >&2
27+
exit $KSFT_SKIP
2628
fi
2729
done
2830

tools/testing/selftests/rdma/rxe_rping_between_netns.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ IP_A="1.1.1.1"
88
IP_B="1.1.1.2"
99
PORT=4791
1010

11+
source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
12+
1113
exec > /dev/null
1214

1315
# --- Cleanup Routine ---
@@ -27,6 +29,11 @@ if [[ $EUID -ne 0 ]]; then
2729
exit 1
2830
fi
2931

32+
if ! modinfo rdma_rxe >/dev/null 2>&1; then
33+
echo "SKIP: Kernel module 'rdma_rxe' not found." >&2
34+
exit $KSFT_SKIP
35+
fi
36+
3037
modprobe rdma_rxe || { echo "Failed to load rdma_rxe"; exit 1; }
3138

3239
# --- Setup Network Topology ---

tools/testing/selftests/rdma/rxe_socket_with_netns.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
PORT=4791
55
MODS=("tun" "rdma_rxe")
66

7+
source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
8+
79
exec > /dev/null
810

911
# --- Helper: Cleanup Routine ---
@@ -26,6 +28,10 @@ if [[ $EUID -ne 0 ]]; then
2628
fi
2729

2830
for m in "${MODS[@]}"; do
31+
if ! modinfo "$m" >/dev/null 2>&1; then
32+
echo "SKIP: Kernel module '$m' not found." >&2
33+
exit $KSFT_SKIP
34+
fi
2935
modprobe "$m" || { echo "Error: Failed to load $m"; exit 1; }
3036
done
3137

tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ DEV_NAME="tun0"
55
RXE_NAME="rxe0"
66
RDMA_PORT=4791
77

8+
source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
9+
810
exec > /dev/null
911

1012
# --- Cleanup Routine ---
@@ -19,8 +21,8 @@ trap cleanup EXIT
1921

2022
# 1. Dependency Check
2123
if ! modinfo rdma_rxe >/dev/null 2>&1; then
22-
echo "Error: rdma_rxe module not found."
23-
exit 1
24+
echo "SKIP: rdma_rxe module not found." >&2
25+
exit $KSFT_SKIP
2426
fi
2527

2628
modprobe rdma_rxe

0 commit comments

Comments
 (0)