Add new test scripts and generally improve code coverage of tests.
authorMichael Poole <mdpoole@troilus.org>
Tue, 31 May 2005 00:26:19 +0000 (00:26 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 31 May 2005 00:26:19 +0000 (00:26 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1419 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

16 files changed:
ChangeLog
ircd/test/Makefile.in
ircd/test/channel-1.cmd
ircd/test/client-1.cmd
ircd/test/commands-1.cmd [new file with mode: 0644]
ircd/test/feature-1.cmd [new file with mode: 0644]
ircd/test/gline-1.cmd
ircd/test/ircd-t1-2.conf [new file with mode: 0644]
ircd/test/ircd-t1.conf
ircd/test/ircd-t2.conf [new file with mode: 0644]
ircd/test/ircd_match_t.c
ircd/test/jupe-1.cmd [new file with mode: 0644]
ircd/test/kill-block-1.cmd [new file with mode: 0644]
ircd/test/run-tests.sh
ircd/test/stats-1.cmd
ircd/test/test-driver.pl

index 149957ad9484c1be7da21d89d5d04e9651ceb835..ff5a1814b16d077d1622cc8d07ebda76d9912d63 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2005-05-30  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/test/Makefile.in: Add LDFLAGS variable for profiling purposes.
+
+       * ircd/test/ircd_match_t.c: Test recovery from backtracking.
+
+       * ircd/test/channel-1.cmd: Modify to improve code coverage.
+
+       * ircd/test/client-1.cmd: Likewise.
+
+       * ircd/test/gline-1.cmd: Likewise.
+
+       * ircd/test/ircd-t1.conf: Likewise.
+
+       * ircd/test/stats-1.cmd: Likewise.
+
+       * ircd/test/run-tests.sh: Explicitly start ircds.  Add new test scripts.
+
+       * ircd/test/test-driver.pl: Silently handle more signals from IRC.
+
+       * ircd/test/commands-1.cmd: New test script.
+
+       * ircd/test/feature-1.cmd: New test script.
+
+       * ircd/test/jupe-1.cmd: New test script.
+
+       * ircd/test/kill-block-1.cmd: New test script.
+
+       * ircd/test/ircd-t1-2.conf: New configuration file for test scripts.
+
+       * ircd/test/ircd-t2.conf: Likewise.
+
 2005-05-30  Michael Poole <mdpoole@troilus.org>
 
        * ircd/s_debug.c (count_memory): Use count_listener_memory() to
index 8449b09dd14c02d1c67957f47e03768b2695b1e2..44b4cda0914be5b1cff082115bb8a6825b26fd82 100644 (file)
@@ -3,6 +3,7 @@ srcdir = @srcdir@
 VPATH = @srcdir@
 CPPFLAGS = -I${top_srcdir}/include -I../..
 CFLAGS   = -g -Wall
+LDFLAGS  =
 CC = @CC@
 
 TESTPROGS = \
@@ -36,19 +37,19 @@ install:
 
 IRCD_CHATTR_T_OBJS = ircd_chattr_t.o test_stub.o ../ircd_string.o
 ircd_chattr_t: $(IRCD_CHATTR_T_OBJS)
-       ${CC} -o $@ $(IRCD_CHATTR_T_OBJS)
+       ${CC} -o $@ $(LDFLAGS) $(IRCD_CHATTR_T_OBJS)
 
 IRCD_IN_ADDR_T_OBJS = ircd_in_addr_t.o test_stub.o ../ircd_alloc.o ../ircd_string.o ../match.o ../numnicks.o
 ircd_in_addr_t: $(IRCD_IN_ADDR_T_OBJS)
-       ${CC} -o $@ $(IRCD_IN_ADDR_T_OBJS)
+       ${CC} -o $@ $(LDFLAGS) $(IRCD_IN_ADDR_T_OBJS)
 
 IRCD_MATCH_T_OBJS = ircd_match_t.o test_stub.o ../ircd_string.o ../match.o
 ircd_match_t: $(IRCD_MATCH_T_OBJS)
-       ${CC} -o $@ $(IRCD_MATCH_T_OBJS)
+       ${CC} -o $@ $(LDFLAGS) $(IRCD_MATCH_T_OBJS)
 
 IRCD_STRING_T_OBJS = ircd_string_t.o test_stub.o ../ircd_string.o
 ircd_string_t: $(IRCD_STRING_T_OBJS)
-       ${CC} -o $@ $(IRCD_STRING_T_OBJS)
+       ${CC} -o $@ $(LDFLAGS) $(IRCD_STRING_T_OBJS)
 
 .c.o:
        ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
index dfdcb8c4635151fd634027f22559c1d642833dc4..54efbb310f7c0289a5de0028c7a2bf6b08541a0c 100644 (file)
@@ -1,29 +1,50 @@
-define srv localhost:7701
+define srv localhost
 
-connect cl1 Alex alex %srv% :Test client 1
-connect cl2 Bubb bubb %srv% :Test client 2
+connect cl1 Alex alex %srv%:7701 :Test client 1
+connect cl2 Bubb bubb %srv%:7711 :Test client 2
 :cl1 join #test
 :cl1 join #test2
 :cl1 mode #test +bb *!*@127.0.0.1 *!*@127.0.0.2
 :cl2 wait cl1
-:cl2 join #test
+:cl2 raw :away :I'm not here, go away.  I'm not here, go away.  I'm not here, go away.  I'm not here, go away.  I'm not here, go away.  I'm not here, go away.  I'm not here, go away.  I'm not here, go away.  I'm not here, go away.  I'm not here, go away.
+:cl2 raw :away :I'm not here, go away.
+:cl2 join #test,#test3,#test4,+local
 :cl1 wait cl2
+:cl1 join #test3
+:cl1 raw :invite Bubb
+:cl1 raw :invite #test
+:cl1 invite Bubb #non-existent-channel
+:cl1 invite Bubb #test3
+:cl1 invite Bubb #test4
 :cl1 invite Bubb #test
 :cl2 expect *cl1 invite #test
+:cl2 mode #test3 +o Alex
+:cl2 raw :invite
 :cl2 join #test
 :cl2 privmsg #test :Hello, *cl1.
+:cl2 notice #test :Hello, *cl1 (via notice).
+:cl2 notice @#test :Hello, *cl1 (via wallchops).
+:cl2 privmsg #test5 :Hello, *cl1.
 :cl2 nick Buba
 :cl2 mode #test +l 15
 :cl1 wait cl2
 :cl1 privmsg #test :Hello, *cl2.
+:cl1 raw :cprivmsg bubb #test :Hello, bubb.
+:cl1 raw :cnotice bubb #test :Hello, bubb.
 :cl1 mode #test -b+kv *!*@127.0.0.1 secret Bubb
 :cl1 mode #test +b foo!bar@baz
 :cl1 mode #test +b
 :cl1 mode #test :
 :cl1 mode #test
-:cl1 raw who #test %lfuh
+:cl1 raw :names
+:cl1 raw :names #test
+:cl1 raw :names +local
+:cl1 raw :names +local test-2.*
+:cl1 raw :who #test %lfuh
 :cl2 wait cl1
+:cl2 raw :part
 :cl2 part #test
+:cl2 part #test5
 :cl1 wait cl2
 :cl2 join #test public
 :cl2 join #test secret
@@ -45,4 +66,9 @@ connect cl2 Bubb bubb %srv% :Test client 2
 :cl2 wait cl1
 :cl2 mode #test2 -D
 :cl2 mode #test +v Alex
+:cl1 raw :kick #test bubb
+:cl2 raw :squit test-1.*
+:cl2 sleep 1
+:cl2 raw :connect test-1.*
+:cl2 raw :away :
 :cl1 wait cl2
index 9a588c125b5770487abbb85fe8a29d6aea01e746..1db7fd13c89b74dbdebdaac986d2a9eb443dfda1 100644 (file)
@@ -1,9 +1,12 @@
-define srv localhost:7701
+define srv localhost
 
-connect cl1 Alex alex %srv% :Test client 1
+connect cl1 Alex alex %srv%:7701 :Test client 1
 :cl1 oper oper1 oper1
-connect cl2 Bubb bubb %srv% :Test client 2
+:cl1 oper oper1 oper1
+connect cl2 Bubb bubb %srv%:7711 :Test client 2
+:cl1 raw :time
 :cl2 oper oper3 oper4
+:cl1 raw :version
 :cl2 oper oldoper wrongpass
 :cl2 oper md5oper wrongpass
 :cl2 oper cryptoper wrongpass
@@ -13,3 +16,10 @@ connect cl2 Bubb bubb %srv% :Test client 2
 :cl1 raw :privs Bubb
 :cl1 nick A
 :cl1 nick Alexey
+:cl1 raw :privmsg :
+:cl1 raw :privmsg Alexey :
+:cl1 raw :privmsg Bubb :hello Bubb
+:cl1 raw :privmsg $*.net :Hello all *.net servers.
+:cl1 raw :notice $*.net :Hello all *.net servers.
+:cl1 raw :kill Bubb :goodbye Bubb
+:cl1 raw :whowas Alex,Bubb 5
diff --git a/ircd/test/commands-1.cmd b/ircd/test/commands-1.cmd
new file mode 100644 (file)
index 0000000..d97aaad
--- /dev/null
@@ -0,0 +1,43 @@
+define srv localhost:7701
+
+connect cl1 Alex alex %srv% :Test client 1
+connect cl2 Bubb bubb %srv% :Test client 2
+:cl1 raw :help
+:cl1 raw :admin
+:cl1 raw :admin test-2.*
+:cl1 raw :info
+:cl1 raw :wallops :HELLO OPERZ!!!
+:cl1 wait cl2
+:cl1 raw :ison alex,bubb,alex,bubb,alex,bubb
+:cl1 raw :who b*b
+:cl1 raw :burst the bubble
+:cl1 raw :server huh huh i'm a server
+:cl1 raw :links
+:cl1 raw :map
+:cl1 raw :nick
+:cl1 raw :nick ~
+:cl1 raw :nick -dude-
+:cl1 raw :nick alex
+:cl1 raw :nick Bubb
+:cl1 raw :ping alex test-1.*
+
+:cl1 oper oper1 oper1
+:cl1 raw :admin
+:cl1 raw :admin test-2.*
+:cl1 raw :asll
+:cl1 raw :asll test-2.*
+:cl1 raw :info
+:cl1 raw :info test-2.*
+:cl1 raw :who x b*b
+:cl1 raw :close
+:cl1 raw :map
+:cl1 raw :links
+:cl1 raw :links test-2.*
+:cl1 raw :lusers
+:cl1 raw :lusers test-2.*
+:cl1 raw :motd
+:cl1 raw :motd test-2.*
+:cl1 raw :ping alex test-2.*
+:cl1 raw :rping test-2.*
+
+:cl2 raw :quit
diff --git a/ircd/test/feature-1.cmd b/ircd/test/feature-1.cmd
new file mode 100644 (file)
index 0000000..af93c52
--- /dev/null
@@ -0,0 +1,18 @@
+define srv localhost:7701
+
+connect cl1 Alex alex %srv% :Test client 1
+:cl1 oper oper1 oper1
+:cl1 raw :GET LOG
+:cl1 raw :RESET LOG
+:cl1 raw :GET RANDOM_SEED
+:cl1 raw :SET RANDOM_SEED
+:cl1 raw :SET RANDOM_SEED abcdefghijklmnop
+:cl1 raw :GET DEFAULT_LIST_PARAM
+:cl1 raw :SET DEFAULT_LIST_PARAM FALSE
+:cl1 raw :SET DEFAULT_LIST_PARAM TRUE
+:cl1 nick Alexey
+:cl1 nick Amdahl
+:cl1 nick Andy
+:cl1 nick Aon
+:cl1 nick Apple
+:cl1 raw :SET NICKNAMEHISTORYLENGTH 4
index aa08dccce64ed291074b96d588c80af512da6ece..89a1d4bd5f4208163ce0f152bf05fb4bd2194896 100644 (file)
@@ -7,6 +7,9 @@ connect cl1 Alex alex %srv% :Test client 1
 :cl1 raw :gline !+127.2.* 3600 :Localclone?
 :cl1 sleep 5
 :cl1 raw :gline !+127.2.* 3600 :Localclone?
+:cl1 raw :gline !+127.2.*/15 3600 :Localclone?
+:cl1 raw :gline !+127.2.0.0/33 3600 :Localclone?
+:cl1 raw :gline !+127.2.0.0/15 3600 :Localclone?
 connect cl2 Bubb bubb %srv% :Test client 2
 :cl1 raw :gline
 :cl1 raw :gline $Rbubb
diff --git a/ircd/test/ircd-t1-2.conf b/ircd/test/ircd-t1-2.conf
new file mode 100644 (file)
index 0000000..b48017f
--- /dev/null
@@ -0,0 +1,93 @@
+General {
+        name = "test-1.example.net";
+        vhost = "127.0.0.1";
+        vhost = "::1";
+        description = "Test Server 1";
+        numeric = 1;
+};
+
+Admin {
+        location = "Somewhere";
+        contact = "Someone";
+};
+
+Class {
+        name = "Server";
+        pingfreq = 180 seconds;
+        connectfreq = 300 seconds;
+        maxlinks = 1;
+        sendq = 9000000;
+};
+
+Class {
+        name = "others";
+        pingfreq = 180 seconds;
+        sendq = 160000;
+        maxlinks = 100;
+        usermode = "+oiwx";
+};
+
+Class {
+        name = "Opers";
+        pingfreq = 180 seconds;
+        sendq = 160000;
+        maxlinks = 10;
+        local = no;
+};
+
+Connect {
+        name = "bogus.example.net";
+        host = "example.net";
+        password = "bogus_example";
+        port = 7700;
+        class = "Server";
+        maxhops = 2;
+        hub = "*.example.net";
+        autoconnect = yes; # forces a DNS resolution attempt
+};
+
+CRule {
+        server = "bogus.example.net";
+        all = yes;
+        rule = "connected(*)";
+};
+
+CRule {
+        server = "bogus.example.net";
+        all = no;
+        rule = "directcon(*)";
+};
+
+UWorld {
+        name = "uworld.example.net";
+        name = "uworld2.example.net";
+};
+
+Jupe {
+        nick = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q";
+        nick = "R,S,T,U,V,W,X,Y,Z,{,|,},~,-,_,`";
+};
+
+Operator { name = "oper1"; host = "*@*"; password = "$PLAIN$oper1"; class = "Opers"; };
+Operator { name = "oper2"; host = "*@*"; password = "$PLAIN$oper2"; class = "Opers"; local = yes; };
+Operator { name = "oldoper"; host = "*@*"; password = "Xlfc26b4eYGWs"; class = "Opers"; };
+Operator { name = "md5oper"; host = "*@*"; password = "$SMD5$2O$4O.rSAmhE4Fg05MmG.047/"; class = "Opers"; };
+Operator { name = "cryptoper"; host = "*@*"; password = "$CRYPT$41ndrxPQu3B66"; class = "Opers"; };
+
+Kill { username = "sub7"; realname = "s*7*"; reason = "You are infected with a Trojan"; };
+Kill { realname = "Chloe"; reason = "drones"; };
+Kill { username = "sub7"; reason = "You are infected with a Trojan"; };
+
+Client { class = "others"; ip = "*"; };
+
+Port { server = yes; port = 7700; };
+Port { server = no;  port = 7702; };
+
+Quarantine {
+        "#shells" = "Thou shalt not support the h4><0rz";
+};
+
+Features {
+        "HIS_STATS_k" = "FALSE";
+        "PPATH" = "ircd-t1.pid";
+};
index 92243ffb621d8e9207cd8e0131017772adb5a574..66472b08da7fc8454cb257b21ee8b4f9377e20bd 100644 (file)
@@ -46,6 +46,15 @@ Connect {
         autoconnect = yes; # forces a DNS resolution attempt
 };
 
+Connect {
+        name = "test-2.example.net";
+        host = "::1";
+        password = "bogus_example";
+        port = 7710;
+        class = "Server";
+        autoconnect = no;
+};
+
 CRule {
         server = "bogus.example.net";
         all = yes;
@@ -94,4 +103,5 @@ Pseudo "X" {
 
 Features {
         "HIS_STATS_k" = "FALSE";
+        "PPATH" = "ircd-t1.pid";
 };
diff --git a/ircd/test/ircd-t2.conf b/ircd/test/ircd-t2.conf
new file mode 100644 (file)
index 0000000..f692fdd
--- /dev/null
@@ -0,0 +1,95 @@
+General {
+        name = "test-2.example.net";
+        vhost = "127.0.0.1";
+        vhost = "::1";
+        description = "Test Server 2";
+        numeric = 2;
+};
+
+Admin {
+        location = "Somewhere";
+        contact = "Someone";
+};
+
+Class {
+        name = "Server";
+        pingfreq = 180 seconds;
+        connectfreq = 300 seconds;
+        maxlinks = 1;
+        sendq = 9000000;
+};
+
+Class {
+        name = "others";
+        pingfreq = 180 seconds;
+        sendq = 160000;
+        maxlinks = 100;
+        usermode = "+oiwx";
+};
+
+Class {
+        name = "Opers";
+        pingfreq = 180 seconds;
+        sendq = 160000;
+        maxlinks = 10;
+        local = no;
+};
+
+Connect {
+        name = "test-1.example.net";
+        host = "::1";
+        password = "bogus_example";
+        port = 7700;
+        class = "Server";
+        maxhops = 2;
+        hub = "*.example.net";
+        autoconnect = yes;
+};
+
+CRule {
+        server = "bogus.example.net";
+        all = yes;
+        rule = "connected(*)";
+};
+
+CRule {
+        server = "bogus.example.net";
+        all = no;
+        rule = "directcon(*)";
+};
+
+UWorld {
+        name = "uworld.example.net";
+        name = "uworld2.example.net";
+};
+
+Jupe {
+        nick = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q";
+        nick = "R,S,T,U,V,W,X,Y,Z,{,|,},~,-,_,`";
+};
+
+Operator { name = "oper1"; host = "*@*"; password = "$PLAIN$oper1"; class = "Opers"; };
+Operator { name = "oper2"; host = "*@*"; password = "$PLAIN$oper2"; class = "Opers"; local = yes; };
+
+Kill { realname = "Chloe"; reason = "drones"; };
+Kill { username = "sub7"; reason = "You are infected with a Trojan"; };
+
+Client { class = "others"; ip = "*"; };
+
+Port { server = yes; port = 7710; };
+Port { server = no;  port = 7711; mask = "127.0.0.0/8"; };
+
+Quarantine {
+        "#shells" = "Thou shalt not support the h4><0rz";
+};
+
+Pseudo "X" {
+        name = "X";
+        nick = "X@channels.example.net";
+};
+
+Features {
+        "PPATH" = "ircd-t2.pid";
+        "LOG" = "SYSTEM" "FILE" "ircd-t2.log";
+        "LOG" = "SYSTEM" "LEVEL" "NOTICE";
+};
index e051e5f28a3ec37fbc346e9960401454e2b2662f..da7a28fb707da6a09e8cf0be8a071602a6677d68 100644 (file)
@@ -27,7 +27,7 @@ const struct match_test match_tests[] = {
     "abc\0",
     "abcd\0cabc\0" },
   { "*abc",
-    "abc\0fooabc\0",
+    "abc\0fooabc\0ababc\0",
     "abra\0abcd\0" },
   { "\\?",
     "?\0",
diff --git a/ircd/test/jupe-1.cmd b/ircd/test/jupe-1.cmd
new file mode 100644 (file)
index 0000000..52668bb
--- /dev/null
@@ -0,0 +1,8 @@
+define srv localhost:7701
+
+connect cl1 Alex alex %srv% :Test client 1
+:cl1 oper oper1 oper1
+:cl1 raw :jupe +irc-3.example.net 3600 :Server 3 not welcome here.
+:cl1 raw :jupe -irc-3.example.net 3600 :Server 3 not welcome here.
+:cl1 raw :jupe +irc-3.example.net * 3600 :Server 3 not welcome here.
+:cl1 raw :jupe -irc-3.example.net * 3600 :Server 3 not welcome here.
diff --git a/ircd/test/kill-block-1.cmd b/ircd/test/kill-block-1.cmd
new file mode 100644 (file)
index 0000000..a9e4f26
--- /dev/null
@@ -0,0 +1,4 @@
+define srv localhost:7701
+
+connect cl1 Alex sub7 %srv% :s7server
+connect cl2 Chloe chloe %srv% :Chloe
index a2ef7c05acd6dbb503a927a79cf63579f0940489..a6605d62a95018baa7f35a1cdf39e38161e1d8be 100755 (executable)
@@ -1,12 +1,27 @@
 #! /bin/sh
 set -e
 srcdir=$1
-for script in channel-1 client-1 stats-1 gline-1 ; do
+cp ${srcdir}/ircd-t1.conf ircd-t1.conf
+cp ${srcdir}/ircd-t2.conf ircd-t2.conf
+echo "Testing one-shot ircd invocations."
+../ircd -v
+../ircd -x 6 -k -d . -f ircd-t1.conf -c user@127.0.0.1
+echo "Starting ircd."
+../ircd -d . -f ircd-t1.conf
+../ircd -d . -f ircd-t2.conf
+sleep 10
+# stats-1 is out of alphabetical order to avoid triggering IPcheck.
+for script in channel-1 client-1 command-1 feature-1 gline-1 stats-1 jupe-1 kill-block-1 ; do
   echo "Running test $script."
   ${srcdir}/test-driver.pl ${srcdir}/${script}.cmd
 done
-echo "Terminating server."
-${srcdir}/test-driver.pl ${srcdir}/die.cmd
-../ircd -?
-../ircd -v
-../ircd -x 6 -k -d ${srcdir} -f ircd-t1.conf -c user@127.0.0.1
+echo "Sending signals to server."
+cp ${srcdir}/ircd-t1-2.conf ircd-t1.conf
+kill -HUP `cat ircd-t1.pid`
+sleep 1
+kill -INT `cat ircd-t1.pid`
+# A long sleep is necessary to make the server flush its IPcheck entries.
+sleep 610
+kill -TERM `cat ircd-t1.pid` `cat ircd-t2.pid`
+sleep 1
+../ircd -? || true
index 48d36d7a5e2db6571df6df0a35fcd7e6df7af592..ac89e93c499667e54db8c112c670bc2f1188dfda 100644 (file)
@@ -33,6 +33,9 @@ connect cl1 Alex alex localhost:7701 :Test client 1
 :cl1 raw :stats z
 :cl1 raw :stats *
 
+# Remote stats requests
+:cl1 raw :stats f test-2.*
+
 # Named stats commands
 :cl1 raw :stats nameservers
 :cl1 raw :stats connect
@@ -65,6 +68,9 @@ connect cl1 Alex alex localhost:7701 :Test client 1
 :cl1 raw :stats memory
 :cl1 raw :stats help
 :cl1 raw :hash
+:cl1 raw :rehash m
+:cl1 raw :rehash l
+:cl1 raw :rehash q
 :cl1 raw :rehash
 :cl1 nick Alexey
 
index 7ee09cde50b2c45f46a548c711ffb63ca129c9e0..871d6e0805217a20de9dd3d247dce3b57731e352 100755 (executable)
@@ -103,8 +103,11 @@ POE::Session->create(inline_states =>
                       irc_nick => sub {},
                       irc_part => sub {},
                       irc_ping => sub {},
+                      irc_pong => sub {},
+                      irc_rpong => sub {},
                       irc_quit => sub {},
                       irc_topic => sub {},
+                      irc_plugin_add => sub {},
                       irc_error => \&irc_error,
                       irc_disconnected => \&irc_disconnected,
                       irc_socketerr => \&irc_socketerr,
@@ -316,7 +319,8 @@ sub drv_default {
     }
     return undef;
   }
-  print "ERROR: Unexpected event $state to test driver (from ".$sender->ID.")\n";
+  print "ERROR: Unexpected event $state to test driver (from ".$sender->ID.")\n"
+    unless $state eq '_signal';
   return undef;
 }