diff mbox series

[v2] tcp_cmds/ping/ping02: Make it compatible with Busybox

Message ID 20201106143605.27230-1-kory.maincent@bootlin.com
State Changes Requested
Headers show
Series [v2] tcp_cmds/ping/ping02: Make it compatible with Busybox | expand

Commit Message

Kory Maincent Nov. 6, 2020, 2:36 p.m. UTC
The ping from busybox does not have -f parameter, use -i parameter instead.
BusyBox does not accept pattern longer than 2 bytes.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
 testcases/network/tcp_cmds/ping/ping02.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alexey Kodanev Nov. 9, 2020, 11:09 a.m. UTC | #1
On 06.11.2020 17:36, Kory Maincent wrote:
> The ping from busybox does not have -f parameter, use -i parameter instead.
> BusyBox does not accept pattern longer than 2 bytes.
> 
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
>  testcases/network/tcp_cmds/ping/ping02.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/network/tcp_cmds/ping/ping02.sh b/testcases/network/tcp_cmds/ping/ping02.sh
> index e0a63c5f6..2784c8160 100755
> --- a/testcases/network/tcp_cmds/ping/ping02.sh
> +++ b/testcases/network/tcp_cmds/ping/ping02.sh
> @@ -20,7 +20,7 @@ do_setup()
>  
>  do_test()
>  {
> -	local pat="000102030405060708090a0b0c0d0e0f"
> +	local pat="aa"
>  

Hi Kory,

I think we should replace the options only if ping doesn't support
'-f', i.e. something like in the first version and this patch:

local ping_opts="-f -p 000102030405060708090a0b0c0d0e0f"
local ipaddr=$(tst_ipaddr rhost)
local s

$PING -h 2>&1 | grep -q '[-]f' || ping_opts="-i 0.01 -p aa"

for s in $PACKETSIZES; do
	EXPECT_PASS $PING -c $COUNT -s $s $ipaddr $ping_opts \>/dev/null
done


>  	tst_res TINFO "flood $PING: ICMP packets filled with pattern '$pat'"
>  
> @@ -28,7 +28,7 @@ do_test()
>  	local s
>  
>  	for s in $PACKETSIZES; do
> -		EXPECT_PASS $PING -c $COUNT -f -s $s $ipaddr -p "$pat" \>/dev/null
> +		EXPECT_PASS $PING -c $COUNT -i 0.001 -s $s $ipaddr -p "$pat" \>/dev/null
>  	done
>  }
>  
>
Kory Maincent Nov. 9, 2020, 6:27 p.m. UTC | #2
Hello Alexey,

Thank for your feedback.

On Mon, 9 Nov 2020 14:09:24 +0300
Alexey Kodanev <alexey.kodanev@oracle.com> wrote:

> On 06.11.2020 17:36, Kory Maincent wrote:
> > The ping from busybox does not have -f parameter, use -i parameter instead.
> > BusyBox does not accept pattern longer than 2 bytes.
> > 
> > Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> > ---
> >  testcases/network/tcp_cmds/ping/ping02.sh | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/testcases/network/tcp_cmds/ping/ping02.sh
> > b/testcases/network/tcp_cmds/ping/ping02.sh index e0a63c5f6..2784c8160
> > 100755 --- a/testcases/network/tcp_cmds/ping/ping02.sh
> > +++ b/testcases/network/tcp_cmds/ping/ping02.sh
> > @@ -20,7 +20,7 @@ do_setup()
> >  
> >  do_test()
> >  {
> > -	local pat="000102030405060708090a0b0c0d0e0f"
> > +	local pat="aa"
> >    
> 
> Hi Kory,
> 
> I think we should replace the options only if ping doesn't support
> '-f', i.e. something like in the first version and this patch:
> 
> local ping_opts="-f -p 000102030405060708090a0b0c0d0e0f"
> local ipaddr=$(tst_ipaddr rhost)
> local s
> 
> $PING -h 2>&1 | grep -q '[-]f' || ping_opts="-i 0.01 -p aa"

The grep in parameter is not working for all cases.
For example the ping usage of my Ubuntu laptop is:
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
            [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
            [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
            [-w deadline] [-W timeout] [hop1 ...] destination


I may use test like this:
$PING -c 1 -f $ipaddr >/dev/null 2>&1 || ping_opts="-i 0.01 -p aa"

What do you think?

Regards,

> 
> for s in $PACKETSIZES; do
> 	EXPECT_PASS $PING -c $COUNT -s $s $ipaddr $ping_opts \>/dev/null
> done
> 
> 
> >  	tst_res TINFO "flood $PING: ICMP packets filled with pattern
> > '$pat'" 
> > @@ -28,7 +28,7 @@ do_test()
> >  	local s
> >  
> >  	for s in $PACKETSIZES; do
> > -		EXPECT_PASS $PING -c $COUNT -f -s $s $ipaddr -p "$pat"
> > \>/dev/null
> > +		EXPECT_PASS $PING -c $COUNT -i 0.001 -s $s $ipaddr -p
> > "$pat" \>/dev/null done
> >  }
> >  
> >   
>
Alexey Kodanev Nov. 9, 2020, 6:48 p.m. UTC | #3
On 09.11.2020 21:27, Köry Maincent wrote:
>>
>> $PING -h 2>&1 | grep -q '[-]f' || ping_opts="-i 0.01 -p aa"
> 
> The grep in parameter is not working for all cases.
> For example the ping usage of my Ubuntu laptop is:
> Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
>             [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
>             [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
>             [-w deadline] [-W timeout] [hop1 ...] destination
> 
> 
> I may use test like this:
> $PING -c 1 -f $ipaddr >/dev/null 2>&1 || ping_opts="-i 0.01 -p aa"
> 
> What do you think?
> 

Agree, in that case it's better to try ping with the option.
diff mbox series

Patch

diff --git a/testcases/network/tcp_cmds/ping/ping02.sh b/testcases/network/tcp_cmds/ping/ping02.sh
index e0a63c5f6..2784c8160 100755
--- a/testcases/network/tcp_cmds/ping/ping02.sh
+++ b/testcases/network/tcp_cmds/ping/ping02.sh
@@ -20,7 +20,7 @@  do_setup()
 
 do_test()
 {
-	local pat="000102030405060708090a0b0c0d0e0f"
+	local pat="aa"
 
 	tst_res TINFO "flood $PING: ICMP packets filled with pattern '$pat'"
 
@@ -28,7 +28,7 @@  do_test()
 	local s
 
 	for s in $PACKETSIZES; do
-		EXPECT_PASS $PING -c $COUNT -f -s $s $ipaddr -p "$pat" \>/dev/null
+		EXPECT_PASS $PING -c $COUNT -i 0.001 -s $s $ipaddr -p "$pat" \>/dev/null
 	done
 }