summaryrefslogtreecommitdiff
path: root/regress/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'regress/usr.sbin')
-rw-r--r--regress/usr.sbin/syslogd/Makefile4
-rw-r--r--regress/usr.sbin/syslogd/Proc.pm5
-rw-r--r--regress/usr.sbin/syslogd/Syslogc.pm58
-rw-r--r--regress/usr.sbin/syslogd/Syslogd.pm18
-rw-r--r--regress/usr.sbin/syslogd/args-client-native.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-client-udp-nodns.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-client-udp.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-client-udp4-nodns.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-client-udp4.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-client-udp6-nodns.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-client-udp6.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-client-unix.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-localhost.pl6
-rw-r--r--regress/usr.sbin/syslogd/args-maxhostlen.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-maxloghostlen.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-maxportlen.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-maxunix.pl18
-rw-r--r--regress/usr.sbin/syslogd/args-memory-clear.pl30
-rw-r--r--regress/usr.sbin/syslogd/args-memory-flags.pl30
-rw-r--r--regress/usr.sbin/syslogd/args-memory-list.pl26
-rw-r--r--regress/usr.sbin/syslogd/args-memory-overflow-cont.pl40
-rw-r--r--regress/usr.sbin/syslogd/args-memory-overflow-flags.pl39
-rw-r--r--regress/usr.sbin/syslogd/args-memory-overflow.pl50
-rw-r--r--regress/usr.sbin/syslogd/args-memory-read-clear.pl30
-rw-r--r--regress/usr.sbin/syslogd/args-memory-read-cont.pl32
-rw-r--r--regress/usr.sbin/syslogd/args-memory-read.pl30
-rw-r--r--regress/usr.sbin/syslogd/args-only4.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-only6.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-invalid.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp4-host6.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp4-only6.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp4.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp6-host4.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp6-only4.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-proto-udp6.pl2
-rw-r--r--regress/usr.sbin/syslogd/args-server-udp4.pl4
-rw-r--r--regress/usr.sbin/syslogd/args-server-udp6.pl4
-rw-r--r--regress/usr.sbin/syslogd/funcs.pl50
-rw-r--r--regress/usr.sbin/syslogd/syslogd.pl39
40 files changed, 478 insertions, 77 deletions
diff --git a/regress/usr.sbin/syslogd/Makefile b/regress/usr.sbin/syslogd/Makefile
index 517cf0bcec6..5647005e1a4 100644
--- a/regress/usr.sbin/syslogd/Makefile
+++ b/regress/usr.sbin/syslogd/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.4 2014/09/03 15:56:07 bluhm Exp $
+# $OpenBSD: Makefile,v 1.5 2014/09/13 23:38:24 bluhm Exp $
# The following ports must be installed for the regression tests:
# p5-IO-Socket-INET6 object interface for AF_INET and AF_INET6 domain sockets
@@ -25,7 +25,7 @@ ARGS != cd ${.CURDIR} && ls args-*.pl
TARGETS ?= ${ARGS}
REGRESS_TARGETS = ${TARGETS:S/^/run-regress-/}
CLEANFILES += *.log *.log.? *.pem *.crt *.key syslogd.conf stamp-*
-CLEANFILES += unix.* ktrace.out *.ktrace *.fstat
+CLEANFILES += *.sock ktrace.out *.ktrace *.fstat
.MAIN: all
diff --git a/regress/usr.sbin/syslogd/Proc.pm b/regress/usr.sbin/syslogd/Proc.pm
index a3d0976d58c..46d70019e7a 100644
--- a/regress/usr.sbin/syslogd/Proc.pm
+++ b/regress/usr.sbin/syslogd/Proc.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Proc.pm,v 1.2 2014/09/02 00:26:30 bluhm Exp $
+# $OpenBSD: Proc.pm,v 1.3 2014/09/13 23:38:24 bluhm Exp $
# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
@@ -147,12 +147,13 @@ sub wait {
sub loggrep {
my $self = shift;
my($regex, $timeout) = @_;
+ my $exit = ($self->{exit} // 0) << 8;
my $end = time() + $timeout if $timeout;
do {
my($kid, $status, $code) = $self->wait(WNOHANG);
- if ($kid > 0 && $status != 0) {
+ if ($kid > 0 && $status != $exit) {
# child terminated with failure
die ref($self), " child status: $status $code";
}
diff --git a/regress/usr.sbin/syslogd/Syslogc.pm b/regress/usr.sbin/syslogd/Syslogc.pm
new file mode 100644
index 00000000000..651ad50bd1a
--- /dev/null
+++ b/regress/usr.sbin/syslogd/Syslogc.pm
@@ -0,0 +1,58 @@
+# $OpenBSD: Syslogc.pm,v 1.1 2014/09/13 23:38:24 bluhm Exp $
+
+# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+use strict;
+use warnings;
+
+package Syslogc;
+use parent 'Proc';
+use Carp;
+
+sub new {
+ my $class = shift;
+ my %args = @_;
+ $args{ktracefile} ||= "syslogc.ktrace";
+ $args{logfile} ||= "syslogc.log";
+ $args{ctlsock} ||= "ctl.sock";
+ $args{up} ||= "execute: ";
+ $args{func} = sub { Carp::confess "$class func may not be called" };
+ my $self = Proc::new($class, %args);
+
+ return $self;
+}
+
+sub child {
+ my $self = shift;
+ my @sudo = $ENV{SUDO} ? $ENV{SUDO} : ();
+
+ my @ktrace = $ENV{KTRACE} || ();
+ @ktrace = "ktrace" if $self->{ktrace} && !@ktrace;
+ push @ktrace, "-i", "-f", $self->{ktracefile} if @ktrace;
+ my @cmd = (@sudo, @ktrace, "syslogc", "-s", $self->{ctlsock});
+ push @cmd, @{$self->{options}} if $self->{options};
+ print STDERR "execute: @cmd\n";
+ exec @cmd;
+ die ref($self), " exec '@cmd' failed: $!";
+}
+
+sub down {
+ my $self = shift;
+ eval { Proc::down($self, @_) };
+ die $@ if $@ && $self->{down} ne "Shutdown";
+ return $self;
+}
+
+1;
diff --git a/regress/usr.sbin/syslogd/Syslogd.pm b/regress/usr.sbin/syslogd/Syslogd.pm
index 982d27ff38e..e3cd027c9b5 100644
--- a/regress/usr.sbin/syslogd/Syslogd.pm
+++ b/regress/usr.sbin/syslogd/Syslogd.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Syslogd.pm,v 1.4 2014/09/02 17:43:29 bluhm Exp $
+# $OpenBSD: Syslogd.pm,v 1.5 2014/09/13 23:38:24 bluhm Exp $
# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
@@ -36,6 +36,11 @@ sub new {
$args{conffile} ||= "syslogd.conf";
$args{outfile} ||= "file.log";
$args{outpipe} ||= "pipe.log";
+ if ($args{memory}) {
+ $args{memory} = {} unless ref $args{memory};
+ $args{memory}{name} ||= "memory";
+ $args{memory}{size} //= 1;
+ }
my $self = Proc::new($class, %args);
$self->{connectaddr}
or croak "$class connect addr not given";
@@ -52,6 +57,8 @@ sub new {
or die ref($self), " create conf file $self->{conffile} failed: $!";
print $fh "*.*\t$self->{outfile}\n";
print $fh "*.*\t|dd of=$self->{outpipe} status=none\n";
+ my $memory = $self->{memory};
+ print $fh "*.*\t:$memory->{size}:$memory->{name}\n" if $memory;
my $loghost = $self->{loghost};
if ($loghost) {
$loghost =~ s/(\$[a-z]+)/$1/eeg;
@@ -101,14 +108,13 @@ sub child {
push @libevent, "$_=$ENV{$_}" if $ENV{$_};
}
push @libevent, "EVENT_SHOW_METHOD=1" if @libevent;
- my @ktrace = $ENV{KTRACE} ? ($ENV{KTRACE}, "-i") : ();
- if ($self->{ktrace}) {
- @ktrace = $ENV{KTRACE} || "ktrace";
- push @ktrace, "-i", "-f", $self->{ktracefile};
- }
+ my @ktrace = $ENV{KTRACE} || ();
+ @ktrace = "ktrace" if $self->{ktrace} && !@ktrace;
+ push @ktrace, "-i", "-f", $self->{ktracefile} if @ktrace;
my $syslogd = $ENV{SYSLOGD} ? $ENV{SYSLOGD} : "syslogd";
my @cmd = (@sudo, @libevent, @ktrace, $syslogd, "-d",
"-f", $self->{conffile});
+ push @cmd, "-s", $self->{ctlsock} if $self->{ctlsock};
push @cmd, @{$self->{options}} if $self->{options};
print STDERR "execute: @cmd\n";
exec @cmd;
diff --git a/regress/usr.sbin/syslogd/args-client-native.pl b/regress/usr.sbin/syslogd/args-client-native.pl
index 62045adf3e9..4fbdf6e581a 100644
--- a/regress/usr.sbin/syslogd/args-client-native.pl
+++ b/regress/usr.sbin/syslogd/args-client-native.pl
@@ -16,7 +16,7 @@ our %args = (
logsock => { type => "native" },
},
file => {
- loggrep => qr/ $host syslogd-regress\[\d+\]: /. get_log(),
+ loggrep => qr/ $host syslogd-regress\[\d+\]: /. get_testlog(),
},
);
diff --git a/regress/usr.sbin/syslogd/args-client-udp-nodns.pl b/regress/usr.sbin/syslogd/args-client-udp-nodns.pl
index 00d88926a5c..f7edc7ca80a 100644
--- a/regress/usr.sbin/syslogd/args-client-udp-nodns.pl
+++ b/regress/usr.sbin/syslogd/args-client-udp-nodns.pl
@@ -16,7 +16,7 @@ our %args = (
options => ["-un"],
},
file => {
- loggrep => qr/ 127.0.0.1 syslogd-regress\[\d+\]: /. get_log(),
+ loggrep => qr/ 127.0.0.1 syslogd-regress\[\d+\]: /. get_testlog(),
},
);
diff --git a/regress/usr.sbin/syslogd/args-client-udp.pl b/regress/usr.sbin/syslogd/args-client-udp.pl
index 6f62737fa84..d9e495b15a4 100644
--- a/regress/usr.sbin/syslogd/args-client-udp.pl
+++ b/regress/usr.sbin/syslogd/args-client-udp.pl
@@ -16,7 +16,7 @@ our %args = (
options => ["-u"],
},
file => {
- loggrep => qr/ localhost syslogd-regress\[\d+\]: /. get_log(),
+ loggrep => qr/ localhost syslogd-regress\[\d+\]: /. get_testlog(),
},
);
diff --git a/regress/usr.sbin/syslogd/args-client-udp4-nodns.pl b/regress/usr.sbin/syslogd/args-client-udp4-nodns.pl
index a0cced6d04f..24aba63e881 100644
--- a/regress/usr.sbin/syslogd/args-client-udp4-nodns.pl
+++ b/regress/usr.sbin/syslogd/args-client-udp4-nodns.pl
@@ -17,7 +17,7 @@ our %args = (
options => ["-un"],
},
file => {
- loggrep => qr/ 127.0.0.1 /. get_log(),
+ loggrep => qr/ 127.0.0.1 /. get_testlog(),
},
);
diff --git a/regress/usr.sbin/syslogd/args-client-udp4.pl b/regress/usr.sbin/syslogd/args-client-udp4.pl
index de58100b4d5..1f7109e3eb5 100644
--- a/regress/usr.sbin/syslogd/args-client-udp4.pl
+++ b/regress/usr.sbin/syslogd/args-client-udp4.pl
@@ -17,7 +17,7 @@ our %args = (
options => ["-u"],
},
file => {
- loggrep => qr/ localhost /. get_log(),
+ loggrep => qr/ localhost /. get_testlog(),
},
);
diff --git a/regress/usr.sbin/syslogd/args-client-udp6-nodns.pl b/regress/usr.sbin/syslogd/args-client-udp6-nodns.pl
index b8b7da109eb..27fd3f97f99 100644
--- a/regress/usr.sbin/syslogd/args-client-udp6-nodns.pl
+++ b/regress/usr.sbin/syslogd/args-client-udp6-nodns.pl
@@ -17,7 +17,7 @@ our %args = (
options => ["-un"],
},
file => {
- loggrep => qr/ ::1 /. get_log(),
+ loggrep => qr/ ::1 /. get_testlog(),
},
);
diff --git a/regress/usr.sbin/syslogd/args-client-udp6.pl b/regress/usr.sbin/syslogd/args-client-udp6.pl
index 8580516087c..3052f61ec98 100644
--- a/regress/usr.sbin/syslogd/args-client-udp6.pl
+++ b/regress/usr.sbin/syslogd/args-client-udp6.pl
@@ -17,7 +17,7 @@ our %args = (
options => ["-u"],
},
file => {
- loggrep => qr/ localhost /. get_log(),
+ loggrep => qr/ localhost /. get_testlog(),
},
);
diff --git a/regress/usr.sbin/syslogd/args-client-unix.pl b/regress/usr.sbin/syslogd/args-client-unix.pl
index c9fcec554ea..142b59ccb5a 100644
--- a/regress/usr.sbin/syslogd/args-client-unix.pl
+++ b/regress/usr.sbin/syslogd/args-client-unix.pl
@@ -16,7 +16,7 @@ our %args = (
logsock => { type => "unix" },
},
file => {
- loggrep => qr/ $host syslogd-regress\[\d+\]: /. get_log(),
+ loggrep => qr/ $host syslogd-regress\[\d+\]: /. get_testlog(),
},
);
diff --git a/regress/usr.sbin/syslogd/args-localhost.pl b/regress/usr.sbin/syslogd/args-localhost.pl
index 82633dea9db..3bd2a4e6732 100644
--- a/regress/usr.sbin/syslogd/args-localhost.pl
+++ b/regress/usr.sbin/syslogd/args-localhost.pl
@@ -13,21 +13,21 @@ our %args = (
connect => { domain => AF_UNSPEC, addr => "localhost", port => 514 },
loggrep => {
qr/connect sock: (127.0.0.1|::1) \d+/ => 1,
- get_log() => 1,
+ get_testlog() => 1,
},
},
syslogd => {
loghost => '@localhost:$connectport',
options => ["-u"],
loggrep => {
- qr/ from localhost, msg /.get_log() => 1,
+ qr/ from localhost, msg /.get_testlog() => 1,
},
},
server => {
listen => { domain => AF_UNSPEC, addr => "localhost" },
loggrep => {
qr/listen sock: (127.0.0.1|::1) \d+/ => 1,
- get_log() => 1,
+ get_testlog() => 1,
},
},
);
diff --git a/regress/usr.sbin/syslogd/args-maxhostlen.pl b/regress/usr.sbin/syslogd/args-maxhostlen.pl
index 5bd3efe00fd..d742f545dde 100644
--- a/regress/usr.sbin/syslogd/args-maxhostlen.pl
+++ b/regress/usr.sbin/syslogd/args-maxhostlen.pl
@@ -12,7 +12,7 @@ our %args = (
loghost => '@'.('X'x256).':514',
loggrep => {
qr/syslogd: host too long "\@X+/ => 2,
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-maxloghostlen.pl b/regress/usr.sbin/syslogd/args-maxloghostlen.pl
index 0c9a1d66c1a..88ed1302b07 100644
--- a/regress/usr.sbin/syslogd/args-maxloghostlen.pl
+++ b/regress/usr.sbin/syslogd/args-maxloghostlen.pl
@@ -12,7 +12,7 @@ our %args = (
loghost => '@'.('X'x300),
loggrep => {
qr/syslogd: loghost too long "\@X+/ => 2,
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-maxportlen.pl b/regress/usr.sbin/syslogd/args-maxportlen.pl
index 842ae23883b..d3f53a17732 100644
--- a/regress/usr.sbin/syslogd/args-maxportlen.pl
+++ b/regress/usr.sbin/syslogd/args-maxportlen.pl
@@ -13,7 +13,7 @@ our %args = (
loghost => '@127.0.0.1:'.('X'x32),
loggrep => {
qr/syslogd: port too long "\@127.0.0.1:X+/ => 2,
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-maxunix.pl b/regress/usr.sbin/syslogd/args-maxunix.pl
index 783f8114008..084e85fb5ba 100644
--- a/regress/usr.sbin/syslogd/args-maxunix.pl
+++ b/regress/usr.sbin/syslogd/args-maxunix.pl
@@ -17,25 +17,25 @@ our %args = (
my $self = shift;
write_unix($self);
foreach (1..(MAXUNIX-1)) {
- write_unix($self, "unix.$_");
+ write_unix($self, "unix-$_.sock");
}
write_shutdown($self, @_);
},
},
syslogd => {
- options => [ map { ("-a" => "unix.$_") } (1..MAXUNIX) ],
+ options => [ map { ("-a" => "unix-$_.sock") } (1..MAXUNIX) ],
loggrep => {
- qr/syslogd: out of descriptors, ignoring unix.20/ => 0,
- qr/syslogd: out of descriptors, ignoring unix.21/ => 1,
- qr/syslogd: out of descriptors, ignoring unix.22/ => 0,
+ qr/syslogd: out of descriptors, ignoring unix-20.sock/ => 0,
+ qr/syslogd: out of descriptors, ignoring unix-21.sock/ => 1,
+ qr/syslogd: out of descriptors, ignoring unix-22.sock/ => 0,
},
},
file => {
loggrep => {
- get_log()." /dev/log unix socket" => 1,
- (map { (get_log()." unix.$_ unix socket" => 1) } (1..(MAXUNIX-1))),
-
- get_log()." unix.".MAXUNIX." unix socket" => 0,
+ get_testlog()." /dev/log unix socket" => 1,
+ (map { (get_testlog()." unix-$_.sock unix socket" => 1) }
+ (1..(MAXUNIX-1))),
+ get_testlog()." unix-".MAXUNIX.".sock unix socket" => 0,
}
},
);
diff --git a/regress/usr.sbin/syslogd/args-memory-clear.pl b/regress/usr.sbin/syslogd/args-memory-clear.pl
new file mode 100644
index 00000000000..7975d06aef9
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-clear.pl
@@ -0,0 +1,30 @@
+# 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.
+# Syslogc clears the memory logs.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that memory buffer has been cleared.
+
+use strict;
+use warnings;
+
+our %args = (
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 2,
+ qr/ctlcmd 3/ => 1,
+ get_testlog() => 1,
+ },
+ },
+ syslogc => [ {
+ options => ["-C", "memory"],
+ loggrep => qr/Log cleared/,
+ }, {
+ options => ["memory"],
+ loggrep => { get_testlog() => 0 },
+ } ],
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-memory-flags.pl b/regress/usr.sbin/syslogd/args-memory-flags.pl
new file mode 100644
index 00000000000..3c05a11137c
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-flags.pl
@@ -0,0 +1,30 @@
+# 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.
+# Syslogc lists the memory logs.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that syslogc -o does not report overflow.
+
+use strict;
+use warnings;
+
+our %args = (
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 1,
+ qr/ctlcmd 5/ => 1,
+ get_testlog() => 1,
+ },
+ },
+ syslogc => {
+ options => ["-o", "memory"],
+ loggrep => {
+ qr/^memory/ => 0,
+ qr/overflowed/ => 0,
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-memory-list.pl b/regress/usr.sbin/syslogd/args-memory-list.pl
new file mode 100644
index 00000000000..12697d60728
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-list.pl
@@ -0,0 +1,26 @@
+# 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.
+# Syslogc lists the memory logs.
+# Find the message in client, file, pipe, syslogd, server log.
+
+use strict;
+use warnings;
+
+our %args = (
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 1,
+ qr/ctlcmd 4/ => 1,
+ get_testlog() => 1,
+ },
+ },
+ syslogc => {
+ options => ["-q"],
+ loggrep => qr/^memory /,
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-memory-overflow-cont.pl b/regress/usr.sbin/syslogd/args-memory-overflow-cont.pl
new file mode 100644
index 00000000000..23e15a6ef78
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-overflow-cont.pl
@@ -0,0 +1,40 @@
+# Syslogc reads the memory logs continously.
+# The client writes message to overflow the memory buffer 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.
+# Check that syslogc logs lost lines.
+
+use strict;
+use warnings;
+use Time::HiRes 'sleep';
+
+our %args = (
+ client => {
+ func => sub {
+ my $self = shift;
+ foreach (1..300) {
+ write_message($self, $_ x 1024);
+ # if client sends too fast, syslogd will not see everything
+ sleep .01;
+ }
+ write_log($self);
+ },
+ },
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 1,
+ qr/ctlcmd 6/ => 1, # read cont
+ },
+ },
+ syslogc => [ {
+ early => 1,
+ stop => 1,
+ options => ["-f", "memory"],
+ down => qr/Lines were dropped!/,
+ loggrep => {},
+ } ],
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-memory-overflow-flags.pl b/regress/usr.sbin/syslogd/args-memory-overflow-flags.pl
new file mode 100644
index 00000000000..1a4eb9b4b5a
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-overflow-flags.pl
@@ -0,0 +1,39 @@
+# The client writes message to overflow the memory buffer 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.
+# Syslogc checks the memory logs.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that syslogc -o reports overflow.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => sub {
+ my $self = shift;
+ foreach (1..4) {
+ write_message($self, $_ x 1024);
+ }
+ write_log($self);
+ },
+ },
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 1,
+ qr/ctlcmd 5/ => 1,
+ get_testlog() => 1,
+ },
+ },
+ syslogc => {
+ options => ["-o", "memory"],
+ exit => 1,
+ loggrep => {
+ qr/^memory has overflowed/ => 1,
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-memory-overflow.pl b/regress/usr.sbin/syslogd/args-memory-overflow.pl
new file mode 100644
index 00000000000..0c5a984c81b
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-overflow.pl
@@ -0,0 +1,50 @@
+# The client writes message to overflow the memory buffer 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.
+# Syslogc checks the memory logs.
+# Check that memory buffer has overflow flag.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => sub {
+ my $self = shift;
+ foreach (1..4) {
+ write_message($self, $_ x 1024);
+ }
+ write_log($self);
+ },
+ },
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 5,
+ qr/ctlcmd 1/ => 1, # read
+ qr/ctlcmd 2/ => 1, # read clear
+ qr/ctlcmd 4/ => 3, # list
+ },
+ },
+ syslogc => [ {
+ options => ["-q"],
+ loggrep => qr/^memory\* /,
+ }, {
+ options => ["memory"],
+ down => get_downlog(),
+ loggrep => {},
+ }, {
+ options => ["-q"],
+ loggrep => qr/^memory\* /,
+ }, {
+ options => ["-c", "memory"],
+ down => get_downlog(),
+ loggrep => {},
+ }, {
+ options => ["-q"],
+ loggrep => qr/^memory /,
+ } ],
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-memory-read-clear.pl b/regress/usr.sbin/syslogd/args-memory-read-clear.pl
new file mode 100644
index 00000000000..31b0029e604
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-read-clear.pl
@@ -0,0 +1,30 @@
+# 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.
+# Syslogc reads and clears the memory logs.
+# Find the message in client, file, pipe, syslogd, server, syslogc log.
+# Check that memory buffer has been cleared.
+
+use strict;
+use warnings;
+
+our %args = (
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 2,
+ qr/ctlcmd 2/ => 1,
+ get_testlog() => 1,
+ },
+ },
+ syslogc => [ {
+ options => ["-c", "memory"],
+ down => get_downlog(),
+ }, {
+ options => ["memory"],
+ loggrep => { get_testlog() => 0 },
+ } ],
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-memory-read-cont.pl b/regress/usr.sbin/syslogd/args-memory-read-cont.pl
new file mode 100644
index 00000000000..1e1ccdaab13
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-read-cont.pl
@@ -0,0 +1,32 @@
+# Syslogc reads the memory logs continously.
+# 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, syslogc log.
+# Check that memory buffer has not been cleared.
+
+use strict;
+use warnings;
+
+our %args = (
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 2,
+ qr/ctlcmd 6/ => 1,
+ get_testlog() => 1,
+ },
+ },
+ syslogc => [ {
+ early => 1,
+ stop => 1,
+ options => ["-f", "memory"],
+ down => get_downlog(),
+ }, {
+ options => ["memory"],
+ down => get_downlog(),
+ } ],
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-memory-read.pl b/regress/usr.sbin/syslogd/args-memory-read.pl
new file mode 100644
index 00000000000..6d65480592b
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-memory-read.pl
@@ -0,0 +1,30 @@
+# 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.
+# Syslogc reads the memory logs.
+# Find the message in client, file, pipe, syslogd, server, syslogc log.
+# Check that memory buffer has not been cleared.
+
+use strict;
+use warnings;
+
+our %args = (
+ syslogd => {
+ memory => 1,
+ loggrep => {
+ qr/Accepting control connection/ => 2,
+ qr/ctlcmd 1/ => 2,
+ get_testlog() => 1,
+ },
+ },
+ syslogc => [ {
+ options => ["memory"],
+ down => get_downlog(),
+ }, {
+ options => ["memory"],
+ down => get_downlog(),
+ } ],
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-only4.pl b/regress/usr.sbin/syslogd/args-only4.pl
index c4b46602ca3..db4d9df2155 100644
--- a/regress/usr.sbin/syslogd/args-only4.pl
+++ b/regress/usr.sbin/syslogd/args-only4.pl
@@ -22,7 +22,7 @@ our %args = (
listen => { domain => AF_INET, addr => "127.0.0.1" },
},
file => {
- loggrep => qr/ 127.0.0.1 /. get_log(),
+ loggrep => qr/ 127.0.0.1 /. get_testlog(),
},
fstat => {
loggrep => {
diff --git a/regress/usr.sbin/syslogd/args-only6.pl b/regress/usr.sbin/syslogd/args-only6.pl
index 5978dd94ab5..bda7243088b 100644
--- a/regress/usr.sbin/syslogd/args-only6.pl
+++ b/regress/usr.sbin/syslogd/args-only6.pl
@@ -22,7 +22,7 @@ our %args = (
listen => { domain => AF_INET6, addr => "::1" },
},
file => {
- loggrep => qr/ ::1 /. get_log(),
+ loggrep => qr/ ::1 /. get_testlog(),
},
fstat => {
loggrep => {
diff --git a/regress/usr.sbin/syslogd/args-proto-invalid.pl b/regress/usr.sbin/syslogd/args-proto-invalid.pl
index f6408e317fc..fdb6172e221 100644
--- a/regress/usr.sbin/syslogd/args-proto-invalid.pl
+++ b/regress/usr.sbin/syslogd/args-proto-invalid.pl
@@ -12,7 +12,7 @@ our %args = (
loghost => '@invalid://127.0.0.1',
loggrep => {
qr/syslogd: bad protocol "\@invalid:\/\/127.0.0.1"/ => 2,
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-proto-udp.pl b/regress/usr.sbin/syslogd/args-proto-udp.pl
index ed730b17f7f..835ee05bcf6 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp.pl
@@ -14,7 +14,7 @@ our %args = (
loghost => '@udp://127.0.0.1:$connectport',
loggrep => {
qr/Logging to FORW \@udp:\/\/127.0.0.1:\d+/ => '>=4',
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-proto-udp4-host6.pl b/regress/usr.sbin/syslogd/args-proto-udp4-host6.pl
index cf16cd66f24..9ce70c77e43 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp4-host6.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp4-host6.pl
@@ -12,7 +12,7 @@ our %args = (
loghost => '@udp4://[::1]',
loggrep => {
qr/syslogd: bad hostname "\@udp4:\/\/\[::1\]"/ => 2,
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-proto-udp4-only6.pl b/regress/usr.sbin/syslogd/args-proto-udp4-only6.pl
index 908f5b2c5db..c092de98834 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp4-only6.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp4-only6.pl
@@ -12,7 +12,7 @@ our %args = (
loghost => '@udp4://127.0.0.1',
loggrep => {
qr/syslogd: no udp4 "\@udp4:\/\/127.0.0.1/ => 2,
- get_log() => 1,
+ get_testlog() => 1,
},
options => ["-6"],
},
diff --git a/regress/usr.sbin/syslogd/args-proto-udp4.pl b/regress/usr.sbin/syslogd/args-proto-udp4.pl
index 70a8b98bb33..b6de14fdae3 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp4.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp4.pl
@@ -14,7 +14,7 @@ our %args = (
loghost => '@udp4://127.0.0.1:$connectport',
loggrep => {
qr/Logging to FORW \@udp4:\/\/127.0.0.1:\d+/ => '>=4',
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-proto-udp6-host4.pl b/regress/usr.sbin/syslogd/args-proto-udp6-host4.pl
index 669b95c240a..390097261e7 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp6-host4.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp6-host4.pl
@@ -12,7 +12,7 @@ our %args = (
loghost => '@udp6://127.0.0.1',
loggrep => {
qr/syslogd: bad hostname "\@udp6:\/\/127.0.0.1"/ => 2,
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-proto-udp6-only4.pl b/regress/usr.sbin/syslogd/args-proto-udp6-only4.pl
index a0a0a2e686d..1977824f6b1 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp6-only4.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp6-only4.pl
@@ -12,7 +12,7 @@ our %args = (
loghost => '@udp6://[::1]',
loggrep => {
qr/syslogd: no udp6 "\@udp6:\/\/\[::1\]/ => 2,
- get_log() => 1,
+ get_testlog() => 1,
},
options => ["-4"],
},
diff --git a/regress/usr.sbin/syslogd/args-proto-udp6.pl b/regress/usr.sbin/syslogd/args-proto-udp6.pl
index 0798f0f50e2..55d3ea5806b 100644
--- a/regress/usr.sbin/syslogd/args-proto-udp6.pl
+++ b/regress/usr.sbin/syslogd/args-proto-udp6.pl
@@ -14,7 +14,7 @@ our %args = (
loghost => '@udp6://[::1]:$connectport',
loggrep => {
qr/Logging to FORW \@udp6:\/\/\[::1\]:\d+/ => '>=4',
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
diff --git a/regress/usr.sbin/syslogd/args-server-udp4.pl b/regress/usr.sbin/syslogd/args-server-udp4.pl
index 22bd7439b25..93a8298f68e 100644
--- a/regress/usr.sbin/syslogd/args-server-udp4.pl
+++ b/regress/usr.sbin/syslogd/args-server-udp4.pl
@@ -14,14 +14,14 @@ our %args = (
loghost => '@127.0.0.1:$connectport',
loggrep => {
qr/Logging to FORW \@127.0.0.1:\d+/ => '>=4',
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
listen => { domain => AF_INET, addr => "127.0.0.1" },
loggrep => {
qr/listen sock: 127.0.0.1 \d+/ => 1,
- get_log() => 1,
+ get_testlog() => 1,
},
},
);
diff --git a/regress/usr.sbin/syslogd/args-server-udp6.pl b/regress/usr.sbin/syslogd/args-server-udp6.pl
index 6fdee7c83c9..8db614ade11 100644
--- a/regress/usr.sbin/syslogd/args-server-udp6.pl
+++ b/regress/usr.sbin/syslogd/args-server-udp6.pl
@@ -14,14 +14,14 @@ our %args = (
loghost => '@[::1]:$connectport',
loggrep => {
qr/Logging to FORW \@\[::1\]:\d+/ => '>=4',
- get_log() => 1,
+ get_testlog() => 1,
},
},
server => {
listen => { domain => AF_INET6, addr => "::1" },
loggrep => {
qr/listen sock: ::1 \d+/ => 1,
- get_log() => 1,
+ get_testlog() => 1,
},
},
);
diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl
index 423a54ab9b3..b6e9c289a73 100644
--- a/regress/usr.sbin/syslogd/funcs.pl
+++ b/regress/usr.sbin/syslogd/funcs.pl
@@ -1,4 +1,4 @@
-# $OpenBSD: funcs.pl,v 1.6 2014/09/03 15:56:07 bluhm Exp $
+# $OpenBSD: funcs.pl,v 1.7 2014/09/13 23:38:24 bluhm Exp $
# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -76,7 +76,7 @@ sub write_unix {
Type => SOCK_DGRAM,
Peer => $path,
) or die ref($self), " connect to $path unix socket failed: $!";
- my $msg = get_log(). " $path unix socket";
+ my $msg = get_testlog(). " $path unix socket";
print $u $msg;
print STDERR $msg, "\n";
}
@@ -120,7 +120,7 @@ sub read_message {
# Script funcs
########################################################################
-sub get_log {
+sub get_testlog {
return $testlog;
}
@@ -131,15 +131,19 @@ sub get_between2loggrep {
);
}
+sub get_downlog {
+ return $downlog;
+}
+
sub check_logs {
- my ($c, $r, $s, %args) = @_;
+ my ($c, $r, $s, $m, %args) = @_;
return if $args{nocheck};
- check_log($c, $r, $s, %args);
+ check_log($c, $r, $s, @$m);
check_out($r, %args);
check_stat($r, %args);
- check_kdump($c, $r, $s, %args);
+ check_kdump($c, $r, $s);
}
sub compare($$) {
@@ -178,14 +182,10 @@ sub check_pattern {
}
sub check_log {
- my ($c, $r, $s, %args) = @_;
-
- my %name2proc = (client => $c, syslogd => $r, server => $s);
- foreach my $name (qw(client syslogd server)) {
- next if $args{$name}{nocheck};
- my $p = $name2proc{$name} or next;
- my $pattern = $args{$name}{loggrep} || $testlog;
- check_pattern($name, $p, $pattern, \&loggrep);
+ foreach my $proc (@_) {
+ next unless $proc && !$proc->{nocheck};
+ my $pattern = $proc->{loggrep} || $testlog;
+ check_pattern(ref $proc, $proc, $pattern, \&loggrep);
}
}
@@ -200,7 +200,7 @@ sub check_out {
foreach my $name (qw(file pipe)) {
next if $args{$name}{nocheck};
- my $file = $r->{"out$name"} or next;
+ my $file = $r->{"out$name"} or die;
my $pattern = $args{$name}{loggrep} || $testlog;
check_pattern($name, $file, $pattern, \&filegrep);
}
@@ -210,9 +210,9 @@ sub check_stat {
my ($r, %args) = @_;
foreach my $name (qw(fstat)) {
- next if $args{$name}{nocheck};
- my $file = $r->{$name} && $r->{"${name}file"} or next;
- my $pattern = $args{$name}{loggrep} or next;
+ next unless $r && $r->{$name};
+ my $file = $r->{"${name}file"} or die;
+ my $pattern = $args{$name}{loggrep} or die;
check_pattern($name, $file, $pattern, \&filegrep);
}
}
@@ -227,15 +227,11 @@ sub filegrep {
}
sub check_kdump {
- my ($c, $r, $s, %args) = @_;
-
- my %name2proc = (client => $c, syslogd => $r, server => $s);
- foreach my $name (qw(client syslogd server)) {
- next unless $args{$name}{ktrace};
- my $p = $name2proc{$name} or next;
- my $file = $p->{ktracefile} or next;
- my $pattern = $args{$name}{kdump} or next;
- check_pattern($name, $file, $pattern, \&kdumpgrep);
+ foreach my $proc (@_) {
+ next unless $proc && $proc->{ktrace};
+ my $file = $proc->{ktracefile} or die;
+ my $pattern = $proc->{kdump} or die;
+ check_pattern(ref $proc, $file, $pattern, \&kdumpgrep);
}
}
diff --git a/regress/usr.sbin/syslogd/syslogd.pl b/regress/usr.sbin/syslogd/syslogd.pl
index 98c351e6f7f..80a7085af5b 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.2 2014/09/02 00:26:30 bluhm Exp $
+# $OpenBSD: syslogd.pl,v 1.3 2014/09/13 23:38:24 bluhm Exp $
# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -23,6 +23,7 @@ use Socket6;
use Client;
use Syslogd;
use Server;
+use Syslogc;
require 'funcs.pl';
sub usage {
@@ -46,7 +47,7 @@ foreach my $name (qw(client syslogd server)) {
}
}
}
-my($s, $c, $r);
+my($s, $c, $r, @m);
$s = Server->new(
func => \&read_log,
listendomain => AF_INET,
@@ -56,9 +57,18 @@ $s = Server->new(
client => \$c,
syslogd => \$r,
) unless $args{server}{noserver};
+$args{syslogc} = [ $args{syslogc} ] if ref $args{syslogc} eq 'HASH';
+my $i = 0;
+@m = map { Syslogc->new(
+ %{$_},
+ testfile => $testfile,
+ ktracefile => "syslogc-$i.ktrace",
+ logfile => "syslogc-".$i++.".log",
+) } @{$args{syslogc}};
$r = Syslogd->new(
connectaddr => "127.0.0.1",
connectport => $s && $s->{listenport},
+ ctlsock => @m && $m[0]->{ctlsock},
%{$args{syslogd}},
testfile => $testfile,
client => \$c,
@@ -75,12 +85,35 @@ $c = Client->new(
$r->run;
$s->run->up unless $args{server}{noserver};
$r->up;
+my $control = 0;
+foreach (@m) {
+ if ($_->{early} || $_->{stop}) {
+ $_->run->up;
+ $control++;
+ }
+}
+$r->loggrep("Accepting control connection") if $control;
+foreach (@m) {
+ if ($_->{stop}) {
+ $_->kill('STOP');
+ }
+}
$c->run->up unless $args{client}{noclient};
$c->down unless $args{client}{noclient};
$s->down unless $args{server}{noserver};
+foreach (@m) {
+ if ($_->{stop}) {
+ $_->kill('CONT');
+ $_->down;
+ } elsif ($_->{early}) {
+ $_->down;
+ } else {
+ $_->run->up->down;
+ }
+}
$r->kill_child;
$r->down;
-check_logs($c, $r, $s, %args);
+check_logs($c, $r, $s, \@m, %args);
$args{check}->({client => $c, syslogd => $r, server => $s}) if $args{check};