[PATCH] selftests/net: gro: use variable sleep to handle slow environments

Brian Grech <[email protected]> Fri, 31 Jul 2026 11:25:50 -0500
Newsgroups org.kernel.vger.linux-kselftest,org.kernel.vger.stable
Message-ID <[email protected]>
The server socket initialization sleep was hardcoded at 0.5 seconds.
On slow or heavily loaded machines this is insufficient, causing the
client to connect before the server is ready and producing spurious
test failures.

Respect KSFT_MACHINE_SLOW by extending the sleep to 2 seconds when
set, consistent with how other selftests handle slow environments.

Note: tools/testing/selftests/net/gro.sh was replaced by gro.py in
mainline after v6.12. This fix applies to stable trees that still
carry the original gro.sh implementation.

Fixes: 7d1575014a63 ("selftests/net: GRO coalesce test")
Cc: [email protected]  # 6.12

Signed-off-by: Brian Grech <[email protected]>
---
 tools/testing/selftests/net/gro.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/gro.sh b/tools/testing/selftests/net/gro.sh
index aabd6e5480b8..c4ed09e5f002 100755
--- a/tools/testing/selftests/net/gro.sh
+++ b/tools/testing/selftests/net/gro.sh
@@ -21,12 +21,14 @@ run_test() {
   # Each test is run 3 times to deflake, because given the receive timing,
   # not all packets that should coalesce will be considered in the same flow
   # on every try.
+  local sleep_time=0.5
+  [ "$KSFT_MACHINE_SLOW" = yes ] && sleep_time=2
   for tries in {1..3}; do
     # Actual test starts here
     ip netns exec $server_ns ./gro "${ARGS[@]}" "--rx" "--iface" "server" \
       1>>log.txt &
     server_pid=$!
-    sleep 0.5  # to allow for socket init
+    sleep $sleep_time   # to allow for socket init
     ip netns exec $client_ns ./gro "${ARGS[@]}" "--iface" "client" \
       1>>log.txt
     wait "${server_pid}"
-- 
2.55.0