ipneigh : Use new API
PATCH v2 1/1 ipneigh : Use new API
Besides all obvious changes for moving to new API, also was done :
1. more generic variable names
2. add check for del command failure
--- testcases/network/tcp_cmds/ipneigh/ipneigh01.sh | 65 ++++++++++++------------- 1 file changed, 32 insertions(+), 33 deletions(-)
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +32 -33
@@ -1,4 +1,5 @@ #!/bin/sh +# Copyright (c) 2018 SUSE Linux GmbH # Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved. # Copyright (c) International Business Machines Corp., 2000 # This program is free software; you can redistribute it and/or
@@ -18,8 +19,8 @@ TCID=ipneigh01 NUMLOOPS=${NUMLOOPS:-50} -TST_TOTAL=2 -TST_USE_LEGACY_API=1 +TST_TESTFUNC=do_test +TST_CNT=2 . tst_net.sh do_setup()
@@ -30,55 +31,53 @@ do_setup() do_test() { - local arp_show_cmd="$1" - local arp_del_cmd="$2" + local rhost=$(tst_ipaddr rhost) + case $1 in + 1) + local show_cmd="ip neigh show" + local del_cmd="ip neigh del $rhost dev $(tst_iface)" + ;; + 2) + if [ -n "$TST_IPV6" ] then + tst_res TCONF "'arp cmd doesn't support IPv6, skipping test-case" + return 1 + fi + local show_cmd="arp -a" + local del_cmd="arp -d $rhost" + ;; + esac local entry_name [ "$TST_IPV6" ] && entry_name="NDISC" || entry_name="ARP" - tst_resm TINFO "Stress auto-creation of $entry_name cache entry" - tst_resm TINFO "by pinging '$rhost' and deleting entry again" - tst_resm TINFO "with '$arp_del_cmd'" + tst_res TINFO "Stress auto-creation of $entry_name cache entry" + tst_res TINFO "by pinging '$rhost' and deleting entry again" + tst_res TINFO "with '$del_cmd'" for i in $(seq 1 $NUMLOOPS); do ping$TST_IPV6 -q -c1 $rhost > /dev/null local k - local ret=1 - # wait for arp entry at least 3 seconds for k in $(seq 1 30); do - $arp_show_cmd | grep -q $rhost - if [ $? -eq 0 ]; then - ret=0 - break; + $show_cmd | grep -q $rhost + if [ $? -ne 0 ]; then + tst_brk TFAIL "$entry_name entry '$rhost' not listed" fi tst_sleep 100ms done - [ "$ret" -ne 0 ] && \ - tst_brkm TFAIL "$entry_name entry '$rhost' not listed" + $del_cmd + if [ $? -ne 0 ]; then + tst_brk TFAIL "fail to delete entry" + fi - $arp_del_cmd - - $arp_show_cmd | grep -q "${rhost}.*$(tst_hwaddr rhost)" && \ - tst_brkm TFAIL "'$arp_del_cmd' failed, entry has " \ + $show_cmd | grep -q "${rhost}.*$(tst_hwaddr rhost)" && \ + tst_brk TFAIL "'$del_cmd' failed, entry has " \ "$(tst_hwaddr rhost)' $i/$NUMLOOPS" done - tst_resm TPASS "verified adding/removing of $entry_name cache entry" + tst_res TPASS "verified adding/removing of $entry_name cache entry" } -do_setup - -rhost=$(tst_ipaddr rhost) - -if [ -z "$TST_IPV6" ]; then - do_test "arp -a" "arp -d $rhost" -else - tst_resm TCONF "'arp cmd doesn't support IPv6, skipping test-case" -fi - -do_test "ip neigh show" "ip neigh del $rhost dev $(tst_iface)" - -tst_exit +tst_run
Signature · 1 line
2.13.6
PATCH v2 1/1 ipneigh : Use new API
Hi Anton,
Quoted 7 lines
Besides all obvious changes for moving to new API, also was done :
1. more generic variable names
2. add check for del command failure--- testcases/network/tcp_cmds/ipneigh/ipneigh01.sh | 65 ++++++++++++------------- 1 file changed, 32 insertions(+), 33 deletions(-)
I'm sorry to NACK your patch, there needs to be some changes to done.
Some change I'd like to have is to pass this script command (-c [ arp | ip ]) and run test only once, i.e. TST_CNT=1 (then it does not need to be included).
Then in runtest files it'd be:
runtest/net.ipv6 +0 -0
-ipneigh601 ipneigh01.sh -6
+ipneigh6_ip ipneigh01.sh -6 -c ip
runtest/net.tcp_cmds +0 -0
-ipneigh01 ipneigh01.sh
+ipneigh01_arp ipneigh01.sh -c arp
+ipneigh01_ip ipneigh01.sh -c ip
By this test is 1) cleaner 2) we get rid of TCONF for IPv6.
Quoted 1 line
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +0
-0
...
Quoted 1 line
TCID=ipneigh01
In new API you don't use TCID.
Quoted 1 line
NUMLOOPS=${NUMLOOPS:-50}
It'd be better to use some variable from tst_net.sh, but not sure which one (NS_TIMES? Or create new one for TCP tests?), so feel free to ignore it.
Quoted 11 lines
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +2
-2-TST_TOTAL=2 -TST_USE_LEGACY_API=1 +TST_TESTFUNC=do_test +TST_CNT=2 . tst_net.sh do_setup()@@ -30,55 +31,53 @@ do_setup() do_test() {
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh do_setup() · line 41
Quoted 10 lines
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +8
-2- local arp_show_cmd="$1" - local arp_del_cmd="$2" + local rhost=$(tst_ipaddr rhost) + case $1 in + 1) + local show_cmd="ip neigh show" + local del_cmd="ip neigh del $rhost dev $(tst_iface)" + ;; + 2) + if [ -n "$TST_IPV6" ] then
^ Missing semicolon
if [ -n "$TST_IPV6" ]; then
Test don't run without that. I'd fix that before commit, but there are other issues.
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh do_setup() · line 42
Quoted 1 line
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +1
-0+ tst_res TCONF "'arp cmd doesn't support IPv6, skipping test-case"
You still do TCONF.
Quoted 6 lines
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +6
-0+ return 1 + fi + local show_cmd="arp -a" + local del_cmd="arp -d $rhost" + ;; + esac
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh do_setup() · line 55
Quoted 10 lines
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +3
-3local entry_name [ "$TST_IPV6" ] && entry_name="NDISC" || entry_name="ARP" - tst_resm TINFO "Stress auto-creation of $entry_name cache entry" - tst_resm TINFO "by pinging '$rhost' and deleting entry again" - tst_resm TINFO "with '$arp_del_cmd'" + tst_res TINFO "Stress auto-creation of $entry_name cache entry" + tst_res TINFO "by pinging '$rhost' and deleting entry again" + tst_res TINFO "with '$del_cmd'"
Maybe you could specify number of times: $NUMLOOPS.
tst_res TINFO "with '$del_cmd' $NUMLOOPS times"
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh do_setup() · line 58
Quoted 3 lines
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +0
-0for i in $(seq 1 $NUMLOOPS); do ping$TST_IPV6 -q -c1 $rhost > /dev/null
It looks to me better using tst_ping() from tst_net.sh (API function, other tests use it). Then we could get rid of checking in do_setup:tst_check_cmds arp grep ping$TST_IPV6
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh do_setup() · line 64
Quoted 12 lines
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +3
-6local k - local ret=1 - # wait for arp entry at least 3 seconds for k in $(seq 1 30); do - $arp_show_cmd | grep -q $rhost - if [ $? -eq 0 ]; then - ret=0 - break; + $show_cmd | grep -q $rhost + if [ $? -ne 0 ]; then + tst_brk TFAIL "$entry_name entry '$rhost' not listed" fi
You test to run much longer by removing break. By running it 30times until it fails. IMHO that's not needed, the "stress" of the test is done by upper loop.
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh do_setup() · line 66
Quoted 2 lines
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +0
-0tst_sleep 100ms done
...
Kind regards,
Petr
PATCH v2 1/1 ipneigh : Use new API
Hi Petr,
Thanks for review !
Quoted 14 lines
I'm sorry to NACK your patch, there needs to be some changes to done.
Some change I'd like to have is to pass this script command (-c [ arp | ip ]) and run test only once, i.e. TST_CNT=1 (then it does not need to be included).
Then in runtest files it'd be:runtest/net.ipv6 +1
-1-ipneigh601 ipneigh01.sh -6 +ipneigh6_ip ipneigh01.sh -6 -c ipruntest/net.tcp_cmds +2
-1-ipneigh01 ipneigh01.sh +ipneigh01_arp ipneigh01.sh -c arp +ipneigh01_ip ipneigh01.sh -c ip
Quoted 1 line
By this test is 1) cleaner 2) we get rid of TCONF for IPv6.
ok , make sense .
Quoted 2 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ tst_res TCONF "'arp cmd doesn't support IPv6, skipping test-case"You still do TCONF.
Yes and it make perfect sense now because I am doing exit just after this message , so it is ok
Quoted 5 lines
Quoted 2 lines
ping$TST_IPV6 -q -c1 $rhost >
/dev/nullIt looks to me better using
tst_ping()fromtst_net.sh(API function, other tests use it). Then we could get rid of checking indo_setup:tst_check_cmdsarp grep ping$TST_IPV6
ok , was not aware about that , will change this
Signature · 10 lines
Anton Smorodskyi <[email protected]> QA Engineer SUSE Linux GmbH, Maxfeldstr. 5, D-90409 Nürnberg Tel: +49-911-74053-0; Fax: +49-911-7417755; https://www.suse.com/ SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20180516/db2a3670/attachment.html>
PATCH v2 1/1 ipneigh : Use new API
Hi Anton,
...
Quoted 12 lines
Quoted 11 lines
Some change I'd like to have is to pass this script command (-c [ arp | ip ]) and run test only once, i.e. TST_CNT=1 (then it does not need to be included).
Then in runtest files it'd be:runtest/net.ipv6 +1
-1-ipneigh601 ipneigh01.sh -6 +ipneigh6_ip ipneigh01.sh -6 -c ipruntest/net.tcp_cmds +2
-1-ipneigh01 ipneigh01.sh +ipneigh01_arp ipneigh01.sh -c arp +ipneigh01_ip ipneigh01.sh -c ip
Quoted 5 lines
Quoted 1 line
By this test is 1) cleaner 2) we get rid of TCONF for IPv6.
ok , make sense .
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ tst_res TCONF "'arp cmd doesn't support IPv6, skipping test-case"
^ left quote, which was in previous version, please remove it.
Quoted 3 lines
Quoted 1 line
You still do TCONF.
Yes and it make perfect sense now because I am doing exit just after this message , so it is ok
OK, it make sense to check for it. But if you pass 1 command in the test, you can have it as:tst_res TCONF "arp doesn't support IPv6"
Kind regards,
Petr