From 5e1a5f7f6091e4f1eb80e9c50bc6f7e8df3a0243 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Wed, 28 Nov 2007 05:50:53 +0000 Subject: [PATCH] Update test scripts to run properly with newer POE; add test for SF#1840011. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1847 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- tests/bug-1640796.cmd | 4 ++-- tests/bug-1674539.cmd | 6 +++--- tests/bug-1840011.cmd | 39 +++++++++++++++++++++++++++++++++++++++ tests/test-driver.pl | 24 ++++++------------------ 4 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 tests/bug-1840011.cmd diff --git a/tests/bug-1640796.cmd b/tests/bug-1640796.cmd index 8a3c0d8..0d34e36 100644 --- a/tests/bug-1640796.cmd +++ b/tests/bug-1640796.cmd @@ -26,10 +26,10 @@ connect cl2 %cl2-nick% d00dm4n %srv1% :Someone Else # servers.) :cl1 mode %channel% +D-D :cl1 mode %channel% -:cl1 expect %srv1-name% 324 %cl1-nick% %channel% \\+.*d +:cl1 expect %srv1-name% 324 %channel% \\+.*d # Make sure that client 1 does see the -d when client 2 quits :cl2 wait cl1 -:cl2 part %channel% leaving :cl1 expect %hidden-srv% mode %channel% -d +:cl2 part %channel% :cl1 quit done diff --git a/tests/bug-1674539.cmd b/tests/bug-1674539.cmd index e084d1f..a00484e 100644 --- a/tests/bug-1674539.cmd +++ b/tests/bug-1674539.cmd @@ -17,14 +17,14 @@ connect cl3 %cl3-nick% oper %srv2% :Oper 3 # Check that we get local privileges properly. :cl1 wait cl2,cl3 :cl1 raw :privs %cl1-nick% -:cl1 expect %srv1-name% 270 %cl1-nick% %cl1-nick% :CHAN_LIMIT +:cl1 expect %srv1-name% 270 %cl1-nick% :CHAN_LIMIT :cl1 raw :privs %cl2-nick% -:cl1 expect %srv1-name% 270 %cl1-nick% %cl2-nick% :CHAN_LIMIT +:cl1 expect %srv1-name% 270 %cl2-nick% :CHAN_LIMIT # Bug 1674539 is that remote /privs do not get any response. # Testing shows that the problem only shows up with a hub between. :cl1 raw :privs %cl3-nick% -:cl1 expect %srv2-name% 270 %cl1-nick% %cl3-nick% :CHAN_LIMIT +:cl1 expect %srv2-name% 270 %cl3-nick% :CHAN_LIMIT # Synchronize everything sync cl1,cl2,cl3 diff --git a/tests/bug-1840011.cmd b/tests/bug-1840011.cmd new file mode 100644 index 0000000..6a71c77 --- /dev/null +++ b/tests/bug-1840011.cmd @@ -0,0 +1,39 @@ +define srv1 localhost:7601 +define srv1-name irc.example.net +define hidden-srv *.undernet.org +define channel #random-channel +define cl1-nick Ch4n0pm4n + +# Connect a client and join it to the test channel. +connect cl1 %cl1-nick% op3rm4n %srv1% :Some Chanop +:cl1 join %channel% + +# Issue a variety of bans, all of which should be accepted. +:cl1 mode %channel% +b *!*@1.0.0.0/16 +:cl1 mode %channel% +b *!*@1.0.0.* +:cl1 mode %channel% +b *!*@*.example.com +:cl1 mode %channel% +b *!foo@*.example.org +:cl1 mode %channel% +b *!*@*.bar.example.* + +# Check the modes on the channel. +:cl1 mode %channel% +b +# These regexps make my eyes bleed almost enough to add a load of code to test-driver.pl. +# There's another test-driver problem here, too: one "expect" works fine, but a second +# one never sees the second numeric response from the server. +:cl1 expect %srv1-name% 367 %channel% \\*!\\*@\\*\\.bar\\.example\\.* %cl1-nick% \\d+ + +# Check that a more-encompassing ban removes the old bans. +:cl1 mode %channel% +b *!*@1.0.* +:cl1 expect %cl1-nick% mode %channel% -bb\\+b \\*!\\*@1\\.0\\.0\\.\\* \\*!\\*@1\\.0\\.0\\.0/16 \\*!\\*@1\\.0\\.\\* + +# Check that a narrower ban cannot be added. +# Somewhat sadly, the first command gets no response at all. +:cl1 mode %channel% +b *!*@1.0.0.1 +:cl1 mode %channel% +b +:cl1 expect %srv1-name% 367 %channel% \\*!\\*@1\\.0\\.\\* %cl1-nick% \\d+ + +# Can we remove a broader ban and add a narrow ban at the same time? +# This was the core of the bug report (SF#1840011). +:cl1 mode %channel% -b+b *!*@1.0.* *!*@1.0.0.1 +:cl1 expect %cl1-nick% mode %channel% -b\\+b \\*!\\*@1\\.0\\.\\* \\*!\\*@1\\.0\\.0\\.1 +:cl1 quit done diff --git a/tests/test-driver.pl b/tests/test-driver.pl index 8fd0102..e20745c 100755 --- a/tests/test-driver.pl +++ b/tests/test-driver.pl @@ -297,12 +297,12 @@ sub drv_default { my $expect = $client->{expect}->[0]; my $mismatch; $args = $args->[2]; # ->[1] is the entire string, ->[2] is split - for (my $x=2; ($x<=$#$expect) and ($x<=$#$args) and not $mismatch; $x++) { - if ($args->[$x] !~ /$expect->[$x]/i) { + for (my $x=0; ($x+2<=$#$expect) and ($x<=$#$args) and not $mismatch; $x++) { + my $expectation = $expect->[$x+2]; + if ($args->[$x] !~ /$expectation/i) { $mismatch = 1; - print "Mismatch in arg $x: $args->[$x] !~ $expect->[$x]\n"; + print "Mismatch in arg $x: $args->[$x] !~ $expectation\n"; } - # $mismatch = 1 unless $args->[$x] =~ /$expect->[$x]/i; } unexpect($kernel, $session, $client) unless $mismatch; } @@ -391,22 +391,10 @@ sub check_expect { my $expected = $client->{expect}->[0]; # check sender - if ($expected->[0] =~ /\*(.+)/) { - # we expect *sessionname, so look up session's current nick - my $exp = $1; - $sender =~ /^(.+)!/; - return 0 if lc($heap->{clients}->{$exp}->{nick}) ne lc($1); - } elsif ($expected->[0] =~ /^:?(.+!.+)/) { - # expect :nick!user@host, so compare whole thing - return 0 if lc($1) ne lc($sender); - } else { - # we only expect :nick, so compare that part - $sender =~ /^:?(.+)!/; - return 0 if lc($expected->[0]) ne lc($1); - } + return 0 unless $sender =~ /^:?\Q$expected->[0]\E/i; # compare text - return 0 if lc($text) !~ /$expected->[2]/i; + return 0 unless $text =~ /$expected->[2]/i; # drop expectation of event unexpect($kernel, $session, $client); -- 2.20.1