2002-09-10 00:56:07 +02:00
|
|
|
#!/bin/sh
|
2004-09-04 15:58:31 +02:00
|
|
|
#
|
2002-09-10 00:56:07 +02:00
|
|
|
# ngIRCd Test Suite
|
2012-09-27 00:56:03 +02:00
|
|
|
# Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
|
2004-09-04 15:58:31 +02:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
# Please read the file COPYING, README and AUTHORS for more information.
|
|
|
|
#
|
2002-09-10 00:56:07 +02:00
|
|
|
|
2004-09-04 15:58:31 +02:00
|
|
|
# detect source directory
|
2002-09-24 00:07:42 +02:00
|
|
|
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
|
|
|
|
2004-09-04 15:58:31 +02:00
|
|
|
# parse command line
|
2003-04-22 21:27:50 +02:00
|
|
|
[ "$1" -gt 0 ] 2> /dev/null && CLIENTS="$1" || CLIENTS=5
|
2004-09-04 20:20:16 +02:00
|
|
|
[ "$2" -gt 0 ] 2> /dev/null && MAX="$2" || MAX=-1
|
2002-09-10 00:56:07 +02:00
|
|
|
|
2004-09-04 15:58:31 +02:00
|
|
|
# get our name
|
2002-09-10 00:56:07 +02:00
|
|
|
name=`basename $0`
|
2004-09-04 15:58:31 +02:00
|
|
|
|
|
|
|
# create directories
|
2012-09-27 00:56:03 +02:00
|
|
|
[ -d logs ] || mkdir logs
|
|
|
|
[ -d tests ] || mkdir tests
|
2002-09-10 00:56:07 +02:00
|
|
|
|
2004-09-04 15:58:31 +02:00
|
|
|
# test for required external tools
|
2002-09-10 00:56:07 +02:00
|
|
|
type expect > /dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
2003-08-22 13:31:18 +02:00
|
|
|
echo " ${name}: \"expect\" not found."; exit 77
|
2002-09-10 00:56:07 +02:00
|
|
|
fi
|
|
|
|
type telnet > /dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
2003-08-22 13:31:18 +02:00
|
|
|
echo " ${name}: \"telnet\" not found."; exit 77
|
2002-09-10 00:56:07 +02:00
|
|
|
fi
|
|
|
|
|
2004-09-04 15:58:31 +02:00
|
|
|
# hello world! :-)
|
2004-09-04 17:45:27 +02:00
|
|
|
echo " stressing server with $CLIENTS clients (be patient!):"
|
2004-09-04 15:58:31 +02:00
|
|
|
|
2004-09-07 00:04:06 +02:00
|
|
|
# read in functions
|
|
|
|
. ${srcdir}/functions.inc
|
|
|
|
|
2004-09-04 15:58:31 +02:00
|
|
|
# create scripts for expect(1)
|
2002-09-10 00:56:07 +02:00
|
|
|
no=0
|
|
|
|
while [ ${no} -lt $CLIENTS ]; do
|
2002-09-12 04:28:44 +02:00
|
|
|
cat ${srcdir}/stress-A.e > tests/${no}.e
|
2002-09-10 00:56:07 +02:00
|
|
|
echo "send \"nick test${no}\\r\"" >> tests/${no}.e
|
2002-09-12 04:28:44 +02:00
|
|
|
cat ${srcdir}/stress-B.e >> tests/${no}.e
|
2002-09-10 00:56:07 +02:00
|
|
|
no=`expr ${no} + 1`
|
|
|
|
done
|
|
|
|
|
2005-12-30 23:13:21 +01:00
|
|
|
# run first script and check if it succeeds
|
|
|
|
echo_n " checking stress script ..."
|
|
|
|
expect tests/0.e > logs/stress-0.log 2> /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo " failure!"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo " ok."
|
|
|
|
fi
|
|
|
|
|
2004-09-04 17:45:27 +02:00
|
|
|
no=0
|
|
|
|
while [ ${no} -lt $CLIENTS ]; do
|
|
|
|
expect tests/${no}.e > logs/stress-${no}.log 2> /dev/null &
|
2004-09-04 15:58:31 +02:00
|
|
|
|
2004-09-04 20:20:16 +02:00
|
|
|
no=`expr ${no} + 1`
|
|
|
|
echo " started client $no/$CLIENTS."
|
2004-09-04 15:58:31 +02:00
|
|
|
|
2004-09-04 20:20:16 +02:00
|
|
|
[ $MAX -gt 0 ] && $srcdir/wait-tests.sh $MAX
|
2004-09-04 17:45:27 +02:00
|
|
|
done
|
|
|
|
|
2004-09-07 00:04:06 +02:00
|
|
|
echo_n " waiting for clients to complete: ."
|
2004-09-04 17:45:27 +02:00
|
|
|
touch logs/check-idle.log
|
|
|
|
while true; do
|
|
|
|
expect ${srcdir}/check-idle.e >> logs/check-idle.log; res=$?
|
|
|
|
echo "====================" >> logs/check-idle.log
|
|
|
|
[ $res -ne 99 ] && break
|
2004-09-04 15:58:31 +02:00
|
|
|
|
2004-09-04 17:45:27 +02:00
|
|
|
# there are still clients connected. Wait ...
|
|
|
|
sleep 3
|
2004-09-07 00:04:06 +02:00
|
|
|
echo_n "."
|
2002-09-10 00:56:07 +02:00
|
|
|
done
|
|
|
|
|
2004-09-04 21:14:46 +02:00
|
|
|
[ $res -eq 0 ] && echo " ok." || echo " failure!"
|
2004-09-04 17:45:27 +02:00
|
|
|
|
2004-09-04 15:58:31 +02:00
|
|
|
exit $res
|
|
|
|
|
2002-09-10 00:56:07 +02:00
|
|
|
# -eof-
|