diff --git a/src/testsuite/Makefile.am b/src/testsuite/Makefile.am index 8043c71d..85c85546 100644 --- a/src/testsuite/Makefile.am +++ b/src/testsuite/Makefile.am @@ -9,17 +9,21 @@ # Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste # der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. # -# $Id: Makefile.am,v 1.1 2002/09/09 10:16:24 alex Exp $ +# $Id: Makefile.am,v 1.2 2002/09/09 22:56:07 alex Exp $ # AUTOMAKE_OPTIONS = ../portab/ansi2knr INCLUDES = -I$(srcdir)/../portab -EXTRA_DIST = ngircd-test.conf connect-test.e channel-test.e mode-test.e +EXTRA_DIST = \ + start-server.sh stop-server.sh tests.sh stress-server.sh \ + connect-test.e channel-test.e mode-test.e \ + stress-A.e stress-B.e check-idle.e + ngircd-test.conf clean-local: - rm -f *.log *-test + rm -rf logs tests *-test ngircd-test.log ngircd-test.motd maintainer-clean-local: rm -f Makefile Makefile.in @@ -39,6 +43,7 @@ TESTS = start-server.sh \ connect-test \ channel-test \ mode-test \ + stress-server.sh \ stop-server.sh # -eof- diff --git a/src/testsuite/check-idle.e b/src/testsuite/check-idle.e new file mode 100644 index 00000000..08d79cab --- /dev/null +++ b/src/testsuite/check-idle.e @@ -0,0 +1,31 @@ +# $Id: check-idle.e,v 1.1 2002/09/09 22:56:07 alex Exp $ + +spawn telnet localhost 6789 +expect { + timeout { exit 1 } + "Connected" +} + +send "nick IdleTest\r" +send "user idle . . :Idle-Test\r" +expect { + timeout { exit 1 } + "376" +} + +send "lusers\r" +expect { + timeout { exit 1 } + "251 IdleTest :There are 1 users and 0 services on 1 servers" { set r 0 } + "251 IdleTest :There are" { set r 99 } +} + +send "quit\r" +expect { + timeout { exit 1 } + "Connection closed" +} + +exit $r + +# -eof- diff --git a/src/testsuite/start-server.sh b/src/testsuite/start-server.sh index 11b8121b..51de410e 100755 --- a/src/testsuite/start-server.sh +++ b/src/testsuite/start-server.sh @@ -1,6 +1,6 @@ #!/bin/sh # ngIRCd Test Suite -# $Id: start-server.sh,v 1.1 2002/09/09 10:16:24 alex Exp $ +# $Id: start-server.sh,v 1.2 2002/09/09 22:56:07 alex Exp $ echo " starting server ..." @@ -12,4 +12,6 @@ sleep 1 pid=`ps a | grep ngircd-test | head -n 1 | cut -d ' ' -f 1` kill -0 $pid > /dev/null 2>&1 +rm -rf logs + # -eof- diff --git a/src/testsuite/stress-A.e b/src/testsuite/stress-A.e new file mode 100644 index 00000000..4127dcc3 --- /dev/null +++ b/src/testsuite/stress-A.e @@ -0,0 +1,9 @@ +# $Id: stress-A.e,v 1.1 2002/09/09 22:56:07 alex Exp $ + +spawn telnet localhost 6789 +expect { + timeout { exit 1 } + "Connected" +} + +# -eof- diff --git a/src/testsuite/stress-B.e b/src/testsuite/stress-B.e new file mode 100644 index 00000000..117e1524 --- /dev/null +++ b/src/testsuite/stress-B.e @@ -0,0 +1,69 @@ +# $Id: stress-B.e,v 1.1 2002/09/09 22:56:07 alex Exp $ + +send "user user . . :User\r" +expect { + timeout { exit 1 } + "376" +} + +send "oper TestOp 123\r" +expect { + timeout { exit 1 } + "MODE test* :+o" +} +expect { + timeout { exit 1 } + "381 test*" +} + +send "join #channel\r" +expect { + timeout { exit 1 } + ":test*!~user@* JOIN :#channel" +} +expect { + timeout { exit 1 } + "366" +} + +send "mode #channel\r" +expect { + timeout { exit 1 } + "324 test* #channel" +} + +send "join #channel2\r" +expect { + timeout { exit 1 } + ":test*!~user@* JOIN :#channel2" +} +expect { + timeout { exit 1 } + "366" +} + +send "names\r" +expect { + timeout { exit 1 } + "366" +} + +send "part #channel2\r" +expect { + timeout { exit 1 } + ":test*!~user@* PART #channel2" +} + +send "part #channel\r" +expect { + timeout { exit 1 } + ":test*!~user@* PART #channel" +} + +send "quit\r" +expect { + timeout { exit 1 } + "Connection closed" +} + +# -eof- diff --git a/src/testsuite/stress-server.sh b/src/testsuite/stress-server.sh new file mode 100755 index 00000000..f978f4b8 --- /dev/null +++ b/src/testsuite/stress-server.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# ngIRCd Test Suite +# $Id: stress-server.sh,v 1.1 2002/09/09 22:56:07 alex Exp $ + +CLIENTS=50 + +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 stress-A.e > tests/${no}.e + echo "send \"nick test${no}\\r\"" >> tests/${no}.e + cat 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 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- diff --git a/src/testsuite/tests.sh b/src/testsuite/tests.sh index 46786549..e2ddd930 100755 --- a/src/testsuite/tests.sh +++ b/src/testsuite/tests.sh @@ -1,16 +1,21 @@ #!/bin/sh # ngIRCd Test Suite -# $Id: tests.sh,v 1.1 2002/09/09 10:16:24 alex Exp $ +# $Id: tests.sh,v 1.2 2002/09/09 22:56:07 alex Exp $ name=`basename $0` test=`echo ${name} | cut -d '.' -f 1` +mkdir -p logs 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 " doing ${test} ..." -expect ${test}.e > ${test}.log +expect ${test}.e > logs/${test}.log # -eof-