Skip to contentSkip to conversation

ip_tests.sh: fix errors

PATCH In review Simon Xu 2 participants 9 messages Dec 11, 2013 – Feb 18, 2014

lore
Share & tools
lore

Simon Xu

author
#0 lore raw

PATCH 1/1 ip_tests.sh: fix errors

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

---
 testcases/network/iproute/ip_tests.sh | 128 ++++++++++++++++++++--------------
 1 file changed, 74 insertions(+), 54 deletions(-)
testcases/network/iproute/ip_tests.sh +74 -54
index 0416300..ed20540 100755
@@ -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
Signature · 13 lines
1.8.4.2


------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#1 lore raw

Could anyone help to review this?

Thanks
Simon

Quoted 412 lines · Simon Xu

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

---
  testcases/network/iproute/ip_tests.sh | 128 ++++++++++++++++++++--------------
  1 file changed, 74 insertions(+), 54 deletions(-)
testcases/network/iproute/ip_tests.sh +67 -52
index 0416300..ed20540 100755
@@ -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=$?

testcases/network/iproute/ip_tests.sh test06() · line 633

Quoted 10 lines
testcases/network/iproute/ip_tests.sh +7 -2
-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#2 lore raw

Could anyone help to review this?

Thanks
Simon

Quoted 426 lines · Simon Xu

Could anyone help to review this?

Thanks
Simon

Quoted 420 lines · Simon Xu

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

---
   testcases/network/iproute/ip_tests.sh | 128 ++++++++++++++++++++--------------
   1 file changed, 74 insertions(+), 54 deletions(-)
testcases/network/iproute/ip_tests.sh +73 -53
index 0416300..ed20540 100755
@@ -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
 
Quoted 2 lines

testcases/network/iproute/ip_tests.sh test06() · line 633

Quoted 2 lines
testcases/network/iproute/ip_tests.sh +1 -1
-exit $RC
+exit 0

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw

----- Original Message -----

Quoted 5 lines

From: "Simon Xu" <[email protected]>
To: [email protected]
Sent: Tuesday, 21 January, 2014 2:43:53 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

Quoted 14 lines

Could anyone help to review this?

Thanks
Simon

Quoted 8 lines · Simon Xu

Could anyone help to review this?

Thanks
Simon

Quoted 2 lines · Simon Xu

1) Eliminate '|| RC=$?' because because it may not be excecuted and the original value in RC can mess things up.

Hi,

"original value in RC can mess things up"
Can you elaborate on this? Isn't original value (initialized to) 0?

Regards,
Jan

Quoted 432 lines

Also remove the RC=0

Quoted 431 lines
Quoted 431 lines

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

---
   testcases/network/iproute/ip_tests.sh | 128
   ++++++++++++++++++++--------------
   1 file changed, 74 insertions(+), 54 deletions(-)
testcases/network/iproute/ip_tests.sh +14 -9
index 0416300..ed20540 100755
@@ -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

testcases/network/iproute/ip_tests.sh +5 -5
-		/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"
testcases/network/iproute/ip_tests.sh +6 -6
@@ -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:"

testcases/network/iproute/ip_tests.sh +8 -7
@@ -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=$?

testcases/network/iproute/ip_tests.sh +8 -4
+	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$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1 || RC=$?

testcases/network/iproute/ip_tests.sh +1 -0
+			ip neigh show | grep 127.0.0.1 | grep -v " FAILED$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1

testcases/network/iproute/ip_tests.sh +1 -2
+			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=$?

testcases/network/iproute/ip_tests.sh +12 -7
+	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=$?

testcases/network/iproute/ip_tests.sh +2 -1
+	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=$?

testcases/network/iproute/ip_tests.sh +2 -1
+	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=$?

testcases/network/iproute/ip_tests.sh +4 -2
+		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=$?

testcases/network/iproute/ip_tests.sh +10 -9
+		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
 
Quoted 14 lines
Quoted 2 lines

testcases/network/iproute/ip_tests.sh test06() · line 633

Quoted 2 lines
testcases/network/iproute/ip_tests.sh +1 -1
-exit $RC
+exit 0

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#4 lore raw
Quoted 18 lines · Jan Stancek

----- Original Message -----

Quoted 16 lines

From: "Simon Xu" <[email protected]>
To: [email protected]
Sent: Tuesday, 21 January, 2014 2:43:53 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

Could anyone help to review this?

Thanks
Simon

Quoted 5 lines · Simon Xu

Could anyone help to review this?

Thanks
Simon

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines · Simon Xu
Quoted 2 lines

1) Eliminate '|| RC=$?' because because it may not be excecuted and the original value in RC can mess things up.

Hi,

"original value in RC can mess things up"
Can you elaborate on this? Isn't original value (initialized to) 0?

It's been a while since I created the patch, I remember I had some issue where a command succeeds but test fails because RC was not 0 before the command executes. Anyway, I think

RC=0
...
...
command || RC=$?
check RC value

is bad design. It's error prone. While

command
RC=$?
check RC value

is simple and robust.

Thanks
Simon

Quoted 432 lines
Quoted 432 lines

Also remove the RC=0

Quoted 431 lines
Quoted 431 lines

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

---
    testcases/network/iproute/ip_tests.sh | 128
    ++++++++++++++++++++--------------
    1 file changed, 74 insertions(+), 54 deletions(-)
testcases/network/iproute/ip_tests.sh +14 -9
index 0416300..ed20540 100755
@@ -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

testcases/network/iproute/ip_tests.sh +5 -5
-		/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"
testcases/network/iproute/ip_tests.sh +6 -6
@@ -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:"

testcases/network/iproute/ip_tests.sh +8 -7
@@ -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=$?

testcases/network/iproute/ip_tests.sh +8 -4
+	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$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1 || RC=$?

testcases/network/iproute/ip_tests.sh +1 -0
+			ip neigh show | grep 127.0.0.1 | grep -v " FAILED$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1

testcases/network/iproute/ip_tests.sh +1 -2
+			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=$?

testcases/network/iproute/ip_tests.sh +12 -7
+	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=$?

testcases/network/iproute/ip_tests.sh +2 -1
+	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=$?

testcases/network/iproute/ip_tests.sh +2 -1
+	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=$?

testcases/network/iproute/ip_tests.sh +4 -2
+		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=$?

testcases/network/iproute/ip_tests.sh +10 -9
+		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
 
Quoted 13 lines
Quoted 4 lines
Quoted 2 lines

testcases/network/iproute/ip_tests.sh test06() · line 633

Quoted 2 lines
testcases/network/iproute/ip_tests.sh +1 -1
-exit $RC
+exit 0

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.

Quoted 9 lines

Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Acked-by
#5 lore raw

----- Original Message -----

Quoted 43 lines

From: "Simon Xu" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Monday, 10 February, 2014 3:42:30 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

Quoted 18 lines · Jan Stancek

----- Original Message -----

Quoted 16 lines

From: "Simon Xu" <[email protected]>
To: [email protected]
Sent: Tuesday, 21 January, 2014 2:43:53 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

Could anyone help to review this?

Thanks
Simon

Quoted 5 lines · Simon Xu

Could anyone help to review this?

Thanks
Simon

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines · Simon Xu
Quoted 2 lines

1) Eliminate '|| RC=$?' because because it may not be excecuted and the original value in RC can mess things up.

Hi,

"original value in RC can mess things up"
Can you elaborate on this? Isn't original value (initialized to) 0?

It's been a while since I created the patch, I remember I had some issue where a command succeeds but test fails because RC was not 0 before the command executes. Anyway, I think

RC=0
...
...
command || RC=$?
check RC value

Quoted 7 lines

is bad design. It's error prone. While

command
RC=$?
check RC value

is simple and robust.

I see what you mean, it's easier to make new bug if you're not careful with RC at every single place. The rest looks good to me:

Regards,
Jan

Quoted 461 lines

Thanks
Simon

Quoted 454 lines
Quoted 454 lines

Also remove the RC=0

Quoted 440 lines
Quoted 440 lines

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

---
    testcases/network/iproute/ip_tests.sh | 128
    ++++++++++++++++++++--------------
    1 file changed, 74 insertions(+), 54 deletions(-)
testcases/network/iproute/ip_tests.sh +14 -9
index 0416300..ed20540 100755
@@ -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

testcases/network/iproute/ip_tests.sh +5 -5
-		/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"
testcases/network/iproute/ip_tests.sh +6 -6
@@ -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:"

testcases/network/iproute/ip_tests.sh +2 -2
@@ -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 \
testcases/network/iproute/ip_tests.sh +0 -1
@@ -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=$?

testcases/network/iproute/ip_tests.sh +4 -2
+		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=$?

testcases/network/iproute/ip_tests.sh +2 -2
+			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=$?

testcases/network/iproute/ip_tests.sh +8 -4
+	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$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1 || RC=$?

testcases/network/iproute/ip_tests.sh +1 -0
+			ip neigh show | grep 127.0.0.1 | grep -v " FAILED$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1

testcases/network/iproute/ip_tests.sh +1 -2
+			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=$?

testcases/network/iproute/ip_tests.sh +1 -0
+	ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err

2>&1

testcases/network/iproute/ip_tests.sh +11 -7
+	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=$?

testcases/network/iproute/ip_tests.sh +1 -0
+	ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err

2>&1

testcases/network/iproute/ip_tests.sh +1 -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=$?

testcases/network/iproute/ip_tests.sh +2 -1
+	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=$?

testcases/network/iproute/ip_tests.sh +4 -2
+		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=$?

testcases/network/iproute/ip_tests.sh +10 -9
+		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
 
Quoted 2 lines

testcases/network/iproute/ip_tests.sh test06() · line 633

Quoted 2 lines
testcases/network/iproute/ip_tests.sh +1 -1
-exit $RC
+exit 0

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#6 lore raw
Quoted 49 lines · Jan Stancek

----- Original Message -----

Quoted 47 lines

From: "Simon Xu" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Monday, 10 February, 2014 3:42:30 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

Quoted 17 lines · Jan Stancek

----- Original Message -----

Quoted 16 lines

From: "Simon Xu" <[email protected]>
To: [email protected]
Sent: Tuesday, 21 January, 2014 2:43:53 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

Could anyone help to review this?

Thanks
Simon

Quoted 5 lines · Simon Xu

Could anyone help to review this?

Thanks
Simon

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines · Simon Xu
Quoted 2 lines

1) Eliminate '|| RC=$?' because because it may not be excecuted and the original value in RC can mess things up.

Hi,

"original value in RC can mess things up"
Can you elaborate on this? Isn't original value (initialized to) 0?

It's been a while since I created the patch, I remember I had some issue where a command succeeds but test fails because RC was not 0 before the command executes. Anyway, I think

RC=0
...
...
command || RC=$?
check RC value

is bad design. It's error prone. While

command
RC=$?
check RC value

Quoted 5 lines
Quoted 1 line

is simple and robust.

I see what you mean, it's easier to make new bug if you're not careful with RC at every single place. The rest looks good to me:

I double checked all places where I modified the RC logic and retested the script, it works fine.

Thanks
Simon

Quoted 441 lines
Quoted 441 lines
Quoted 441 lines
Quoted 441 lines

Also remove the RC=0

Quoted 440 lines
Quoted 440 lines

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

---
     testcases/network/iproute/ip_tests.sh | 128
     ++++++++++++++++++++--------------
     1 file changed, 74 insertions(+), 54 deletions(-)
testcases/network/iproute/ip_tests.sh +14 -9
index 0416300..ed20540 100755
@@ -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

testcases/network/iproute/ip_tests.sh +5 -5
-		/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"
testcases/network/iproute/ip_tests.sh +6 -6
@@ -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:"

testcases/network/iproute/ip_tests.sh +2 -2
@@ -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 \
testcases/network/iproute/ip_tests.sh +0 -1
@@ -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=$?

testcases/network/iproute/ip_tests.sh +4 -2
+		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=$?

testcases/network/iproute/ip_tests.sh +2 -2
+			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=$?

testcases/network/iproute/ip_tests.sh +8 -4
+	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$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1 || RC=$?

testcases/network/iproute/ip_tests.sh +1 -0
+			ip neigh show | grep 127.0.0.1 | grep -v " FAILED$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1

testcases/network/iproute/ip_tests.sh +1 -2
+			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=$?

testcases/network/iproute/ip_tests.sh +1 -0
+	ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err

2>&1

testcases/network/iproute/ip_tests.sh +11 -7
+	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=$?

testcases/network/iproute/ip_tests.sh +1 -0
+	ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err

2>&1

testcases/network/iproute/ip_tests.sh +1 -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=$?

testcases/network/iproute/ip_tests.sh +2 -1
+	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=$?

testcases/network/iproute/ip_tests.sh +4 -2
+		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=$?

testcases/network/iproute/ip_tests.sh +10 -9
+		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
 
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

testcases/network/iproute/ip_tests.sh test06() · line 633

Quoted 2 lines
testcases/network/iproute/ip_tests.sh +1 -1
-exit $RC
+exit 0

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#7 lore raw

Hi!

Quoted 49 lines · Simon Xu
Quoted 48 lines · Jan Stancek

----- Original Message -----

Quoted 47 lines

From: "Simon Xu" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Monday, 10 February, 2014 3:42:30 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

Quoted 17 lines · Jan Stancek

----- Original Message -----

Quoted 16 lines

From: "Simon Xu" <[email protected]>
To: [email protected]
Sent: Tuesday, 21 January, 2014 2:43:53 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

Could anyone help to review this?

Thanks
Simon

Quoted 5 lines · Simon Xu

Could anyone help to review this?

Thanks
Simon

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines · Simon Xu
Quoted 2 lines

1) Eliminate '|| RC=$?' because because it may not be excecuted and the original value in RC can mess things up.

Hi,

"original value in RC can mess things up"
Can you elaborate on this? Isn't original value (initialized to) 0?

It's been a while since I created the patch, I remember I had some issue where a command succeeds but test fails because RC was not 0 before the command executes. Anyway, I think

RC=0
...
...
command || RC=$?
check RC value

is bad design. It's error prone. While

command
RC=$?
check RC value

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

is simple and robust.

I see what you mean, it's easier to make new bug if you're not careful with RC at every single place. The rest looks good to me:

I double checked all places where I modified the RC logic and retested the script, it works fine.

Can we push this patch now?

Thanks
Simon

Quoted 455 lines
Quoted 441 lines
Quoted 441 lines
Quoted 441 lines
Quoted 441 lines

Also remove the RC=0

Quoted 440 lines
Quoted 440 lines

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

---
      testcases/network/iproute/ip_tests.sh | 128
      ++++++++++++++++++++--------------
      1 file changed, 74 insertions(+), 54 deletions(-)
testcases/network/iproute/ip_tests.sh +14 -9
index 0416300..ed20540 100755
@@ -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

testcases/network/iproute/ip_tests.sh +5 -5
-		/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"
testcases/network/iproute/ip_tests.sh +6 -6
@@ -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:"

testcases/network/iproute/ip_tests.sh +2 -2
@@ -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 \
testcases/network/iproute/ip_tests.sh +0 -1
@@ -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=$?

testcases/network/iproute/ip_tests.sh +4 -2
+		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=$?

testcases/network/iproute/ip_tests.sh +2 -2
+			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=$?

testcases/network/iproute/ip_tests.sh +8 -4
+	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$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1 || RC=$?

testcases/network/iproute/ip_tests.sh +1 -0
+			ip neigh show | grep 127.0.0.1 | grep -v " FAILED$"
Quoted 1 line

$LTPTMP/tst_ip.err 2>&1

testcases/network/iproute/ip_tests.sh +1 -2
+			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=$?

testcases/network/iproute/ip_tests.sh +1 -0
+	ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err

2>&1

testcases/network/iproute/ip_tests.sh +11 -7
+	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=$?

testcases/network/iproute/ip_tests.sh +1 -0
+	ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err

2>&1

testcases/network/iproute/ip_tests.sh +1 -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=$?

testcases/network/iproute/ip_tests.sh +2 -1
+	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=$?

testcases/network/iproute/ip_tests.sh +4 -2
+		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=$?

testcases/network/iproute/ip_tests.sh +10 -9
+		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
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

testcases/network/iproute/ip_tests.sh test06() · line 633

Quoted 2 lines
testcases/network/iproute/ip_tests.sh +1 -1
-exit $RC
+exit 0

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Quoted 10 lines

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#8 lore raw
In reply to Simon Xu

----- Original Message -----

Quoted 8 lines

From: "Simon Xu" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Wednesday, 12 February, 2014 7:52:22 AM
Subject: Re: [LTP] [PATCH] ip_tests.sh: fix errors

I double checked all places where I modified the RC logic and retested the script, it works fine.

Pushed, thank you,
Jan

Quoted 4 lines

Thanks
Simon

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list