diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-06-28 18:52:12 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-06-28 18:52:12 +0000 |
commit | 9c62228341021e6d213465488da734be21b3c515 (patch) | |
tree | e75898489599ee5cd504702c015fb9808b4da497 | |
parent | b946d61c42568f6579c11361ec5a27f8cb45e1b0 (diff) |
Add tests for the !prog and !!prog and !* keywords in syslog.conf.
-rw-r--r-- | regress/usr.sbin/syslogd/args-block-prog-quick.pl | 35 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-block-prog.pl | 35 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/funcs.pl | 19 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/syslogd.pl | 3 |
4 files changed, 90 insertions, 2 deletions
diff --git a/regress/usr.sbin/syslogd/args-block-prog-quick.pl b/regress/usr.sbin/syslogd/args-block-prog-quick.pl new file mode 100644 index 00000000000..bf11c31b6ab --- /dev/null +++ b/regress/usr.sbin/syslogd/args-block-prog-quick.pl @@ -0,0 +1,35 @@ +# The client writes a message to Sys::Syslog native method. +# The syslogd writes into multiple files depending on program name. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via UDP to the loghost. +# The server receives the message on its UDP socket. +# Find the message in client, file, pipe, syslogd, server log. +# Check that the quick message appears only in one log file. + +use strict; +use warnings; +use Cwd; + +my $objdir = getcwd(); + +our %args = ( + syslogd => { + conf => <<"EOF", +!nonexist +*.* $objdir/file-0.log +!!syslogd-regress +*.* $objdir/file-1.log +*.* $objdir/file-2.log +!* +*.* $objdir/file-3.log +EOF + }, + multifile => [ + { loggrep => { get_testlog() => 0 } }, + { loggrep => { get_testlog() => 1 } }, + { loggrep => { get_testlog() => 0 } }, + { loggrep => { get_testlog() => 0 } }, + ], +); + +1; diff --git a/regress/usr.sbin/syslogd/args-block-prog.pl b/regress/usr.sbin/syslogd/args-block-prog.pl new file mode 100644 index 00000000000..b944625cac1 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-block-prog.pl @@ -0,0 +1,35 @@ +# The client writes a message to Sys::Syslog native method. +# The syslogd writes into multiple files depending on program name. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via UDP to the loghost. +# The server receives the message on its UDP socket. +# Find the message in client, file, pipe, syslogd, server log. +# Check that the message appears in the correct log files. + +use strict; +use warnings; +use Cwd; + +my $objdir = getcwd(); + +our %args = ( + syslogd => { + conf => <<"EOF", +!nonexist +*.* $objdir/file-0.log +!syslogd-regress +*.* $objdir/file-1.log +*.* $objdir/file-2.log +!* +*.* $objdir/file-3.log +EOF + }, + multifile => [ + { loggrep => { get_testlog() => 0 } }, + { loggrep => { get_testlog() => 1 } }, + { loggrep => { get_testlog() => 1 } }, + { loggrep => { get_testlog() => 1 } }, + ], +); + +1; diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index a30d97e1bc6..ef744c499ef 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.19 2015/06/15 21:44:57 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.20 2015/06/28 18:52:11 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org> # @@ -254,6 +254,7 @@ sub check_logs { my $pattern = $s->{filegrep} || $testlog; check_pattern(ref $s, $file, $pattern, \&filegrep); } + check_multifile(@{$args{multifile} || []}); } sub compare($$) { @@ -362,4 +363,20 @@ sub kdumpgrep { return wantarray ? @matches : $matches[0]; } +sub create_multifile { + for (my $i = 0; $i < @_; $i++) { + my $file = "file-$i.log"; + open(my $fh, '>', $file) + or die "Create $file failed: $!"; + } +} + +sub check_multifile { + for (my $i = 0; $i < @_; $i++) { + my $file = "file-$i.log"; + my $pattern = $_[$i]{loggrep} or die; + check_pattern("multifile $i", $file, $pattern, \&filegrep); + } +} + 1; diff --git a/regress/usr.sbin/syslogd/syslogd.pl b/regress/usr.sbin/syslogd/syslogd.pl index 758d6d1aa40..5518d1ddd7a 100644 --- a/regress/usr.sbin/syslogd/syslogd.pl +++ b/regress/usr.sbin/syslogd/syslogd.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: syslogd.pl,v 1.5 2015/02/13 21:40:50 bluhm Exp $ +# $OpenBSD: syslogd.pl,v 1.6 2015/06/28 18:52:11 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -40,6 +40,7 @@ if (@ARGV and -f $ARGV[-1]) { } @ARGV == 0 or usage(); +create_multifile(@{$args{multifile} || []}); if ($args{rsyslogd}) { $args{rsyslogd}{listen}{domain} ||= AF_INET; $args{rsyslogd}{listen}{addr} ||= "127.0.0.1"; |