• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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@us.ibm.com)
19
20TCID="telnet01"
21TST_TOTAL=1
22
23TST_USE_LEGACY_API=1
24. tst_net.sh
25
26setup()
27{
28	tst_require_cmds telnet expect
29
30	if [ -z $RUSER ]; then
31		RUSER=root
32	fi
33
34	if [ -z $PASSWD ]; then
35		tst_brkm TCONF "Please set PASSWD for $RUSER."
36	fi
37
38	if [ -z $RHOST ]; then
39		tst_brkm TCONF "Please set RHOST."
40	fi
41
42	if [ -z $LOOPCOUNT ]; then
43		LOOPCOUNT=25
44	fi
45}
46
47do_test()
48{
49	tst_resm TINFO "Starting"
50
51	for i in $(seq 1 ${LOOPCOUNT})
52	do
53		telnet_test || return 1
54	done
55}
56
57telnet_test()
58{
59	tst_resm TINFO "login with telnet($i/$LOOPCOUNT)"
60
61	expect -c "
62		spawn telnet $RHOST
63
64		expect -re \"login:\"
65		send \"$RUSER\r\"
66
67		expect -re \"Password:\"
68		send \"$PASSWD\r\"
69
70		expect {
71			\"incorrect\" {
72				exit 1
73			} \"$RUSER@\" {
74				send \"LC_ALL=C ls -l /etc/hosts | \\
75				       wc -w > $RUSER.$RHOST\rexit\r\";
76				exp_continue}
77		}
78
79	" > /dev/null || return 1
80
81	tst_resm TINFO "checking telnet status($i/$LOOPCOUNT)"
82	tst_rhost_run -u $RUSER -c "grep -q 9 $RUSER.$RHOST" || return 1
83	tst_rhost_run -u $RUSER -c "rm -f $RUSER.$RHOST"
84}
85
86setup
87
88do_test
89if [ $? -ne 0 ]; then
90	tst_resm TFAIL "Test $TCID failed."
91else
92	tst_resm TPASS "Test $TCID succeeded."
93fi
94
95tst_exit
96