head     1.1;
branch   1.1.1;
access   ;
symbols  LTP_20031204:1.1.1.1 LINUX_TEST_PROJECT:1.1.1;
locks    ; strict;
comment  @# @;


1.1
date     2003.12.31.09.00.28;  author mtm;  state Exp;
branches 1.1.1.1;
next     ;

1.1.1.1
date     2003.12.31.09.00.28;  author mtm;  state Exp;
branches ;
next     ;


desc
@@



1.1
log
@Initial revision
@
text
@#!/bin/sh
unset LIBPATH
#
#   Copyright (c) International Business Machines  Corp., 2000
#
#   This program is free software;  you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
#   the GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this pronram;  if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
#  FILE   : echo
#
#  PURPOSE: Stresses the inetd/xinetd daemon using the `echo` service.
#           
#  SETUP: The echo service MUST be active on the RHOST machine. This is
#         controlled by the inetd/xinetd daemon.
#
#  HISTORY:
#    03/01 Robbie Williamson (robbiew@@us.ibm.com)
#      -Ported
#
#
#***********************************************************************
#Uncomment line below for debug output.
#trace_logic=${trace_logic:-"set -x"}
$trace_logic

TC=sine
RHOST=${RHOST:-`hostname`}
TCbin=${TCbin:-`pwd`}
TCsrc=${TCsrc:-$TCbin}
TCtmp=${TCtmp:-$TCsrc/echo$$}
CLEANUP=${CLEANUP:-ON}
CREATFILE=createfile
ECHOES=echoes

EXECUTABLES=${EXECUTABLES:-"$CREATFILE $ECHOES"}
ECHOFILE=${ECHOFILE:-echofile}
ECHOSIZE=${ECHOSIZE:-8192}
NUMLOOPS=${NUMLOOPS:-2}
NUMPROCESSES=${NUMPROCESSES:-10}

#-----------------------------------------------------------------------
#
# FUNCTION:  do_test
# PURPOSE:   Loop until interrupted creating the echo file and then
#	     echoing it to RHOST.
# INPUT:     None.
# OUTPUT:    Informational messages are logged into the run log.
#
#-----------------------------------------------------------------------

do_test() 
{
   $trace_logic
   mkdir $TCtmp 
   echo  "Creating echo file $ECHOFILE"
   $TCbin/$CREATFILE $ECHOSIZE $TCtmp/$ECHOFILE
   [ $? = 0 ] || end_testcase "$ECHOFILE not created"

   echo "Compute the checksum of this file"
   csum1=`sum $TCtmp/$ECHOFILE |awk '{print $1}'`
   [ $csum1 ] || end_testcase "initial checksum computation failed"

   COUNT=1
   while [ $COUNT -le $NUMLOOPS ]
   do
      $TCbin/$ECHOES $RHOST $TCtmp/$ECHOFILE $NUMPROCESSES
      [ $? = 0 ] || end_testcase "Error in $ECHOES test in loop $COUNT"

      NUM=0
      while [ $NUM -lt $NUMPROCESSES ]
      do
         csum2=`sum $TCtmp/$ECHOFILE\$NUM |awk '{print $1}'`
         [ "$csum1" -eq "$csum2" ] || end_testcase "Checksums differ in loop $COUNT"
         NUM=`expr $NUM + 1`
      done

      echo "Successful execution for loop $COUNT" 
      COUNT=`expr $COUNT + 1`
      if [ $COUNT -le $NUMLOOPS ]; then
        echo "Sleeping 60 seconds to avoid hitting max. connections setting for service"
        sleep 60
      fi
   done
}

#-----------------------------------------------------------------------
#
# FUNCTION:	do_cleanup
# PURPOSE:	Called when the testcase is interrupted by the user
#		or by interrupt_testcase() when time limit expired
# INPUT:	None.
# OUTPUT:	None.
#
#-----------------------------------------------------------------------

do_cleanup()
{
   $trace_logic

   cd /
   if [ $TCtmp = $TCsrc ]; then
      rm -f $TCtmp/echofile*
   else
      rm -rf $TCtmp
   fi
}

#=============================================================================
# FUNCTION NAME:        end_testcase
# 
# FUNCTION DESCRIPTION: Clean up
# 
# PARAMETERS:           string, IF AND ONLY IF the testcase fails
# 
# RETURNS:              None.
#=============================================================================

end_testcase()
{  
   $trace_logic
    
   # Call other cleanup functions
   [ $CLEANUP = "ON" ] && do_cleanup

   [ $# -eq 0 ] && { echo "Test Successful"; exit 0; }
   echo "Test Failed: $@@"
   echo""
   echo "***NOTE***"
   echo "Make sure the streamed echo is uncommented in inetd.conf"
   echo "on the server. Also try increasing max connections from"
   echo "default of 40, i.e. nowait.400"
   exit 1
}   

#-----------------------------------------------------------------------
#
# FUNCTION:  MAIN
# PURPOSE:   To invoke functions that perform the tasks as described in
#	     the design in the prolog above.
# INPUT:     See SETUP in the prolog above.
# OUTPUT:    Logged run results written to testcase run log
#
#-----------------------------------------------------------------------
do_test
end_testcase
@


1.1.1.1
log
@Initial import of the Linux Test Project (http://ltp.sourceforge.net).

This import is minus the Posix test suite, which will be imported separately,
and the HPI suite, which doesn't concern us.
@
text
@@
