You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2005/05/11 04:15:10 UTC

svn commit: r169559 - in /spamassassin/trunk: MANIFEST t/recursion.t

Author: jm
Date: Tue May 10 19:15:10 2005
New Revision: 169559

URL: http://svn.apache.org/viewcvs?rev=169559&view=rev
Log:
bug 4103: test recursion limits in test suite

Added:
    spamassassin/trunk/t/recursion.t   (with props)
Modified:
    spamassassin/trunk/MANIFEST

Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/MANIFEST?rev=169559&r1=169558&r2=169559&view=diff
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Tue May 10 19:15:10 2005
@@ -374,6 +374,7 @@
 t/razor2.t
 t/rcvd_parser.t
 t/recips.t
+t/recursion.t
 t/relative_scores.t
 t/report_safe.t
 t/reportheader.t

Added: spamassassin/trunk/t/recursion.t
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/t/recursion.t?rev=169559&view=auto
==============================================================================
--- spamassassin/trunk/t/recursion.t (added)
+++ spamassassin/trunk/t/recursion.t Tue May 10 19:15:10 2005
@@ -0,0 +1,113 @@
+#!/usr/bin/perl
+
+use lib '.'; use lib 't';
+use SATest; sa_t_init("recursion");
+use Test; BEGIN { plan tests => 7 };
+use IO::File;
+
+# ---------------------------------------------------------------------------
+
+%patterns = (
+  q{X-Spam-Status: }, 'headerfound',
+);
+
+# ---------------------------------------------------------------------------
+
+my $msg1 = q{From: foo
+Message-Id: <bar>
+To: baz
+Subject: testing recursion
+Content-Type: multipart/report; report-type=delivery-status;
+    boundary="__BOUND__"
+
+--__BOUND__
+
+This is the report.
+
+--__BOUND__
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; example.org
+Diagnostic-Info: hi!
+
+--__BOUND__
+Content-Type: message/rfc822
+
+__MSG__
+
+--__BOUND__--
+
+};
+
+my $msg2 = q{From: foo
+Message-Id: <bar>
+To: baz
+Subject: testing recursion 2
+Content-Type: multipart/mixed; boundary="__BOUND__"
+
+
+--__BOUND__
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+
+hi!
+
+--__BOUND__
+Content-Type: message/rfc822
+MIME-Version: 1.0
+
+__MSG__
+
+--__BOUND__--
+
+};
+
+# ---------------------------------------------------------------------------
+
+sub create_test_message {
+  my $msg = shift;
+
+  my $boundstr = "AAAAAAAAAAAAAAAAAAA";
+  my $bound = $boundstr; $boundstr++;
+  my $text = $msg;
+  $text =~ s/__BOUND__/${bound}/g;
+
+  for my $i (1 .. 600) {
+    my $newmsg = $msg;
+    $bound = $boundstr; $boundstr++;
+    $newmsg =~ s/__BOUND__/${bound}/g;
+    $newmsg =~ s/__MSG__/${text}/g;
+    $text = $newmsg;
+  }
+
+  open (OUT, ">log/recurse.eml") or die;
+  print OUT $text;
+  close OUT or die;
+}
+
+sub try_scan {
+  my $fh = IO::File->new_tmpfile();
+  ok($fh);
+  open(STDERR, ">&=".fileno($fh)) || die "Cannot reopen STDERR";
+  sarun("-D -L -t < log/recurse.eml",
+        \&patterns_run_cb);
+  seek($fh, 0, 0);
+  my $error = do {
+    local $/;
+    <$fh>;
+  };
+
+  print "# $error\n";
+  if ($error =~ /Deep recursion on subroutine/) { ok(0); }
+      else { ok(1); }
+
+  ok_all_patterns();
+}
+
+create_test_message($msg1);
+try_scan();
+create_test_message($msg2);
+try_scan();
+
+ok(unlink 'log/recurse.eml');

Propchange: spamassassin/trunk/t/recursion.t
------------------------------------------------------------------------------
    svn:executable = *