1 #!/bin/sh 2 # Copyright (c) International Business Machines Corp., 2000 3 # 4 # This program is free software; you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License as published by 6 # the Free Software Foundation; either version 2 of the License, or 7 # (at your option) any later version. 8 # 9 # This program is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 12 # the GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with this program; if not, write to the Free Software 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 # 18 # 03/01 Robbie Williamson (robbiew (at] us.ibm.com) 19 20 TCID="telnet01" 21 TST_TOTAL=1 22 23 . test_net.sh 24 25 setup() 26 { 27 tst_check_cmds telnet expect 28 29 if [ -z $RUSER ]; then 30 RUSER=root 31 fi 32 33 if [ -z $PASSWD ]; then 34 tst_brkm TCONF "Please set PASSWD for $RUSER." 35 fi 36 37 if [ -z $RHOST ]; then 38 tst_brkm TCONF "Please set RHOST." 39 fi 40 41 if [ -z $LOOPCOUNT ]; then 42 LOOPCOUNT=25 43 fi 44 } 45 46 do_test() 47 { 48 tst_resm TINFO "Starting" 49 50 for i in $(seq 1 ${LOOPCOUNT}) 51 do 52 telnet_test || return 1 53 done 54 } 55 56 telnet_test() 57 { 58 tst_resm TINFO "login with telnet($i/$LOOPCOUNT)" 59 60 expect -c " 61 spawn telnet $RHOST 62 63 expect -re \"login:\" 64 send \"$RUSER\r\" 65 66 expect -re \"Password:\" 67 send \"$PASSWD\r\" 68 69 expect { 70 \"incorrect\" { 71 exit 1 72 } \"$RUSER@\" { 73 send \"LC_ALL=C ls -l /etc/hosts | \\ 74 wc -w > $RUSER.$RHOST\rexit\r\"; 75 exp_continue} 76 } 77 78 " > /dev/null || return 1 79 80 tst_resm TINFO "checking telnet status($i/$LOOPCOUNT)" 81 tst_rhost_run -u $RUSER -c "grep -q 9 $RUSER.$RHOST" || return 1 82 tst_rhost_run -u $RUSER -c "rm -f $RUSER.$RHOST" 83 } 84 85 setup 86 87 do_test 88 if [ $? -ne 0 ]; then 89 tst_resm TFAIL "Test $TCID failed." 90 else 91 tst_resm TPASS "Test $TCID succeeded." 92 fi 93 94 tst_exit 95