Update test scripts to run properly with newer POE; add test for SF#1840011.
authorMichael Poole <mdpoole@troilus.org>
Wed, 28 Nov 2007 05:50:53 +0000 (05:50 +0000)
committerMichael Poole <mdpoole@troilus.org>
Wed, 28 Nov 2007 05:50:53 +0000 (05:50 +0000)
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
tests/bug-1674539.cmd
tests/bug-1840011.cmd [new file with mode: 0644]
tests/test-driver.pl

index 8a3c0d8250270ab8a635a68f09ae8579e778a8fe..0d34e3664310bdde794784a92030d5a4f6120eb6 100644 (file)
@@ -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
index e084d1f6d2233b7e81fcf0455477f2ea611bb060..a00484ea64eb959f77f62bb3d7055442a18111f8 100644 (file)
@@ -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 (file)
index 0000000..6a71c77
--- /dev/null
@@ -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
index 8fd010255c089e036c84586e6b79d484050fd6bb..e20745cda33a58400bc513a0a7171c10c7cfd1a3 100755 (executable)
@@ -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);