4 # Copyright (c)2002-2004 by Alexander Barton (alex@barton.de)
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 # Please read the file COPYING, README and AUTHORS for more information.
12 # $Id: stress-server.sh,v 1.8.2.1 2004/09/04 20:49:36 alex Exp $
15 # detect source directory
16 [ -z "$srcdir" ] && srcdir=`dirname $0`
19 [ "$1" -gt 0 ] 2> /dev/null && CLIENTS="$1" || CLIENTS=5
20 [ "$2" -gt 0 ] 2> /dev/null && MAX="$2" || MAX=-1
28 # test for required external tools
29 type expect > /dev/null 2>&1
31 echo " ${name}: \"expect\" not found."; exit 77
33 type telnet > /dev/null 2>&1
35 echo " ${name}: \"telnet\" not found."; exit 77
39 echo " stressing server with $CLIENTS clients (be patient!):"
41 # create scripts for expect(1)
43 while [ ${no} -lt $CLIENTS ]; do
44 cat ${srcdir}/stress-A.e > tests/${no}.e
45 echo "send \"nick test${no}\\r\"" >> tests/${no}.e
46 cat ${srcdir}/stress-B.e >> tests/${no}.e
51 while [ ${no} -lt $CLIENTS ]; do
52 expect tests/${no}.e > logs/stress-${no}.log 2> /dev/null &
55 echo " started client $no/$CLIENTS."
57 [ $MAX -gt 0 ] && $srcdir/wait-tests.sh $MAX
60 echo -n " waiting for clients to complete: ."
61 touch logs/check-idle.log
63 expect ${srcdir}/check-idle.e >> logs/check-idle.log; res=$?
64 echo "====================" >> logs/check-idle.log
65 [ $res -ne 99 ] && break
67 # there are still clients connected. Wait ...
72 [ $res -eq 0 ] && echo " ok." || echo " failure!"