4 # Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
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.
13 # detect source directory
14 [ -z "$srcdir" ] && srcdir=`dirname $0`
17 [ "$1" -gt 0 ] 2> /dev/null && CLIENTS="$1" || CLIENTS=5
18 [ "$2" -gt 0 ] 2> /dev/null && MAX="$2" || MAX=-1
24 [ -d logs ] || mkdir logs
25 [ -d tests ] || mkdir tests
27 # test for required external tools
28 type expect > /dev/null 2>&1
30 echo "${name}: \"expect\" not found."; exit 77
32 type telnet > /dev/null 2>&1
34 echo "${name}: \"telnet\" not found."; exit 77
38 echo "stressing server with $CLIENTS clients (be patient!):"
41 . ${srcdir}/functions.inc
43 # create scripts for expect(1)
45 while [ ${no} -lt $CLIENTS ]; do
46 cat ${srcdir}/stress-A.e > tests/${no}.e
47 echo "send \"nick test${no}\\r\"" >> tests/${no}.e
48 cat ${srcdir}/stress-B.e >> tests/${no}.e
52 # run first script and check if it succeeds
53 echo_n "checking stress script ..."
54 expect tests/0.e > logs/stress-0.log 2> /dev/null
63 while [ ${no} -lt $CLIENTS ]; do
64 expect tests/${no}.e > logs/stress-${no}.log 2> /dev/null &
67 echo "started client $no/$CLIENTS."
69 [ $MAX -gt 0 ] && $srcdir/wait-tests.sh $MAX
72 echo_n "waiting for clients to complete: ."
73 touch logs/check-idle.log
75 expect ${srcdir}/check-idle.e >> logs/check-idle.log; res=$?
76 echo "====================" >> logs/check-idle.log
77 [ $res -ne 99 ] && break
79 # there are still clients connected. Wait ...
84 [ $res -eq 0 ] && echo " ok." || echo " failure!"