* [PATCH] selftests/rdma: explicitly skip tests when required modules are missing
@ 2026-05-07 12:51 Yi Lai
2026-05-08 4:21 ` Zhu Yanjun
0 siblings, 1 reply; 3+ messages in thread
From: Yi Lai @ 2026-05-07 12:51 UTC (permalink / raw)
To: Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky, Shuah Khan,
linux-rdma, linux-kselftest, linux-kernel, yi1.lai, yi1.lai
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.
Signed-off-by: Yi Lai <yi1.lai@intel.com>
---
tools/testing/selftests/rdma/rxe_ipv6.sh | 6 ++++--
tools/testing/selftests/rdma/rxe_rping_between_netns.sh | 7 +++++++
tools/testing/selftests/rdma/rxe_socket_with_netns.sh | 6 ++++++
tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh | 6 ++++--
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/rdma/rxe_ipv6.sh b/tools/testing/selftests/rdma/rxe_ipv6.sh
index b7059bfd6d7c..32dad687a044 100755
--- a/tools/testing/selftests/rdma/rxe_ipv6.sh
+++ b/tools/testing/selftests/rdma/rxe_ipv6.sh
@@ -8,6 +8,8 @@ RXE_NAME="rxe6"
PORT=4791
IP6_ADDR="2001:db8::1/64"
+source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
+
exec > /dev/null
# Cleanup function to run on exit (even on failure)
@@ -21,8 +23,8 @@ trap cleanup EXIT
# 1. Prerequisites check
for mod in tun veth rdma_rxe; do
if ! modinfo "$mod" >/dev/null 2>&1; then
- echo "Error: Kernel module '$mod' not found."
- exit 1
+ echo "SKIP: Kernel module '$mod' not found." >&2
+ exit $KSFT_SKIP
fi
done
diff --git a/tools/testing/selftests/rdma/rxe_rping_between_netns.sh b/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
index e5b876f58c6e..e7554fbb8951 100755
--- a/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
+++ b/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
@@ -8,6 +8,8 @@ IP_A="1.1.1.1"
IP_B="1.1.1.2"
PORT=4791
+source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
+
exec > /dev/null
# --- Cleanup Routine ---
@@ -27,6 +29,11 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
+if ! modinfo rdma_rxe >/dev/null 2>&1; then
+ echo "SKIP: Kernel module 'rdma_rxe' not found." >&2
+ exit $KSFT_SKIP
+fi
+
modprobe rdma_rxe || { echo "Failed to load rdma_rxe"; exit 1; }
# --- Setup Network Topology ---
diff --git a/tools/testing/selftests/rdma/rxe_socket_with_netns.sh b/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
index 002e5098f751..9478657c02c1 100755
--- a/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
+++ b/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
@@ -4,6 +4,8 @@
PORT=4791
MODS=("tun" "rdma_rxe")
+source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
+
exec > /dev/null
# --- Helper: Cleanup Routine ---
@@ -26,6 +28,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
diff --git a/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh b/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
index 021ca451499d..8c18cea7535c 100755
--- a/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
+++ b/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
@@ -5,6 +5,8 @@ DEV_NAME="tun0"
RXE_NAME="rxe0"
RDMA_PORT=4791
+source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
+
exec > /dev/null
# --- Cleanup Routine ---
@@ -19,8 +21,8 @@ trap cleanup EXIT
# 1. Dependency Check
if ! modinfo rdma_rxe >/dev/null 2>&1; then
- echo "Error: rdma_rxe module not found."
- exit 1
+ echo "SKIP: rdma_rxe module not found." >&2
+ exit $KSFT_SKIP
fi
modprobe rdma_rxe
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/rdma: explicitly skip tests when required modules are missing
2026-05-07 12:51 [PATCH] selftests/rdma: explicitly skip tests when required modules are missing Yi Lai
@ 2026-05-08 4:21 ` Zhu Yanjun
2026-05-08 11:24 ` Lai, Yi
0 siblings, 1 reply; 3+ messages in thread
From: Zhu Yanjun @ 2026-05-08 4:21 UTC (permalink / raw)
To: Yi Lai, Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky, Shuah Khan,
linux-rdma, linux-kselftest, linux-kernel, yi1.lai,
yanjun.zhu@linux.dev
在 2026/5/7 5:51, Yi Lai 写道:
> 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.
tools/testing/selftests/rdma/rxe_rping_between_netns.sh:30:modprobe
rdma_rxe || { echo "Failed to load rdma_rxe"; exit 1; }
tools/testing/selftests/rdma/rxe_socket_with_netns.sh:29: modprobe "$m"
|| { echo "Error: Failed to load $m"; exit 1; }
In the above script files, if modprobe fails, exit 1;
I am wondering if we need to replace error code 1 with $KSFT_SKIP.
Except the above, I am fine with this commit.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
>
> Signed-off-by: Yi Lai <yi1.lai@intel.com>
> ---
> tools/testing/selftests/rdma/rxe_ipv6.sh | 6 ++++--
> tools/testing/selftests/rdma/rxe_rping_between_netns.sh | 7 +++++++
> tools/testing/selftests/rdma/rxe_socket_with_netns.sh | 6 ++++++
> tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh | 6 ++++--
> 4 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/rdma/rxe_ipv6.sh b/tools/testing/selftests/rdma/rxe_ipv6.sh
> index b7059bfd6d7c..32dad687a044 100755
> --- a/tools/testing/selftests/rdma/rxe_ipv6.sh
> +++ b/tools/testing/selftests/rdma/rxe_ipv6.sh
> @@ -8,6 +8,8 @@ RXE_NAME="rxe6"
> PORT=4791
> IP6_ADDR="2001:db8::1/64"
>
> +source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
> +
> exec > /dev/null
>
> # Cleanup function to run on exit (even on failure)
> @@ -21,8 +23,8 @@ trap cleanup EXIT
> # 1. Prerequisites check
> for mod in tun veth rdma_rxe; do
> if ! modinfo "$mod" >/dev/null 2>&1; then
> - echo "Error: Kernel module '$mod' not found."
> - exit 1
> + echo "SKIP: Kernel module '$mod' not found." >&2
> + exit $KSFT_SKIP
> fi
> done
>
> diff --git a/tools/testing/selftests/rdma/rxe_rping_between_netns.sh b/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
> index e5b876f58c6e..e7554fbb8951 100755
> --- a/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
> +++ b/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
> @@ -8,6 +8,8 @@ IP_A="1.1.1.1"
> IP_B="1.1.1.2"
> PORT=4791
>
> +source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
> +
> exec > /dev/null
>
> # --- Cleanup Routine ---
> @@ -27,6 +29,11 @@ if [[ $EUID -ne 0 ]]; then
> exit 1
> fi
>
> +if ! modinfo rdma_rxe >/dev/null 2>&1; then
> + echo "SKIP: Kernel module 'rdma_rxe' not found." >&2
> + exit $KSFT_SKIP
> +fi
> +
> modprobe rdma_rxe || { echo "Failed to load rdma_rxe"; exit 1; }
>
> # --- Setup Network Topology ---
> diff --git a/tools/testing/selftests/rdma/rxe_socket_with_netns.sh b/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
> index 002e5098f751..9478657c02c1 100755
> --- a/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
> +++ b/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
> @@ -4,6 +4,8 @@
> PORT=4791
> MODS=("tun" "rdma_rxe")
>
> +source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
> +
> exec > /dev/null
>
> # --- Helper: Cleanup Routine ---
> @@ -26,6 +28,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
>
> diff --git a/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh b/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
> index 021ca451499d..8c18cea7535c 100755
> --- a/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
> +++ b/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
> @@ -5,6 +5,8 @@ DEV_NAME="tun0"
> RXE_NAME="rxe0"
> RDMA_PORT=4791
>
> +source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
> +
> exec > /dev/null
>
> # --- Cleanup Routine ---
> @@ -19,8 +21,8 @@ trap cleanup EXIT
>
> # 1. Dependency Check
> if ! modinfo rdma_rxe >/dev/null 2>&1; then
> - echo "Error: rdma_rxe module not found."
> - exit 1
> + echo "SKIP: rdma_rxe module not found." >&2
> + exit $KSFT_SKIP
> fi
>
> modprobe rdma_rxe
--
Best Regards,
Yanjun.Zhu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/rdma: explicitly skip tests when required modules are missing
2026-05-08 4:21 ` Zhu Yanjun
@ 2026-05-08 11:24 ` Lai, Yi
0 siblings, 0 replies; 3+ messages in thread
From: Lai, Yi @ 2026-05-08 11:24 UTC (permalink / raw)
To: Zhu Yanjun
Cc: Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky, Shuah Khan,
linux-rdma, linux-kselftest, linux-kernel, yi1.lai
On Thu, May 07, 2026 at 09:21:09PM -0700, Zhu Yanjun wrote:
>
> 在 2026/5/7 5:51, Yi Lai 写道:
> > 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.
> tools/testing/selftests/rdma/rxe_rping_between_netns.sh:30:modprobe rdma_rxe
> || { echo "Failed to load rdma_rxe"; exit 1; }
> tools/testing/selftests/rdma/rxe_socket_with_netns.sh:29: modprobe "$m" || {
> echo "Error: Failed to load $m"; exit 1; }
>
> In the above script files, if modprobe fails, exit 1;
>
> I am wondering if we need to replace error code 1 with $KSFT_SKIP.
>
Thanks for the review.
At this point, the module's existence is already verified using modinfo.
In my opinion, a failure at modprobe here implies an active operational
error, so returning 1 to highlight the malfunction seems reasonable.
Regards,
Yi Lai
> Except the above, I am fine with this commit.
>
> Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
>
> Zhu Yanjun
>
> >
> > Signed-off-by: Yi Lai <yi1.lai@intel.com>
> > ---
> > tools/testing/selftests/rdma/rxe_ipv6.sh | 6 ++++--
> > tools/testing/selftests/rdma/rxe_rping_between_netns.sh | 7 +++++++
> > tools/testing/selftests/rdma/rxe_socket_with_netns.sh | 6 ++++++
> > tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh | 6 ++++--
> > 4 files changed, 21 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/testing/selftests/rdma/rxe_ipv6.sh b/tools/testing/selftests/rdma/rxe_ipv6.sh
> > index b7059bfd6d7c..32dad687a044 100755
> > --- a/tools/testing/selftests/rdma/rxe_ipv6.sh
> > +++ b/tools/testing/selftests/rdma/rxe_ipv6.sh
> > @@ -8,6 +8,8 @@ RXE_NAME="rxe6"
> > PORT=4791
> > IP6_ADDR="2001:db8::1/64"
> > +source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
> > +
> > exec > /dev/null
> > # Cleanup function to run on exit (even on failure)
> > @@ -21,8 +23,8 @@ trap cleanup EXIT
> > # 1. Prerequisites check
> > for mod in tun veth rdma_rxe; do
> > if ! modinfo "$mod" >/dev/null 2>&1; then
> > - echo "Error: Kernel module '$mod' not found."
> > - exit 1
> > + echo "SKIP: Kernel module '$mod' not found." >&2
> > + exit $KSFT_SKIP
> > fi
> > done
> > diff --git a/tools/testing/selftests/rdma/rxe_rping_between_netns.sh b/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
> > index e5b876f58c6e..e7554fbb8951 100755
> > --- a/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
> > +++ b/tools/testing/selftests/rdma/rxe_rping_between_netns.sh
> > @@ -8,6 +8,8 @@ IP_A="1.1.1.1"
> > IP_B="1.1.1.2"
> > PORT=4791
> > +source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
> > +
> > exec > /dev/null
> > # --- Cleanup Routine ---
> > @@ -27,6 +29,11 @@ if [[ $EUID -ne 0 ]]; then
> > exit 1
> > fi
> > +if ! modinfo rdma_rxe >/dev/null 2>&1; then
> > + echo "SKIP: Kernel module 'rdma_rxe' not found." >&2
> > + exit $KSFT_SKIP
> > +fi
> > +
> > modprobe rdma_rxe || { echo "Failed to load rdma_rxe"; exit 1; }
> > # --- Setup Network Topology ---
> > diff --git a/tools/testing/selftests/rdma/rxe_socket_with_netns.sh b/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
> > index 002e5098f751..9478657c02c1 100755
> > --- a/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
> > +++ b/tools/testing/selftests/rdma/rxe_socket_with_netns.sh
> > @@ -4,6 +4,8 @@
> > PORT=4791
> > MODS=("tun" "rdma_rxe")
> > +source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
> > +
> > exec > /dev/null
> > # --- Helper: Cleanup Routine ---
> > @@ -26,6 +28,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
> > diff --git a/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh b/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
> > index 021ca451499d..8c18cea7535c 100755
> > --- a/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
> > +++ b/tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
> > @@ -5,6 +5,8 @@ DEV_NAME="tun0"
> > RXE_NAME="rxe0"
> > RDMA_PORT=4791
> > +source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
> > +
> > exec > /dev/null
> > # --- Cleanup Routine ---
> > @@ -19,8 +21,8 @@ trap cleanup EXIT
> > # 1. Dependency Check
> > if ! modinfo rdma_rxe >/dev/null 2>&1; then
> > - echo "Error: rdma_rxe module not found."
> > - exit 1
> > + echo "SKIP: rdma_rxe module not found." >&2
> > + exit $KSFT_SKIP
> > fi
> > modprobe rdma_rxe
>
> --
> Best Regards,
> Yanjun.Zhu
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-08 11:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 12:51 [PATCH] selftests/rdma: explicitly skip tests when required modules are missing Yi Lai
2026-05-08 4:21 ` Zhu Yanjun
2026-05-08 11:24 ` Lai, Yi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox