1#!/bin/sh 2unset LIBPATH 3# 4# Copyright (c) International Business Machines Corp., 2000 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 14# the GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19# 20# 21# 22# FILE : echo 23# 24# PURPOSE: Stresses the inetd/xinetd daemon using the `echo` service. 25# 26# SETUP: The echo service MUST be active on the RHOST machine. This is 27# controlled by the inetd/xinetd daemon. 28# 29# HISTORY: 30# 03/01 Robbie Williamson (robbiew@us.ibm.com) 31# -Ported 32# 33# 34#*********************************************************************** 35 36#----------------------------------------------------------------------- 37# 38# FUNCTION: do_setup 39# 40#----------------------------------------------------------------------- 41 42do_setup() 43{ 44 45 NUMLOOPS=${NUMLOOPS:-2} 46 TST_TOTAL=$NUMLOOPS 47 48 export TST_COUNT TST_TOTAL 49 50 exists hostname sum 51 tst_setup 52 53 TC=sine 54 RHOST=${RHOST:-`hostname`} 55 CLEANUP=${CLEANUP:-ON} 56 CREATEFILE=createfile 57 ECHOES=echoes${EXEC_SUFFIX} 58 59 ECHOFILE=${ECHOFILE:-echofile${EXEC_SUFFIX}} 60 ECHOSIZE=${ECHOSIZE:-8192} 61 NUMPROCESSES=${NUMPROCESSES:-10} 62 63} 64 65#----------------------------------------------------------------------- 66# 67# FUNCTION: do_test 68# PURPOSE: Loop until interrupted creating the echo file and then 69# echoing it to RHOST. 70# INPUT: None. 71# OUTPUT: Informational messages are logged into the run log. 72# 73#----------------------------------------------------------------------- 74 75do_test() 76{ 77 echo "Creating echo file $ECHOFILE" 78 if ! "$LTPROOT/testcases/bin/$CREATEFILE" $ECHOSIZE "$TCtmp/$ECHOFILE"; then 79 end_testcase "$ECHOFILE not created" 80 fi 81 82 echo "Compute the checksum of this file" 83 csum1=$(sum $TCtmp/$ECHOFILE | awk '{print $1}') 84 [ $csum1 ] || end_testcase "initial checksum computation failed" 85 86 while [ $TST_COUNT -le $NUMLOOPS ]; do 87 88 if ! $ECHOES $RHOST "$TCtmp/$ECHOFILE" $NUMPROCESSES; then 89 end_testcase "Error in $ECHOES test in loop $TST_COUNT" 90 fi 91 92 NUM=0 93 while [ $NUM -lt $NUMPROCESSES ] 94 do 95 csum2=$(sum "$TCtmp/${ECHOFILE}${NUM}" | awk '{print $1}') 96 if [ "$csum1" != "$csum2" ]; then 97 end_testcase "Checksums differ in loop $TST_COUNT" 98 fi 99 NUM=$(( $NUM + 1 )) 100 done 101 102 tst_resm TINFO "Execution $TST_COUNT passed." 103 104 incr_tst_count 105 if [ $TST_COUNT -le $NUMLOOPS ]; then 106 tst_resm TINFO "Sleeping 60 seconds to avoid hitting max. connections setting for service" 107 sleep 60 108 fi 109 done 110} 111 112#----------------------------------------------------------------------- 113# 114# FUNCTION: MAIN 115# PURPOSE: To invoke functions that perform the tasks as described in 116# the design in the prolog above. 117# INPUT: See SETUP in the prolog above. 118# OUTPUT: Logged run results written to testcase run log 119# 120#----------------------------------------------------------------------- 121 122. net_cmdlib.sh 123 124read_opts $* 125do_setup 126do_test 127end_testcase 128