Skip to contentSkip to conversation

selftests: netfilter: Avoid hanging ipvs.sh

PATCH Applied Phil Sutter 2 participants 2 messages Sep 19, 2024

Subsystems (3)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH v2 1/1 selftests: netfilter: Avoid hanging ipvs.sh

If the client can't reach the server, the latter remains listening forever. Kill it after 5s of waiting.

Fixes 867d2190799ab ("selftests: netfilter: add ipvs test script")

---
Changes since v1:
- Don't rely upon availability of 'waitpid' but use 'timeout' instead.

---
 tools/testing/selftests/net/netfilter/ipvs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/netfilter/ipvs.sh +1 -1
index 4ceee9fb3949..d3edb16cd4b3 100755
@@ -97,7 +97,7 @@ cleanup() {
 }
 
 server_listen() {
-	ip netns exec "$ns2" socat -u -4 TCP-LISTEN:8080,reuseaddr STDOUT > "${outfile}" &
+	ip netns exec "$ns2" timeout 5 socat -u -4 TCP-LISTEN:8080,reuseaddr STDOUT > "${outfile}" &
 	server_pid=$!
 	sleep 0.2
 }
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 2 lines · Phil Sutter

If the client can't reach the server, the latter remains listening forever. Kill it after 5s of waiting.

This looks more similar to what I have seen.

I have to admit I am still learning the common idioms that are used in selftest.

Applied, thanks.