summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2014-10-29 16:42:57 +0000
committerbluhm <bluhm@openbsd.org>2014-10-29 16:42:57 +0000
commit1c84e4fa30c8ea4708818812f9bb6cccfb5bc0c4 (patch)
treed19afc0cfaea907a2b8bb020b0151f811c5b5f63
parentCalling a function to htonl() a constant 32-bit value into a stack (diff)
downloadwireguard-openbsd-1c84e4fa30c8ea4708818812f9bb6cccfb5bc0c4.tar.xz
wireguard-openbsd-1c84e4fa30c8ea4708818812f9bb6cccfb5bc0c4.zip
Add a test the checks the syslogd !prog !!prog !* feature.
-rw-r--r--regress/usr.sbin/syslogd/Syslogd.pm3
-rw-r--r--regress/usr.sbin/syslogd/args-prog.pl44
2 files changed, 46 insertions, 1 deletions
diff --git a/regress/usr.sbin/syslogd/Syslogd.pm b/regress/usr.sbin/syslogd/Syslogd.pm
index e3cd027c9b5..28bf627929b 100644
--- a/regress/usr.sbin/syslogd/Syslogd.pm
+++ b/regress/usr.sbin/syslogd/Syslogd.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Syslogd.pm,v 1.5 2014/09/13 23:38:24 bluhm Exp $
+# $OpenBSD: Syslogd.pm,v 1.6 2014/10/29 16:42:57 bluhm Exp $
# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
@@ -67,6 +67,7 @@ sub new {
$loghost .= ":$connectport" if $connectport;
}
print $fh "*.*\t$loghost\n";
+ print $fh $self->{conf} if $self->{conf};
close $fh;
return $self->create_out();
diff --git a/regress/usr.sbin/syslogd/args-prog.pl b/regress/usr.sbin/syslogd/args-prog.pl
new file mode 100644
index 00000000000..f44ae616751
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-prog.pl
@@ -0,0 +1,44 @@
+# Test with default values, that is:
+# The client writes a message to Sys::Syslog native method.
+# 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 messages in special log files selected with !prog !!prog !*.
+
+use strict;
+use warnings;
+use Cwd;
+
+my %log;
+@log{qw(foo bar foobar)} = ();
+foreach my $name (keys %log) {
+ $log{$name} = getcwd()."/$name.log";
+ open(my $fh, '>', $log{$name})
+ or die "Create $log{$name} failed: $!";
+}
+
+sub check_file {
+ my ($name, $pattern) = @_;
+ check_pattern($name, $log{$name}, $pattern, \&filegrep);
+}
+
+our %args = (
+ syslogd => {
+ conf => <<"EOF",
+!syslogd
+*.* $log{foo}
+!!syslogd-regress
+*.* $log{bar}
+!*
+*.* $log{foobar}
+EOF
+ },
+ check => sub {
+ check_file("foo", { get_testlog() => 0, qr/syslogd: start/ => 1 });
+ check_file("bar", { get_testlog() => 1, qr/syslogd: start/ => 0 });
+ check_file("foobar", { get_testlog() => 0, qr/syslogd: start/ => 1 });
+ },
+);
+
+1;