public inbox for ltp@lists.linux.it
 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 v2 1/3] rlogin: Cleanup
@ 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

* 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

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
  -- strict thread matches above, loose matches on Subject: below --
2015-01-19  2:17 Zeng Linggang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox