about summary refs log tree commit diff
path: root/src/testsuite/stress-server.sh
blob: f9364462df5899795762237f25d7f55413fb12a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# ngIRCd Test Suite
# $Id: stress-server.sh,v 1.6 2002/09/23 22:07:43 alex Exp $

[ -z "$srcdir" ] && srcdir=`dirname $0`

[ $1 -gt 0 ] 2> /dev/null && CLIENTS=$1 || CLIENTS=5

name=`basename $0`
test=`echo ${name} | cut -d '.' -f 1`
mkdir -p logs tests

type expect > /dev/null 2>&1
if [ $? -ne 0 ]; then
  echo "SKIP: ${name} -- \"expect\" not found.";  exit 77
fi
type telnet > /dev/null 2>&1
if [ $? -ne 0 ]; then
  echo "SKIP: ${name} -- \"telnet\" not found.";  exit 77
fi

echo "      stressing server with $CLIENTS clients (be patient!) ..."
no=0
while [ ${no} -lt $CLIENTS ]; do
  cat ${srcdir}/stress-A.e > tests/${no}.e
  echo "send \"nick test${no}\\r\"" >> tests/${no}.e
  cat ${srcdir}/stress-B.e >> tests/${no}.e
  no=`expr ${no} + 1`
done
no=0
while [ ${no} -lt $CLIENTS ]; do
  expect tests/${no}.e > logs/stress-${no}.log 2> /dev/null &
  no=`expr ${no} + 1`
done

touch logs/check-idle.log
while true; do
  expect ${srcdir}/check-idle.e >> logs/check-idle.log
  res=$?
  [ $res -eq 0 ] && exit 0
  [ $res -eq 1 ] && exit 1
  sleep 1
  echo "====================" >> logs/check-idle.log
done

# -eof-