Commit Diff


commit - 920d0636ff5741cb191f895e97ad151186701816
commit + 7ad167f4c43948f19125123a27dbe68a93e863b8
blob - 9a2529f25821668478fd6bd6e2e2b34f1dba30a4
blob + fd628e3dc9c5515a7faf1e3a31ed958ad4f8eae3
--- src/testsuite/.gitignore
+++ src/testsuite/.gitignore
@@ -1,4 +1,5 @@
-T-ngircd
+T-ngircd1
+T-ngircd2
 channel-test
 connect-test
 invite-test
@@ -8,8 +9,11 @@ message-test
 misc-test
 mode-test
 opless-channel-test
+server-link-test
 who-test
-ngircd-test.log
-ngircd-test.motd
+ngircd-test1.log
+ngircd-test2.log
+ngircd-test1.motd
+ngircd-test2.motd
 logs
 tests
blob - e9a1b1ceea3dcef1fc9d31545c1d822272552cfb
blob + f72453f15e011b2a58a94755f364f346901ebe08
--- src/testsuite/Makefile.am
+++ src/testsuite/Makefile.am
@@ -1,6 +1,6 @@
 #
 # ngIRCd -- The Next Generation IRC Daemon
-# Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+# Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
 #
 # Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
 # der GNU General Public License (GPL), wie von der Free Software Foundation
@@ -9,8 +9,6 @@
 # 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.18 2008/02/17 13:26:42 alex Exp $
-#
 
 AUTOMAKE_OPTIONS = ../portab/ansi2knr
 
@@ -22,14 +20,16 @@ EXTRA_DIST = \
 	test-loop.sh wait-tests.sh \
 	channel-test.e connect-test.e check-idle.e invite-test.e \
 	join-test.e kick-test.e message-test.e misc-test.e mode-test.e \
-	opless-channel-test.e who-test.e stress-A.e stress-B.e \
-	ngircd-test.conf
+	opless-channel-test.e server-link-test.e who-test.e \
+	stress-A.e stress-B.e \
+	start-server1 stop-server1 ngircd-test1.conf \
+	start-server2 stop-server2 ngircd-test2.conf
 
 all:
 
 clean-local:
-	rm -rf logs tests *-test ngircd-test.log ngircd-test.motd \
-	 T-ngircd procs.tmp 
+	rm -rf logs tests *-test ngircd-test*.log procs.tmp \
+	 T-ngircd1 ngircd-test1.motd T-ngircd2 ngircd-test2.motd
 
 maintainer-clean-local:
 	rm -f Makefile Makefile.in
@@ -37,7 +37,8 @@ maintainer-clean-local:
 check_SCRIPTS = ngircd-TEST-Binary tests.sh
 
 ngircd-TEST-Binary:
-	cp ../ngircd/ngircd T-ngircd
+	cp ../ngircd/ngircd T-ngircd1
+	cp ../ngircd/ngircd T-ngircd2
 	[ -f getpid.sh ] || ln -s $(srcdir)/getpid.sh .
 
 connect-test: tests.sh
@@ -76,12 +77,17 @@ opless-channel-test: tests.sh
 	rm -f opless-channel-test
 	ln -s $(srcdir)/tests.sh opless-channel-test
 
+server-link-test: tests.sh
+	rm -f server-link-test
+	ln -s $(srcdir)/tests.sh server-link-test
+
 who-test: tests.sh
 	rm -f who-test
 	ln -s $(srcdir)/tests.sh who-test
 
-TESTS = start-server.sh \
+TESTS = start-server1 \
 	connect-test \
+	start-server2 \
 	channel-test \
 	invite-test \
 	join-test \
@@ -91,7 +97,9 @@ TESTS = start-server.sh \
 	mode-test \
 	opless-channel-test \
 	who-test \
+	server-link-test \
+	stop-server2 \
 	stress-server.sh \
-	stop-server.sh
+	stop-server1
 
 # -eof-
blob - 2a39be0242ae4d043c44a0ee52bfb0e13ee7a93f
blob + 8b695a1b4a5cea9eb8d68fc76d1918d125ed4c41
--- src/testsuite/README
+++ src/testsuite/README
@@ -1,7 +1,7 @@
 
                      ngIRCd - Next Generation IRC Server
 
-                      (c)2001-2004 by Alexander Barton,
+                       (c)2001-2008 Alexander Barton,
                     alex@barton.de, http://www.barton.de/
 
                ngIRCd is free software and published under the
@@ -17,15 +17,21 @@ The purpose of the "test suite" contained in this dire
 bugs and incompatibilities in ngIRCd introduced during coding and after
 building ngIRCd on a specific platform.
 
-To run the "standard" tests call "make check". It will build ngIRCd (if
-required) and run some tests on it. These tests should be portable and run
-on all supported platforms without errors.
+To run the "standard" tests call "make check" (which runs "make check" in
+all the source directories, testing the "portab" library as well for example)
+or "make testsuite" (which only runs the tests in this directory). Both will
+build ngIRCd (if required) and run some tests on it. These tests should be
+portable and run on all supported platforms without errors.
 
-Please note: most tests of this suite depend on the external tools expect(1)
+NOTE #1: most tests of this suite depend on the external tools expect(1)
 and telnet(1), so make sure you have them installed. If not, the tests will
 not fail but simply be skipped.
 
+NOTE #2: the two test servers started by this test suite are configured to
+run on port 6789 and 6790; so it will fail if one or both of these ports
+are already used by some other daemons!
 
+
 II. Shell Scripts
 ~~~~~~~~~~~~~~~~
 
@@ -35,38 +41,59 @@ getpid.sh <name>
 	the given name in a portable manner. The result is echoed on the
 	console. It is a helper script for some other scripts of this suite.
 
-start-server.sh
+start-server.sh [<id>]
 
-	start-server.sh starts up the test binary, "T-ngircd". It makes sure
-	that getpid.sh is available and working, and that no other instance
-	of the test binary is already running.
+	start-server.sh starts up the test binary, "T-ngircd<id>" (the default
+	for <id> is 1) with configuration file "ngircd-test<id>.conf" and the
+	console output redirected to "ngircd-test<id>.log".
+	The script first makes sure that getpid.sh is available and working,
+	and that no other instance of the test binary is already running.
 	The exit code is 0 if the test binary could be started.
 
-stop-server.sh
+stop-server.sha [<id>]
 
-	This script uses getpid.sh to detect a running test binary "T-ngircd"
-	and then shuts it down using the TERM signal.
+	This script uses getpid.sh to detect a running test binary
+	"T-ngircd<id>" and then shuts it down using the TERM signal.
 	The exit code is 0 if the test binary could be stopped.
 
-stress-server.sh
+stress-server.sh [<clientCount> [<maxConcurrent>]]
 
-	...
+	stress-server.sh starts <clientCount> clients that "stress" the
+	running test server (id 1); but no more than <maxConcurrent> clients
+	are started at the same moment.
 
 tests.sh
 
-	...
+	Most of the tests scripts are symlinked to tests.sh, which in turn
+	uses expect(1) to run the respective script <name>.e and checks
+	its exit code.
 
+test-loop.sh [<loops> [<wait>]]
 
+	This script runs all the tests <loops> times (default: 5) and pauses
+	<wait> seconds (default: 5) betweed runs.
+	It isn't used by "make check" or "make testsuite".
+
+wait-tests.sh [<max>]
+
+	stress-server.sh uses this script to ensure that no more than <max>
+	clients are connected to the test server (id 1).
+
+
 III. Scripts for expect(1)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 channel-test.e
 check-idle.e
 connect-test.e
+invite-test.e
+join-test.e
+kick-test.e
+message-test.e
+misc-test.e
 mode-test.e
+opless-channel-test.e
+server-link-test.e
 stress-A.e
 stress-B.e
-
-
--- 
-$Id: README,v 1.1 2004/09/04 13:58:31 alex Exp $
+who-test.e
blob - 4d918e0eec1d0975e17adfe387a1c9fa6efca096 (mode 644)
blob + /dev/null
--- src/testsuite/ngircd-test.conf
+++ /dev/null
@@ -1,37 +0,0 @@
-# $Id: ngircd-test.conf,v 1.6 2008/02/17 00:00:13 fw Exp $
-
-[Global]
-	Name = ngircd.test.server
-	Info = ngIRCd Test-Server
-	Ports = 6789
-	MotdFile = ngircd-test.motd
-	AdminEMail = admin@irc.server
-	MaxConnectionsIP = 0
-	OperCanUseMode = yes
-	MaxJoins = 4
-
-[Operator]
-	Name = TestOp
-	Password = 123
-
-[CHANNEL]
-	Name = #InviteChannel
-	Modes = i
-
-[CHANNEL]
-	Name = #FullKeyed
-	Modes = lk
-	MaxUsers = 0
-	Key = Secret
-
-[CHANNEL]
-	Name = #TopicChannel
-	Modes = t
-	Topic = the topic
-	
-[CHANNEL]
-	Name = #SecretChannel
-	Modes = s
-	Topic = A secret Channel
-
-# -eof-
blob - /dev/null
blob + 299bf7ca2b1df0467dae95e82c4c7da62a4ee7c6 (mode 644)
--- /dev/null
+++ src/testsuite/ngircd-test1.conf
@@ -0,0 +1,43 @@
+# ngIRCd test suite
+# configuration file for test server #2
+
+[Global]
+	Name = ngircd.test.server
+	Info = ngIRCd Test-Server 1
+	Ports = 6789
+	MotdFile = ngircd-test1.motd
+	AdminEMail = admin@irc.server
+	MaxConnectionsIP = 0
+	OperCanUseMode = yes
+	MaxJoins = 4
+
+[Operator]
+	Name = TestOp
+	Password = 123
+
+[Server]
+	Name = ngircd.test.server2
+	MyPassword = pwd1
+	PeerPassword = pwd2
+
+[Channel]
+	Name = #InviteChannel
+	Modes = i
+
+[Channel]
+	Name = #FullKeyed
+	Modes = lk
+	MaxUsers = 0
+	Key = Secret
+
+[Channel]
+	Name = #TopicChannel
+	Modes = t
+	Topic = the topic
+	
+[Channel]
+	Name = #SecretChannel
+	Modes = s
+	Topic = A secret Channel
+
+# -eof-
blob - /dev/null
blob + 3c2829bc80575125df63c1ffcff1e8ba2ea3aa19 (mode 644)
--- /dev/null
+++ src/testsuite/ngircd-test2.conf
@@ -0,0 +1,25 @@
+# ngIRCd test suite
+# configuration file for test server #2
+
+[Global]
+	Name = ngircd.test.server2
+	Info = ngIRCd Test-Server 2
+	Ports = 6790
+	MotdFile = ngircd-test2.motd
+	AdminEMail = admin@irc.server2
+	MaxConnectionsIP = 0
+	OperCanUseMode = yes
+	MaxJoins = 4
+
+[Operator]
+	Name = TestOp
+	Password = 123
+
+[Server]
+	Name = ngircd.test.server
+	Host = localhost
+	Port = 6789
+	MyPassword = pwd2
+	PeerPassword = pwd1
+
+# -eof-
blob - 8d6c650674d183706bd97ff66e69df107c5311b5
blob + 15fa3f065bca64709a5d8ccb31a914be6a38562b
--- src/testsuite/start-server.sh
+++ src/testsuite/start-server.sh
@@ -1,17 +1,22 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: start-server.sh,v 1.14 2004/09/06 22:04:06 alex Exp $
 
 [ -z "$srcdir" ] && srcdir=`dirname $0`
 
 # read in functions
 . ${srcdir}/functions.inc
 
-echo_n "      starting server ..."
+if [ -n "$1" ]; then
+	id="$1"; shift
+else
+	id="1"
+fi
 
-# remove old logfiles
-rm -rf logs *.log
+echo_n "      starting server ${id} ..."
 
+# remove old logfiles, if this is the first server (ID 1)
+[ "$id" = "1" ] && rm -rf logs *.log
+
 # check weather getpid.sh returns valid PIDs. If not, don't start up the
 # test-server, because we won't be able to kill it at the end of the test.
 ./getpid.sh sh > /dev/null 2>&1
@@ -21,21 +26,22 @@ if [ $? -ne 0 ]; then
 fi
 
 # check if there is a test-server already running
-./getpid.sh T-ngircd > /dev/null 2>&1
+./getpid.sh T-ngircd${id} >/dev/null 2>&1
 if [ $? -eq 0 ]; then
-  echo " failure: test-server already running!"
+  echo " failure: test-server ${id} already running!"
   exit 1
 fi
 
 # generate MOTD for test-server
-echo "This is an ngIRCd Test Server" > ngircd-test.motd
+echo "This is an ngIRCd Test Server" > ngircd-test${id}.motd
 
 # starting up test-server ...
-./T-ngircd -np -f ${srcdir}/ngircd-test.conf $* > ngircd-test.log 2>&1 &
+./T-ngircd${id} -n -f ${srcdir}/ngircd-test${id}.conf $* \
+ >ngircd-test${id}.log 2>&1 &
 sleep 1
 
 # validate running test-server
-pid=`./getpid.sh T-ngircd`
+pid=`./getpid.sh T-ngircd${id}`
 [ -n "$pid" ] && kill -0 $pid > /dev/null 2>&1; r=$?
 
 [ $r -eq 0 ] && echo " ok." || echo " failure!"
blob - 256d512eeb17f7ad1787d71e6e22601561290399
blob + 7e6ee4f76b5e5c8afdae76d35fabbc7fee450d7c
--- src/testsuite/stop-server.sh
+++ src/testsuite/stop-server.sh
@@ -1,16 +1,21 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: stop-server.sh,v 1.13 2004/09/06 22:04:06 alex Exp $
 
 [ -z "$srcdir" ] && srcdir=`dirname $0`
 
 # read in functions
 . ${srcdir}/functions.inc
 
-echo_n "      stopping server ..."
+if [ -n "$1" ]; then
+	id="$1"; shift
+else
+	id="1"
+fi
 
+echo_n "      stopping server ${id} ..."
+
 # stop test-server ...
-pid=`./getpid.sh T-ngircd`
+pid=`./getpid.sh T-ngircd${id}`
 if [ -z "$pid" ]; then
   echo " failure: no running server found!?"
   exit 1
@@ -26,7 +31,7 @@ for i in 1 2 3 4 5; do
   fi
   sleep 1
 done
-echo " failure: server still running!?"
+echo " failure: server ${id} still running!?"
 exit 1
 
 # -eof-
blob - /dev/null
blob + 3a1c232d8f11eaab020e421ad2a368bbedb08b01 (mode 644)
--- /dev/null
+++ src/testsuite/server-link-test.e
@@ -0,0 +1,52 @@
+# ngIRCd test suite
+# server-server link test
+
+spawn telnet localhost 6790
+expect {
+	timeout { exit 1 }
+	"Connected"
+}
+
+send "nick nick\r"
+send "user user . . :User\r"
+expect {
+	timeout { exit 1 }
+	"376"
+}
+
+send "version ngircd.test.server2\r"
+expect {
+	timeout { exit 1 }
+	":ngircd.test.server2 351"
+}
+send "version ngircd.test.server\r"
+expect {
+	timeout { exit 1 }
+	":ngircd.test.server 351"
+}
+
+send "whois ngircd.test.server nick\r"
+expect {
+	timeout { exit 1 }
+	":ngircd.test.server 318"
+}
+
+send "admin ngircd.test.server\r"
+expect {
+	timeout { exit 1 }
+	":ngircd.test.server 259 nick :admin@irc.server"
+}
+
+send "links\r"
+expect {
+	timeout { exit 1 }
+	"364 nick ngircd.test.server ngircd.test.server2 :1"
+}
+
+send "quit\r"
+expect {
+	timeout { exit 1 }
+	"ERROR"
+}
+
+# -eof-
blob - /dev/null
blob + 7fb4e94caa58c86fc10383b5260a1d05090b8f6d (mode 755)
--- /dev/null
+++ src/testsuite/start-server1
@@ -0,0 +1,7 @@
+#!/bin/sh
+# ngIRCd Test Suite
+
+[ -z "$srcdir" ] && srcdir=`dirname $0`
+${srcdir}/start-server.sh 1
+
+# -eof-
blob - /dev/null
blob + 2c4ffa6b332729d57651ca7224e97efdd8dbdfd1 (mode 755)
--- /dev/null
+++ src/testsuite/start-server2
@@ -0,0 +1,7 @@
+#!/bin/sh
+# ngIRCd Test Suite
+
+[ -z "$srcdir" ] && srcdir=`dirname $0`
+${srcdir}/start-server.sh 2
+
+# -eof-
blob - /dev/null
blob + 9b562076f4dc129f1688ed7c8a4df46cadcced80 (mode 755)
--- /dev/null
+++ src/testsuite/stop-server1
@@ -0,0 +1,7 @@
+#!/bin/sh
+# ngIRCd Test Suite
+
+[ -z "$srcdir" ] && srcdir=`dirname $0`
+${srcdir}/stop-server.sh 1
+
+# -eof-
blob - /dev/null
blob + 304d174960a4f2ed5e34007633ba8d88106f6824 (mode 755)
--- /dev/null
+++ src/testsuite/stop-server2
@@ -0,0 +1,7 @@
+#!/bin/sh
+# ngIRCd Test Suite
+
+[ -z "$srcdir" ] && srcdir=`dirname $0`
+${srcdir}/stop-server.sh 2
+
+# -eof-