From 54c4b35713d6bb671440f79b7429a54f892b0c3f Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Tue, 31 May 2005 00:26:19 +0000 Subject: [PATCH] Add new test scripts and generally improve code coverage of tests. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1419 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 32 +++++++++++++ ircd/test/Makefile.in | 9 ++-- ircd/test/channel-1.cmd | 36 +++++++++++++-- ircd/test/client-1.cmd | 16 +++++-- ircd/test/commands-1.cmd | 43 +++++++++++++++++ ircd/test/feature-1.cmd | 18 ++++++++ ircd/test/gline-1.cmd | 3 ++ ircd/test/ircd-t1-2.conf | 93 +++++++++++++++++++++++++++++++++++++ ircd/test/ircd-t1.conf | 10 ++++ ircd/test/ircd-t2.conf | 95 ++++++++++++++++++++++++++++++++++++++ ircd/test/ircd_match_t.c | 2 +- ircd/test/jupe-1.cmd | 8 ++++ ircd/test/kill-block-1.cmd | 4 ++ ircd/test/run-tests.sh | 27 ++++++++--- ircd/test/stats-1.cmd | 6 +++ ircd/test/test-driver.pl | 6 ++- 16 files changed, 388 insertions(+), 20 deletions(-) create mode 100644 ircd/test/commands-1.cmd create mode 100644 ircd/test/feature-1.cmd create mode 100644 ircd/test/ircd-t1-2.conf create mode 100644 ircd/test/ircd-t2.conf create mode 100644 ircd/test/jupe-1.cmd create mode 100644 ircd/test/kill-block-1.cmd diff --git a/ChangeLog b/ChangeLog index 149957a..ff5a181 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2005-05-30 Michael Poole + + * 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 * ircd/s_debug.c (count_memory): Use count_listener_memory() to diff --git a/ircd/test/Makefile.in b/ircd/test/Makefile.in index 8449b09..44b4cda 100644 --- a/ircd/test/Makefile.in +++ b/ircd/test/Makefile.in @@ -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 $@ diff --git a/ircd/test/channel-1.cmd b/ircd/test/channel-1.cmd index dfdcb8c..54efbb3 100644 --- a/ircd/test/channel-1.cmd +++ b/ircd/test/channel-1.cmd @@ -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 diff --git a/ircd/test/client-1.cmd b/ircd/test/client-1.cmd index 9a588c1..1db7fd1 100644 --- a/ircd/test/client-1.cmd +++ b/ircd/test/client-1.cmd @@ -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 index 0000000..d97aaad --- /dev/null +++ b/ircd/test/commands-1.cmd @@ -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 index 0000000..af93c52 --- /dev/null +++ b/ircd/test/feature-1.cmd @@ -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 diff --git a/ircd/test/gline-1.cmd b/ircd/test/gline-1.cmd index aa08dcc..89a1d4b 100644 --- a/ircd/test/gline-1.cmd +++ b/ircd/test/gline-1.cmd @@ -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 index 0000000..b48017f --- /dev/null +++ b/ircd/test/ircd-t1-2.conf @@ -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"; +}; diff --git a/ircd/test/ircd-t1.conf b/ircd/test/ircd-t1.conf index 92243ff..66472b0 100644 --- a/ircd/test/ircd-t1.conf +++ b/ircd/test/ircd-t1.conf @@ -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 index 0000000..f692fdd --- /dev/null +++ b/ircd/test/ircd-t2.conf @@ -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"; +}; diff --git a/ircd/test/ircd_match_t.c b/ircd/test/ircd_match_t.c index e051e5f..da7a28f 100644 --- a/ircd/test/ircd_match_t.c +++ b/ircd/test/ircd_match_t.c @@ -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 index 0000000..52668bb --- /dev/null +++ b/ircd/test/jupe-1.cmd @@ -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 index 0000000..a9e4f26 --- /dev/null +++ b/ircd/test/kill-block-1.cmd @@ -0,0 +1,4 @@ +define srv localhost:7701 + +connect cl1 Alex sub7 %srv% :s7server +connect cl2 Chloe chloe %srv% :Chloe diff --git a/ircd/test/run-tests.sh b/ircd/test/run-tests.sh index a2ef7c0..a6605d6 100755 --- a/ircd/test/run-tests.sh +++ b/ircd/test/run-tests.sh @@ -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 diff --git a/ircd/test/stats-1.cmd b/ircd/test/stats-1.cmd index 48d36d7..ac89e93 100644 --- a/ircd/test/stats-1.cmd +++ b/ircd/test/stats-1.cmd @@ -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 diff --git a/ircd/test/test-driver.pl b/ircd/test/test-driver.pl index 7ee09cd..871d6e0 100755 --- a/ircd/test/test-driver.pl +++ b/ircd/test/test-driver.pl @@ -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; } -- 2.20.1