All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/3] rlogin: Cleanup
@ 2014-12-26 10:58 Zeng Linggang
  2014-12-26 10:58 ` [LTP] [PATCH 2/3] telnet: Cleanup Zeng Linggang
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Zeng Linggang @ 2014-12-26 10:58 UTC (permalink / raw)
  To: ltp-list

* Add 'TCID' and 'TST_TOTAL'.

* Use 'test.sh'.

* Delete some useless comment.

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/tcp_cmds/rlogin/rlogin01 | 140 +++++++++++++++--------------
 1 file changed, 71 insertions(+), 69 deletions(-)

diff --git a/testcases/network/tcp_cmds/rlogin/rlogin01 b/testcases/network/tcp_cmds/rlogin/rlogin01
index ae670c9..f09f252 100755
--- a/testcases/network/tcp_cmds/rlogin/rlogin01
+++ b/testcases/network/tcp_cmds/rlogin/rlogin01
@@ -1,5 +1,4 @@
-#! /usr/bin/expect -f
-#*********************************************************************
+#!/bin/sh
 #   Copyright (c) International Business Machines  Corp., 2000
 #
 #   This program is free software;  you can redistribute it and/or modify
@@ -16,87 +15,90 @@
 #   along with this program;  if not, write to the Free Software
 #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 #
-#
-#
-#  FILE   : rlogin
-#
-#  PURPOSE: Tests the basic functionality of `rlogin`.
-#
 #  SETUP: The program `/usr/bin/expect' MUST be installed.
 #         The home directory of root on the machine exported as "RHOST"
 #         should have a ".rhosts" file with the hostname of the machine
 #         where the test is executed, OR the "PASSWD" section below MUST
 #	  be uncommented and set.
 #
-#  HISTORY:
 #    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
 #
-#
-# rlogin perform a rlogin session to each host in HOST_LIST with user
-#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
-#    verify that the rlogin was established.
-#
-#*********************************************************************
 
-set TC rlogin
-set TCtmp "/tmp"
-set SLEEPTIME 3
-set TESTLOG "$TCtmp"
+TCID="rlogin01"
+TST_TOTAL=1
+. test.sh
+
+setup()
+{
+	if [ -z $RUSER ]; then
+		RUSER=root
+	fi
+
+	if [ -z $PASSWD ]; then
+		tst_brkm TCONF "Please set PASSWD for $RUSER."
+	fi
 
-if [info exists env(RUSER)] {
-   set RUSER $env(RUSER)
-} else {
-   set RUSER root
+	if [ -z $RHOST ]; then
+		tst_brkm TCONF "Please set RHOST."
+	fi
+
+	if [ -z $LOOPCOUNT ]; then
+		LOOPCOUNT=25
+	fi
 }
 
-set RHOST $env(RHOST)
-set timeout 10
+do_test()
+{
+	tst_resm TINFO "Starting"
 
-if [info exists env(LOOPCOUNT)] {
-   set LOOPCOUNT $env(LOOPCOUNT)
-} else {
-   set LOOPCOUNT 25
+	for ((count=0;count<${LOOPCOUNT};count++)) {
+		rlogin_test
+	}
 }
 
-# stty echo
-send_user " Starting\n"
-
-set count 0
-while {$count < $LOOPCOUNT} {
-   set count [expr $count+1]
-      send_user "Host: $RHOST\n"
-
-      # rlogin to the host
-      spawn rlogin $RHOST -l $RUSER
-
-      # Uncomment code below and add root's passwd if .rhosts file is not
-      # present on remote host.
-      #---------------------------------
-      #set PASSWD "<ROOT PASSWORD HERE>"
-      #expect -re "Password:"
-      #send "$PASSWD\r"
-
-      # Wait for shell prompt
-      expect -re "$RUSER@"
-
-      # Run passwd command - and respond to its prompts
-      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$RHOST \r"
-      # When shell prompt comes back, logout
-
-      expect -re "$RUSER@"
-      exp_send "logout\r"
-
-      send_user "CHECKING RLOGIN STATUS\n"
-      set nummatch [exec rsh -n -l $RUSER $RHOST "cat $TESTLOG/$RUSER.$RHOST|grep -c 9"]
-      if {$nummatch==1} {
-         send_user "$TC interactive Test Successful in LOOP $count\r"
-         exec rsh -n -l $RUSER $RHOST "rm -f $TESTLOG/$RUSER.$RHOST"
-      } else {
-         send_user "$TC interactive session FAILED\r"
-         exit 1
-      }
+rlogin_test()
+{
+	expect -c "
+		spawn rlogin $RHOST -l $RUSER
+
+                expect {
+                        \"Password:\" {
+                                send \"$PASSWD\r\"
+                                expect -re \"$RUSER@\"
+                                send \"LC_ALL=C ls -l /etc/hosts | \\
+				       wc -w > $RUSER.$RHOST\r\"
+                        }
+                        \"$RUSER@\" {
+                                send \"LC_ALL=C ls -l /etc/hosts | \\
+				       wc -w > $RUSER.$RHOST\r\"
+                        }
+                }
+
+		expect -re \"$RUSER@\"
+		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST\r\"
+
+		expect -re \"$RUSER@\"
+		exp_send \"logout\r\"
+
+		send_user \"CHECKING RLOGIN STATUS\n\";
+
+		set nummatch [exec rsh -n -l $RUSER $RHOST \\
+			      \"grep -c 9 $RUSER.$RHOST\"]
+		if {\$nummatch==1} {
+			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
+		} else {
+			exit 1
+		}
+	"
 }
 
-send_user "\nTest PASSES\n\n"
-exit 0
+setup
+
+do_test
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "Test $TCID failed."
+else
+	tst_resm TPASS "Test $TCID successed."
+fi
+
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH 2/3] telnet: Cleanup
  2014-12-26 10:58 [LTP] [PATCH 1/3] rlogin: Cleanup Zeng Linggang
@ 2014-12-26 10:58 ` Zeng Linggang
  2014-12-26 10:58 ` [LTP] [PATCH 3/3] iptables_tests.sh: Cleanup Zeng Linggang
  2015-01-15 15:13 ` [LTP] [PATCH 1/3] rlogin: Cleanup Alexey Kodanev
  2 siblings, 0 replies; 23+ messages in thread
From: Zeng Linggang @ 2014-12-26 10:58 UTC (permalink / raw)
  To: ltp-list

* Add 'TCID' and 'TST_TOTAL'.

* Use 'test.sh'.

* Delete some useless comment.

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/tcp_cmds/telnet/telnet01 | 142 ++++++++++++-----------------
 1 file changed, 57 insertions(+), 85 deletions(-)

diff --git a/testcases/network/tcp_cmds/telnet/telnet01 b/testcases/network/tcp_cmds/telnet/telnet01
index 36ebf12..20257a1 100755
--- a/testcases/network/tcp_cmds/telnet/telnet01
+++ b/testcases/network/tcp_cmds/telnet/telnet01
@@ -1,5 +1,4 @@
-#! /usr/bin/expect -f
-#*********************************************************************
+#!/bin/bash
 #   Copyright (c) International Business Machines  Corp., 2000
 #
 #   This program is free software;  you can redistribute it and/or modify
@@ -16,102 +15,75 @@
 #   along with this program;  if not, write to the Free Software
 #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 #
-#
-#
-#  FILE   : telnet
-#
-#  PURPOSE: Tests the basic functionality of `telnet`.
-#
 #  SETUP: The program `/usr/bin/expect' MUST be installed.
 #	  The PASSWD and RHOST variables MUST be set prior to execution.
 #
-#  HISTORY:
 #    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#*********************************************************************
-#
-# telnet perform a telnet session to each host in HOST_LIST with user
-#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
-#    verify that the telnet was established.
-#
-#*********************************************************************
 
-set TC telnet
-set TCtmp "/tmp"
-set SLEEPTIME 3
-set TESTLOG "$TCtmp"
-set PROMPT "Alpha Bravo"
-
-if [info exists env(RUSER)] {
-   set RUSER $env(RUSER)
-} else {
-   set RUSER root
-}
+TCID="telnet01"
+TST_TOTAL=1
+. test.sh
 
-if [info exists env(PASSWD)] {
-   set PASSWD $env(PASSWD)
-} else {
-   set PASSWD .pasroot
-   send_user "PASSWD NOT SET:Using .pasroot as the PASSWD variable for $RUSER. \n"
-}
+setup()
+{
+	if [ -z $RUSER ]; then
+		RUSER=root
+	fi
 
-if [info exists env(RHOST)] {
-   set RHOST $env(RHOST)
-} else {
-   send_user "Please set/export the RHOST variable. \n"
-   exit 1
-}
+	if [ -z $PASSWD ]; then
+		tst_brkm TCONF "Please set PASSWD for $RUSER."
+	fi
 
-set timeout 90
+	if [ -z $RHOST ]; then
+		tst_brkm TCONF "Please set RHOST."
+	fi
 
-if [info exists env(LOOPCOUNT)] {
-   set LOOPCOUNT $env(LOOPCOUNT)
-} else {
-   set LOOPCOUNT 25
+	if [ -z $LOOPCOUNT ]; then
+		LOOTCOUNT=25
+	fi
 }
 
-# stty echo
-send_user " Starting\n"
-
-# Do foreach host on command line
-set count 0
-while {$count < $LOOPCOUNT} {
-   set count [expr $count+1]
-   foreach HOST $RHOST {
-      send_user "Host: $HOST\n"
-
-      # telnet to the host
-      spawn telnet $HOST
-      expect -re "login:"
-
-      send "$RUSER\r"
-      expect -re "Password:"
+do_test()
+{
+	tst_resm TINFO "Starting"
 
-      send "$PASSWD\r"
-
-      send "PS1=\"$PROMPT\"\r"
-      # Wait for shell prompt
-      expect "$PROMPT"
+	for((count=0;count<=$LOOPCOUNT;count++)) {
+		telnet_test
+	}
+}
 
-      # Run passwd command - and respond to its prompts
-      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$HOST \r"
-      # When shell prompt comes back, logout
+telnet_test()
+{
+	expect -c "
+		spawn telnet $RHOST
+		expect -re \"login:\"
+		send \"$RUSER\r\"
+		expect -re \"Password:\"
+		send \"$PASSWD\r\"
+
+		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST \r\"
+		expect \"$RUSER@\"
+		exp_send \"logout\r\"
+
+		send_user \"CHECKING TELNET STATUS\n\"
+
+		set nummatch [exec rsh -n -l $RUSER $RHOST \\
+			      \"grep -c 9 $RUSER.$RHOST\"]
+		if {\$nummatch==1} {
+			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
+		} else {
+			exit 1
+		}
+	"
+}
 
-      expect "$PROMPT"
-      exp_send "logout\r"
+setup
 
-      send_user "CHECKING TELNET STATUS\n"
-      set nummatch [exec rsh -n -l $RUSER $HOST "cat $TESTLOG/$RUSER.$HOST|grep -c 9"]
-      if {$nummatch==1} {
-         send_user "$TC interactive Test Successful in LOOP $count\r"
-         exec rsh -n -l $RUSER $HOST "rm -f $TESTLOG/$RUSER.$HOST"
-      } else {
-         send_user "$TC interactive session failed\n"
-         exit 1
-      }
-   }
-}
+do_test
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "Test $TCID failed."
+else
+	tst_resm TPASS "Test $TCID successed."
+fi
 
-send_user "\nTest PASSES\n\n"
-exit 0
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH 3/3] iptables_tests.sh: Cleanup
  2014-12-26 10:58 [LTP] [PATCH 1/3] rlogin: Cleanup Zeng Linggang
  2014-12-26 10:58 ` [LTP] [PATCH 2/3] telnet: Cleanup Zeng Linggang
@ 2014-12-26 10:58 ` Zeng Linggang
  2015-01-15 15:13 ` [LTP] [PATCH 1/3] rlogin: Cleanup Alexey Kodanev
  2 siblings, 0 replies; 23+ messages in thread
From: Zeng Linggang @ 2014-12-26 10:58 UTC (permalink / raw)
  To: ltp-list

* Use 'test.sh'.

* Use 'tst_*' which defined in 'test.sh'.

* Delete some useless comment.

* Delete 'RC' and 'TFAILCNT'.

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/iptables/iptables_tests.sh | 675 +++++++++------------------
 1 file changed, 224 insertions(+), 451 deletions(-)

diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
index 77ee29b..adc3f82 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -14,576 +14,349 @@
 ## for more details.                                                          ##
 ##                                                                            ##
 ## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
-#
-# File :        iptables_tests.sh
-#
-# Description:  Test basic functionality of iptables (firewall administration)
-#		- Test #1:  iptables -L -t <table> will list all rules in the
-#		  selected table.
-#		- Test #2:  Test iptables DROP packets from particular IP.
-#		- Test #3:  Test iptables REJECT ping request.
-#		- Test #4:  Test iptables log packets to single port.
-#		- Test #5:  Test iptables log packets to multiple ports.
-#		- Test #6:  Test limit matched logging for ping request.
-#
-#
-# History:
-#		Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com or hubertNOSPAAAM@symbio.com.tw>
-#		  - Ported test01, test02 from Manoj Iyer's ipchains_tests.sh
-#		  - Added test03, test04, test05, test06
-#
-# Function:	init
-#
-# Description:	- Check if command iptables is available.
-# Description:	- Check if iptables kernel support is available.
-#               - Initialize environment variables.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
-init()
-{
+#  Author:	Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com>
+#				       <hubertNOSPAAAM@symbio.com.tw>
 
-	export RC=0			# Return code from commands.
-	export TST_TOTAL=6		# total numner of tests in this file.
-	export TCID="iptables"		# Test case identifier
-	export TST_COUNT=0		# init identifier
-
-	if [ -z $TMP ]; then
-		LTPTMP=/tmp
-	else
-		LTPTMP=$TMP
-	fi
+export TCID="iptables"
+export TST_TOTAL=6
 
-	# Initialize cleanup function.
-	trap "cleanup" 0
+. test.sh
 
-	which tst_resm  > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brkm TBROK \
-			"Test INIT: USCTEST commands not found, set PATH correctly."
-		return $RC
-	fi
+init()
+{
+	tst_tmpdir
 
 	tst_resm TINFO "INIT: Inititalizing tests."
-	which iptables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"Test INIT: iptables command does not exist. Reason:"
-		return $RC
-	fi
 
-	modprobe ip_tables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		iptables -L > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-				"Test INIT: no iptables support in kenrel. Reason:"
-			return $RC
+	modprobe ip_tables > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		iptables -L > tst_iptables.out 2>&1
+		if [ $? -ne 0 ]; then
+			tst_brkm TBROK "no iptables support in kenrel."
 		fi
 	fi
 
 	tst_resm TINFO "INIT: Flushing all rules."
-	iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	return $RC
+	iptables -F -t filter > tst_iptables.out 2>&1
+	iptables -F -t nat > tst_iptables.out 2>&1
+	iptables -F -t mangle > tst_iptables.out 2>&1
 }
 
-
-# Function:	cleanup
-#
-# Description	- remove temporary files and directories.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 cleanup()
 {
-	TCID=iptables
-	TST_COUNT=0
-	RC=0
-
-	lsmod | grep "ip_tables" > $LTPTMP/tst_iptables.out 2>&1 || RC=0
-	if [ $RC -eq 0 ]; then
-		iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1
-		iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1
-		iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1
-		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT iptable_mangle iptable_nat ip_conntrack iptable_filter ip_tables > $LTPTMP/tst_iptables.out 2>&1
+	lsmod | grep "ip_tables" > tst_iptables.out 2>&1
+	if [ $? -eq 0 ]; then
+		iptables -F -t filter > tst_iptables.out 2>&1
+		iptables -F -t nat > tst_iptables.out 2>&1
+		iptables -F -t mangle > tst_iptables.out 2>&1
+		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
+			 iptable_mangle iptable_nat ip_conntrack \
+			 iptable_filter ip_tables > tst_iptables.out 2>&1
 	fi
-	rm -fr $LTPTMP/tst_iptables.*
-	return $RC
+	tst_rmdir
 }
 
-
-# Function:	test01
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #1:  iptables -L -t <table> will list all rules in the
-#                 selected table.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
-
 test01()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables01		# Name of the test case.
-	TST_COUNT=1		# Test number.
-
-	local chaincnt=0	# chain counter
+	local chaincnt=0
 
 	local cmd="iptables -L -t filter"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table filter."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table filter."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -lt 3 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
+			return
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
 	local cmd="iptables -L -t nat"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table nat."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table nat."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -ne 3 ] && [ $chaincnt -ne 4 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
+			return
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
 	local cmd="iptables -L -t mangle"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table mangle."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table mangle."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -ne 5 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
-	tst_resm TPASS "$TCID: iptables -L lists rules."
-	return $RC
+	tst_resm TPASS "iptables -L lists rules."
 }
 
-
-# Function:	test02
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #2:  Test iptables DROP packets from particular IP.
-#               - Append new rule to block all packets from loopback.
-#				- ping -c 2 loopback, this should fail.
-#				- remove rule, and ping -c loopback, this should work.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test02()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables02		# Name of the test case.
-	TST_COUNT=2		# Test number.
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to DROP packets from particular IP"
-	tst_resm TINFO "$TCID: Rule to block icmp from 127.0.0.1"
-
-	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Use iptables to DROP packets from particular IP"
+	tst_resm TINFO "Rule to block icmp from 127.0.0.1"
+
+	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		grep "100% packet loss" $LTPTMP/tst_iptables.out \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not block packets from loopback"
-			return $RC
+	tst_resm TINFO "Pinging 127.0.0.1"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL \
+				 "iptables did not block packets from loopback"
+			return
 		else
-			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
+			tst_resm TINFO "Ping 127.0.0.1 not successful."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not block icmp from 127.0.0.1"
-		return $RC
+		tst_resm TFAIL "iptables did not block icmp from 127.0.0.1"
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting icmp DROP from 127.0.0.1 rule."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting icmp DROP from 127.0.0.1 rule."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	fi
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables blocking loopback. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+	tst_resm TINFO "Pinging 127.0.0.1 again"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables blocking loopback. This is expected" \
+			       "behaviour on certain distributions where" \
+			       "enabling firewall drops all packets by default."
+		return
 	else
-		tst_resm TINFO "$TCID: Ping succsess"
-		tst_resm TPASS "$TCID: iptables can DROP packets from particular IP."
+		tst_resm TINFO "Ping succsess"
+		tst_resm TPASS "iptables can DROP packets from particular IP."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test03
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #3:  Test iptables REJECT ping request.
-#               - Append new rule to block all packets from loopback.
-#				- ping -c 2 loopback, this should fail.
-#				- remove rule, and ping -c loopback, this should work.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test03()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables03		# Name of the test case.
-	TST_COUNT=3		# Test number.
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to REJECT ping request."
-	tst_resm TINFO "$TCID: Rule to reject ping request."
-
-	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j REJECT \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Use iptables to REJECT ping request."
+	tst_resm TINFO "Rule to reject ping request."
+
+	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j \
+		 REJECT > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		grep "100% packet loss" $LTPTMP/tst_iptables.out \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not block ping request."
-			return $RC
+	tst_resm TINFO "Pinging 127.0.0.1"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL "iptables did not block ping request."
+			return
 		else
-			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
+			tst_resm TINFO "Ping 127.0.0.1 not successful."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not reject ping request."
-		return $RC
+		tst_resm TFAIL "iptables did not reject ping request."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting icmp request REJECT rule."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting icmp request REJECT rule."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	fi
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables blocking ping requests. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+	tst_resm TINFO "Pinging 127.0.0.1 again"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables blocking ping requests. This is" \
+			       "expected behaviour on certain distributions" \
+			       "where enabling firewall drops all packets by" \
+			       "default."
+		return
 	else
-		tst_resm TINFO "$TCID: Ping succsess"
-		tst_resm TPASS "$TCID: iptables can REJECT ping requests."
+		tst_resm TINFO "Ping succsess"
+		tst_resm TPASS "iptables can REJECT ping requests."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test04
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #4:  Test iptables log packets to single port
-#               - Append new rule to log tcp packets to localhost:45886
-#		- telnet localhost 45886, this should be logged.
-#		- remove rule.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test04()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables04		# Name of the test case.
-	TST_COUNT=4		# Test number.
-	local dport=45886				# destination port
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log packets to particular port."
-	tst_resm TINFO "$TCID: Rule to log tcp packets to particular port."
-
-	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local dport=45886
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log packets to particular port."
+	tst_resm TINFO "Rule to log tcp packets to particular port."
+
+	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG \
+		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
-	telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
+	tst_resm TINFO "telnet 127.0.0.1 $dport"
+	telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
 		sleep 2
-		dmesg | grep "$logprefix" \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not log packets to port $dport"
-			return $RC
+		dmesg | grep "$logprefix" > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL \
+				 "iptables did not log packets to port $dport"
+			return
 		else
-			tst_resm TINFO "$TCID: Packets to port $dport logged."
+			tst_resm TINFO "Packets to port $dport logged."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: telnet to 127.0.0.1 $dport should fail."
-		return $RC
+		tst_resm TFAIL "telnet to 127.0.0.1 $dport should fail."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting the rule to log."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting the rule to log."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets to particular port."
+		tst_resm TINFO "iptables logging succsess"
+		tst_resm TPASS "iptables can log packets to particular port."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test05
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #5:  Test iptables log packets to multiple ports
-#               - Append new rule to log tcp packets to localhost port 45801 - 45803
-#               - Append new rule to log tcp packets to localhost port 45804 - 45806 (ipt_multiport introduced)
-#		- telnet localhost port 45801 - 45806, this should be logged.
-#		- flush rules.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test05()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables05		# Name of the test case.
-	TST_COUNT=5		# Test number.
-	local dport=0					# destination port
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log packets to multiple ports."
-	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45801 - 45803."
-	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local dport=0
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log packets to multiple ports."
+	tst_resm TINFO "Rule to log tcp packets to port 45801 - 45803."
+	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG \
+		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45804 - 45806."
-	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Rule to log tcp packets to port 45804 - 45806."
+	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports \
+		 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
+		 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
 	for dport in 45801 45802 45803 45804 45805 45806; do
-		tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
-		telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			RC=0
+		tst_resm TINFO "telnet 127.0.0.1 $dport"
+		telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
+		if [ $? -ne 0 ]; then
 			sleep 2
 			dmesg | grep "$logprefix" | grep "=$dport " \
-				> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-			if [ $RC -ne 0 ]; then
-				tst_res TFAIL $LTPTMP/tst_iptables.out \
-					"$TCID: iptables did not log packets to port $dport"
-				return $RC
+				> tst_iptables.err 2>&1
+			if [ $? -ne 0 ]; then
+				tst_resm TFAIL "iptables did not log packets" \
+					       "to port $dport"
+				return
 			else
-				tst_resm TINFO "$TCID: Packets to port $dport logged."
+				tst_resm TINFO "Packets to port $dport logged."
 			fi
 		else
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: telnet to 127.0.0.1 $dport should fail."
-			return $RC
+			tst_res TFAIL "telnet to 127.0.0.1 $dport should fail."
+			return
 		fi
 	done
 
-	tst_resm TINFO "$TCID: Flushing all rules."
-	iptables -F > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not flush all rules. Reason:"
-		return $RC
+	tst_resm TINFO "Flushing all rules."
+	iptables -F > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not flush all rules."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets to multiple ports."
+		tst_resm TINFO "iptables logging succsess"
+		tst_resm TPASS "iptables can log packets to multiple ports."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test06
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #6:  Test limit matched logging for ping request.
-#               - Append new rule to log ping request with rate of 3/hour, burst 5
-#		- ping localhost 10 times, only the first 5 will be logged.
-#		- remove rule.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test06()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables06		# Name of the test case.
-	TST_COUNT=6		# Test number.
-	local logcnt=0		# log counter
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log ping request with limited rate."
-	tst_resm TINFO "$TCID: Rule to log ping request."
-
-	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m limit -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local logcnt=0
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log ping request with limited rate."
+	tst_resm TINFO "Rule to log ping request."
+
+	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m \
+		 limit -j LOG --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: ping 127.0.0.1"
-	ping -c 10 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -eq 0 ]; then
-		RC=0
+	tst_resm TINFO "ping 127.0.0.1"
+	ping -c 10 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -eq 0 ]; then
 		sleep 2
 		logcnt=$(dmesg | grep -c "$logprefix")
 		if [ $logcnt -ne 5 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not log packets with limited rate."
-			return $logcnt
+			tst_resm TFAIL "iptables did not log packets with" \
+				       "limited rate."
+			return
 		else
-			tst_resm TINFO "$TCID: ping requests logged with limited rate."
+			tst_resm TINFO "ping requests logged with limited rate."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: ping to 127.0.0.1 failed. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+		tst_resm TFAIL "ping to 127.0.0.1 failed. This is expected" \
+			       "behaviour on certain distributions where" \
+			       "enabling firewall drops all packets by default."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting the rule to log."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting the rule to log."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables limited logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets with limited rate."
+		tst_resm TINFO "iptables limited logging succsess"
+		tst_resm TPASS "iptables can log packets with limited rate."
 	fi
-
-	return $RC
 }
 
-# Function:	main
-#
-# Description:	- Execute all tests, report results.
-#
-# 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 # Exit if initializing testcases fails.
-
-test01 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test02 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test03 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test04 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test05 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test06 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-exit $TFAILCNT
+init
+TST_CLEANUP=cleanup
+
+test01
+test02
+test03
+test04
+test05
+test06
+
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH 1/3] rlogin: Cleanup
  2014-12-26 10:58 [LTP] [PATCH 1/3] rlogin: Cleanup Zeng Linggang
  2014-12-26 10:58 ` [LTP] [PATCH 2/3] telnet: Cleanup Zeng Linggang
  2014-12-26 10:58 ` [LTP] [PATCH 3/3] iptables_tests.sh: Cleanup Zeng Linggang
@ 2015-01-15 15:13 ` Alexey Kodanev
  2015-01-16  7:38   ` Zeng Linggang
  2015-01-21  5:28   ` [LTP] [PATCH v2 " Zeng Linggang
  2 siblings, 2 replies; 23+ messages in thread
From: Alexey Kodanev @ 2015-01-15 15:13 UTC (permalink / raw)
  To: Zeng Linggang, ltp-list

Hi!
On 12/26/2014 01:58 PM, Zeng Linggang wrote:
> * Add 'TCID' and 'TST_TOTAL'.
>
> * Use 'test.sh'.
>
> * Delete some useless comment.
>
> * Some cleanup.
>
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
>   testcases/network/tcp_cmds/rlogin/rlogin01 | 140 +++++++++++++++--------------
>   1 file changed, 71 insertions(+), 69 deletions(-)
>
> diff --git a/testcases/network/tcp_cmds/rlogin/rlogin01 b/testcases/network/tcp_cmds/rlogin/rlogin01
> index ae670c9..f09f252 100755
> --- a/testcases/network/tcp_cmds/rlogin/rlogin01
> +++ b/testcases/network/tcp_cmds/rlogin/rlogin01
> @@ -1,5 +1,4 @@
> -#! /usr/bin/expect -f
> -#*********************************************************************
> +#!/bin/sh
>   #   Copyright (c) International Business Machines  Corp., 2000
>   #
>   #   This program is free software;  you can redistribute it and/or modify
> @@ -16,87 +15,90 @@
>   #   along with this program;  if not, write to the Free Software
>   #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   #
> -#
> -#
> -#  FILE   : rlogin
> -#
> -#  PURPOSE: Tests the basic functionality of `rlogin`.
> -#
>   #  SETUP: The program `/usr/bin/expect' MUST be installed.
>   #         The home directory of root on the machine exported as "RHOST"
>   #         should have a ".rhosts" file with the hostname of the machine
>   #         where the test is executed, OR the "PASSWD" section below MUST
>   #	  be uncommented and set.
>   #
> -#  HISTORY:
>   #    03/01 Robbie Williamson (robbiew@us.ibm.com)
> -#      -Ported
>   #
> -#
> -# rlogin perform a rlogin session to each host in HOST_LIST with user
> -#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
> -#    verify that the rlogin was established.
> -#
> -#*********************************************************************
>   
> -set TC rlogin
> -set TCtmp "/tmp"
> -set SLEEPTIME 3
> -set TESTLOG "$TCtmp"
> +TCID="rlogin01"
> +TST_TOTAL=1
> +. test.sh
> +
> +setup()
> +{
> +	if [ -z $RUSER ]; then
> +		RUSER=root
> +	fi
> +
> +	if [ -z $PASSWD ]; then
> +		tst_brkm TCONF "Please set PASSWD for $RUSER."
> +	fi
>   
> -if [info exists env(RUSER)] {
> -   set RUSER $env(RUSER)
> -} else {
> -   set RUSER root
> +	if [ -z $RHOST ]; then
> +		tst_brkm TCONF "Please set RHOST."
> +	fi
> +
> +	if [ -z $LOOPCOUNT ]; then
> +		LOOPCOUNT=25
> +	fi
>   }
>   
> -set RHOST $env(RHOST)
> -set timeout 10
> +do_test()
> +{
> +	tst_resm TINFO "Starting"
>   
> -if [info exists env(LOOPCOUNT)] {
> -   set LOOPCOUNT $env(LOOPCOUNT)
> -} else {
> -   set LOOPCOUNT 25
> +	for ((count=0;count<${LOOPCOUNT};count++)) {
> +		rlogin_test
> +	}
>   }
>   

Why the return status of rlogin_test() not checked here, but only the 
last one after do_test()? May be, we could write something like this: 
'rlogin_test || return 1'.

'for (())'  is a bash extension, you can do the same with for i in $(seq 
0 $LOOPCOUNT); do ... done.

> -# stty echo
> -send_user " Starting\n"
> -
> -set count 0
> -while {$count < $LOOPCOUNT} {
> -   set count [expr $count+1]
> -      send_user "Host: $RHOST\n"
> -
> -      # rlogin to the host
> -      spawn rlogin $RHOST -l $RUSER
> -
> -      # Uncomment code below and add root's passwd if .rhosts file is not
> -      # present on remote host.
> -      #---------------------------------
> -      #set PASSWD "<ROOT PASSWORD HERE>"
> -      #expect -re "Password:"
> -      #send "$PASSWD\r"
> -
> -      # Wait for shell prompt
> -      expect -re "$RUSER@"
> -
> -      # Run passwd command - and respond to its prompts
> -      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$RHOST \r"
> -      # When shell prompt comes back, logout
> -
> -      expect -re "$RUSER@"
> -      exp_send "logout\r"
> -
> -      send_user "CHECKING RLOGIN STATUS\n"
> -      set nummatch [exec rsh -n -l $RUSER $RHOST "cat $TESTLOG/$RUSER.$RHOST|grep -c 9"]
> -      if {$nummatch==1} {
> -         send_user "$TC interactive Test Successful in LOOP $count\r"
> -         exec rsh -n -l $RUSER $RHOST "rm -f $TESTLOG/$RUSER.$RHOST"
> -      } else {
> -         send_user "$TC interactive session FAILED\r"
> -         exit 1
> -      }
> +rlogin_test()
> +{
> +	expect -c "
> +		spawn rlogin $RHOST -l $RUSER
> +
> +                expect {
> +                        \"Password:\" {
> +                                send \"$PASSWD\r\"
> +                                expect -re \"$RUSER@\"
> +                                send \"LC_ALL=C ls -l /etc/hosts | \\
> +				       wc -w > $RUSER.$RHOST\r\"
> +                        }
> +                        \"$RUSER@\" {
> +                                send \"LC_ALL=C ls -l /etc/hosts | \\
> +				       wc -w > $RUSER.$RHOST\r\"
> +                        }
> +                }
> +
> +		expect -re \"$RUSER@\"
> +		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST\r\"
> +
> +		expect -re \"$RUSER@\"
> +		exp_send \"logout\r\"
> +
> +		send_user \"CHECKING RLOGIN STATUS\n\";
> +
> +		set nummatch [exec rsh -n -l $RUSER $RHOST \\
> +			      \"grep -c 9 $RUSER.$RHOST\"]
> +		if {\$nummatch==1} {
> +			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
> +		} else {
> +			exit 1
> +		}
> +	"
>   }
>   
> -send_user "\nTest PASSES\n\n"
> -exit 0
> +setup
> +
> +do_test
> +if [ $? -ne 0 ]; then
> +	tst_resm TFAIL "Test $TCID failed."
> +else
> +	tst_resm TPASS "Test $TCID successed."
> +fi
> +
> +tst_exit

Thanks,
Alexey

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH 1/3] rlogin: Cleanup
  2015-01-15 15:13 ` [LTP] [PATCH 1/3] rlogin: Cleanup Alexey Kodanev
@ 2015-01-16  7:38   ` Zeng Linggang
  2015-01-21  5:28   ` [LTP] [PATCH v2 " Zeng Linggang
  1 sibling, 0 replies; 23+ messages in thread
From: Zeng Linggang @ 2015-01-16  7:38 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: ltp-list

Hi!

On Thu, 2015-01-15 at 18:13 +0300, Alexey Kodanev wrote:
> Hi!

> > -if [info exists env(LOOPCOUNT)] {
> > -   set LOOPCOUNT $env(LOOPCOUNT)
> > -} else {
> > -   set LOOPCOUNT 25
> > +	for ((count=0;count<${LOOPCOUNT};count++)) {
> > +		rlogin_test
> > +	}
> >   }
> >   
> 
> Why the return status of rlogin_test() not checked here, but only the 
> last one after do_test()? May be, we could write something like this: 
> 'rlogin_test || return 1'.
> 

'rlogin_test || return 1' looks better.

> 'for (())'  is a bash extension, you can do the same with for i in $(seq 
> 0 $LOOPCOUNT); do ... done.
> 

Oh, I got it.

And thank you very much. :)

Best regards,
Zeng


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 1/3] rlogin: Cleanup
  2015-01-15 15:13 ` [LTP] [PATCH 1/3] rlogin: Cleanup Alexey Kodanev
  2015-01-16  7:38   ` Zeng Linggang
@ 2015-01-21  5:28   ` Zeng Linggang
  2015-01-21  5:28     ` [LTP] [PATCH v2 2/3] telnet: Cleanup Zeng Linggang
                       ` (2 more replies)
  1 sibling, 3 replies; 23+ messages in thread
From: Zeng Linggang @ 2015-01-21  5:28 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

* Add 'TCID' and 'TST_TOTAL'.
* Use 'test.sh'.
* Delete some useless comment.
* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/tcp_cmds/rlogin/rlogin01 | 141 +++++++++++++++--------------
 1 file changed, 72 insertions(+), 69 deletions(-)

diff --git a/testcases/network/tcp_cmds/rlogin/rlogin01 b/testcases/network/tcp_cmds/rlogin/rlogin01
index ae670c9..ff3d8ed 100755
--- a/testcases/network/tcp_cmds/rlogin/rlogin01
+++ b/testcases/network/tcp_cmds/rlogin/rlogin01
@@ -1,5 +1,4 @@
-#! /usr/bin/expect -f
-#*********************************************************************
+#!/bin/sh
 #   Copyright (c) International Business Machines  Corp., 2000
 #
 #   This program is free software;  you can redistribute it and/or modify
@@ -16,87 +15,91 @@
 #   along with this program;  if not, write to the Free Software
 #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 #
-#
-#
-#  FILE   : rlogin
-#
-#  PURPOSE: Tests the basic functionality of `rlogin`.
-#
 #  SETUP: The program `/usr/bin/expect' MUST be installed.
 #         The home directory of root on the machine exported as "RHOST"
 #         should have a ".rhosts" file with the hostname of the machine
 #         where the test is executed, OR the "PASSWD" section below MUST
 #	  be uncommented and set.
 #
-#  HISTORY:
 #    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
 #
-#
-# rlogin perform a rlogin session to each host in HOST_LIST with user
-#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
-#    verify that the rlogin was established.
-#
-#*********************************************************************
 
-set TC rlogin
-set TCtmp "/tmp"
-set SLEEPTIME 3
-set TESTLOG "$TCtmp"
+TCID="rlogin01"
+TST_TOTAL=1
+. test.sh
+
+setup()
+{
+	if [ -z $RUSER ]; then
+		RUSER=root
+	fi
+
+	if [ -z $PASSWD ]; then
+		tst_brkm TCONF "Please set PASSWD for $RUSER."
+	fi
 
-if [info exists env(RUSER)] {
-   set RUSER $env(RUSER)
-} else {
-   set RUSER root
+	if [ -z $RHOST ]; then
+		tst_brkm TCONF "Please set RHOST."
+	fi
+
+	if [ -z $LOOPCOUNT ]; then
+		LOOPCOUNT=25
+	fi
 }
 
-set RHOST $env(RHOST)
-set timeout 10
+do_test()
+{
+	tst_resm TINFO "Starting"
 
-if [info exists env(LOOPCOUNT)] {
-   set LOOPCOUNT $env(LOOPCOUNT)
-} else {
-   set LOOPCOUNT 25
+	for i in $(seq 1 ${LOOPCOUNT})
+	do
+		rlogin_test || return 1
+	done
 }
 
-# stty echo
-send_user " Starting\n"
-
-set count 0
-while {$count < $LOOPCOUNT} {
-   set count [expr $count+1]
-      send_user "Host: $RHOST\n"
-
-      # rlogin to the host
-      spawn rlogin $RHOST -l $RUSER
-
-      # Uncomment code below and add root's passwd if .rhosts file is not
-      # present on remote host.
-      #---------------------------------
-      #set PASSWD "<ROOT PASSWORD HERE>"
-      #expect -re "Password:"
-      #send "$PASSWD\r"
-
-      # Wait for shell prompt
-      expect -re "$RUSER@"
-
-      # Run passwd command - and respond to its prompts
-      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$RHOST \r"
-      # When shell prompt comes back, logout
-
-      expect -re "$RUSER@"
-      exp_send "logout\r"
-
-      send_user "CHECKING RLOGIN STATUS\n"
-      set nummatch [exec rsh -n -l $RUSER $RHOST "cat $TESTLOG/$RUSER.$RHOST|grep -c 9"]
-      if {$nummatch==1} {
-         send_user "$TC interactive Test Successful in LOOP $count\r"
-         exec rsh -n -l $RUSER $RHOST "rm -f $TESTLOG/$RUSER.$RHOST"
-      } else {
-         send_user "$TC interactive session FAILED\r"
-         exit 1
-      }
+rlogin_test()
+{
+	expect -c "
+		spawn rlogin $RHOST -l $RUSER
+
+		expect {
+			\"Password:\" {
+				send \"$PASSWD\r\"
+				expect -re \"$RUSER@\"
+				send \"LC_ALL=C ls -l /etc/hosts | \\
+				       wc -w > $RUSER.$RHOST\r\"
+			}
+			\"$RUSER@\" {
+				send \"LC_ALL=C ls -l /etc/hosts | \\
+				       wc -w > $RUSER.$RHOST\r\"
+			}
+		}
+
+		expect -re \"$RUSER@\"
+		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST\r\"
+
+		expect -re \"$RUSER@\"
+		exp_send \"logout\r\"
+
+		send_user \"CHECKING RLOGIN STATUS\n\";
+
+		set nummatch [exec rsh -n -l $RUSER $RHOST \\
+			      \"grep -c 9 $RUSER.$RHOST\"]
+		if {\$nummatch==1} {
+			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
+		} else {
+			exit 1
+		}
+	"
 }
 
-send_user "\nTest PASSES\n\n"
-exit 0
+setup
+
+do_test
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "Test $TCID failed."
+else
+	tst_resm TPASS "Test $TCID successed."
+fi
+
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 2/3] telnet: Cleanup
  2015-01-21  5:28   ` [LTP] [PATCH v2 " Zeng Linggang
@ 2015-01-21  5:28     ` Zeng Linggang
  2015-01-23 11:01       ` Alexey Kodanev
  2015-01-21  5:28     ` [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup Zeng Linggang
  2015-01-23 11:02     ` [LTP] [PATCH v2 " Alexey Kodanev
  2 siblings, 1 reply; 23+ messages in thread
From: Zeng Linggang @ 2015-01-21  5:28 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

* Add 'TCID' and 'TST_TOTAL'.
* Use 'test.sh'.
* Delete some useless comment.
* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/tcp_cmds/telnet/telnet01 | 143 ++++++++++++-----------------
 1 file changed, 58 insertions(+), 85 deletions(-)

diff --git a/testcases/network/tcp_cmds/telnet/telnet01 b/testcases/network/tcp_cmds/telnet/telnet01
index 36ebf12..b006fe9 100755
--- a/testcases/network/tcp_cmds/telnet/telnet01
+++ b/testcases/network/tcp_cmds/telnet/telnet01
@@ -1,5 +1,4 @@
-#! /usr/bin/expect -f
-#*********************************************************************
+#!/bin/bash
 #   Copyright (c) International Business Machines  Corp., 2000
 #
 #   This program is free software;  you can redistribute it and/or modify
@@ -16,102 +15,76 @@
 #   along with this program;  if not, write to the Free Software
 #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 #
-#
-#
-#  FILE   : telnet
-#
-#  PURPOSE: Tests the basic functionality of `telnet`.
-#
 #  SETUP: The program `/usr/bin/expect' MUST be installed.
 #	  The PASSWD and RHOST variables MUST be set prior to execution.
 #
-#  HISTORY:
 #    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#*********************************************************************
-#
-# telnet perform a telnet session to each host in HOST_LIST with user
-#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
-#    verify that the telnet was established.
-#
-#*********************************************************************
 
-set TC telnet
-set TCtmp "/tmp"
-set SLEEPTIME 3
-set TESTLOG "$TCtmp"
-set PROMPT "Alpha Bravo"
-
-if [info exists env(RUSER)] {
-   set RUSER $env(RUSER)
-} else {
-   set RUSER root
-}
+TCID="telnet01"
+TST_TOTAL=1
+. test.sh
 
-if [info exists env(PASSWD)] {
-   set PASSWD $env(PASSWD)
-} else {
-   set PASSWD .pasroot
-   send_user "PASSWD NOT SET:Using .pasroot as the PASSWD variable for $RUSER. \n"
-}
+setup()
+{
+	if [ -z $RUSER ]; then
+		RUSER=root
+	fi
 
-if [info exists env(RHOST)] {
-   set RHOST $env(RHOST)
-} else {
-   send_user "Please set/export the RHOST variable. \n"
-   exit 1
-}
+	if [ -z $PASSWD ]; then
+		tst_brkm TCONF "Please set PASSWD for $RUSER."
+	fi
 
-set timeout 90
+	if [ -z $RHOST ]; then
+		tst_brkm TCONF "Please set RHOST."
+	fi
 
-if [info exists env(LOOPCOUNT)] {
-   set LOOPCOUNT $env(LOOPCOUNT)
-} else {
-   set LOOPCOUNT 25
+	if [ -z $LOOPCOUNT ]; then
+		LOOTCOUNT=25
+	fi
 }
 
-# stty echo
-send_user " Starting\n"
-
-# Do foreach host on command line
-set count 0
-while {$count < $LOOPCOUNT} {
-   set count [expr $count+1]
-   foreach HOST $RHOST {
-      send_user "Host: $HOST\n"
-
-      # telnet to the host
-      spawn telnet $HOST
-      expect -re "login:"
-
-      send "$RUSER\r"
-      expect -re "Password:"
+do_test()
+{
+	tst_resm TINFO "Starting"
 
-      send "$PASSWD\r"
-
-      send "PS1=\"$PROMPT\"\r"
-      # Wait for shell prompt
-      expect "$PROMPT"
+	for i in $(seq 1 ${LOOPCOUNT})
+	do
+		telnet_test || return 1
+	done
+}
 
-      # Run passwd command - and respond to its prompts
-      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$HOST \r"
-      # When shell prompt comes back, logout
+telnet_test()
+{
+	expect -c "
+		spawn telnet $RHOST
+		expect -re \"login:\"
+		send \"$RUSER\r\"
+		expect -re \"Password:\"
+		send \"$PASSWD\r\"
+
+		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST \r\"
+		expect \"$RUSER@\"
+		exp_send \"logout\r\"
+
+		send_user \"CHECKING TELNET STATUS\n\"
+
+		set nummatch [exec rsh -n -l $RUSER $RHOST \\
+			      \"grep -c 9 $RUSER.$RHOST\"]
+		if {\$nummatch==1} {
+			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
+		} else {
+			exit 1
+		}
+	"
+}
 
-      expect "$PROMPT"
-      exp_send "logout\r"
+setup
 
-      send_user "CHECKING TELNET STATUS\n"
-      set nummatch [exec rsh -n -l $RUSER $HOST "cat $TESTLOG/$RUSER.$HOST|grep -c 9"]
-      if {$nummatch==1} {
-         send_user "$TC interactive Test Successful in LOOP $count\r"
-         exec rsh -n -l $RUSER $HOST "rm -f $TESTLOG/$RUSER.$HOST"
-      } else {
-         send_user "$TC interactive session failed\n"
-         exit 1
-      }
-   }
-}
+do_test
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "Test $TCID failed."
+else
+	tst_resm TPASS "Test $TCID successed."
+fi
 
-send_user "\nTest PASSES\n\n"
-exit 0
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup
  2015-01-21  5:28   ` [LTP] [PATCH v2 " Zeng Linggang
  2015-01-21  5:28     ` [LTP] [PATCH v2 2/3] telnet: Cleanup Zeng Linggang
@ 2015-01-21  5:28     ` Zeng Linggang
  2015-01-26 18:37       ` Alexey Kodanev
  2015-01-23 11:02     ` [LTP] [PATCH v2 " Alexey Kodanev
  2 siblings, 1 reply; 23+ messages in thread
From: Zeng Linggang @ 2015-01-21  5:28 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

* Use 'test.sh'.
* Use 'tst_*' which defined in 'test.sh'.
* Delete some useless comment.
* Delete 'RC' and 'TFAILCNT'.
* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/iptables/iptables_tests.sh | 675 +++++++++------------------
 1 file changed, 224 insertions(+), 451 deletions(-)

diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
index 77ee29b..66e98bd 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -14,576 +14,349 @@
 ## for more details.                                                          ##
 ##                                                                            ##
 ## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
-#
-# File :        iptables_tests.sh
-#
-# Description:  Test basic functionality of iptables (firewall administration)
-#		- Test #1:  iptables -L -t <table> will list all rules in the
-#		  selected table.
-#		- Test #2:  Test iptables DROP packets from particular IP.
-#		- Test #3:  Test iptables REJECT ping request.
-#		- Test #4:  Test iptables log packets to single port.
-#		- Test #5:  Test iptables log packets to multiple ports.
-#		- Test #6:  Test limit matched logging for ping request.
-#
-#
-# History:
-#		Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com or hubertNOSPAAAM@symbio.com.tw>
-#		  - Ported test01, test02 from Manoj Iyer's ipchains_tests.sh
-#		  - Added test03, test04, test05, test06
-#
-# Function:	init
-#
-# Description:	- Check if command iptables is available.
-# Description:	- Check if iptables kernel support is available.
-#               - Initialize environment variables.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
-init()
-{
+#  Author:	Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com>
+#				       <hubertNOSPAAAM@symbio.com.tw>
 
-	export RC=0			# Return code from commands.
-	export TST_TOTAL=6		# total numner of tests in this file.
-	export TCID="iptables"		# Test case identifier
-	export TST_COUNT=0		# init identifier
-
-	if [ -z $TMP ]; then
-		LTPTMP=/tmp
-	else
-		LTPTMP=$TMP
-	fi
+export TCID="iptables"
+export TST_TOTAL=6
 
-	# Initialize cleanup function.
-	trap "cleanup" 0
+. test.sh
 
-	which tst_resm  > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brkm TBROK \
-			"Test INIT: USCTEST commands not found, set PATH correctly."
-		return $RC
-	fi
+init()
+{
+	tst_tmpdir
 
 	tst_resm TINFO "INIT: Inititalizing tests."
-	which iptables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"Test INIT: iptables command does not exist. Reason:"
-		return $RC
-	fi
 
-	modprobe ip_tables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		iptables -L > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-				"Test INIT: no iptables support in kenrel. Reason:"
-			return $RC
+	modprobe ip_tables > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		iptables -L > tst_iptables.out 2>&1
+		if [ $? -ne 0 ]; then
+			tst_brkm TBROK "no iptables support in kenrel."
 		fi
 	fi
 
 	tst_resm TINFO "INIT: Flushing all rules."
-	iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	return $RC
+	iptables -F -t filter > tst_iptables.out 2>&1
+	iptables -F -t nat > tst_iptables.out 2>&1
+	iptables -F -t mangle > tst_iptables.out 2>&1
 }
 
-
-# Function:	cleanup
-#
-# Description	- remove temporary files and directories.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 cleanup()
 {
-	TCID=iptables
-	TST_COUNT=0
-	RC=0
-
-	lsmod | grep "ip_tables" > $LTPTMP/tst_iptables.out 2>&1 || RC=0
-	if [ $RC -eq 0 ]; then
-		iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1
-		iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1
-		iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1
-		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT iptable_mangle iptable_nat ip_conntrack iptable_filter ip_tables > $LTPTMP/tst_iptables.out 2>&1
+	lsmod | grep "ip_tables" > tst_iptables.out 2>&1
+	if [ $? -eq 0 ]; then
+		iptables -F -t filter > tst_iptables.out 2>&1
+		iptables -F -t nat > tst_iptables.out 2>&1
+		iptables -F -t mangle > tst_iptables.out 2>&1
+		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
+			 iptable_mangle iptable_nat ip_conntrack \
+			 iptable_filter ip_tables > tst_iptables.out 2>&1
 	fi
-	rm -fr $LTPTMP/tst_iptables.*
-	return $RC
+	tst_rmdir
 }
 
-
-# Function:	test01
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #1:  iptables -L -t <table> will list all rules in the
-#                 selected table.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
-
 test01()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables01		# Name of the test case.
-	TST_COUNT=1		# Test number.
-
-	local chaincnt=0	# chain counter
+	local chaincnt=0
 
 	local cmd="iptables -L -t filter"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table filter."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table filter."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -lt 3 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
+			return
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
 	local cmd="iptables -L -t nat"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table nat."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table nat."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -ne 3 ] && [ $chaincnt -ne 4 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
+			return
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
 	local cmd="iptables -L -t mangle"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table mangle."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table mangle."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -ne 5 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
-	tst_resm TPASS "$TCID: iptables -L lists rules."
-	return $RC
+	tst_resm TPASS "iptables -L lists rules."
 }
 
-
-# Function:	test02
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #2:  Test iptables DROP packets from particular IP.
-#               - Append new rule to block all packets from loopback.
-#				- ping -c 2 loopback, this should fail.
-#				- remove rule, and ping -c loopback, this should work.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test02()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables02		# Name of the test case.
-	TST_COUNT=2		# Test number.
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to DROP packets from particular IP"
-	tst_resm TINFO "$TCID: Rule to block icmp from 127.0.0.1"
-
-	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Use iptables to DROP packets from particular IP"
+	tst_resm TINFO "Rule to block icmp from 127.0.0.1"
+
+	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		grep "100% packet loss" $LTPTMP/tst_iptables.out \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not block packets from loopback"
-			return $RC
+	tst_resm TINFO "Pinging 127.0.0.1"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL \
+				 "iptables did not block packets from loopback"
+			return
 		else
-			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
+			tst_resm TINFO "Ping 127.0.0.1 not successful."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not block icmp from 127.0.0.1"
-		return $RC
+		tst_resm TFAIL "iptables did not block icmp from 127.0.0.1"
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting icmp DROP from 127.0.0.1 rule."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting icmp DROP from 127.0.0.1 rule."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	fi
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables blocking loopback. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+	tst_resm TINFO "Pinging 127.0.0.1 again"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables blocking loopback. This is expected" \
+			       "behaviour on certain distributions where" \
+			       "enabling firewall drops all packets by default."
+		return
 	else
-		tst_resm TINFO "$TCID: Ping succsess"
-		tst_resm TPASS "$TCID: iptables can DROP packets from particular IP."
+		tst_resm TINFO "Ping succsess"
+		tst_resm TPASS "iptables can DROP packets from particular IP."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test03
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #3:  Test iptables REJECT ping request.
-#               - Append new rule to block all packets from loopback.
-#				- ping -c 2 loopback, this should fail.
-#				- remove rule, and ping -c loopback, this should work.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test03()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables03		# Name of the test case.
-	TST_COUNT=3		# Test number.
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to REJECT ping request."
-	tst_resm TINFO "$TCID: Rule to reject ping request."
-
-	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j REJECT \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Use iptables to REJECT ping request."
+	tst_resm TINFO "Rule to reject ping request."
+
+	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j \
+		 REJECT > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		grep "100% packet loss" $LTPTMP/tst_iptables.out \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not block ping request."
-			return $RC
+	tst_resm TINFO "Pinging 127.0.0.1"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL "iptables did not block ping request."
+			return
 		else
-			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
+			tst_resm TINFO "Ping 127.0.0.1 not successful."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not reject ping request."
-		return $RC
+		tst_resm TFAIL "iptables did not reject ping request."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting icmp request REJECT rule."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting icmp request REJECT rule."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	fi
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables blocking ping requests. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+	tst_resm TINFO "Pinging 127.0.0.1 again"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables blocking ping requests. This is" \
+			       "expected behaviour on certain distributions" \
+			       "where enabling firewall drops all packets by" \
+			       "default."
+		return
 	else
-		tst_resm TINFO "$TCID: Ping succsess"
-		tst_resm TPASS "$TCID: iptables can REJECT ping requests."
+		tst_resm TINFO "Ping succsess"
+		tst_resm TPASS "iptables can REJECT ping requests."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test04
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #4:  Test iptables log packets to single port
-#               - Append new rule to log tcp packets to localhost:45886
-#		- telnet localhost 45886, this should be logged.
-#		- remove rule.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test04()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables04		# Name of the test case.
-	TST_COUNT=4		# Test number.
-	local dport=45886				# destination port
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log packets to particular port."
-	tst_resm TINFO "$TCID: Rule to log tcp packets to particular port."
-
-	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local dport=45886
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log packets to particular port."
+	tst_resm TINFO "Rule to log tcp packets to particular port."
+
+	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG \
+		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
-	telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
+	tst_resm TINFO "telnet 127.0.0.1 $dport"
+	telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
 		sleep 2
-		dmesg | grep "$logprefix" \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not log packets to port $dport"
-			return $RC
+		dmesg | grep "$logprefix" > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL \
+				 "iptables did not log packets to port $dport"
+			return
 		else
-			tst_resm TINFO "$TCID: Packets to port $dport logged."
+			tst_resm TINFO "Packets to port $dport logged."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: telnet to 127.0.0.1 $dport should fail."
-		return $RC
+		tst_resm TFAIL "telnet to 127.0.0.1 $dport should fail."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting the rule to log."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting the rule to log."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets to particular port."
+		tst_resm TINFO "iptables logging succsess"
+		tst_resm TPASS "iptables can log packets to particular port."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test05
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #5:  Test iptables log packets to multiple ports
-#               - Append new rule to log tcp packets to localhost port 45801 - 45803
-#               - Append new rule to log tcp packets to localhost port 45804 - 45806 (ipt_multiport introduced)
-#		- telnet localhost port 45801 - 45806, this should be logged.
-#		- flush rules.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test05()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables05		# Name of the test case.
-	TST_COUNT=5		# Test number.
-	local dport=0					# destination port
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log packets to multiple ports."
-	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45801 - 45803."
-	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local dport=0
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log packets to multiple ports."
+	tst_resm TINFO "Rule to log tcp packets to port 45801 - 45803."
+	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG \
+		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45804 - 45806."
-	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Rule to log tcp packets to port 45804 - 45806."
+	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports \
+		 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
+		 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
 	for dport in 45801 45802 45803 45804 45805 45806; do
-		tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
-		telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			RC=0
+		tst_resm TINFO "telnet 127.0.0.1 $dport"
+		telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
+		if [ $? -ne 0 ]; then
 			sleep 2
 			dmesg | grep "$logprefix" | grep "=$dport " \
-				> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-			if [ $RC -ne 0 ]; then
-				tst_res TFAIL $LTPTMP/tst_iptables.out \
-					"$TCID: iptables did not log packets to port $dport"
-				return $RC
+				> tst_iptables.err 2>&1
+			if [ $? -ne 0 ]; then
+				tst_resm TFAIL "iptables did not log packets" \
+					       "to port $dport"
+				return
 			else
-				tst_resm TINFO "$TCID: Packets to port $dport logged."
+				tst_resm TINFO "Packets to port $dport logged."
 			fi
 		else
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: telnet to 127.0.0.1 $dport should fail."
-			return $RC
+			tst_res TFAIL "telnet to 127.0.0.1 $dport should fail."
+			return
 		fi
 	done
 
-	tst_resm TINFO "$TCID: Flushing all rules."
-	iptables -F > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not flush all rules. Reason:"
-		return $RC
+	tst_resm TINFO "Flushing all rules."
+	iptables -F > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not flush all rules."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets to multiple ports."
+		tst_resm TINFO "iptables logging succsess"
+		tst_resm TPASS "iptables can log packets to multiple ports."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test06
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #6:  Test limit matched logging for ping request.
-#               - Append new rule to log ping request with rate of 3/hour, burst 5
-#		- ping localhost 10 times, only the first 5 will be logged.
-#		- remove rule.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test06()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables06		# Name of the test case.
-	TST_COUNT=6		# Test number.
-	local logcnt=0		# log counter
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log ping request with limited rate."
-	tst_resm TINFO "$TCID: Rule to log ping request."
-
-	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m limit -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local logcnt=0
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log ping request with limited rate."
+	tst_resm TINFO "Rule to log ping request."
+
+	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m \
+		 limit -j LOG --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: ping 127.0.0.1"
-	ping -c 10 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -eq 0 ]; then
-		RC=0
+	tst_resm TINFO "ping 127.0.0.1"
+	ping -c 10 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -eq 0 ]; then
 		sleep 2
 		logcnt=$(dmesg | grep -c "$logprefix")
 		if [ $logcnt -ne 5 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not log packets with limited rate."
-			return $logcnt
+			tst_resm TFAIL "iptables did not log packets with" \
+				       "limited rate."
+			return
 		else
-			tst_resm TINFO "$TCID: ping requests logged with limited rate."
+			tst_resm TINFO "ping requests logged with limited rate."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: ping to 127.0.0.1 failed. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+		tst_resm TFAIL "ping to 127.0.0.1 failed. This is expected" \
+			       "behaviour on certain distributions where" \
+			       "enabling firewall drops all packets by default."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting the rule to log."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting the rule to log."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables limited logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets with limited rate."
+		tst_resm TINFO "iptables limited logging succsess"
+		tst_resm TPASS "iptables can log packets with limited rate."
 	fi
-
-	return $RC
 }
 
-# Function:	main
-#
-# Description:	- Execute all tests, report results.
-#
-# 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 # Exit if initializing testcases fails.
-
-test01 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test02 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test03 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test04 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test05 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test06 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-exit $TFAILCNT
+init
+TST_CLEANUP=cleanup
+
+test01
+test02
+test03
+test04
+test05
+test06
+
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 2/3] telnet: Cleanup
  2015-01-21  5:28     ` [LTP] [PATCH v2 2/3] telnet: Cleanup Zeng Linggang
@ 2015-01-23 11:01       ` Alexey Kodanev
  2015-01-27  7:41         ` Zeng Linggang
  0 siblings, 1 reply; 23+ messages in thread
From: Alexey Kodanev @ 2015-01-23 11:01 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
On 21.01.2015 8:28, Zeng Linggang wrote:
> * Add 'TCID' and 'TST_TOTAL'.
> * Use 'test.sh'.
> * Delete some useless comment.
> * Some cleanup.
>
> Signed-off-by: Zeng Linggang<zenglg.jy@cn.fujitsu.com>
> ---
>   testcases/network/tcp_cmds/telnet/telnet01 | 143 ++++++++++++-----------------
>   1 file changed, 58 insertions(+), 85 deletions(-)
>
> diff --git a/testcases/network/tcp_cmds/telnet/telnet01 b/testcases/network/tcp_cmds/telnet/telnet01
> index 36ebf12..b006fe9 100755
> --- a/testcases/network/tcp_cmds/telnet/telnet01
> +++ b/testcases/network/tcp_cmds/telnet/telnet01
> @@ -1,5 +1,4 @@
> -#! /usr/bin/expect -f
> -#*********************************************************************
> +#!/bin/bash
>   #   Copyright (c) International Business Machines  Corp., 2000
>   #
>   #   This program is free software;  you can redistribute it and/or modify
> @@ -16,102 +15,76 @@
>   #   along with this program;  if not, write to the Free Software
>   #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   #
> -#
> -#
> -#  FILE   : telnet
> -#
> -#  PURPOSE: Tests the basic functionality of `telnet`.
> -#
>   #  SETUP: The program `/usr/bin/expect' MUST be installed.
>   #	  The PASSWD and RHOST variables MUST be set prior to execution.
>   #
> -#  HISTORY:
>   #    03/01 Robbie Williamson (robbiew@us.ibm.com)
> -#      -Ported
> -#
> -#*********************************************************************
> -#
> -# telnet perform a telnet session to each host in HOST_LIST with user
> -#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
> -#    verify that the telnet was established.
> -#
> -#*********************************************************************
>   
> -set TC telnet
> -set TCtmp "/tmp"
> -set SLEEPTIME 3
> -set TESTLOG "$TCtmp"
> -set PROMPT "Alpha Bravo"
> -
> -if [info exists env(RUSER)] {
> -   set RUSER $env(RUSER)
> -} else {
> -   set RUSER root
> -}
> +TCID="telnet01"
> +TST_TOTAL=1
> +. test.sh
>   
> -if [info exists env(PASSWD)] {
> -   set PASSWD $env(PASSWD)
> -} else {
> -   set PASSWD .pasroot
> -   send_user "PASSWD NOT SET:Using .pasroot as the PASSWD variable for $RUSER. \n"
> -}
> +setup()
> +{
> +	if [ -z $RUSER ]; then
> +		RUSER=root
> +	fi
>   
> -if [info exists env(RHOST)] {
> -   set RHOST $env(RHOST)
> -} else {
> -   send_user "Please set/export the RHOST variable. \n"
> -   exit 1
> -}
> +	if [ -z $PASSWD ]; then
> +		tst_brkm TCONF "Please set PASSWD for $RUSER."
> +	fi
>   
> -set timeout 90
> +	if [ -z $RHOST ]; then
> +		tst_brkm TCONF "Please set RHOST."
> +	fi
>   
> -if [info exists env(LOOPCOUNT)] {
> -   set LOOPCOUNT $env(LOOPCOUNT)
> -} else {
> -   set LOOPCOUNT 25
> +	if [ -z $LOOPCOUNT ]; then
> +		LOOTCOUNT=25
                                            ^
                                            should be 'P' here

> +	fi
>   }
>   
> -# stty echo
> -send_user " Starting\n"
> -
> -# Do foreach host on command line
> -set count 0
> -while {$count < $LOOPCOUNT} {
> -   set count [expr $count+1]
> -   foreach HOST $RHOST {
> -      send_user "Host: $HOST\n"
> -
> -      # telnet to the host
> -      spawn telnet $HOST
> -      expect -re "login:"
> -
> -      send "$RUSER\r"
> -      expect -re "Password:"
> +do_test()
> +{
> +	tst_resm TINFO "Starting"
>   
> -      send "$PASSWD\r"
> -
> -      send "PS1=\"$PROMPT\"\r"
> -      # Wait for shell prompt
> -      expect "$PROMPT"
> +	for i in $(seq 1 ${LOOPCOUNT})
> +	do
> +		telnet_test || return 1
> +	done
> +}
>   
> -      # Run passwd command - and respond to its prompts
> -      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$HOST \r"
> -      # When shell prompt comes back, logout
> +telnet_test()
> +{
> +	expect -c "
> +		spawn telnet $RHOST
> +		expect -re \"login:\"
> +		send \"$RUSER\r\"
> +		expect -re \"Password:\"
> +		send \"$PASSWD\r\"
> +
> +		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST \r\"
> +		expect \"$RUSER@\"

This part needs some extra checking for failed login, e.g. 'incorrect' 
password or connection timeout:

expect -re "incorrect" {
     exit 1
} -re "$USERS@"


> +		exp_send \"logout\r\"
> +

The below part can be changed to:
         tst_resm TINFO "checking telnet status"
         tst_rhost_run -s -c "grep -q 9 $RUSER.$RHOST"
         tst_rhost_run -c "rm -f $RUSER.$RHOST"

Note, 'tst_rhost_run' with '-s' option should exit with TBROK if remote 
command returns non-zero exit status, please find the following patch 
with the fix:

[PATCH v2] lib/test_net.sh: fix 'tst_rhost_run -s' when errors occur.

> +		send_user \"CHECKING TELNET STATUS\n\"
> +
> +		set nummatch [exec rsh -n -l $RUSER $RHOST \\
> +			      \"grep -c 9 $RUSER.$RHOST\"]
> +		if {\$nummatch==1} {
> +			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
> +		} else {
> +			exit 1
> +		}
> +	"
> +}
>   
> -      expect "$PROMPT"
> -      exp_send "logout\r"
> +setup
>   
> -      send_user "CHECKING TELNET STATUS\n"
> -      set nummatch [exec rsh -n -l $RUSER $HOST "cat $TESTLOG/$RUSER.$HOST|grep -c 9"]
> -      if {$nummatch==1} {
> -         send_user "$TC interactive Test Successful in LOOP $count\r"
> -         exec rsh -n -l $RUSER $HOST "rm -f $TESTLOG/$RUSER.$HOST"
> -      } else {
> -         send_user "$TC interactive session failed\n"
> -         exit 1
> -      }
> -   }
> -}
> +do_test
> +if [ $? -ne 0 ]; then
> +	tst_resm TFAIL "Test $TCID failed."
> +else
> +	tst_resm TPASS "Test $TCID successed."

"'succeeded"

> +fi
>   
> -send_user "\nTest PASSES\n\n"
> -exit 0
> +tst_exit

Also, there is too much non-standard LTP output, especially if LOOPCOUNT 
is big. Could we send it to a file and only if there are some errors, 
print it. Any thoughts?

Thanks,
Alexey


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 1/3] rlogin: Cleanup
  2015-01-21  5:28   ` [LTP] [PATCH v2 " Zeng Linggang
  2015-01-21  5:28     ` [LTP] [PATCH v2 2/3] telnet: Cleanup Zeng Linggang
  2015-01-21  5:28     ` [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup Zeng Linggang
@ 2015-01-23 11:02     ` Alexey Kodanev
  2015-01-27  7:29       ` Zeng Linggang
  2 siblings, 1 reply; 23+ messages in thread
From: Alexey Kodanev @ 2015-01-23 11:02 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

On 21.01.2015 8:28, Zeng Linggang wrote:
> * Add 'TCID' and 'TST_TOTAL'.
> * Use 'test.sh'.
> * Delete some useless comment.
> * Some cleanup.
>
> Signed-off-by: Zeng Linggang<zenglg.jy@cn.fujitsu.com>
> ---
>   testcases/network/tcp_cmds/rlogin/rlogin01 | 141 +++++++++++++++--------------
>   1 file changed, 72 insertions(+), 69 deletions(-)
>
> diff --git a/testcases/network/tcp_cmds/rlogin/rlogin01 b/testcases/network/tcp_cmds/rlogin/rlogin01
> index ae670c9..ff3d8ed 100755
> --- a/testcases/network/tcp_cmds/rlogin/rlogin01
> +++ b/testcases/network/tcp_cmds/rlogin/rlogin01
> @@ -1,5 +1,4 @@
> -#! /usr/bin/expect -f
> -#*********************************************************************
> +#!/bin/sh
>   #   Copyright (c) International Business Machines  Corp., 2000
>   #
>   #   This program is free software;  you can redistribute it and/or modify
> @@ -16,87 +15,91 @@
>   #   along with this program;  if not, write to the Free Software
>   #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   #
> -#
> -#
> -#  FILE   : rlogin
> -#
> -#  PURPOSE: Tests the basic functionality of `rlogin`.
> -#
>   #  SETUP: The program `/usr/bin/expect' MUST be installed.
>   #         The home directory of root on the machine exported as "RHOST"
>   #         should have a ".rhosts" file with the hostname of the machine
>   #         where the test is executed, OR the "PASSWD" section below MUST
>   #	  be uncommented and set.
>   #
> -#  HISTORY:
>   #    03/01 Robbie Williamson (robbiew@us.ibm.com)
> -#      -Ported
>   #
> -#
> -# rlogin perform a rlogin session to each host in HOST_LIST with user
> -#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
> -#    verify that the rlogin was established.
> -#
> -#*********************************************************************
>   
> -set TC rlogin
> -set TCtmp "/tmp"
> -set SLEEPTIME 3
> -set TESTLOG "$TCtmp"
> +TCID="rlogin01"
> +TST_TOTAL=1
> +. test.sh
> +
> +setup()
> +{
> +	if [ -z $RUSER ]; then
> +		RUSER=root
> +	fi
> +
> +	if [ -z $PASSWD ]; then
> +		tst_brkm TCONF "Please set PASSWD for $RUSER."
> +	fi
>   

What about password-less configuration, do we really need to exit with 
TCONF in that case?

> -if [info exists env(RUSER)] {
> -   set RUSER $env(RUSER)
> -} else {
> -   set RUSER root
> +	if [ -z $RHOST ]; then
> +		tst_brkm TCONF "Please set RHOST."
> +	fi
> +
> +	if [ -z $LOOPCOUNT ]; then
> +		LOOPCOUNT=25
> +	fi
>   }
>   
> -set RHOST $env(RHOST)
> -set timeout 10
> +do_test()
> +{
> +	tst_resm TINFO "Starting"
>   
> -if [info exists env(LOOPCOUNT)] {
> -   set LOOPCOUNT $env(LOOPCOUNT)
> -} else {
> -   set LOOPCOUNT 25
> +	for i in $(seq 1 ${LOOPCOUNT})
> +	do
> +		rlogin_test || return 1
> +	done
>   }
>   
> -# stty echo
> -send_user " Starting\n"
> -
> -set count 0
> -while {$count < $LOOPCOUNT} {
> -   set count [expr $count+1]
> -      send_user "Host: $RHOST\n"
> -
> -      # rlogin to the host
> -      spawn rlogin $RHOST -l $RUSER
> -
> -      # Uncomment code below and add root's passwd if .rhosts file is not
> -      # present on remote host.
> -      #---------------------------------
> -      #set PASSWD "<ROOT PASSWORD HERE>"
> -      #expect -re "Password:"
> -      #send "$PASSWD\r"
> -
> -      # Wait for shell prompt
> -      expect -re "$RUSER@"
> -
> -      # Run passwd command - and respond to its prompts
> -      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$RHOST \r"
> -      # When shell prompt comes back, logout
> -
> -      expect -re "$RUSER@"
> -      exp_send "logout\r"
> -
> -      send_user "CHECKING RLOGIN STATUS\n"
> -      set nummatch [exec rsh -n -l $RUSER $RHOST "cat $TESTLOG/$RUSER.$RHOST|grep -c 9"]
> -      if {$nummatch==1} {
> -         send_user "$TC interactive Test Successful in LOOP $count\r"
> -         exec rsh -n -l $RUSER $RHOST "rm -f $TESTLOG/$RUSER.$RHOST"
> -      } else {
> -         send_user "$TC interactive session FAILED\r"
> -         exit 1
> -      }
> +rlogin_test()
> +{
> +	expect -c "
> +		spawn rlogin $RHOST -l $RUSER
> +
> +		expect {
> +			\"Password:\" {
> +				send \"$PASSWD\r\"
> +				expect -re \"$RUSER@\"
> +				send \"LC_ALL=C ls -l /etc/hosts | \\
> +				       wc -w > $RUSER.$RHOST\r\"
> +			}
> +			\"$RUSER@\" {
> +				send \"LC_ALL=C ls -l /etc/hosts | \\
> +				       wc -w > $RUSER.$RHOST\r\"
> +			}
> +		}
> +
> +		expect -re \"$RUSER@\"
> +		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST\r\"
> +
> +		expect -re \"$RUSER@\"
> +		exp_send \"logout\r\"
> +
> +		send_user \"CHECKING RLOGIN STATUS\n\";
> +
> +		set nummatch [exec rsh -n -l $RUSER $RHOST \\
> +			      \"grep -c 9 $RUSER.$RHOST\"]
> +		if {\$nummatch==1} {
> +			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
> +		} else {
> +			exit 1
> +		}
> +	"
>   }

The same comments as in 'telnet' patch

>   
> -send_user "\nTest PASSES\n\n"
> -exit 0
> +setup
> +
> +do_test
> +if [ $? -ne 0 ]; then
> +	tst_resm TFAIL "Test $TCID failed."
> +else
> +	tst_resm TPASS "Test $TCID successed."
                                                          ^
                                                   succeeded

> +fi
> +
> +tst_exit

Thanks,
Alexey

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup
  2015-01-21  5:28     ` [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup Zeng Linggang
@ 2015-01-26 18:37       ` Alexey Kodanev
  2015-01-27  9:16         ` Zeng Linggang
  0 siblings, 1 reply; 23+ messages in thread
From: Alexey Kodanev @ 2015-01-26 18:37 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
On 01/21/2015 08:28 AM, Zeng Linggang wrote:
> * Use 'test.sh'.
> * Use 'tst_*' which defined in 'test.sh'.
> * Delete some useless comment.
> * Delete 'RC' and 'TFAILCNT'.
> * Some cleanup.
>
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
>   testcases/network/iptables/iptables_tests.sh | 675 +++++++++------------------
>   1 file changed, 224 insertions(+), 451 deletions(-)
>
> diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
> index 77ee29b..66e98bd 100755
> --- a/testcases/network/iptables/iptables_tests.sh
> +++ b/testcases/network/iptables/iptables_tests.sh
> @@ -14,576 +14,349 @@
>   ## for more details.                                                          ##
>   ##                                                                            ##
>   ## You should have received a copy of the GNU General Public License          ##
> -## along with this program;  if not, write to the Free Software               ##
> -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
> +## along with this program;  if not, write to the Free Software Foundation,   ##
> +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
>   ##                                                                            ##
>   ################################################################################
> -#
> -# File :        iptables_tests.sh
> -#
> -# Description:  Test basic functionality of iptables (firewall administration)
> -#		- Test #1:  iptables -L -t <table> will list all rules in the
> -#		  selected table.
> -#		- Test #2:  Test iptables DROP packets from particular IP.
> -#		- Test #3:  Test iptables REJECT ping request.
> -#		- Test #4:  Test iptables log packets to single port.
> -#		- Test #5:  Test iptables log packets to multiple ports.
> -#		- Test #6:  Test limit matched logging for ping request.
> -#
> -#
> -# History:
> -#		Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com or hubertNOSPAAAM@symbio.com.tw>
> -#		  - Ported test01, test02 from Manoj Iyer's ipchains_tests.sh
> -#		  - Added test03, test04, test05, test06
> -#
> -# Function:	init
> -#
> -# Description:	- Check if command iptables is available.
> -# Description:	- Check if iptables kernel support is available.
> -#               - Initialize environment variables.
> -#
> -# Return	- zero on success
> -#               - non zero on failure. return value from commands ($RC)
> -init()
> -{
> +#  Author:	Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com>
> +#				       <hubertNOSPAAAM@symbio.com.tw>
>   
> -	export RC=0			# Return code from commands.
> -	export TST_TOTAL=6		# total numner of tests in this file.
> -	export TCID="iptables"		# Test case identifier
> -	export TST_COUNT=0		# init identifier
> -
> -	if [ -z $TMP ]; then
> -		LTPTMP=/tmp
> -	else
> -		LTPTMP=$TMP
> -	fi
> +export TCID="iptables"
> +export TST_TOTAL=6
>   
> -	# Initialize cleanup function.
> -	trap "cleanup" 0
> +. test.sh
>   
> -	which tst_resm  > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_brkm TBROK \
> -			"Test INIT: USCTEST commands not found, set PATH correctly."
> -		return $RC
> -	fi
> +init()
> +{
> +	tst_tmpdir
>   
>   	tst_resm TINFO "INIT: Inititalizing tests."
> -	which iptables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
> -			"Test INIT: iptables command does not exist. Reason:"
> -		return $RC
> -	fi
>   
> -	modprobe ip_tables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		RC=0
> -		iptables -L > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -		if [ $RC -ne 0 ]; then
> -			tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
> -				"Test INIT: no iptables support in kenrel. Reason:"
> -			return $RC
> +	modprobe ip_tables > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		iptables -L > tst_iptables.out 2>&1
> +		if [ $? -ne 0 ]; then
> +			tst_brkm TBROK "no iptables support in kenrel."
>   		fi
>   	fi

May be I missed something, but why we need to send output to the file, 
then, in case of errors, rewrite it with "iptables -L" command?


>   
>   	tst_resm TINFO "INIT: Flushing all rules."
> -	iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	return $RC
> +	iptables -F -t filter > tst_iptables.out 2>&1
> +	iptables -F -t nat > tst_iptables.out 2>&1
> +	iptables -F -t mangle > tst_iptables.out 2>&1
>   }
>   
> -
> -# Function:	cleanup
> -#
> -# Description	- remove temporary files and directories.
> -#
> -# Return	- zero on success
> -#               - non zero on failure. return value from commands ($RC)
>   cleanup()
>   {
> -	TCID=iptables
> -	TST_COUNT=0
> -	RC=0
> -
> -	lsmod | grep "ip_tables" > $LTPTMP/tst_iptables.out 2>&1 || RC=0
> -	if [ $RC -eq 0 ]; then
> -		iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1
> -		iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1
> -		iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1
> -		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT iptable_mangle iptable_nat ip_conntrack iptable_filter ip_tables > $LTPTMP/tst_iptables.out 2>&1
> +	lsmod | grep "ip_tables" > tst_iptables.out 2>&1
> +	if [ $? -eq 0 ]; then
> +		iptables -F -t filter > tst_iptables.out 2>&1
> +		iptables -F -t nat > tst_iptables.out 2>&1
> +		iptables -F -t mangle > tst_iptables.out 2>&1
> +		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
> +			 iptable_mangle iptable_nat ip_conntrack \
> +			 iptable_filter ip_tables > tst_iptables.out 2>&1
>   	fi
> -	rm -fr $LTPTMP/tst_iptables.*
> -	return $RC
> +	tst_rmdir

And here, writing output to the file, then removing tmp dir.

>   }
>   
> -
> -# Function:	test01
> -#
> -# Description	- Test basic functionality of iptables (firewall administration)
> -#               - Test #1:  iptables -L -t <table> will list all rules in the
> -#                 selected table.
> -#
> -# Return	- zero on success
> -#               - non zero on failure. return value from commands ($RC)
> -
>   test01()
>   {
> -	RC=0			# Return value from commands.
> -	TCID=iptables01		# Name of the test case.
> -	TST_COUNT=1		# Test number.
> -
> -	local chaincnt=0	# chain counter
> +	local chaincnt=0
>   
>   	local cmd="iptables -L -t filter"
> -	tst_resm TINFO \
> -		"$TCID: $cmd will list all rules in table filter."
> -	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: $cmd failed to list rules. Reason:"
> -		return $RC
> +	tst_resm TINFO "$cmd will list all rules in table filter."
> +	$cmd > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "$cmd failed to list rules."
> +		return
>   	else
> -		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
> +		chaincnt=$(grep -c Chain tst_iptables.out)
>   		if [ $chaincnt -lt 3 ]; then
> -			tst_res TFAIL $LTPTMP/tst_iptables.out \
> -				"$TCID: $cmd failed to list rules. Reason:"
> -			return $chaincnt
> +			tst_resm TFAIL "$cmd failed to list rules."
> +			return
>   		else
> -			tst_resm TINFO "$TCID: $cmd lists rules."
> +			tst_resm TINFO "$cmd lists rules."
>   		fi
>   	fi
>   
>   	local cmd="iptables -L -t nat"
> -	tst_resm TINFO \
> -		"$TCID: $cmd will list all rules in table nat."
> -	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: $cmd failed to list rules. Reason:"
> -		return $RC
> +	tst_resm TINFO "$cmd will list all rules in table nat."
> +	$cmd > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "$cmd failed to list rules."
> +		return
>   	else
> -		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
> +		chaincnt=$(grep -c Chain tst_iptables.out)
>   		if [ $chaincnt -ne 3 ] && [ $chaincnt -ne 4 ]; then
> -			tst_res TFAIL $LTPTMP/tst_iptables.out \
> -				"$TCID: $cmd failed to list rules. Reason:"
> -			return $chaincnt
> +			tst_resm TFAIL "$cmd failed to list rules."
> +			return
>   		else
> -			tst_resm TINFO "$TCID: $cmd lists rules."
> +			tst_resm TINFO "$cmd lists rules."
>   		fi
>   	fi
>   
>   	local cmd="iptables -L -t mangle"
> -	tst_resm TINFO \
> -		"$TCID: $cmd will list all rules in table mangle."
> -	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: $cmd failed to list rules. Reason:"
> -		return $RC
> +	tst_resm TINFO "$cmd will list all rules in table mangle."
> +	$cmd > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "$cmd failed to list rules."
> +		return
>   	else
> -		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
> +		chaincnt=$(grep -c Chain tst_iptables.out)
>   		if [ $chaincnt -ne 5 ]; then
> -			tst_res TFAIL $LTPTMP/tst_iptables.out \
> -				"$TCID: $cmd failed to list rules. Reason:"
> -			return $chaincnt
> +			tst_resm TFAIL "$cmd failed to list rules."
>   		else
> -			tst_resm TINFO "$TCID: $cmd lists rules."
> +			tst_resm TINFO "$cmd lists rules."
>   		fi
>   	fi
>   
> -	tst_resm TPASS "$TCID: iptables -L lists rules."
> -	return $RC
> +	tst_resm TPASS "iptables -L lists rules."
>   }
>   
> -
> -# Function:	test02
> -#
> -# Description	- Test basic functionality of iptables (firewall administration)
> -#               - Test #2:  Test iptables DROP packets from particular IP.
> -#               - Append new rule to block all packets from loopback.
> -#				- ping -c 2 loopback, this should fail.
> -#				- remove rule, and ping -c loopback, this should work.
> -#
> -# Return	- zero on success
> -#               - non zero on failure. return value from commands ($RC)
>   test02()
>   {
> -	RC=0			# Return value from commands.
> -	TCID=iptables02		# Name of the test case.
> -	TST_COUNT=2		# Test number.
> -
> -	tst_resm TINFO \
> -		"$TCID: Use iptables to DROP packets from particular IP"
> -	tst_resm TINFO "$TCID: Rule to block icmp from 127.0.0.1"
> -
> -	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP \
> -		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
> -			"$TCID: iptables command failed to append new rule. Reason:"
> -		return $RC
> +	tst_resm TINFO "Use iptables to DROP packets from particular IP"
> +	tst_resm TINFO "Rule to block icmp from 127.0.0.1"
> +
> +	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables command failed to append new rule."
> +		return
>   	fi

At least, we could print 'tst_iptables.out' if the command failed.

>   
> -	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
> -	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		RC=0
> -		grep "100% packet loss" $LTPTMP/tst_iptables.out \
> -			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
> -		if [ $RC -ne 0 ]; then
> -			tst_res TFAIL $LTPTMP/tst_iptables.out \
> -				"$TCID: iptables did not block packets from loopback"
> -			return $RC
> +	tst_resm TINFO "Pinging 127.0.0.1"
> +	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
> +		if [ $? -ne 0 ]; then
> +			tst_resm TFAIL \
> +				 "iptables did not block packets from loopback"
> +			return
>   		else
> -			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
> +			tst_resm TINFO "Ping 127.0.0.1 not successful."
>   		fi
>   	else
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables did not block icmp from 127.0.0.1"
> -		return $RC
> +		tst_resm TFAIL "iptables did not block icmp from 127.0.0.1"
> +		return
>   	fi
>   
> -	tst_resm TINFO "$TCID: Deleting icmp DROP from 127.0.0.1 rule."
> -	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables did not remove the rule. Reason:"
> -		return $RC
> +	tst_resm TINFO "Deleting icmp DROP from 127.0.0.1 rule."
> +	iptables -D INPUT 1 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables did not remove the rule."
> +		return
>   	fi
> -	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
> -	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables blocking loopback. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
> -		return $RC
> +	tst_resm TINFO "Pinging 127.0.0.1 again"
> +	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables blocking loopback. This is expected" \
> +			       "behaviour on certain distributions where" \
> +			       "enabling firewall drops all packets by default."
> +		return
>   	else
> -		tst_resm TINFO "$TCID: Ping succsess"
> -		tst_resm TPASS "$TCID: iptables can DROP packets from particular IP."
> +		tst_resm TINFO "Ping succsess"
> +		tst_resm TPASS "iptables can DROP packets from particular IP."
>   	fi
> -
> -	return $RC
>   }
>   
> -
> -# Function:	test03
> -#
> -# Description	- Test basic functionality of iptables (firewall administration)
> -#               - Test #3:  Test iptables REJECT ping request.
> -#               - Append new rule to block all packets from loopback.
> -#				- ping -c 2 loopback, this should fail.
> -#				- remove rule, and ping -c loopback, this should work.
> -#
> -# Return	- zero on success
> -#               - non zero on failure. return value from commands ($RC)
>   test03()
>   {
> -	RC=0			# Return value from commands.
> -	TCID=iptables03		# Name of the test case.
> -	TST_COUNT=3		# Test number.
> -
> -	tst_resm TINFO \
> -		"$TCID: Use iptables to REJECT ping request."
> -	tst_resm TINFO "$TCID: Rule to reject ping request."
> -
> -	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j REJECT \
> -		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
> -			"$TCID: iptables command failed to append new rule. Reason:"
> -		return $RC
> +	tst_resm TINFO "Use iptables to REJECT ping request."
> +	tst_resm TINFO "Rule to reject ping request."
> +
> +	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j \
> +		 REJECT > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables command failed to append new rule."
> +		return
>   	fi
>   
> -	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
> -	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		RC=0
> -		grep "100% packet loss" $LTPTMP/tst_iptables.out \
> -			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
> -		if [ $RC -ne 0 ]; then
> -			tst_res TFAIL $LTPTMP/tst_iptables.out \
> -				"$TCID: iptables did not block ping request."
> -			return $RC
> +	tst_resm TINFO "Pinging 127.0.0.1"
> +	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1

The same with tst_iptables.err file.

> +		if [ $? -ne 0 ]; then
> +			tst_resm TFAIL "iptables did not block ping request."
> +			return
>   		else
> -			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
> +			tst_resm TINFO "Ping 127.0.0.1 not successful."
>   		fi
>   	else
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables did not reject ping request."
> -		return $RC
> +		tst_resm TFAIL "iptables did not reject ping request."
> +		return
>   	fi
>   
> -	tst_resm TINFO "$TCID: Deleting icmp request REJECT rule."
> -	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables did not remove the rule. Reason:"
> -		return $RC
> +	tst_resm TINFO "Deleting icmp request REJECT rule."
> +	iptables -D INPUT 1 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables did not remove the rule."
> +		return
>   	fi
> -	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
> -	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables blocking ping requests. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
> -		return $RC
> +	tst_resm TINFO "Pinging 127.0.0.1 again"
> +	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables blocking ping requests. This is" \
> +			       "expected behaviour on certain distributions" \
> +			       "where enabling firewall drops all packets by" \
> +			       "default."
> +		return
>   	else
> -		tst_resm TINFO "$TCID: Ping succsess"
> -		tst_resm TPASS "$TCID: iptables can REJECT ping requests."
> +		tst_resm TINFO "Ping succsess"
> +		tst_resm TPASS "iptables can REJECT ping requests."
>   	fi
> -
> -	return $RC
>   }
>   
> -
> -# Function:	test04
> -#
> -# Description	- Test basic functionality of iptables (firewall administration)
> -#               - Test #4:  Test iptables log packets to single port
> -#               - Append new rule to log tcp packets to localhost:45886
> -#		- telnet localhost 45886, this should be logged.
> -#		- remove rule.
> -#
> -# Return	- zero on success
> -#               - non zero on failure. return value from commands ($RC)
>   test04()
>   {
> -	RC=0			# Return value from commands.
> -	TCID=iptables04		# Name of the test case.
> -	TST_COUNT=4		# Test number.
> -	local dport=45886				# destination port
> -	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
> -
> -	tst_resm TINFO \
> -		"$TCID: Use iptables to log packets to particular port."
> -	tst_resm TINFO "$TCID: Rule to log tcp packets to particular port."
> -
> -	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG --log-prefix "$logprefix" \
> -		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
> -			"$TCID: iptables command failed to append new rule. Reason:"
> -		return $RC
> +	local dport=45886
> +	local logprefix="$TCID-$(date +%m%d%H%M%S):"
> +
> +	tst_resm TINFO "Use iptables to log packets to particular port."
> +	tst_resm TINFO "Rule to log tcp packets to particular port."
> +
> +	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG \
> +		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables command failed to append new rule."
> +		return
>   	fi
>   
> -	tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
> -	telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		RC=0
> +	tst_resm TINFO "telnet 127.0.0.1 $dport"
> +	telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
>   		sleep 2
> -		dmesg | grep "$logprefix" \
> -			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
> -		if [ $RC -ne 0 ]; then
> -			tst_res TFAIL $LTPTMP/tst_iptables.out \
> -				"$TCID: iptables did not log packets to port $dport"
> -			return $RC
> +		dmesg | grep "$logprefix" > tst_iptables.err 2>&1
> +		if [ $? -ne 0 ]; then
> +			tst_resm TFAIL \
> +				 "iptables did not log packets to port $dport"
> +			return
>   		else
> -			tst_resm TINFO "$TCID: Packets to port $dport logged."
> +			tst_resm TINFO "Packets to port $dport logged."
>   		fi
>   	else
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: telnet to 127.0.0.1 $dport should fail."
> -		return $RC
> +		tst_resm TFAIL "telnet to 127.0.0.1 $dport should fail."
> +		return
>   	fi
>   
> -	tst_resm TINFO "$TCID: Deleting the rule to log."
> -	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables did not remove the rule. Reason:"
> -		return $RC
> +	tst_resm TINFO "Deleting the rule to log."
> +	iptables -D INPUT 1 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables did not remove the rule."
> +		return
>   	else
> -		tst_resm TINFO "$TCID: iptables logging succsess"
> -		tst_resm TPASS "$TCID: iptables can log packets to particular port."
> +		tst_resm TINFO "iptables logging succsess"
> +		tst_resm TPASS "iptables can log packets to particular port."
>   	fi
> -
> -	return $RC
>   }
>   
> -
> -# Function:	test05
> -#
> -# Description	- Test basic functionality of iptables (firewall administration)
> -#               - Test #5:  Test iptables log packets to multiple ports
> -#               - Append new rule to log tcp packets to localhost port 45801 - 45803
> -#               - Append new rule to log tcp packets to localhost port 45804 - 45806 (ipt_multiport introduced)
> -#		- telnet localhost port 45801 - 45806, this should be logged.
> -#		- flush rules.
> -#
> -# Return	- zero on success
> -#               - non zero on failure. return value from commands ($RC)
>   test05()
>   {
> -	RC=0			# Return value from commands.
> -	TCID=iptables05		# Name of the test case.
> -	TST_COUNT=5		# Test number.
> -	local dport=0					# destination port
> -	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
> -
> -	tst_resm TINFO \
> -		"$TCID: Use iptables to log packets to multiple ports."
> -	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45801 - 45803."
> -	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG --log-prefix "$logprefix" \
> -		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
> -			"$TCID: iptables command failed to append new rule. Reason:"
> -		return $RC
> +	local dport=0
> +	local logprefix="$TCID-$(date +%m%d%H%M%S):"
> +
> +	tst_resm TINFO "Use iptables to log packets to multiple ports."
> +	tst_resm TINFO "Rule to log tcp packets to port 45801 - 45803."
> +	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG \
> +		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables command failed to append new rule."
> +		return
>   	fi
>   
> -	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45804 - 45806."
> -	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
> -		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
> -			"$TCID: iptables command failed to append new rule. Reason:"
> -		return $RC
> +	tst_resm TINFO "Rule to log tcp packets to port 45804 - 45806."
> +	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports \
> +		 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
> +		 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables command failed to append new rule."
> +		return
>   	fi
>   
>   	for dport in 45801 45802 45803 45804 45805 45806; do
> -		tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
> -		telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -		if [ $RC -ne 0 ]; then
> -			RC=0
> +		tst_resm TINFO "telnet 127.0.0.1 $dport"
> +		telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
> +		if [ $? -ne 0 ]; then
>   			sleep 2
>   			dmesg | grep "$logprefix" | grep "=$dport " \
> -				> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
> -			if [ $RC -ne 0 ]; then
> -				tst_res TFAIL $LTPTMP/tst_iptables.out \
> -					"$TCID: iptables did not log packets to port $dport"
> -				return $RC
> +				> tst_iptables.err 2>&1
> +			if [ $? -ne 0 ]; then
> +				tst_resm TFAIL "iptables did not log packets" \
> +					       "to port $dport"
> +				return
>   			else
> -				tst_resm TINFO "$TCID: Packets to port $dport logged."
> +				tst_resm TINFO "Packets to port $dport logged."
>   			fi
>   		else
> -			tst_res TFAIL $LTPTMP/tst_iptables.out \
> -				"$TCID: telnet to 127.0.0.1 $dport should fail."
> -			return $RC
> +			tst_res TFAIL "telnet to 127.0.0.1 $dport should fail."
> +			return
>   		fi
>   	done
>   
> -	tst_resm TINFO "$TCID: Flushing all rules."
> -	iptables -F > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables did not flush all rules. Reason:"
> -		return $RC
> +	tst_resm TINFO "Flushing all rules."
> +	iptables -F > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables did not flush all rules."
> +		return
>   	else
> -		tst_resm TINFO "$TCID: iptables logging succsess"
> -		tst_resm TPASS "$TCID: iptables can log packets to multiple ports."
> +		tst_resm TINFO "iptables logging succsess"
> +		tst_resm TPASS "iptables can log packets to multiple ports."
>   	fi

You don't need "else .. fi" block because you return in the first one.

> -
> -	return $RC
>   }
>   
> -
> -# Function:	test06
> -#
> -# Description	- Test basic functionality of iptables (firewall administration)
> -#               - Test #6:  Test limit matched logging for ping request.
> -#               - Append new rule to log ping request with rate of 3/hour, burst 5
> -#		- ping localhost 10 times, only the first 5 will be logged.
> -#		- remove rule.
> -#
> -# Return	- zero on success
> -#               - non zero on failure. return value from commands ($RC)
>   test06()
>   {
> -	RC=0			# Return value from commands.
> -	TCID=iptables06		# Name of the test case.
> -	TST_COUNT=6		# Test number.
> -	local logcnt=0		# log counter
> -	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
> -
> -	tst_resm TINFO \
> -		"$TCID: Use iptables to log ping request with limited rate."
> -	tst_resm TINFO "$TCID: Rule to log ping request."
> -
> -	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m limit -j LOG --log-prefix "$logprefix" \
> -		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
> -			"$TCID: iptables command failed to append new rule. Reason:"
> -		return $RC
> +	local logcnt=0
> +	local logprefix="$TCID-$(date +%m%d%H%M%S):"
> +
> +	tst_resm TINFO "Use iptables to log ping request with limited rate."
> +	tst_resm TINFO "Rule to log ping request."
> +
> +	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m \
> +		 limit -j LOG --log-prefix "$logprefix" > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables command failed to append new rule."
> +		return
>   	fi
>   
> -	tst_resm TINFO "$TCID: ping 127.0.0.1"
> -	ping -c 10 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -eq 0 ]; then
> -		RC=0
> +	tst_resm TINFO "ping 127.0.0.1"
> +	ping -c 10 127.0.0.1 > tst_iptables.out 2>&1
> +	if [ $? -eq 0 ]; then
>   		sleep 2
>   		logcnt=$(dmesg | grep -c "$logprefix")
>   		if [ $logcnt -ne 5 ]; then
> -			tst_res TFAIL $LTPTMP/tst_iptables.out \
> -				"$TCID: iptables did not log packets with limited rate."
> -			return $logcnt
> +			tst_resm TFAIL "iptables did not log packets with" \
> +				       "limited rate."
> +			return
>   		else
> -			tst_resm TINFO "$TCID: ping requests logged with limited rate."
> +			tst_resm TINFO "ping requests logged with limited rate."
>   		fi
>   	else
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: ping to 127.0.0.1 failed. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
> -		return $RC
> +		tst_resm TFAIL "ping to 127.0.0.1 failed. This is expected" \
> +			       "behaviour on certain distributions where" \
> +			       "enabling firewall drops all packets by default."
> +		return
>   	fi
>   
> -	tst_resm TINFO "$TCID: Deleting the rule to log."
> -	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
> -	if [ $RC -ne 0 ]; then
> -		tst_res TFAIL $LTPTMP/tst_iptables.out \
> -			"$TCID: iptables did not remove the rule. Reason:"
> -		return $RC
> +	tst_resm TINFO "Deleting the rule to log."
> +	iptables -D INPUT 1 > tst_iptables.out 2>&1
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "iptables did not remove the rule."
> +		return
>   	else
> -		tst_resm TINFO "$TCID: iptables limited logging succsess"
> -		tst_resm TPASS "$TCID: iptables can log packets with limited rate."
> +		tst_resm TINFO "iptables limited logging succsess"
> +		tst_resm TPASS "iptables can log packets with limited rate."
>   	fi
> -
> -	return $RC
>   }
>   
> -# Function:	main
> -#
> -# Description:	- Execute all tests, report results.
> -#
> -# 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 # Exit if initializing testcases fails.
> -
> -test01 || RC=$?
> -if [ $RC -ne 0 ]; then
> -	TFAILCNT=$(($TFAILCNT+1))
> -fi
> -
> -RC=0		# Return code from test.
> -test02 || RC=$?
> -if [ $RC -ne 0 ]; then
> -	TFAILCNT=$(($TFAILCNT+1))
> -fi
> -
> -RC=0		# Return code from test.
> -test03 || RC=$?
> -if [ $RC -ne 0 ]; then
> -	TFAILCNT=$(($TFAILCNT+1))
> -fi
> -
> -RC=0		# Return code from test.
> -test04 || RC=$?
> -if [ $RC -ne 0 ]; then
> -	TFAILCNT=$(($TFAILCNT+1))
> -fi
> -
> -RC=0		# Return code from test.
> -test05 || RC=$?
> -if [ $RC -ne 0 ]; then
> -	TFAILCNT=$(($TFAILCNT+1))
> -fi
> -
> -RC=0		# Return code from test.
> -test06 || RC=$?
> -if [ $RC -ne 0 ]; then
> -	TFAILCNT=$(($TFAILCNT+1))
> -fi
> -
> -exit $TFAILCNT
> +init
> +TST_CLEANUP=cleanup
> +
> +test01
> +test02
> +test03
> +test04
> +test05
> +test06
> +
> +tst_exit

Thanks,
Alexey



------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 1/3] rlogin: Cleanup
  2015-01-23 11:02     ` [LTP] [PATCH v2 " Alexey Kodanev
@ 2015-01-27  7:29       ` Zeng Linggang
  0 siblings, 0 replies; 23+ messages in thread
From: Zeng Linggang @ 2015-01-27  7:29 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: ltp-list

Hi!
On Fri, 2015-01-23 at 14:02 +0300, Alexey Kodanev wrote:
> On 21.01.2015 8:28, Zeng Linggang wrote:
> > * Add 'TCID' and 'TST_TOTAL'.
> > * Use 'test.sh'.
> > * Delete some useless comment.
> > * Some cleanup.
> >
> > Signed-off-by: Zeng Linggang<zenglg.jy@cn.fujitsu.com>
...
> > +
> > +	if [ -z $PASSWD ]; then
> > +		tst_brkm TCONF "Please set PASSWD for $RUSER."
> > +	fi
> >   
> 
> What about password-less configuration, do we really need to exit with 
> TCONF in that case?
> 

To be honest, it is really not need to exit. I just want to make the
test as simple as possible. We cannot expect everyone to setup
password-less.

Best regards,
Zeng


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 2/3] telnet: Cleanup
  2015-01-23 11:01       ` Alexey Kodanev
@ 2015-01-27  7:41         ` Zeng Linggang
  2015-01-27 16:19           ` Alexey Kodanev
  0 siblings, 1 reply; 23+ messages in thread
From: Zeng Linggang @ 2015-01-27  7:41 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: ltp-list

Hi!
On Fri, 2015-01-23 at 14:01 +0300, Alexey Kodanev wrote:
> Hi!
> On 21.01.2015 8:28, Zeng Linggang wrote:
> > * Add 'TCID' and 'TST_TOTAL'.
> > * Use 'test.sh'.
> > * Delete some useless comment.
> > * Some cleanup.
> >
> > Signed-off-by: Zeng Linggang<zenglg.jy@cn.fujitsu.com>
> > ---

> > -} else {
> > -   set LOOPCOUNT 25
> > +	if [ -z $LOOPCOUNT ]; then
> > +		LOOTCOUNT=25
>                                             ^
>                                             should be 'P' here
> 

What is the 'P' mean?

> > +	fi
> >   }
> >   
> > -# stty echo
> > -send_user " Starting\n"
> > -
> > -# Do foreach host on command line
> > -set count 0
> > -while {$count < $LOOPCOUNT} {
> > -   set count [expr $count+1]
> > -   foreach HOST $RHOST {
> > -      send_user "Host: $HOST\n"
> > -
> > -      # telnet to the host
> > -      spawn telnet $HOST
> > -      expect -re "login:"
> > -
> > -      send "$RUSER\r"
> > -      expect -re "Password:"
> > +do_test()
> > +{
> > +	tst_resm TINFO "Starting"
> >   
> > -      send "$PASSWD\r"
> > -
> > -      send "PS1=\"$PROMPT\"\r"
> > -      # Wait for shell prompt
> > -      expect "$PROMPT"
> > +	for i in $(seq 1 ${LOOPCOUNT})
> > +	do
> > +		telnet_test || return 1
> > +	done
> > +}
> >   
> > -      # Run passwd command - and respond to its prompts
> > -      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$HOST \r"
> > -      # When shell prompt comes back, logout
> > +telnet_test()
> > +{
> > +	expect -c "
> > +		spawn telnet $RHOST
> > +		expect -re \"login:\"
> > +		send \"$RUSER\r\"
> > +		expect -re \"Password:\"
> > +		send \"$PASSWD\r\"
> > +
> > +		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST \r\"
> > +		expect \"$RUSER@\"
> 
> This part needs some extra checking for failed login, e.g. 'incorrect' 
> password or connection timeout:
> 
> expect -re "incorrect" {
>      exit 1
> } -re "$USERS@"
> 
> 

Good idea. Thanks.

> > +		exp_send \"logout\r\"
> > +
> 
> The below part can be changed to:
>          tst_resm TINFO "checking telnet status"
>          tst_rhost_run -s -c "grep -q 9 $RUSER.$RHOST"
>          tst_rhost_run -c "rm -f $RUSER.$RHOST"
> 
> Note, 'tst_rhost_run' with '-s' option should exit with TBROK if remote 
> command returns non-zero exit status, please find the following patch 
> with the fix:
> 
> [PATCH v2] lib/test_net.sh: fix 'tst_rhost_run -s' when errors occur.
> 

Thank you. I have found the patch.

> > +		send_user \"CHECKING TELNET STATUS\n\"
> > +
> > +		set nummatch [exec rsh -n -l $RUSER $RHOST \\
> > +			      \"grep -c 9 $RUSER.$RHOST\"]
> > +		if {\$nummatch==1} {
> > +			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
> > +		} else {
> > +			exit 1
> > +		}
> > +	"
> > +}
> >   
> > -      expect "$PROMPT"
> > -      exp_send "logout\r"
> > +setup
> >   
> > -      send_user "CHECKING TELNET STATUS\n"
> > -      set nummatch [exec rsh -n -l $RUSER $HOST "cat $TESTLOG/$RUSER.$HOST|grep -c 9"]
> > -      if {$nummatch==1} {
> > -         send_user "$TC interactive Test Successful in LOOP $count\r"
> > -         exec rsh -n -l $RUSER $HOST "rm -f $TESTLOG/$RUSER.$HOST"
> > -      } else {
> > -         send_user "$TC interactive session failed\n"
> > -         exit 1
> > -      }
> > -   }
> > -}
> > +do_test
> > +if [ $? -ne 0 ]; then
> > +	tst_resm TFAIL "Test $TCID failed."
> > +else
> > +	tst_resm TPASS "Test $TCID successed."
> 
> "'succeeded"
> 

Yep.

> > +fi
> >   
> > -send_user "\nTest PASSES\n\n"
> > -exit 0
> > +tst_exit
> 
> Also, there is too much non-standard LTP output, especially if LOOPCOUNT 
> is big. Could we send it to a file and only if there are some errors, 
> print it. Any thoughts?
> 

It is not bad, but we could not sure whether the test is being run when
we wait.

Best regards,
Zeng

> Thanks,
> Alexey
> 



------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup
  2015-01-26 18:37       ` Alexey Kodanev
@ 2015-01-27  9:16         ` Zeng Linggang
  2015-01-27 16:30           ` Alexey Kodanev
  0 siblings, 1 reply; 23+ messages in thread
From: Zeng Linggang @ 2015-01-27  9:16 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: ltp-list

Hi!
On Mon, 2015-01-26 at 21:37 +0300, Alexey Kodanev wrote:
> Hi!
> On 01/21/2015 08:28 AM, Zeng Linggang wrote:
> > * Use 'test.sh'.
> > * Use 'tst_*' which defined in 'test.sh'.
> > * Delete some useless comment.
> > * Delete 'RC' and 'TFAILCNT'.
> > * Some cleanup.
> >
> > Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>

> > +	modprobe ip_tables > tst_iptables.out 2>&1
> > +	if [ $? -ne 0 ]; then
> > +		iptables -L > tst_iptables.out 2>&1
> > +		if [ $? -ne 0 ]; then
> > +			tst_brkm TBROK "no iptables support in kenrel."
> >   		fi
> >   	fi
> 
> May be I missed something, but why we need to send output to the file, 
> then, in case of errors, rewrite it with "iptables -L" command?
> 

The output file is really not necessary here. Maybe it just make our
screen clearer. I think we need more discussion.

> > +	lsmod | grep "ip_tables" > tst_iptables.out 2>&1
> > +	if [ $? -eq 0 ]; then
> > +		iptables -F -t filter > tst_iptables.out 2>&1
> > +		iptables -F -t nat > tst_iptables.out 2>&1
> > +		iptables -F -t mangle > tst_iptables.out 2>&1
> > +		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
> > +			 iptable_mangle iptable_nat ip_conntrack \
> > +			 iptable_filter ip_tables > tst_iptables.out 2>&1
> >   	fi
> > -	rm -fr $LTPTMP/tst_iptables.*
> > -	return $RC
> > +	tst_rmdir
> 
> And here, writing output to the file, then removing tmp dir.
> 

...

> > +	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP > tst_iptables.out 2>&1
> > +	if [ $? -ne 0 ]; then
> > +		tst_resm TFAIL "iptables command failed to append new rule."
> > +		return
> >   	fi
> 
> At least, we could print 'tst_iptables.out' if the command failed.
> 

OK. I will do that.

> > +	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
> > +	if [ $? -ne 0 ]; then
> > +		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
> 
> The same with tst_iptables.err file.
> 

OK.

> > +	iptables -F > tst_iptables.out 2>&1
> > +	if [ $? -ne 0 ]; then
> > +		tst_resm TFAIL "iptables did not flush all rules."
> > +		return
> >   	else
> > -		tst_resm TINFO "$TCID: iptables logging succsess"
> > -		tst_resm TPASS "$TCID: iptables can log packets to multiple ports."
> > +		tst_resm TINFO "iptables logging succsess"
> > +		tst_resm TPASS "iptables can log packets to multiple ports."
> >   	fi
> 
> You don't need "else .. fi" block because you return in the first one.
> 

I think "else ... fi" is necessary when "$? -eq 0".
I should remove the 'return' here.

Best regards,
Zeng


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 2/3] telnet: Cleanup
  2015-01-27  7:41         ` Zeng Linggang
@ 2015-01-27 16:19           ` Alexey Kodanev
  2015-01-28  1:17             ` Zeng Linggang
  0 siblings, 1 reply; 23+ messages in thread
From: Alexey Kodanev @ 2015-01-27 16:19 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
On 01/27/2015 10:41 AM, Zeng Linggang wrote:
> Hi!
> On Fri, 2015-01-23 at 14:01 +0300, Alexey Kodanev wrote:
>> Hi!
>> On 21.01.2015 8:28, Zeng Linggang wrote:
>>> * Add 'TCID' and 'TST_TOTAL'.
>>> * Use 'test.sh'.
>>> * Delete some useless comment.
>>> * Some cleanup.
>>>
>>> Signed-off-by: Zeng Linggang<zenglg.jy@cn.fujitsu.com>
>>> ---
>>> -} else {
>>> -   set LOOPCOUNT 25
>>> +	if [ -z $LOOPCOUNT ]; then
>>> +		LOOTCOUNT=25
>>                                              ^
>>                                              should be 'P' here
>>
> What is the 'P' mean?

sorry, pointed to the wrong (empty) place... "LOOPCOUNT=25", not 
"LOOTCOUNT=25"

>>> +	fi
>>>    }
>>>    
>>> -# stty echo
>>> -send_user " Starting\n"
>>> -
>>> -# Do foreach host on command line
>>> -set count 0
>>> -while {$count < $LOOPCOUNT} {
>>> -   set count [expr $count+1]
>>> -   foreach HOST $RHOST {
>>> -      send_user "Host: $HOST\n"
>>> -
>>> -      # telnet to the host
>>> -      spawn telnet $HOST
>>> -      expect -re "login:"
>>> -
>>> -      send "$RUSER\r"
>>> -      expect -re "Password:"
>>> +do_test()
>>> +{
>>> +	tst_resm TINFO "Starting"
>>>    
>>> -      send "$PASSWD\r"
>>> -
>>> -      send "PS1=\"$PROMPT\"\r"
>>> -      # Wait for shell prompt
>>> -      expect "$PROMPT"
>>> +	for i in $(seq 1 ${LOOPCOUNT})
>>> +	do
>>> +		telnet_test || return 1
>>> +	done
>>> +}
>>>    
>>> -      # Run passwd command - and respond to its prompts
>>> -      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$HOST \r"
>>> -      # When shell prompt comes back, logout
>>> +telnet_test()
>>> +{
>>> +	expect -c "
>>> +		spawn telnet $RHOST
>>> +		expect -re \"login:\"
>>> +		send \"$RUSER\r\"
>>> +		expect -re \"Password:\"
>>> +		send \"$PASSWD\r\"
>>> +
>>> +		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST \r\"
>>> +		expect \"$RUSER@\"
>> This part needs some extra checking for failed login, e.g. 'incorrect'
>> password or connection timeout:
>>
>> expect -re "incorrect" {
>>       exit 1
>> } -re "$USERS@"
>>
>>
> Good idea. Thanks.
>
>>> +		exp_send \"logout\r\"
>>> +
>> The below part can be changed to:
>>           tst_resm TINFO "checking telnet status"
>>           tst_rhost_run -s -c "grep -q 9 $RUSER.$RHOST"
>>           tst_rhost_run -c "rm -f $RUSER.$RHOST"
>>
>> Note, 'tst_rhost_run' with '-s' option should exit with TBROK if remote
>> command returns non-zero exit status, please find the following patch
>> with the fix:
>>
>> [PATCH v2] lib/test_net.sh: fix 'tst_rhost_run -s' when errors occur.
>>
> Thank you. I have found the patch.
>
>>> +		send_user \"CHECKING TELNET STATUS\n\"
>>> +
>>> +		set nummatch [exec rsh -n -l $RUSER $RHOST \\
>>> +			      \"grep -c 9 $RUSER.$RHOST\"]
>>> +		if {\$nummatch==1} {
>>> +			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
>>> +		} else {
>>> +			exit 1
>>> +		}
>>> +	"
>>> +}
>>>    
>>> -      expect "$PROMPT"
>>> -      exp_send "logout\r"
>>> +setup
>>>    
>>> -      send_user "CHECKING TELNET STATUS\n"
>>> -      set nummatch [exec rsh -n -l $RUSER $HOST "cat $TESTLOG/$RUSER.$HOST|grep -c 9"]
>>> -      if {$nummatch==1} {
>>> -         send_user "$TC interactive Test Successful in LOOP $count\r"
>>> -         exec rsh -n -l $RUSER $HOST "rm -f $TESTLOG/$RUSER.$HOST"
>>> -      } else {
>>> -         send_user "$TC interactive session failed\n"
>>> -         exit 1
>>> -      }
>>> -   }
>>> -}
>>> +do_test
>>> +if [ $? -ne 0 ]; then
>>> +	tst_resm TFAIL "Test $TCID failed."
>>> +else
>>> +	tst_resm TPASS "Test $TCID successed."
>> "'succeeded"
>>
> Yep.
>
>>> +fi
>>>    
>>> -send_user "\nTest PASSES\n\n"
>>> -exit 0
>>> +tst_exit
>> Also, there is too much non-standard LTP output, especially if LOOPCOUNT
>> is big. Could we send it to a file and only if there are some errors,
>> print it. Any thoughts?
>>
> It is not bad, but we could not sure whether the test is being run when
> we wait.

For example, it could be the below messages on each step or something 
more informative.

tst_resm TINFO "login with telnet, step $i"

expect ...

tst_resm TINFO "checking telnet status"
...

Best regards,
Alexey

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup
  2015-01-27  9:16         ` Zeng Linggang
@ 2015-01-27 16:30           ` Alexey Kodanev
  2015-01-28  1:19             ` Zeng Linggang
  0 siblings, 1 reply; 23+ messages in thread
From: Alexey Kodanev @ 2015-01-27 16:30 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

On 01/27/2015 12:16 PM, Zeng Linggang wrote:
> Hi!
> On Mon, 2015-01-26 at 21:37 +0300, Alexey Kodanev wrote:
>> Hi!
>> On 01/21/2015 08:28 AM, Zeng Linggang wrote:
>>> * Use 'test.sh'.
>>> * Use 'tst_*' which defined in 'test.sh'.
>>> * Delete some useless comment.
>>> * Delete 'RC' and 'TFAILCNT'.
>>> * Some cleanup.
>>>
>>> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
>>> +	modprobe ip_tables > tst_iptables.out 2>&1
>>> +	if [ $? -ne 0 ]; then
>>> +		iptables -L > tst_iptables.out 2>&1
>>> +		if [ $? -ne 0 ]; then
>>> +			tst_brkm TBROK "no iptables support in kenrel."
>>>    		fi
>>>    	fi
>> May be I missed something, but why we need to send output to the file,
>> then, in case of errors, rewrite it with "iptables -L" command?
>>
> The output file is really not necessary here. Maybe it just make our
> screen clearer. I think we need more discussion.
>
>>> +	lsmod | grep "ip_tables" > tst_iptables.out 2>&1
>>> +	if [ $? -eq 0 ]; then
>>> +		iptables -F -t filter > tst_iptables.out 2>&1
>>> +		iptables -F -t nat > tst_iptables.out 2>&1
>>> +		iptables -F -t mangle > tst_iptables.out 2>&1
>>> +		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
>>> +			 iptable_mangle iptable_nat ip_conntrack \
>>> +			 iptable_filter ip_tables > tst_iptables.out 2>&1
>>>    	fi
>>> -	rm -fr $LTPTMP/tst_iptables.*
>>> -	return $RC
>>> +	tst_rmdir
>> And here, writing output to the file, then removing tmp dir.
>>
> ...
>
>>> +	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP > tst_iptables.out 2>&1
>>> +	if [ $? -ne 0 ]; then
>>> +		tst_resm TFAIL "iptables command failed to append new rule."
>>> +		return
>>>    	fi
>> At least, we could print 'tst_iptables.out' if the command failed.
>>
> OK. I will do that.
>
>>> +	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
>>> +	if [ $? -ne 0 ]; then
>>> +		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
>> The same with tst_iptables.err file.
>>
> OK.
>
>>> +	iptables -F > tst_iptables.out 2>&1
>>> +	if [ $? -ne 0 ]; then
>>> +		tst_resm TFAIL "iptables did not flush all rules."
>>> +		return
>>>    	else
>>> -		tst_resm TINFO "$TCID: iptables logging succsess"
>>> -		tst_resm TPASS "$TCID: iptables can log packets to multiple ports."
>>> +		tst_resm TINFO "iptables logging succsess"
>>> +		tst_resm TPASS "iptables can log packets to multiple ports."
>>>    	fi
>> You don't need "else .. fi" block because you return in the first one.
>>
> I think "else ... fi" is necessary when "$? -eq 0".
> I should remove the 'return' here.

What I mean here is that you could write TINFO/TPASS messages without 
"else":

if [ $? -ne 0 ]; then
     tst_resm TFAIL "error"
     return
fi

tst_resm TPASS "success"
...


Thanks,
Alexey


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 2/3] telnet: Cleanup
  2015-01-27 16:19           ` Alexey Kodanev
@ 2015-01-28  1:17             ` Zeng Linggang
  0 siblings, 0 replies; 23+ messages in thread
From: Zeng Linggang @ 2015-01-28  1:17 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: ltp-list

Hi!
On Tue, 2015-01-27 at 19:19 +0300, Alexey Kodanev wrote:
> Hi!
> On 01/27/2015 10:41 AM, Zeng Linggang wrote:
> > Hi!
> > On Fri, 2015-01-23 at 14:01 +0300, Alexey Kodanev wrote:
> >> Hi!
> >> On 21.01.2015 8:28, Zeng Linggang wrote:
> >>> * Add 'TCID' and 'TST_TOTAL'.
> >>> * Use 'test.sh'.
> >>> * Delete some useless comment.
> >>> * Some cleanup.
> >>>
> >>> Signed-off-by: Zeng Linggang<zenglg.jy@cn.fujitsu.com>
> >>> ---
> >>> -} else {
> >>> -   set LOOPCOUNT 25
> >>> +	if [ -z $LOOPCOUNT ]; then
> >>> +		LOOTCOUNT=25
> >>                                              ^
> >>                                              should be 'P' here
> >>
> > What is the 'P' mean?
> 
> sorry, pointed to the wrong (empty) place... "LOOPCOUNT=25", not 
> "LOOTCOUNT=25"
> 

Yep. Thank you very much.

> >>> +	fi
> >>>    }
> >>>    
> >>> -# stty echo
> >>> -send_user " Starting\n"
> >>> -
> >>> -# Do foreach host on command line
> >>> -set count 0
> >>> -while {$count < $LOOPCOUNT} {
> >>> -   set count [expr $count+1]
> >>> -   foreach HOST $RHOST {
> >>> -      send_user "Host: $HOST\n"
> >>> -
> >>> -      # telnet to the host
> >>> -      spawn telnet $HOST
> >>> -      expect -re "login:"
> >>> -
> >>> -      send "$RUSER\r"
> >>> -      expect -re "Password:"
> >>> +do_test()
> >>> +{
> >>> +	tst_resm TINFO "Starting"
> >>>    
> >>> -      send "$PASSWD\r"
> >>> -
> >>> -      send "PS1=\"$PROMPT\"\r"
> >>> -      # Wait for shell prompt
> >>> -      expect "$PROMPT"
> >>> +	for i in $(seq 1 ${LOOPCOUNT})
> >>> +	do
> >>> +		telnet_test || return 1
> >>> +	done
> >>> +}
> >>>    
> >>> -      # Run passwd command - and respond to its prompts
> >>> -      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$HOST \r"
> >>> -      # When shell prompt comes back, logout
> >>> +telnet_test()
> >>> +{
> >>> +	expect -c "
> >>> +		spawn telnet $RHOST
> >>> +		expect -re \"login:\"
> >>> +		send \"$RUSER\r\"
> >>> +		expect -re \"Password:\"
> >>> +		send \"$PASSWD\r\"
> >>> +
> >>> +		send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST \r\"
> >>> +		expect \"$RUSER@\"
> >> This part needs some extra checking for failed login, e.g. 'incorrect'
> >> password or connection timeout:
> >>
> >> expect -re "incorrect" {
> >>       exit 1
> >> } -re "$USERS@"
> >>
> >>
> > Good idea. Thanks.
> >
> >>> +		exp_send \"logout\r\"
> >>> +
> >> The below part can be changed to:
> >>           tst_resm TINFO "checking telnet status"
> >>           tst_rhost_run -s -c "grep -q 9 $RUSER.$RHOST"
> >>           tst_rhost_run -c "rm -f $RUSER.$RHOST"
> >>
> >> Note, 'tst_rhost_run' with '-s' option should exit with TBROK if remote
> >> command returns non-zero exit status, please find the following patch
> >> with the fix:
> >>
> >> [PATCH v2] lib/test_net.sh: fix 'tst_rhost_run -s' when errors occur.
> >>
> > Thank you. I have found the patch.
> >
> >>> +		send_user \"CHECKING TELNET STATUS\n\"
> >>> +
> >>> +		set nummatch [exec rsh -n -l $RUSER $RHOST \\
> >>> +			      \"grep -c 9 $RUSER.$RHOST\"]
> >>> +		if {\$nummatch==1} {
> >>> +			exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
> >>> +		} else {
> >>> +			exit 1
> >>> +		}
> >>> +	"
> >>> +}
> >>>    
> >>> -      expect "$PROMPT"
> >>> -      exp_send "logout\r"
> >>> +setup
> >>>    
> >>> -      send_user "CHECKING TELNET STATUS\n"
> >>> -      set nummatch [exec rsh -n -l $RUSER $HOST "cat $TESTLOG/$RUSER.$HOST|grep -c 9"]
> >>> -      if {$nummatch==1} {
> >>> -         send_user "$TC interactive Test Successful in LOOP $count\r"
> >>> -         exec rsh -n -l $RUSER $HOST "rm -f $TESTLOG/$RUSER.$HOST"
> >>> -      } else {
> >>> -         send_user "$TC interactive session failed\n"
> >>> -         exit 1
> >>> -      }
> >>> -   }
> >>> -}
> >>> +do_test
> >>> +if [ $? -ne 0 ]; then
> >>> +	tst_resm TFAIL "Test $TCID failed."
> >>> +else
> >>> +	tst_resm TPASS "Test $TCID successed."
> >> "'succeeded"
> >>
> > Yep.
> >
> >>> +fi
> >>>    
> >>> -send_user "\nTest PASSES\n\n"
> >>> -exit 0
> >>> +tst_exit
> >> Also, there is too much non-standard LTP output, especially if LOOPCOUNT
> >> is big. Could we send it to a file and only if there are some errors,
> >> print it. Any thoughts?
> >>
> > It is not bad, but we could not sure whether the test is being run when
> > we wait.
> 
> For example, it could be the below messages on each step or something 
> more informative.
> 
> tst_resm TINFO "login with telnet, step $i"
> 
> expect ...
> 
> tst_resm TINFO "checking telnet status"
> ...
> 

That's OK.

Best regards,
Zeng

> Best regards,
> Alexey



------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup
  2015-01-27 16:30           ` Alexey Kodanev
@ 2015-01-28  1:19             ` Zeng Linggang
  2015-01-29 10:19               ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Zeng Linggang
  0 siblings, 1 reply; 23+ messages in thread
From: Zeng Linggang @ 2015-01-28  1:19 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: ltp-list

Hi!
On Tue, 2015-01-27 at 19:30 +0300, Alexey Kodanev wrote:
> On 01/27/2015 12:16 PM, Zeng Linggang wrote:
> > Hi!
> > On Mon, 2015-01-26 at 21:37 +0300, Alexey Kodanev wrote:
> >> Hi!
> >> On 01/21/2015 08:28 AM, Zeng Linggang wrote:
> >>> * Use 'test.sh'.
> >>> * Use 'tst_*' which defined in 'test.sh'.
> >>> * Delete some useless comment.
> >>> * Delete 'RC' and 'TFAILCNT'.
> >>> * Some cleanup.
> >>>
> >>> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> >>> +	modprobe ip_tables > tst_iptables.out 2>&1
> >>> +	if [ $? -ne 0 ]; then
> >>> +		iptables -L > tst_iptables.out 2>&1
> >>> +		if [ $? -ne 0 ]; then
> >>> +			tst_brkm TBROK "no iptables support in kenrel."
> >>>    		fi
> >>>    	fi
> >> May be I missed something, but why we need to send output to the file,
> >> then, in case of errors, rewrite it with "iptables -L" command?
> >>
> > The output file is really not necessary here. Maybe it just make our
> > screen clearer. I think we need more discussion.
> >
> >>> +	lsmod | grep "ip_tables" > tst_iptables.out 2>&1
> >>> +	if [ $? -eq 0 ]; then
> >>> +		iptables -F -t filter > tst_iptables.out 2>&1
> >>> +		iptables -F -t nat > tst_iptables.out 2>&1
> >>> +		iptables -F -t mangle > tst_iptables.out 2>&1
> >>> +		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
> >>> +			 iptable_mangle iptable_nat ip_conntrack \
> >>> +			 iptable_filter ip_tables > tst_iptables.out 2>&1
> >>>    	fi
> >>> -	rm -fr $LTPTMP/tst_iptables.*
> >>> -	return $RC
> >>> +	tst_rmdir
> >> And here, writing output to the file, then removing tmp dir.
> >>
> > ...
> >
> >>> +	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP > tst_iptables.out 2>&1
> >>> +	if [ $? -ne 0 ]; then
> >>> +		tst_resm TFAIL "iptables command failed to append new rule."
> >>> +		return
> >>>    	fi
> >> At least, we could print 'tst_iptables.out' if the command failed.
> >>
> > OK. I will do that.
> >
> >>> +	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
> >>> +	if [ $? -ne 0 ]; then
> >>> +		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
> >> The same with tst_iptables.err file.
> >>
> > OK.
> >
> >>> +	iptables -F > tst_iptables.out 2>&1
> >>> +	if [ $? -ne 0 ]; then
> >>> +		tst_resm TFAIL "iptables did not flush all rules."
> >>> +		return
> >>>    	else
> >>> -		tst_resm TINFO "$TCID: iptables logging succsess"
> >>> -		tst_resm TPASS "$TCID: iptables can log packets to multiple ports."
> >>> +		tst_resm TINFO "iptables logging succsess"
> >>> +		tst_resm TPASS "iptables can log packets to multiple ports."
> >>>    	fi
> >> You don't need "else .. fi" block because you return in the first one.
> >>
> > I think "else ... fi" is necessary when "$? -eq 0".
> > I should remove the 'return' here.
> 
> What I mean here is that you could write TINFO/TPASS messages without 
> "else":
> 
> if [ $? -ne 0 ]; then
>      tst_resm TFAIL "error"
>      return
> fi
> 
> tst_resm TPASS "success"
> ...
> 

That's OK.
Thank you very much.

Best regards,
Zeng

> 
> Thanks,
> Alexey
> 



------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v3 1/3] rlogin: Cleanup
  2015-01-28  1:19             ` Zeng Linggang
@ 2015-01-29 10:19               ` Zeng Linggang
  2015-01-29 10:19                 ` [LTP] [PATCH v3 2/3] telnet: Cleanup Zeng Linggang
                                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Zeng Linggang @ 2015-01-29 10:19 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

* Add 'TCID' and 'TST_TOTAL'.
* Use 'test.sh' and 'tst_check_cmds'.
* Use 'test_net.sh'.
* Delete some useless comment.
* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/tcp_cmds/rlogin/rlogin01 | 127 ++++++++++++++---------------
 1 file changed, 63 insertions(+), 64 deletions(-)

diff --git a/testcases/network/tcp_cmds/rlogin/rlogin01 b/testcases/network/tcp_cmds/rlogin/rlogin01
index ae670c9..b564da1 100755
--- a/testcases/network/tcp_cmds/rlogin/rlogin01
+++ b/testcases/network/tcp_cmds/rlogin/rlogin01
@@ -1,5 +1,4 @@
-#! /usr/bin/expect -f
-#*********************************************************************
+#!/bin/sh
 #   Copyright (c) International Business Machines  Corp., 2000
 #
 #   This program is free software;  you can redistribute it and/or modify
@@ -16,87 +15,87 @@
 #   along with this program;  if not, write to the Free Software
 #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 #
-#
-#
-#  FILE   : rlogin
-#
-#  PURPOSE: Tests the basic functionality of `rlogin`.
-#
 #  SETUP: The program `/usr/bin/expect' MUST be installed.
 #         The home directory of root on the machine exported as "RHOST"
 #         should have a ".rhosts" file with the hostname of the machine
 #         where the test is executed, OR the "PASSWD" section below MUST
 #	  be uncommented and set.
 #
-#  HISTORY:
 #    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-# rlogin perform a rlogin session to each host in HOST_LIST with user
-#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
-#    verify that the rlogin was established.
 #
-#*********************************************************************
 
-set TC rlogin
-set TCtmp "/tmp"
-set SLEEPTIME 3
-set TESTLOG "$TCtmp"
+TCID="rlogin01"
+TST_TOTAL=1
+. test.sh
+. test_net.sh
 
-if [info exists env(RUSER)] {
-   set RUSER $env(RUSER)
-} else {
-   set RUSER root
-}
+setup()
+{
+	tst_check_cmds rlogin expect rsh
 
-set RHOST $env(RHOST)
-set timeout 10
+	if [ -z $RUSER ]; then
+		RUSER=root
+	fi
 
-if [info exists env(LOOPCOUNT)] {
-   set LOOPCOUNT $env(LOOPCOUNT)
-} else {
-   set LOOPCOUNT 25
-}
+	if [ -z $PASSWD ]; then
+		tst_brkm TCONF "Please set PASSWD for $RUSER."
+	fi
 
-# stty echo
-send_user " Starting\n"
+	if [ -z $RHOST ]; then
+		tst_brkm TCONF "Please set RHOST."
+	fi
 
-set count 0
-while {$count < $LOOPCOUNT} {
-   set count [expr $count+1]
-      send_user "Host: $RHOST\n"
+	if [ -z $LOOPCOUNT ]; then
+		LOOPCOUNT=25
+	fi
+}
 
-      # rlogin to the host
-      spawn rlogin $RHOST -l $RUSER
+do_test()
+{
+	tst_resm TINFO "Starting"
 
-      # Uncomment code below and add root's passwd if .rhosts file is not
-      # present on remote host.
-      #---------------------------------
-      #set PASSWD "<ROOT PASSWORD HERE>"
-      #expect -re "Password:"
-      #send "$PASSWD\r"
+	for i in $(seq 1 ${LOOPCOUNT})
+	do
+		rlogin_test || return 1
+	done
+}
 
-      # Wait for shell prompt
-      expect -re "$RUSER@"
+rlogin_test()
+{
+	tst_resm TINFO "login with rlogin($i/$LOOPCOUNT)"
 
-      # Run passwd command - and respond to its prompts
-      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$RHOST \r"
-      # When shell prompt comes back, logout
+	expect -c "
+		spawn rlogin $RHOST -l $RUSER
 
-      expect -re "$RUSER@"
-      exp_send "logout\r"
+		expect {
+			\"Password:\" {
+				send \"$PASSWD\r\"; exp_continue
+			} \"incorrect\" {
+				exit 1
+			} \"$RUSER@\" {
+				send \"LC_ALL=C; ls -l /etc/hosts | \\
+				       wc -w > $RUSER.$RHOST\rexit\r\";
+				exp_continue
+			}
+		}
+	" > /dev/null
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
 
-      send_user "CHECKING RLOGIN STATUS\n"
-      set nummatch [exec rsh -n -l $RUSER $RHOST "cat $TESTLOG/$RUSER.$RHOST|grep -c 9"]
-      if {$nummatch==1} {
-         send_user "$TC interactive Test Successful in LOOP $count\r"
-         exec rsh -n -l $RUSER $RHOST "rm -f $TESTLOG/$RUSER.$RHOST"
-      } else {
-         send_user "$TC interactive session FAILED\r"
-         exit 1
-      }
+	tst_resm TINFO "checking telnet status($i/$LOOPCOUNT)"
+	[ $(tst_rhost_run -s -u $RUSER -c "grep -c 9 $RUSER.$RHOST") -ne 1 ] &&\
+		return 1
+	tst_rhost_run -u $RUSER -c "rm -f $RUSER.$RHOST"
 }
 
-send_user "\nTest PASSES\n\n"
-exit 0
+setup
+
+do_test
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "Test $TCID failed."
+else
+	tst_resm TPASS "Test $TCID succeeded."
+fi
+
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v3 2/3] telnet: Cleanup
  2015-01-29 10:19               ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Zeng Linggang
@ 2015-01-29 10:19                 ` Zeng Linggang
  2015-01-29 10:19                 ` [LTP] [PATCH v3 3/3] iptables_tests.sh: Cleanup Zeng Linggang
  2015-02-06 12:56                 ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Alexey Kodanev
  2 siblings, 0 replies; 23+ messages in thread
From: Zeng Linggang @ 2015-01-29 10:19 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

* Add 'TCID' and 'TST_TOTAL'.
* Use 'test.sh' and 'tst_check_cmds'.
* Use 'test_net.sh'.
* Delete some useless comment.
* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/tcp_cmds/telnet/telnet01 | 160 +++++++++++++----------------
 1 file changed, 72 insertions(+), 88 deletions(-)

diff --git a/testcases/network/tcp_cmds/telnet/telnet01 b/testcases/network/tcp_cmds/telnet/telnet01
index 36ebf12..3648ee2 100755
--- a/testcases/network/tcp_cmds/telnet/telnet01
+++ b/testcases/network/tcp_cmds/telnet/telnet01
@@ -1,5 +1,4 @@
-#! /usr/bin/expect -f
-#*********************************************************************
+#!/bin/sh
 #   Copyright (c) International Business Machines  Corp., 2000
 #
 #   This program is free software;  you can redistribute it and/or modify
@@ -16,102 +15,87 @@
 #   along with this program;  if not, write to the Free Software
 #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 #
-#
-#
-#  FILE   : telnet
-#
-#  PURPOSE: Tests the basic functionality of `telnet`.
-#
 #  SETUP: The program `/usr/bin/expect' MUST be installed.
 #	  The PASSWD and RHOST variables MUST be set prior to execution.
 #
-#  HISTORY:
 #    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#*********************************************************************
-#
-# telnet perform a telnet session to each host in HOST_LIST with user
-#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
-#    verify that the telnet was established.
-#
-#*********************************************************************
-
-set TC telnet
-set TCtmp "/tmp"
-set SLEEPTIME 3
-set TESTLOG "$TCtmp"
-set PROMPT "Alpha Bravo"
-
-if [info exists env(RUSER)] {
-   set RUSER $env(RUSER)
-} else {
-   set RUSER root
-}
 
-if [info exists env(PASSWD)] {
-   set PASSWD $env(PASSWD)
-} else {
-   set PASSWD .pasroot
-   send_user "PASSWD NOT SET:Using .pasroot as the PASSWD variable for $RUSER. \n"
-}
+TCID="telnet01"
+TST_TOTAL=1
+. test.sh
+. test_net.sh
+
+setup()
+{
+	tst_check_cmds telnet expect rsh
+
+	if [ -z $RUSER ]; then
+		RUSER=root
+	fi
+
+	if [ -z $PASSWD ]; then
+		tst_brkm TCONF "Please set PASSWD for $RUSER."
+	fi
 
-if [info exists env(RHOST)] {
-   set RHOST $env(RHOST)
-} else {
-   send_user "Please set/export the RHOST variable. \n"
-   exit 1
+	if [ -z $RHOST ]; then
+		tst_brkm TCONF "Please set RHOST."
+	fi
+
+	if [ -z $LOOPCOUNT ]; then
+		LOOPCOUNT=25
+	fi
 }
 
-set timeout 90
+do_test()
+{
+	tst_resm TINFO "Starting"
 
-if [info exists env(LOOPCOUNT)] {
-   set LOOPCOUNT $env(LOOPCOUNT)
-} else {
-   set LOOPCOUNT 25
+	for i in $(seq 1 ${LOOPCOUNT})
+	do
+		telnet_test || return 1
+	done
 }
 
-# stty echo
-send_user " Starting\n"
-
-# Do foreach host on command line
-set count 0
-while {$count < $LOOPCOUNT} {
-   set count [expr $count+1]
-   foreach HOST $RHOST {
-      send_user "Host: $HOST\n"
-
-      # telnet to the host
-      spawn telnet $HOST
-      expect -re "login:"
-
-      send "$RUSER\r"
-      expect -re "Password:"
-
-      send "$PASSWD\r"
-
-      send "PS1=\"$PROMPT\"\r"
-      # Wait for shell prompt
-      expect "$PROMPT"
-
-      # Run passwd command - and respond to its prompts
-      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$HOST \r"
-      # When shell prompt comes back, logout
-
-      expect "$PROMPT"
-      exp_send "logout\r"
-
-      send_user "CHECKING TELNET STATUS\n"
-      set nummatch [exec rsh -n -l $RUSER $HOST "cat $TESTLOG/$RUSER.$HOST|grep -c 9"]
-      if {$nummatch==1} {
-         send_user "$TC interactive Test Successful in LOOP $count\r"
-         exec rsh -n -l $RUSER $HOST "rm -f $TESTLOG/$RUSER.$HOST"
-      } else {
-         send_user "$TC interactive session failed\n"
-         exit 1
-      }
-   }
+telnet_test()
+{
+	tst_resm TINFO "login with telnet($i/$LOOPCOUNT)"
+
+	expect -c "
+		spawn telnet $RHOST
+
+		expect -re \"login:\"
+		send \"$RUSER\r\"
+
+		expect -re \"Password:\"
+		send \"$PASSWD\r\"
+
+		expect {
+			\"incorrect\" {
+				exit 1
+			} \"$RUSER@\" {
+				send \"LC_ALL=C ls -l /etc/hosts | \\
+				       wc -w > $RUSER.$RHOST\rexit\r\";
+				exp_continue}
+		}
+
+	" > /dev/null
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+
+	tst_resm TINFO "checking telnet status($i/$LOOPCOUNT)"
+	[ $(tst_rhost_run -s -u $RUSER -c "grep -c 9 $RUSER.$RHOST") -ne 1 ] &&\
+		return 1
+	tst_rhost_run -u $RUSER -c "rm -f $RUSER.$RHOST"
 }
 
-send_user "\nTest PASSES\n\n"
-exit 0
+setup
+
+do_test
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "Test $TCID failed."
+else
+	tst_resm TPASS "Test $TCID succeeded."
+fi
+
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v3 3/3] iptables_tests.sh: Cleanup
  2015-01-29 10:19               ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Zeng Linggang
  2015-01-29 10:19                 ` [LTP] [PATCH v3 2/3] telnet: Cleanup Zeng Linggang
@ 2015-01-29 10:19                 ` Zeng Linggang
  2015-02-06 12:56                 ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Alexey Kodanev
  2 siblings, 0 replies; 23+ messages in thread
From: Zeng Linggang @ 2015-01-29 10:19 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

* Use 'test.sh'.
* Use 'tst_*' which defined in 'test.sh'.
* Delete some useless comment.
* Delete 'RC' and 'TFAILCNT'.
* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/iptables/iptables_tests.sh | 713 ++++++++++-----------------
 1 file changed, 255 insertions(+), 458 deletions(-)

diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
index 77ee29b..bdd8591 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -14,576 +14,373 @@
 ## for more details.                                                          ##
 ##                                                                            ##
 ## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
-#
-# File :        iptables_tests.sh
-#
-# Description:  Test basic functionality of iptables (firewall administration)
-#		- Test #1:  iptables -L -t <table> will list all rules in the
-#		  selected table.
-#		- Test #2:  Test iptables DROP packets from particular IP.
-#		- Test #3:  Test iptables REJECT ping request.
-#		- Test #4:  Test iptables log packets to single port.
-#		- Test #5:  Test iptables log packets to multiple ports.
-#		- Test #6:  Test limit matched logging for ping request.
-#
-#
-# History:
-#		Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com or hubertNOSPAAAM@symbio.com.tw>
-#		  - Ported test01, test02 from Manoj Iyer's ipchains_tests.sh
-#		  - Added test03, test04, test05, test06
-#
-# Function:	init
-#
-# Description:	- Check if command iptables is available.
-# Description:	- Check if iptables kernel support is available.
-#               - Initialize environment variables.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
-init()
-{
+#  Author:	Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com>
+#				       <hubertNOSPAAAM@symbio.com.tw>
 
-	export RC=0			# Return code from commands.
-	export TST_TOTAL=6		# total numner of tests in this file.
-	export TCID="iptables"		# Test case identifier
-	export TST_COUNT=0		# init identifier
-
-	if [ -z $TMP ]; then
-		LTPTMP=/tmp
-	else
-		LTPTMP=$TMP
-	fi
+export TCID="iptables"
+export TST_TOTAL=6
 
-	# Initialize cleanup function.
-	trap "cleanup" 0
+. test.sh
 
-	which tst_resm  > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brkm TBROK \
-			"Test INIT: USCTEST commands not found, set PATH correctly."
-		return $RC
-	fi
+init()
+{
+	tst_tmpdir
 
 	tst_resm TINFO "INIT: Inititalizing tests."
-	which iptables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"Test INIT: iptables command does not exist. Reason:"
-		return $RC
-	fi
 
-	modprobe ip_tables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		iptables -L > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-				"Test INIT: no iptables support in kenrel. Reason:"
-			return $RC
+	modprobe ip_tables > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		iptables -L > tst_iptables.out 2>&1
+		if [ $? -ne 0 ]; then
+			tst_brkm TBROK "no iptables support in kenrel."
 		fi
 	fi
 
 	tst_resm TINFO "INIT: Flushing all rules."
-	iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	return $RC
+	iptables -F -t filter > tst_iptables.out 2>&1
+	iptables -F -t nat > tst_iptables.out 2>&1
+	iptables -F -t mangle > tst_iptables.out 2>&1
 }
 
-
-# Function:	cleanup
-#
-# Description	- remove temporary files and directories.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 cleanup()
 {
-	TCID=iptables
-	TST_COUNT=0
-	RC=0
-
-	lsmod | grep "ip_tables" > $LTPTMP/tst_iptables.out 2>&1 || RC=0
-	if [ $RC -eq 0 ]; then
-		iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1
-		iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1
-		iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1
-		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT iptable_mangle iptable_nat ip_conntrack iptable_filter ip_tables > $LTPTMP/tst_iptables.out 2>&1
+	lsmod | grep "ip_tables" > tst_iptables.out 2>&1
+	if [ $? -eq 0 ]; then
+		iptables -F -t filter > tst_iptables.out 2>&1
+		iptables -F -t nat > tst_iptables.out 2>&1
+		iptables -F -t mangle > tst_iptables.out 2>&1
+		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
+			 iptable_mangle iptable_nat ip_conntrack \
+			 iptable_filter ip_tables > tst_iptables.out 2>&1
 	fi
-	rm -fr $LTPTMP/tst_iptables.*
-	return $RC
+	tst_rmdir
 }
 
-
-# Function:	test01
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #1:  iptables -L -t <table> will list all rules in the
-#                 selected table.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
-
 test01()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables01		# Name of the test case.
-	TST_COUNT=1		# Test number.
-
-	local chaincnt=0	# chain counter
+	local chaincnt=0
 
 	local cmd="iptables -L -t filter"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table filter."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table filter."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		cat tst_iptables.out
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -lt 3 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
+			cat tst_iptables.out
+			return
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
 	local cmd="iptables -L -t nat"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table nat."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table nat."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		cat tst_iptables.out
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
-		if [ $chaincnt -ne 3 ] && [ $chaincnt -ne 4 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+		chaincnt=$(grep -c Chain tst_iptables.out)
+		if [ $chaincnt -lt 3 ]; then
+			tst_resm TFAIL "$cmd failed to list rules."
+			cat tst_iptables.out
+			return
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
 	local cmd="iptables -L -t mangle"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table mangle."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table mangle."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		cat tst_iptables.out
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
-		if [ $chaincnt -ne 5 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+		chaincnt=$(grep -c Chain tst_iptables.out)
+		if [ $chaincnt -lt 5 ]; then
+			tst_resm TFAIL "$cmd failed to list rules."
+			cat tst_iptables.out
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
-	tst_resm TPASS "$TCID: iptables -L lists rules."
-	return $RC
+	tst_resm TPASS "iptables -L lists rules."
 }
 
-
-# Function:	test02
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #2:  Test iptables DROP packets from particular IP.
-#               - Append new rule to block all packets from loopback.
-#				- ping -c 2 loopback, this should fail.
-#				- remove rule, and ping -c loopback, this should work.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test02()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables02		# Name of the test case.
-	TST_COUNT=2		# Test number.
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to DROP packets from particular IP"
-	tst_resm TINFO "$TCID: Rule to block icmp from 127.0.0.1"
-
-	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Use iptables to DROP packets from particular IP"
+	tst_resm TINFO "Rule to block icmp from 127.0.0.1"
+
+	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		grep "100% packet loss" $LTPTMP/tst_iptables.out \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not block packets from loopback"
-			return $RC
+	tst_resm TINFO "Pinging 127.0.0.1"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL \
+				 "iptables did not block packets from loopback"
+			cat tst_iptables.err
+			return
 		else
-			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
+			tst_resm TINFO "Ping 127.0.0.1 not successful."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not block icmp from 127.0.0.1"
-		return $RC
+		tst_resm TFAIL "iptables did not block icmp from 127.0.0.1"
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting icmp DROP from 127.0.0.1 rule."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting icmp DROP from 127.0.0.1 rule."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		cat tst_iptables.out
+		return
 	fi
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables blocking loopback. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
-	else
-		tst_resm TINFO "$TCID: Ping succsess"
-		tst_resm TPASS "$TCID: iptables can DROP packets from particular IP."
+	tst_resm TINFO "Pinging 127.0.0.1 again"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables blocking loopback. This is expected" \
+			       "behaviour on certain distributions where" \
+			       "enabling firewall drops all packets by default."
+		cat tst_iptables.out
+		return
 	fi
-
-	return $RC
+	tst_resm TINFO "Ping succsess"
+	tst_resm TPASS "iptables can DROP packets from particular IP."
 }
 
-
-# Function:	test03
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #3:  Test iptables REJECT ping request.
-#               - Append new rule to block all packets from loopback.
-#				- ping -c 2 loopback, this should fail.
-#				- remove rule, and ping -c loopback, this should work.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test03()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables03		# Name of the test case.
-	TST_COUNT=3		# Test number.
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to REJECT ping request."
-	tst_resm TINFO "$TCID: Rule to reject ping request."
-
-	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j REJECT \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Use iptables to REJECT ping request."
+	tst_resm TINFO "Rule to reject ping request."
+
+	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j \
+		 REJECT > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		grep "100% packet loss" $LTPTMP/tst_iptables.out \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not block ping request."
-			return $RC
+	tst_resm TINFO "Pinging 127.0.0.1"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL "iptables did not block ping request."
+			cat tst_iptables.err
+			return
 		else
-			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
+			tst_resm TINFO "Ping 127.0.0.1 not successful."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not reject ping request."
-		return $RC
+		tst_resm TFAIL "iptables did not reject ping request."
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting icmp request REJECT rule."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting icmp request REJECT rule."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		cat tst_iptables.out
+		return
 	fi
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables blocking ping requests. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
-	else
-		tst_resm TINFO "$TCID: Ping succsess"
-		tst_resm TPASS "$TCID: iptables can REJECT ping requests."
+	tst_resm TINFO "Pinging 127.0.0.1 again"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables blocking ping requests. This is" \
+			       "expected behaviour on certain distributions" \
+			       "where enabling firewall drops all packets by" \
+			       "default."
+		cat tst_iptables.out
+		return
 	fi
-
-	return $RC
+	tst_resm TINFO "Ping succsess"
+	tst_resm TPASS "iptables can REJECT ping requests."
 }
 
-
-# Function:	test04
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #4:  Test iptables log packets to single port
-#               - Append new rule to log tcp packets to localhost:45886
-#		- telnet localhost 45886, this should be logged.
-#		- remove rule.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test04()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables04		# Name of the test case.
-	TST_COUNT=4		# Test number.
-	local dport=45886				# destination port
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log packets to particular port."
-	tst_resm TINFO "$TCID: Rule to log tcp packets to particular port."
-
-	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local dport=45886
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log packets to particular port."
+	tst_resm TINFO "Rule to log tcp packets to particular port."
+
+	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG \
+		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
-	telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
+	tst_resm TINFO "telnet 127.0.0.1 $dport"
+	telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
 		sleep 2
-		dmesg | grep "$logprefix" \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not log packets to port $dport"
-			return $RC
+		dmesg | grep "$logprefix" > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL \
+				 "iptables did not log packets to port $dport"
+			cat tst_iptables.err
+			return
 		else
-			tst_resm TINFO "$TCID: Packets to port $dport logged."
+			tst_resm TINFO "Packets to port $dport logged."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: telnet to 127.0.0.1 $dport should fail."
-		return $RC
+		tst_resm TFAIL "telnet to 127.0.0.1 $dport should fail."
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting the rule to log."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
-	else
-		tst_resm TINFO "$TCID: iptables logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets to particular port."
+	tst_resm TINFO "Deleting the rule to log."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		cat tst_iptables.out
+		return
 	fi
-
-	return $RC
+	tst_resm TINFO "iptables logging succsess"
+	tst_resm TPASS "iptables can log packets to particular port."
 }
 
-
-# Function:	test05
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #5:  Test iptables log packets to multiple ports
-#               - Append new rule to log tcp packets to localhost port 45801 - 45803
-#               - Append new rule to log tcp packets to localhost port 45804 - 45806 (ipt_multiport introduced)
-#		- telnet localhost port 45801 - 45806, this should be logged.
-#		- flush rules.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test05()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables05		# Name of the test case.
-	TST_COUNT=5		# Test number.
-	local dport=0					# destination port
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log packets to multiple ports."
-	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45801 - 45803."
-	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local dport=0
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log packets to multiple ports."
+	tst_resm TINFO "Rule to log tcp packets to port 45801 - 45803."
+	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG \
+		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45804 - 45806."
-	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Rule to log tcp packets to port 45804 - 45806."
+	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports \
+		 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
+		 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		cat tst_iptables.out
+		return
 	fi
 
 	for dport in 45801 45802 45803 45804 45805 45806; do
-		tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
-		telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			RC=0
+		tst_resm TINFO "telnet 127.0.0.1 $dport"
+		telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
+		if [ $? -ne 0 ]; then
 			sleep 2
 			dmesg | grep "$logprefix" | grep "=$dport " \
-				> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-			if [ $RC -ne 0 ]; then
-				tst_res TFAIL $LTPTMP/tst_iptables.out \
-					"$TCID: iptables did not log packets to port $dport"
-				return $RC
+				> tst_iptables.err 2>&1
+			if [ $? -ne 0 ]; then
+				tst_resm TFAIL "iptables did not log packets" \
+					       "to port $dport"
+				cat tst_iptables.err
+				return
 			else
-				tst_resm TINFO "$TCID: Packets to port $dport logged."
+				tst_resm TINFO "Packets to port $dport logged."
 			fi
 		else
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: telnet to 127.0.0.1 $dport should fail."
-			return $RC
+			tst_res TFAIL "telnet to 127.0.0.1 $dport should fail."
+			cat tst_iptables.out
+			return
 		fi
 	done
 
-	tst_resm TINFO "$TCID: Flushing all rules."
-	iptables -F > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not flush all rules. Reason:"
-		return $RC
-	else
-		tst_resm TINFO "$TCID: iptables logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets to multiple ports."
+	tst_resm TINFO "Flushing all rules."
+	iptables -F > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not flush all rules."
+		cat tst_iptables.out
+		return
 	fi
-
-	return $RC
+	tst_resm TINFO "iptables logging succsess"
+	tst_resm TPASS "iptables can log packets to multiple ports."
 }
 
-
-# Function:	test06
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #6:  Test limit matched logging for ping request.
-#               - Append new rule to log ping request with rate of 3/hour, burst 5
-#		- ping localhost 10 times, only the first 5 will be logged.
-#		- remove rule.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test06()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables06		# Name of the test case.
-	TST_COUNT=6		# Test number.
-	local logcnt=0		# log counter
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log ping request with limited rate."
-	tst_resm TINFO "$TCID: Rule to log ping request."
-
-	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m limit -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local logcnt=0
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log ping request with limited rate."
+	tst_resm TINFO "Rule to log ping request."
+
+	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m \
+		 limit -j LOG --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: ping 127.0.0.1"
-	ping -c 10 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -eq 0 ]; then
-		RC=0
+	tst_resm TINFO "ping 127.0.0.1"
+	ping -c 10 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -eq 0 ]; then
 		sleep 2
 		logcnt=$(dmesg | grep -c "$logprefix")
 		if [ $logcnt -ne 5 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not log packets with limited rate."
-			return $logcnt
+			tst_resm TFAIL "iptables did not log packets with" \
+				       "limited rate."
+			cat tst_iptables.out
+			return
 		else
-			tst_resm TINFO "$TCID: ping requests logged with limited rate."
+			tst_resm TINFO "ping requests logged with limited rate."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: ping to 127.0.0.1 failed. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+		tst_resm TFAIL "ping to 127.0.0.1 failed. This is expected" \
+			       "behaviour on certain distributions where" \
+			       "enabling firewall drops all packets by default."
+		cat tst_iptables.out
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting the rule to log."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
-	else
-		tst_resm TINFO "$TCID: iptables limited logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets with limited rate."
+	tst_resm TINFO "Deleting the rule to log."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		cat tst_iptables.out
+		return
 	fi
-
-	return $RC
+	tst_resm TINFO "iptables limited logging succsess"
+	tst_resm TPASS "iptables can log packets with limited rate."
 }
 
-# Function:	main
-#
-# Description:	- Execute all tests, report results.
-#
-# 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 # Exit if initializing testcases fails.
-
-test01 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test02 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test03 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test04 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test05 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test06 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-exit $TFAILCNT
+init
+TST_CLEANUP=cleanup
+
+test01
+test02
+test03
+test04
+test05
+test06
+
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [LTP] [PATCH v3 1/3] rlogin: Cleanup
  2015-01-29 10:19               ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Zeng Linggang
  2015-01-29 10:19                 ` [LTP] [PATCH v3 2/3] telnet: Cleanup Zeng Linggang
  2015-01-29 10:19                 ` [LTP] [PATCH v3 3/3] iptables_tests.sh: Cleanup Zeng Linggang
@ 2015-02-06 12:56                 ` Alexey Kodanev
  2 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2015-02-06 12:56 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
On 01/29/2015 01:19 PM, Zeng Linggang wrote:
> * Add 'TCID' and 'TST_TOTAL'.
> * Use 'test.sh' and 'tst_check_cmds'.
> * Use 'test_net.sh'.
> * Delete some useless comment.
> * Some cleanup.
>
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
>   testcases/network/tcp_cmds/rlogin/rlogin01 | 127 ++++++++++++++---------------
>   1 file changed, 63 insertions(+), 64 deletions(-)
>
> diff --git a/testcases/network/tcp_cmds/rlogin/rlogin01 b/testcases/network/tcp_cmds/rlogin/rlogin01
> index ae670c9..b564da1 100755
> --- a/testcases/network/tcp_cmds/rlogin/rlogin01
> +++ b/testcases/network/tcp_cmds/rlogin/rlogin01

Patch-set pushed. I also did minor changes as follows:

* removed setup comments because they repeated what is written in 
network/LTP_network_README.pdf
* removed test.sh from rlogin and telnet as test_net.sh already includes it
* fixed tst_rhost_run() so it can set error code on return without '-s' 
option:

     tst_rhost_run -c "..." || return 1

and updated the tests.

Thanks,
Alexey

> @@ -1,5 +1,4 @@
> -#! /usr/bin/expect -f
> -#*********************************************************************
> +#!/bin/sh
>   #   Copyright (c) International Business Machines  Corp., 2000
>   #
>   #   This program is free software;  you can redistribute it and/or modify
> @@ -16,87 +15,87 @@
>   #   along with this program;  if not, write to the Free Software
>   #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   #
> -#
> -#
> -#  FILE   : rlogin
> -#
> -#  PURPOSE: Tests the basic functionality of `rlogin`.
> -#
>   #  SETUP: The program `/usr/bin/expect' MUST be installed.
>   #         The home directory of root on the machine exported as "RHOST"
>   #         should have a ".rhosts" file with the hostname of the machine
>   #         where the test is executed, OR the "PASSWD" section below MUST
>   #	  be uncommented and set.
>   #
> -#  HISTORY:
>   #    03/01 Robbie Williamson (robbiew@us.ibm.com)
> -#      -Ported
> -#
> -#
> -# rlogin perform a rlogin session to each host in HOST_LIST with user
> -#    RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
> -#    verify that the rlogin was established.
>   #
> -#*********************************************************************
>   
> -set TC rlogin
> -set TCtmp "/tmp"
> -set SLEEPTIME 3
> -set TESTLOG "$TCtmp"
> +TCID="rlogin01"
> +TST_TOTAL=1
> +. test.sh
> +. test_net.sh
>   
> -if [info exists env(RUSER)] {
> -   set RUSER $env(RUSER)
> -} else {
> -   set RUSER root
> -}
> +setup()
> +{
> +	tst_check_cmds rlogin expect rsh
>   
> -set RHOST $env(RHOST)
> -set timeout 10
> +	if [ -z $RUSER ]; then
> +		RUSER=root
> +	fi
>   
> -if [info exists env(LOOPCOUNT)] {
> -   set LOOPCOUNT $env(LOOPCOUNT)
> -} else {
> -   set LOOPCOUNT 25
> -}
> +	if [ -z $PASSWD ]; then
> +		tst_brkm TCONF "Please set PASSWD for $RUSER."
> +	fi
>   
> -# stty echo
> -send_user " Starting\n"
> +	if [ -z $RHOST ]; then
> +		tst_brkm TCONF "Please set RHOST."
> +	fi
>   
> -set count 0
> -while {$count < $LOOPCOUNT} {
> -   set count [expr $count+1]
> -      send_user "Host: $RHOST\n"
> +	if [ -z $LOOPCOUNT ]; then
> +		LOOPCOUNT=25
> +	fi
> +}
>   
> -      # rlogin to the host
> -      spawn rlogin $RHOST -l $RUSER
> +do_test()
> +{
> +	tst_resm TINFO "Starting"
>   
> -      # Uncomment code below and add root's passwd if .rhosts file is not
> -      # present on remote host.
> -      #---------------------------------
> -      #set PASSWD "<ROOT PASSWORD HERE>"
> -      #expect -re "Password:"
> -      #send "$PASSWD\r"
> +	for i in $(seq 1 ${LOOPCOUNT})
> +	do
> +		rlogin_test || return 1
> +	done
> +}
>   
> -      # Wait for shell prompt
> -      expect -re "$RUSER@"
> +rlogin_test()
> +{
> +	tst_resm TINFO "login with rlogin($i/$LOOPCOUNT)"
>   
> -      # Run passwd command - and respond to its prompts
> -      send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$RHOST \r"
> -      # When shell prompt comes back, logout
> +	expect -c "
> +		spawn rlogin $RHOST -l $RUSER
>   
> -      expect -re "$RUSER@"
> -      exp_send "logout\r"
> +		expect {
> +			\"Password:\" {
> +				send \"$PASSWD\r\"; exp_continue
> +			} \"incorrect\" {
> +				exit 1
> +			} \"$RUSER@\" {
> +				send \"LC_ALL=C; ls -l /etc/hosts | \\
> +				       wc -w > $RUSER.$RHOST\rexit\r\";
> +				exp_continue
> +			}
> +		}
> +	" > /dev/null
> +	if [ $? -ne 0 ]; then
> +		return 1
> +	fi
>   
> -      send_user "CHECKING RLOGIN STATUS\n"
> -      set nummatch [exec rsh -n -l $RUSER $RHOST "cat $TESTLOG/$RUSER.$RHOST|grep -c 9"]
> -      if {$nummatch==1} {
> -         send_user "$TC interactive Test Successful in LOOP $count\r"
> -         exec rsh -n -l $RUSER $RHOST "rm -f $TESTLOG/$RUSER.$RHOST"
> -      } else {
> -         send_user "$TC interactive session FAILED\r"
> -         exit 1
> -      }
> +	tst_resm TINFO "checking telnet status($i/$LOOPCOUNT)"
> +	[ $(tst_rhost_run -s -u $RUSER -c "grep -c 9 $RUSER.$RHOST") -ne 1 ] &&\
> +		return 1
> +	tst_rhost_run -u $RUSER -c "rm -f $RUSER.$RHOST"
>   }
>   
> -send_user "\nTest PASSES\n\n"
> -exit 0
> +setup
> +
> +do_test
> +if [ $? -ne 0 ]; then
> +	tst_resm TFAIL "Test $TCID failed."
> +else
> +	tst_resm TPASS "Test $TCID succeeded."
> +fi
> +
> +tst_exit


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup
  2015-01-19  2:17 Zeng Linggang
@ 2015-01-19  2:17 ` Zeng Linggang
  0 siblings, 0 replies; 23+ messages in thread
From: Zeng Linggang @ 2015-01-19  2:17 UTC (permalink / raw)
  To: ltp-list

* Use 'test.sh'.
* Use 'tst_*' which defined in 'test.sh'.
* Delete some useless comment.
* Delete 'RC' and 'TFAILCNT'.
* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/network/iptables/iptables_tests.sh | 675 +++++++++------------------
 1 file changed, 224 insertions(+), 451 deletions(-)

diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
index 77ee29b..66e98bd 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -14,576 +14,349 @@
 ## for more details.                                                          ##
 ##                                                                            ##
 ## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
-#
-# File :        iptables_tests.sh
-#
-# Description:  Test basic functionality of iptables (firewall administration)
-#		- Test #1:  iptables -L -t <table> will list all rules in the
-#		  selected table.
-#		- Test #2:  Test iptables DROP packets from particular IP.
-#		- Test #3:  Test iptables REJECT ping request.
-#		- Test #4:  Test iptables log packets to single port.
-#		- Test #5:  Test iptables log packets to multiple ports.
-#		- Test #6:  Test limit matched logging for ping request.
-#
-#
-# History:
-#		Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com or hubertNOSPAAAM@symbio.com.tw>
-#		  - Ported test01, test02 from Manoj Iyer's ipchains_tests.sh
-#		  - Added test03, test04, test05, test06
-#
-# Function:	init
-#
-# Description:	- Check if command iptables is available.
-# Description:	- Check if iptables kernel support is available.
-#               - Initialize environment variables.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
-init()
-{
+#  Author:	Jan 20 2004 Hubert Lin <linux02NOSPAAAM@tw.ibm.com>
+#				       <hubertNOSPAAAM@symbio.com.tw>
 
-	export RC=0			# Return code from commands.
-	export TST_TOTAL=6		# total numner of tests in this file.
-	export TCID="iptables"		# Test case identifier
-	export TST_COUNT=0		# init identifier
-
-	if [ -z $TMP ]; then
-		LTPTMP=/tmp
-	else
-		LTPTMP=$TMP
-	fi
+export TCID="iptables"
+export TST_TOTAL=6
 
-	# Initialize cleanup function.
-	trap "cleanup" 0
+. test.sh
 
-	which tst_resm  > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brkm TBROK \
-			"Test INIT: USCTEST commands not found, set PATH correctly."
-		return $RC
-	fi
+init()
+{
+	tst_tmpdir
 
 	tst_resm TINFO "INIT: Inititalizing tests."
-	which iptables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"Test INIT: iptables command does not exist. Reason:"
-		return $RC
-	fi
 
-	modprobe ip_tables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		iptables -L > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-				"Test INIT: no iptables support in kenrel. Reason:"
-			return $RC
+	modprobe ip_tables > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		iptables -L > tst_iptables.out 2>&1
+		if [ $? -ne 0 ]; then
+			tst_brkm TBROK "no iptables support in kenrel."
 		fi
 	fi
 
 	tst_resm TINFO "INIT: Flushing all rules."
-	iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	return $RC
+	iptables -F -t filter > tst_iptables.out 2>&1
+	iptables -F -t nat > tst_iptables.out 2>&1
+	iptables -F -t mangle > tst_iptables.out 2>&1
 }
 
-
-# Function:	cleanup
-#
-# Description	- remove temporary files and directories.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 cleanup()
 {
-	TCID=iptables
-	TST_COUNT=0
-	RC=0
-
-	lsmod | grep "ip_tables" > $LTPTMP/tst_iptables.out 2>&1 || RC=0
-	if [ $RC -eq 0 ]; then
-		iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1
-		iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1
-		iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1
-		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT iptable_mangle iptable_nat ip_conntrack iptable_filter ip_tables > $LTPTMP/tst_iptables.out 2>&1
+	lsmod | grep "ip_tables" > tst_iptables.out 2>&1
+	if [ $? -eq 0 ]; then
+		iptables -F -t filter > tst_iptables.out 2>&1
+		iptables -F -t nat > tst_iptables.out 2>&1
+		iptables -F -t mangle > tst_iptables.out 2>&1
+		rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
+			 iptable_mangle iptable_nat ip_conntrack \
+			 iptable_filter ip_tables > tst_iptables.out 2>&1
 	fi
-	rm -fr $LTPTMP/tst_iptables.*
-	return $RC
+	tst_rmdir
 }
 
-
-# Function:	test01
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #1:  iptables -L -t <table> will list all rules in the
-#                 selected table.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
-
 test01()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables01		# Name of the test case.
-	TST_COUNT=1		# Test number.
-
-	local chaincnt=0	# chain counter
+	local chaincnt=0
 
 	local cmd="iptables -L -t filter"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table filter."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table filter."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -lt 3 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
+			return
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
 	local cmd="iptables -L -t nat"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table nat."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table nat."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -ne 3 ] && [ $chaincnt -ne 4 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
+			return
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
 	local cmd="iptables -L -t mangle"
-	tst_resm TINFO \
-		"$TCID: $cmd will list all rules in table mangle."
-	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: $cmd failed to list rules. Reason:"
-		return $RC
+	tst_resm TINFO "$cmd will list all rules in table mangle."
+	$cmd > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed to list rules."
+		return
 	else
-		chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out)
+		chaincnt=$(grep -c Chain tst_iptables.out)
 		if [ $chaincnt -ne 5 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: $cmd failed to list rules. Reason:"
-			return $chaincnt
+			tst_resm TFAIL "$cmd failed to list rules."
 		else
-			tst_resm TINFO "$TCID: $cmd lists rules."
+			tst_resm TINFO "$cmd lists rules."
 		fi
 	fi
 
-	tst_resm TPASS "$TCID: iptables -L lists rules."
-	return $RC
+	tst_resm TPASS "iptables -L lists rules."
 }
 
-
-# Function:	test02
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #2:  Test iptables DROP packets from particular IP.
-#               - Append new rule to block all packets from loopback.
-#				- ping -c 2 loopback, this should fail.
-#				- remove rule, and ping -c loopback, this should work.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test02()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables02		# Name of the test case.
-	TST_COUNT=2		# Test number.
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to DROP packets from particular IP"
-	tst_resm TINFO "$TCID: Rule to block icmp from 127.0.0.1"
-
-	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Use iptables to DROP packets from particular IP"
+	tst_resm TINFO "Rule to block icmp from 127.0.0.1"
+
+	iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		grep "100% packet loss" $LTPTMP/tst_iptables.out \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not block packets from loopback"
-			return $RC
+	tst_resm TINFO "Pinging 127.0.0.1"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL \
+				 "iptables did not block packets from loopback"
+			return
 		else
-			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
+			tst_resm TINFO "Ping 127.0.0.1 not successful."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not block icmp from 127.0.0.1"
-		return $RC
+		tst_resm TFAIL "iptables did not block icmp from 127.0.0.1"
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting icmp DROP from 127.0.0.1 rule."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting icmp DROP from 127.0.0.1 rule."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	fi
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables blocking loopback. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+	tst_resm TINFO "Pinging 127.0.0.1 again"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables blocking loopback. This is expected" \
+			       "behaviour on certain distributions where" \
+			       "enabling firewall drops all packets by default."
+		return
 	else
-		tst_resm TINFO "$TCID: Ping succsess"
-		tst_resm TPASS "$TCID: iptables can DROP packets from particular IP."
+		tst_resm TINFO "Ping succsess"
+		tst_resm TPASS "iptables can DROP packets from particular IP."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test03
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #3:  Test iptables REJECT ping request.
-#               - Append new rule to block all packets from loopback.
-#				- ping -c 2 loopback, this should fail.
-#				- remove rule, and ping -c loopback, this should work.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test03()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables03		# Name of the test case.
-	TST_COUNT=3		# Test number.
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to REJECT ping request."
-	tst_resm TINFO "$TCID: Rule to reject ping request."
-
-	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j REJECT \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Use iptables to REJECT ping request."
+	tst_resm TINFO "Rule to reject ping request."
+
+	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j \
+		 REJECT > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
-		grep "100% packet loss" $LTPTMP/tst_iptables.out \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not block ping request."
-			return $RC
+	tst_resm TINFO "Pinging 127.0.0.1"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL "iptables did not block ping request."
+			return
 		else
-			tst_resm TINFO "$TCID: Ping 127.0.0.1 not successful."
+			tst_resm TINFO "Ping 127.0.0.1 not successful."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not reject ping request."
-		return $RC
+		tst_resm TFAIL "iptables did not reject ping request."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting icmp request REJECT rule."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting icmp request REJECT rule."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	fi
-	tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
-	ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables blocking ping requests. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+	tst_resm TINFO "Pinging 127.0.0.1 again"
+	ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables blocking ping requests. This is" \
+			       "expected behaviour on certain distributions" \
+			       "where enabling firewall drops all packets by" \
+			       "default."
+		return
 	else
-		tst_resm TINFO "$TCID: Ping succsess"
-		tst_resm TPASS "$TCID: iptables can REJECT ping requests."
+		tst_resm TINFO "Ping succsess"
+		tst_resm TPASS "iptables can REJECT ping requests."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test04
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #4:  Test iptables log packets to single port
-#               - Append new rule to log tcp packets to localhost:45886
-#		- telnet localhost 45886, this should be logged.
-#		- remove rule.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test04()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables04		# Name of the test case.
-	TST_COUNT=4		# Test number.
-	local dport=45886				# destination port
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log packets to particular port."
-	tst_resm TINFO "$TCID: Rule to log tcp packets to particular port."
-
-	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local dport=45886
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log packets to particular port."
+	tst_resm TINFO "Rule to log tcp packets to particular port."
+
+	iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG \
+		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
-	telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		RC=0
+	tst_resm TINFO "telnet 127.0.0.1 $dport"
+	telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
 		sleep 2
-		dmesg | grep "$logprefix" \
-			> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not log packets to port $dport"
-			return $RC
+		dmesg | grep "$logprefix" > tst_iptables.err 2>&1
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL \
+				 "iptables did not log packets to port $dport"
+			return
 		else
-			tst_resm TINFO "$TCID: Packets to port $dport logged."
+			tst_resm TINFO "Packets to port $dport logged."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: telnet to 127.0.0.1 $dport should fail."
-		return $RC
+		tst_resm TFAIL "telnet to 127.0.0.1 $dport should fail."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting the rule to log."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting the rule to log."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets to particular port."
+		tst_resm TINFO "iptables logging succsess"
+		tst_resm TPASS "iptables can log packets to particular port."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test05
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #5:  Test iptables log packets to multiple ports
-#               - Append new rule to log tcp packets to localhost port 45801 - 45803
-#               - Append new rule to log tcp packets to localhost port 45804 - 45806 (ipt_multiport introduced)
-#		- telnet localhost port 45801 - 45806, this should be logged.
-#		- flush rules.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test05()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables05		# Name of the test case.
-	TST_COUNT=5		# Test number.
-	local dport=0					# destination port
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log packets to multiple ports."
-	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45801 - 45803."
-	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local dport=0
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log packets to multiple ports."
+	tst_resm TINFO "Rule to log tcp packets to port 45801 - 45803."
+	iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG \
+		 --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Rule to log tcp packets to port 45804 - 45806."
-	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	tst_resm TINFO "Rule to log tcp packets to port 45804 - 45806."
+	iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports \
+		 45804,45806,45805 -j LOG --log-prefix "$logprefix" \
+		 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
 	for dport in 45801 45802 45803 45804 45805 45806; do
-		tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
-		telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-		if [ $RC -ne 0 ]; then
-			RC=0
+		tst_resm TINFO "telnet 127.0.0.1 $dport"
+		telnet 127.0.0.1 $dport > tst_iptables.out 2>&1
+		if [ $? -ne 0 ]; then
 			sleep 2
 			dmesg | grep "$logprefix" | grep "=$dport " \
-				> $LTPTMP/tst_iptables.err 2>&1 || RC=$?
-			if [ $RC -ne 0 ]; then
-				tst_res TFAIL $LTPTMP/tst_iptables.out \
-					"$TCID: iptables did not log packets to port $dport"
-				return $RC
+				> tst_iptables.err 2>&1
+			if [ $? -ne 0 ]; then
+				tst_resm TFAIL "iptables did not log packets" \
+					       "to port $dport"
+				return
 			else
-				tst_resm TINFO "$TCID: Packets to port $dport logged."
+				tst_resm TINFO "Packets to port $dport logged."
 			fi
 		else
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: telnet to 127.0.0.1 $dport should fail."
-			return $RC
+			tst_res TFAIL "telnet to 127.0.0.1 $dport should fail."
+			return
 		fi
 	done
 
-	tst_resm TINFO "$TCID: Flushing all rules."
-	iptables -F > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not flush all rules. Reason:"
-		return $RC
+	tst_resm TINFO "Flushing all rules."
+	iptables -F > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not flush all rules."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets to multiple ports."
+		tst_resm TINFO "iptables logging succsess"
+		tst_resm TPASS "iptables can log packets to multiple ports."
 	fi
-
-	return $RC
 }
 
-
-# Function:	test06
-#
-# Description	- Test basic functionality of iptables (firewall administration)
-#               - Test #6:  Test limit matched logging for ping request.
-#               - Append new rule to log ping request with rate of 3/hour, burst 5
-#		- ping localhost 10 times, only the first 5 will be logged.
-#		- remove rule.
-#
-# Return	- zero on success
-#               - non zero on failure. return value from commands ($RC)
 test06()
 {
-	RC=0			# Return value from commands.
-	TCID=iptables06		# Name of the test case.
-	TST_COUNT=6		# Test number.
-	local logcnt=0		# log counter
-	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
-
-	tst_resm TINFO \
-		"$TCID: Use iptables to log ping request with limited rate."
-	tst_resm TINFO "$TCID: Rule to log ping request."
-
-	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m limit -j LOG --log-prefix "$logprefix" \
-		> $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
-			"$TCID: iptables command failed to append new rule. Reason:"
-		return $RC
+	local logcnt=0
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"
+
+	tst_resm TINFO "Use iptables to log ping request with limited rate."
+	tst_resm TINFO "Rule to log ping request."
+
+	iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m \
+		 limit -j LOG --log-prefix "$logprefix" > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables command failed to append new rule."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: ping 127.0.0.1"
-	ping -c 10 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -eq 0 ]; then
-		RC=0
+	tst_resm TINFO "ping 127.0.0.1"
+	ping -c 10 127.0.0.1 > tst_iptables.out 2>&1
+	if [ $? -eq 0 ]; then
 		sleep 2
 		logcnt=$(dmesg | grep -c "$logprefix")
 		if [ $logcnt -ne 5 ]; then
-			tst_res TFAIL $LTPTMP/tst_iptables.out \
-				"$TCID: iptables did not log packets with limited rate."
-			return $logcnt
+			tst_resm TFAIL "iptables did not log packets with" \
+				       "limited rate."
+			return
 		else
-			tst_resm TINFO "$TCID: ping requests logged with limited rate."
+			tst_resm TINFO "ping requests logged with limited rate."
 		fi
 	else
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: ping to 127.0.0.1 failed. This is expected behaviour on certain distributions where enabling firewall drops all packets by default."
-		return $RC
+		tst_resm TFAIL "ping to 127.0.0.1 failed. This is expected" \
+			       "behaviour on certain distributions where" \
+			       "enabling firewall drops all packets by default."
+		return
 	fi
 
-	tst_resm TINFO "$TCID: Deleting the rule to log."
-	iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_res TFAIL $LTPTMP/tst_iptables.out \
-			"$TCID: iptables did not remove the rule. Reason:"
-		return $RC
+	tst_resm TINFO "Deleting the rule to log."
+	iptables -D INPUT 1 > tst_iptables.out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "iptables did not remove the rule."
+		return
 	else
-		tst_resm TINFO "$TCID: iptables limited logging succsess"
-		tst_resm TPASS "$TCID: iptables can log packets with limited rate."
+		tst_resm TINFO "iptables limited logging succsess"
+		tst_resm TPASS "iptables can log packets with limited rate."
 	fi
-
-	return $RC
 }
 
-# Function:	main
-#
-# Description:	- Execute all tests, report results.
-#
-# 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 # Exit if initializing testcases fails.
-
-test01 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test02 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test03 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test04 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test05 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-RC=0		# Return code from test.
-test06 || RC=$?
-if [ $RC -ne 0 ]; then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-exit $TFAILCNT
+init
+TST_CLEANUP=cleanup
+
+test01
+test02
+test03
+test04
+test05
+test06
+
+tst_exit
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2015-02-06 12:54 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-26 10:58 [LTP] [PATCH 1/3] rlogin: Cleanup Zeng Linggang
2014-12-26 10:58 ` [LTP] [PATCH 2/3] telnet: Cleanup Zeng Linggang
2014-12-26 10:58 ` [LTP] [PATCH 3/3] iptables_tests.sh: Cleanup Zeng Linggang
2015-01-15 15:13 ` [LTP] [PATCH 1/3] rlogin: Cleanup Alexey Kodanev
2015-01-16  7:38   ` Zeng Linggang
2015-01-21  5:28   ` [LTP] [PATCH v2 " Zeng Linggang
2015-01-21  5:28     ` [LTP] [PATCH v2 2/3] telnet: Cleanup Zeng Linggang
2015-01-23 11:01       ` Alexey Kodanev
2015-01-27  7:41         ` Zeng Linggang
2015-01-27 16:19           ` Alexey Kodanev
2015-01-28  1:17             ` Zeng Linggang
2015-01-21  5:28     ` [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup Zeng Linggang
2015-01-26 18:37       ` Alexey Kodanev
2015-01-27  9:16         ` Zeng Linggang
2015-01-27 16:30           ` Alexey Kodanev
2015-01-28  1:19             ` Zeng Linggang
2015-01-29 10:19               ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Zeng Linggang
2015-01-29 10:19                 ` [LTP] [PATCH v3 2/3] telnet: Cleanup Zeng Linggang
2015-01-29 10:19                 ` [LTP] [PATCH v3 3/3] iptables_tests.sh: Cleanup Zeng Linggang
2015-02-06 12:56                 ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Alexey Kodanev
2015-01-23 11:02     ` [LTP] [PATCH v2 " Alexey Kodanev
2015-01-27  7:29       ` Zeng Linggang
2015-01-19  2:17 Zeng Linggang
2015-01-19  2:17 ` [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup Zeng Linggang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.