4 # Copyright (c)2001-2024 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.
14 [ "$1" -gt 0 ] 2>/dev/null && CLIENTS="$1" || CLIENTS=5
15 [ "$2" -gt 0 ] 2>/dev/null && MAX="$2" || MAX=-1
17 # detect source directory
18 [ -z "$srcdir" ] && srcdir=`dirname "$0"`
25 [ -d logs ] || mkdir logs
26 [ -d tests ] || mkdir tests
28 # test for required external tools
29 type expect >/dev/null 2>&1
31 echo "${name}: \"expect\" not found."
34 type telnet >/dev/null 2>&1
36 echo "${name}: \"telnet\" not found.";
41 echo "stressing server with $CLIENTS clients (be patient!):"
44 . "${srcdir}/functions.inc"
46 # create scripts for expect(1)
48 while [ ${no} -lt $CLIENTS ]; do
49 cat "${srcdir}/stress-A.e" >tests/${no}.e
50 echo "send \"nick test${no}\\r\"" >>tests/${no}.e
51 cat "${srcdir}/stress-B.e" >>tests/${no}.e
55 # run first script and check if it succeeds
56 echo_n "checking stress script ..."
57 expect tests/0.e >logs/stress-0.log 2>/dev/null
66 while [ ${no} -lt $CLIENTS ]; do
67 expect tests/${no}.e >logs/stress-${no}.log 2>/dev/null &
70 echo "started client $no/$CLIENTS."
72 [ $MAX -gt 0 ] && "$srcdir/wait-tests.sh" $MAX
75 echo_n "waiting for clients to complete: ."
76 touch logs/check-idle.log
78 expect "${srcdir}/check-idle.e" >>logs/check-idle.log; res=$?
79 echo "====================" >>logs/check-idle.log
80 [ $res -ne 99 ] && break
82 # there are still clients connected. Wait ...
87 [ $res -eq 0 ] && echo " ok." || echo " failure!"