From: Simon Xu <xu.simon@oracle.com>
To: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors
Date: Wed, 25 Dec 2013 09:44:13 +0800 [thread overview]
Message-ID: <52BA386D.50903@oracle.com> (raw)
In-Reply-To: <1386750816-782-1-git-send-email-xu.simon@oracle.com>
Could anyone help to review this?
Thanks
Simon
On 2013/12/11 16:33, Simon Xu wrote:
> 1) Eliminate '|| RC=$?' because because it may not be excecuted and the
> original value in RC can mess things up. Also remove the RC=0
> initializations that are now unnecessary.
> 2) Exit test immediately with non-zero return code when a test fails.
> 3) Add missing parameters in calling tst_brk and tst_brkm
>
> Signed-off-by: Simon Xu <xu.simon@oracle.com>
> ---
> testcases/network/iproute/ip_tests.sh | 128 ++++++++++++++++++++--------------
> 1 file changed, 74 insertions(+), 54 deletions(-)
>
> diff --git a/testcases/network/iproute/ip_tests.sh b/testcases/network/iproute/ip_tests.sh
> index 0416300..ed20540 100755
> --- a/testcases/network/iproute/ip_tests.sh
> +++ b/testcases/network/iproute/ip_tests.sh
> @@ -45,7 +45,6 @@ set +x
> init()
> {
>
> - export RC=0 # Return code from commands.
> export TST_TOTAL=2 # total numner of tests in this file.
> export TCID="ip_tests " # this is the init function.
> export TST_COUNT=0 # init identifier,
> @@ -61,15 +60,17 @@ init()
> trap "cleanup" 0
>
> # create the tmp directory for this testcase.
> - mkdir -p $LTPTMP/ >/dev/null 2>&1 || RC=$?
> + mkdir -p $LTPTMP/ >/dev/null 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> - tst_brkm TBROK "INIT: Unable to create temporary directory"
> + tst_brkm TBROK NULL "INIT: Unable to create temporary directory"
> return $RC
> fi
>
> # Check to see if test harness functions are in the path.
> - which tst_resm >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + which tst_resm >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brkm TBROK NULL \
> @@ -77,7 +78,8 @@ init()
> return $RC
> fi
>
> - which awk >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + which awk >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brkm TBROK NULL \
> @@ -85,7 +87,8 @@ init()
> return $RC
> fi
>
> - which ip >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + which ip >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brkm TBROK NULL \
> @@ -93,7 +96,8 @@ init()
> return $RC
> fi
>
> - which ifconfig >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + which ifconfig >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brkm TBROK NULL \
> @@ -104,24 +108,25 @@ init()
> tst_resm TINFO "INIT: Inititalizing tests."
>
> # Aliasing eth0 to create private network.
> - /sbin/ifconfig eth0:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + /sbin/ifconfig eth0:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> - tst_brk TBROK "INIT: failed aliasing eth0:1 with IP 10.1.1.12"
> + tst_brk TBROK NULL NULL "INIT: failed aliasing eth0:1 with IP 10.1.1.12"
> return $RC
> else
> - /sbin/route add -host 10.1.1.12 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 \
> - || RC=$?
> + /sbin/route add -host 10.1.1.12 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> - tst_brk TBROK "INIT: failed adding route to 10.1.1.12"
> + tst_brk TBROK NULL NULL "INIT: failed adding route to 10.1.1.12"
> return $RC
> else
> tst_resm TINFO "INIT: added alias: `ifconfig eth0:1`"
> fi
> fi
>
> - cat > $LTPTMP/tst_ip02.exp <<-EOF || RC=$?
> + cat > $LTPTMP/tst_ip02.exp <<-EOF
> 1:
> link/loopback
> 2:
> @@ -129,7 +134,7 @@ init()
> 3:
> link/ether
> EOF
> -
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brkm TBROK NULL "INIT: failed creating expected output for test02"
> @@ -151,9 +156,9 @@ cleanup()
> {
> TCID=dhcpd
> TST_COUNT=0
> - RC=0
>
> - /sbin/ifconfig eth0:1 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + /sbin/ifconfig eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -eq 0 ]
> then
> /sbin/ifconfig eth0:1 down >$LTPTMP/tst_ip.err 2>&1
> @@ -178,7 +183,6 @@ cleanup()
>
> test01()
> {
> - RC=0 # Return value from commands.
> TCID=ip01 # Name of the test case.
> TST_COUNT=1 # Test number.
>
> @@ -225,7 +229,6 @@ test01()
>
> test02()
> {
> - RC=0 # Return value from commands.
> TCID=ip02 # Name of the test case.
> TST_COUNT=2 # Test number.
>
> @@ -236,7 +239,8 @@ test02()
> tst_resm TINFO \
> "Test #2: Installing dummy.o in kernel"
>
> - modprobe dummy >$LTPTMP/tst_ip.out 2>&1 || RC=$?
> + modprobe dummy >$LTPTMP/tst_ip.out 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK $LTPTMP/tst_ip.out NULL \
> @@ -244,7 +248,8 @@ test02()
> return $RC
> fi
>
> - ip link show dummy0 | grep dummy0 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip link show dummy0 | grep dummy0 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err "Test #2: ip command failed. Reason:"
> @@ -275,14 +280,14 @@ test02()
>
> test03()
> {
> - RC=0 # Return value from commands.
> TCID=ip03 # Name of the test case.
> TST_COUNT=3 # Test number.
>
> tst_resm TINFO \
> "Test #3: ip addr add - adds a new protolcol address to the device"
>
> - ip addr add 127.6.6.6 dev lo >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip addr add 127.6.6.6 dev lo >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -291,7 +296,8 @@ test03()
> else
> tst_resm TINFO \
> "Test #3: ip addr show dev <device> - shows protocol address."
> - ip addr show dev lo | grep 127.6.6.6 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip addr show dev lo | grep 127.6.6.6 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -301,14 +307,16 @@ test03()
>
> tst_resm TINFO \
> "Test #3: ip addr del <ip> dev <device> - deletes protocol address."
> - ip addr del 127.6.6.6 dev lo >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip addr del 127.6.6.6 dev lo >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> "Test #3: ip addr del command failed. Reason: "
> return $RC
> else
> - ip addr show dev lo | grep 127.6.6.6 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip addr show dev lo | grep 127.6.6.6 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -eq 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -342,14 +350,14 @@ test03()
>
> test04()
> {
> - RC=0 # Return value from commands.
> TCID=ip04 # Name of the test case.
> TST_COUNT=4 # Test number.
>
> tst_resm TINFO \
> "Test #4: ip neigh add - adds a new neighbour to arp tables."
>
> - ip neigh add 127.0.0.1 dev lo nud reachable >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip neigh add 127.0.0.1 dev lo nud reachable >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -363,7 +371,8 @@ test04()
> 127.0.0.1 dev lo lladdr 00:00:00:00:00:00 REACHABLE
> EOF
>
> - ip neigh show 127.0.0.1 | head -n1 >$LTPTMP/tst_ip.out 2>&1 || RC=$?
> + ip neigh show 127.0.0.1 | head -n1 >$LTPTMP/tst_ip.out 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -371,7 +380,8 @@ test04()
> return $RC
> else
> diff -iwB $LTPTMP/tst_ip.out $LTPTMP/tst_ip.exp \
> - >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res FAIL $LTPTMP/tst_ip.err \
> @@ -383,14 +393,16 @@ test04()
> tst_resm TINFO \
> "Test #4: ip neigh del - deletes neighbour from the arp table."
>
> - ip neigh del 127.0.0.1 dev lo >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip neigh del 127.0.0.1 dev lo >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> "Test #4: ip neigh del command failed return = $RC. Reason: "
> return $RC
> else
> - ip neigh show | grep 127.0.0.1 | grep -v " FAILED$" >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip neigh show | grep 127.0.0.1 | grep -v " FAILED$" >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -eq 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -423,7 +435,6 @@ test04()
>
> test05()
> {
> - RC=0 # Return value from commands.
> TCID=ip05 # Name of the test case.
> TST_COUNT=5 # Test number.
>
> @@ -434,7 +445,8 @@ test05()
> tst_resm TINFO \
> "Test #5: create an interface with inet 10.6.6.6 alias to eth0"
>
> - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK $LTPTMP/tst_ip.err NULL \
> @@ -442,7 +454,8 @@ test05()
> return $RC
> fi
>
> - ip route add 10.6.6.6 via 127.0.0.1 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip route add 10.6.6.6 via 127.0.0.1 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -458,7 +471,8 @@ test05()
> EOF
>
> ip route show | grep "10.6.6.6 via 127.0.0.1 dev lo" \
> - >$LTPTMP/tst_ip.out 2>&1 || RC=$?
> + >$LTPTMP/tst_ip.out 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -466,7 +480,8 @@ test05()
> return $RC
> else
> diff -iwB $LTPTMP/tst_ip.out $LTPTMP/tst_ip.exp \
> - >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res FAIL $LTPTMP/tst_ip.err \
> @@ -478,14 +493,16 @@ test05()
> tst_resm TINFO \
> "Test #5: ip route del - deletes route from the route table."
>
> - ip route del 10.6.6.6 via 127.0.0.1 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip route del 10.6.6.6 via 127.0.0.1 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> "Test #5: ip route del command failed return = $RC. Reason: "
> return $RC
> else
> - ip route show | grep 127.0.0.1 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip route show | grep 127.0.0.1 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -eq 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -518,14 +535,14 @@ test05()
>
> test06()
> {
> - RC=0 # Return value from commands.
> TCID=ip06 # Name of the test case.
> TST_COUNT=6 # Test number.
>
> tst_resm TINFO \
> "Test #6: ip maddr add - adds a new multicast addr"
>
> - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK $LTPTMP/tst_ip.err NULL \
> @@ -533,7 +550,8 @@ test06()
> return $RC
> fi
>
> - ip maddr add 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip maddr add 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -547,7 +565,8 @@ test06()
> link 66:66:00:00:00:66 static
> EOF
>
> - ip maddr show | grep "66:66:00:00:00:66" >$LTPTMP/tst_ip.out 2>&1 || RC=$?
> + ip maddr show | grep "66:66:00:00:00:66" >$LTPTMP/tst_ip.out 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -555,7 +574,8 @@ test06()
> return $RC
> else
> diff -iwB $LTPTMP/tst_ip.out $LTPTMP/tst_ip.exp \
> - &>$LTPTMP/tst_ip.err || RC=$?
> + &>$LTPTMP/tst_ip.err
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res FAIL $LTPTMP/tst_ip.err \
> @@ -567,15 +587,16 @@ test06()
> tst_resm TINFO \
> "Test #6: ip maddr del - deletes multicast addr."
>
> - ip maddr del 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 || RC=$?
> + ip maddr del 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + RC=$?
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> "Test #6: ip maddr del command failed return = $RC. Reason: "
> return $RC
> else
> - ip maddr show | grep "66:66:00:00:00:66" &>$LTPTMP/tst_ip.err \
> - || RC=$?
> + ip maddr show | grep "66:66:00:00:00:66" &>$LTPTMP/tst_ip.err
> + RC=$?
> if [ $RC -eq 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -599,15 +620,14 @@ test06()
> # Exit: - zero on success
> # - non-zero on failure.
> TFAILCNT=0 # Set TFAILCNT to 0, increment on failure.
> -RC=0 # Return code from test.
>
> init || exit $RC
>
> -test01 || RC=$?
> -test02 || RC=$?
> -test03 || RC=$?
> -test04 || RC=$?
> -test05 || RC=$?
> -test06 || RC=$?
> +test01 || exit $RC
> +test02 || exit $RC
> +test03 || exit $RC
> +test04 || exit $RC
> +test05 || exit $RC
> +test06 || exit $RC
>
> -exit $RC
> +exit 0
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2013-12-25 1:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-11 8:33 [LTP] [PATCH] ip_tests.sh: fix errors Simon Xu
2013-12-25 1:44 ` Simon Xu [this message]
2014-01-21 1:43 ` Simon Xu
2014-01-30 11:03 ` Jan Stancek
2014-02-10 2:42 ` Simon Xu
2014-02-10 14:35 ` Jan Stancek
2014-02-12 6:52 ` Simon Xu
2014-02-14 0:09 ` Simon Xu
2014-02-18 8:48 ` Jan Stancek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52BA386D.50903@oracle.com \
--to=xu.simon@oracle.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox