1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#!/usr/bin/perl -w
BEGIN {
if (-e 't/test_dir') { # if we are running "t/rule_names.t", kluge around ...
chdir 't';
}
if (-e 'test_dir') { # running from test directory, not ..
unshift(@INC, '../blib/lib');
}
}
my $prefix = '.';
if (-e 'test_dir') { # running from test directory, not ..
$prefix = '..';
}
use strict;
use lib '.'; use lib 't';
use SATest; sa_t_init("debug");
use Mail::SpamAssassin;
use Test::More;
plan skip_all => "Long running tests disabled" unless conf_bool('run_long_tests');
plan tests => 3;
# list of known debug facilities
my %facility = map( ($_, 1),
qw( accessdb archive-iterator async auto-whitelist bayes check config daemon
dcc dkim askdns dns eval generic https_http_mismatch facility FreeMail
hashcash ident ignore info ldap learn locker log logger markup
message metadata mimeheader netset plugin prefork progress pyzor razor2
received-header replacetags reporter rules rules-all spamd spf textcat
timing TxRep uri uridnsbl util ));
my $fh = IO::File->new_tmpfile();
open(STDERR, ">&=".fileno($fh)) || die "Cannot reopen STDERR";
ok(sarun("-t -D < data/spam/dnsbl.eml"));
seek($fh, 0, 0);
my $error = do {
local $/;
<$fh>;
};
my $malformed = 0;
my $unlisted = 0;
for (split(/^/m, $error)) {
# ditch a syslog-like timestamp if present
s/^ [a-z]{3} \s+ \d{1,2} \s+
\d{1,2} : \d{1,2} : \d{1,2} (?: \. \d* )? \s*//xsi;
if (/^(?: \[ \d+ \] \s+)? (dbg|info): \s* ([^:\s]+) : \s* (.*)/x) {
if (!exists $facility{$2}) {
$unlisted++;
print "unlisted debug facility: $2\n";
}
}
elsif (/^(?: \[ \d+ \] \s+)? (warn|error):/x) {
# ok
}
else {
print "malformed debug message: $_";
# $malformed = 1;
}
}
ok(!$malformed);
ok(!$unlisted);
|