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...@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 (robb...@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