Skip to content

Commit 4c639b6

Browse files
committed
selftests: net: move amt to socat for better compatibility
The test seems to expect that nc will exit after the first received message. This is not the case with Ncat 7.94. There are multiple versions of nc out there, switch to socat for better compatibility. Tell socat to exit after 128 bytes and pad the message. Since the test sets -e make sure we don't set exit code (|| true) and print the pass / fail rather then silently moving over the test and just setting non-zero exit code with no output indicating what failed. Fixes: c08e8ba ("selftests: add amt interface selftest script") Acked-by: Paolo Abeni<[email protected]> Tested-by: Taehee Yoo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c499fe9 commit 4c639b6

File tree

1 file changed

+6
-6
lines changed
  • tools/testing/selftests/net

1 file changed

+6
-6
lines changed

tools/testing/selftests/net/amt.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ check_features()
210210

211211
test_ipv4_forward()
212212
{
213-
RESULT4=$(ip netns exec "${LISTENER}" nc -w 1 -l -u 239.0.0.1 4000)
214-
if [ "$RESULT4" == "172.17.0.2" ]; then
213+
RESULT4=$(ip netns exec "${LISTENER}" timeout 15 socat - UDP4-LISTEN:4000,readbytes=128 || true)
214+
if echo "$RESULT4" | grep -q "172.17.0.2"; then
215215
printf "TEST: %-60s [ OK ]\n" "IPv4 amt multicast forwarding"
216216
exit 0
217217
else
@@ -222,8 +222,8 @@ test_ipv4_forward()
222222

223223
test_ipv6_forward()
224224
{
225-
RESULT6=$(ip netns exec "${LISTENER}" nc -w 1 -l -u ff0e::5:6 6000)
226-
if [ "$RESULT6" == "2001:db8:3::2" ]; then
225+
RESULT6=$(ip netns exec "${LISTENER}" timeout 15 socat - UDP6-LISTEN:6000,readbytes=128 || true)
226+
if echo "$RESULT6" | grep -q "2001:db8:3::2"; then
227227
printf "TEST: %-60s [ OK ]\n" "IPv6 amt multicast forwarding"
228228
exit 0
229229
else
@@ -236,14 +236,14 @@ send_mcast4()
236236
{
237237
sleep 2
238238
ip netns exec "${SOURCE}" bash -c \
239-
'echo 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' &
239+
'printf "%s %128s" 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' &
240240
}
241241

242242
send_mcast6()
243243
{
244244
sleep 2
245245
ip netns exec "${SOURCE}" bash -c \
246-
'echo 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' &
246+
'printf "%s %128s" 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' &
247247
}
248248

249249
check_features

0 commit comments

Comments
 (0)