Commit Diff


commit - d040fa2a7da818d84171fa1a5e3c5d2c2fca92a1
commit + fc6f64742cf58203c5e14481498e592d21899f02
blob - 8043c71d5fcc8b7e2f9b05d2a5c81bbea4917fbb
blob + 85c855464f88b36ebe3129f11d455ba393a8e424
--- src/testsuite/Makefile.am
+++ 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-
blob - /dev/null
blob + 08d79cab59c01d1ea1b6d09df0754938b5964931 (mode 644)
--- /dev/null
+++ 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-
blob - 11b8121b4fa7e0c5ee23e23f69bd44136964063b
blob + 51de410ec4f2aa49e5bcd5ddda13f007153089c8
--- src/testsuite/start-server.sh
+++ 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-
blob - 4678654986c4784f5eb758734c5db068319b9475
blob + e2ddd930b78a2ec5a857dd45040b87104cd782f5
--- src/testsuite/tests.sh
+++ 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-
blob - /dev/null
blob + 4127dcc36a10a4c72809f7be29f7904f9a94fd89 (mode 644)
--- /dev/null
+++ 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-
blob - /dev/null
blob + 117e1524d3ab4f0f4fb9fcb2cba053d2f5082493 (mode 644)
--- /dev/null
+++ 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-
blob - /dev/null
blob + f978f4b8c7a3c2b9cd4ddf890a93458f81853492 (mode 755)
--- /dev/null
+++ 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-