tcp_cmds/ping/ping02: Make it compatible with Busybox
PATCH v4 1/1 tcp_cmds/ping/ping02: Make it compatible with Busybox
The ping from busybox does not have -f parameter, use -i parameter instead. BusyBox does not accept pattern longer than 2 bytes.
BusyBox support -i option since version 1.30
---
Changes since v1:
- Use "-i 0.01 -p aa" parameter instead of "-f"
Changes since v2:
- Use "-i 0.01 -p aa" only in the case of "-f" parameter is not valid
Changes since v3:
- Test if -i is a valid option.
- Move all in do_setup function
testcases/network/tcp_cmds/ping/ping02.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
testcases/network/tcp_cmds/ping/ping02.sh +13 -6
@@ -16,19 +16,26 @@ do_setup() PING=ping${TST_IPV6} tst_require_cmds $PING + + ping_opts="-f -p 000102030405060708090a0b0c0d0e0f" + ipaddr=$(tst_ipaddr rhost) + + if ! $PING -c 1 -f $ipaddr >/dev/null 2>&1; then + ping_opts="-i 0.01 -p aa" + if $PING -i 2>&1 | grep -q "invalid option"; then + tst_brk TCONF "unsupported ping version (old busybox?)" + fi + fi } do_test() { - local pat="000102030405060708090a0b0c0d0e0f" - - tst_res TINFO "flood $PING: ICMP packets filled with pattern '$pat'" - - local ipaddr=$(tst_ipaddr rhost) local s + tst_res TINFO "flood $PING: ICMP packets with options '$ping_opts'" + for s in $PACKETSIZES; do - EXPECT_PASS $PING -c $COUNT -f -s $s $ipaddr -p "$pat" \>/dev/null + EXPECT_PASS $PING -c $COUNT -s $s $ipaddr $ping_opts \>/dev/null done }
Signature · 1 line
2.17.1
PATCH v4 1/1 tcp_cmds/ping/ping02: Make it compatible with Busybox
Hi Kory, Alexey,
Quoted 3 lines
The ping from busybox does not have -f parameter, use -i parameter instead. BusyBox does not accept pattern longer than 2 bytes.
BusyBox support -i option since version 1.30
LGTM.
I suggest to merge with few changes below.
* more precise message "ping from old busybox?"
* use just $(tst_ipaddr rhost) instead of $ipaddr
(some time ago we've started to use function calls for these simple evaluations)
* upper case for global variable (ugly, but easily recognizable
Kind regards,
Petr
network/tcp_cmds/ping/ping02.sh +6 -7
@@ -17,13 +17,12 @@ do_setup() tst_require_cmds $PING - ping_opts="-f -p 000102030405060708090a0b0c0d0e0f" - ipaddr=$(tst_ipaddr rhost) + PING_OPTS="-f -p 000102030405060708090a0b0c0d0e0f" - if ! $PING -c 1 -f $ipaddr >/dev/null 2>&1; then - ping_opts="-i 0.01 -p aa" + if ! $PING -c 1 -f $(tst_ipaddr rhost) >/dev/null 2>&1; then + PING_OPTS="-i 0.01 -p aa" if $PING -i 2>&1 | grep -q "invalid option"; then - tst_brk TCONF "unsupported ping version (old busybox?)" + tst_brk TCONF "unsupported ping version (ping from old busybox?)" fi fi }
@@ -32,10 +31,10 @@ do_test() { local s - tst_res TINFO "flood $PING: ICMP packets with options '$ping_opts'" + tst_res TINFO "flood $PING: ICMP packets with options '$PING_OPTS'" for s in $PACKETSIZES; do - EXPECT_PASS $PING -c $COUNT -s $s $ipaddr $ping_opts \>/dev/null + EXPECT_PASS $PING -c $COUNT -s $s $(tst_ipaddr rhost) $PING_OPTS \>/dev/null done }
PATCH v4 1/1 tcp_cmds/ping/ping02: Make it compatible with Busybox
Quoted 9 lines · Petr Vorel
Hi Kory, Alexey,
Quoted 3 lines
The ping from busybox does not have -f parameter, use -i parameter instead. BusyBox does not accept pattern longer than 2 bytes.
BusyBox support -i option since version 1.30Reviewed-by Petr Vorel <[email protected]>Tested-by Petr Vorel <[email protected]>
Quoted 8 lines
LGTM.
I suggest to merge with few changes below.
* more precise message "ping from old busybox?"
* use just $(tst_ipaddr rhost) instead of $ipaddr
(some time ago we've started to use function calls for these simple evaluations)
* upper case for global variable (ugly, but easily recognizable
Hi Petr,
Feel free to add the style changes, ack. I've already applied the patch.
Thanks Kory!
PATCH v4 1/1 tcp_cmds/ping/ping02: Make it compatible with Busybox
Hi Kory, Alexey,
Quoted 16 lines
Quoted 7 lines
Quoted 3 lines
The ping from busybox does not have -f parameter, use -i parameter instead. BusyBox does not accept pattern longer than 2 bytes.
BusyBox support -i option since version 1.30Reviewed-by Petr Vorel <[email protected]>Tested-by Petr Vorel <[email protected]>Quoted 8 lines
LGTM.
I suggest to merge with few changes below.
* more precise message "ping from old busybox?"
* use just $(tst_ipaddr rhost) instead of $ipaddr
(some time ago we've started to use function calls for these simple evaluations)
* upper case for global variable (ugly, but easily recognizable
Quoted 5 lines
Hi Petr,
Feel free to add the style changes, ack. I've already applied the patch.
Thanks Kory!
Let's leave it as it is, not that important.
Thanks a lot both.
Kind regards,
Petr