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