diff options
author | 2014-09-03 15:56:07 +0000 | |
---|---|---|
committer | 2014-09-03 15:56:07 +0000 | |
commit | fa51160f43fc6996b6d2e4399952d42013de12a7 (patch) | |
tree | 89d6515c698eaec38431713278de015904219311 | |
parent | Be coherent in the way arp(8) and ndp(8) display local entries and (diff) | |
download | wireguard-openbsd-fa51160f43fc6996b6d2e4399952d42013de12a7.tar.xz wireguard-openbsd-fa51160f43fc6996b6d2e4399952d42013de12a7.zip |
Add tests that send log messages via unix domain sockets to syslogd.
Also check that the maximum number of -a path is handled correctly.
-rw-r--r-- | regress/usr.sbin/syslogd/Makefile | 4 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-client-unix.pl | 20 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-maxunix.pl | 43 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/funcs.pl | 15 |
4 files changed, 79 insertions, 3 deletions
diff --git a/regress/usr.sbin/syslogd/Makefile b/regress/usr.sbin/syslogd/Makefile index 988a01a9cff..517cf0bcec6 100644 --- a/regress/usr.sbin/syslogd/Makefile +++ b/regress/usr.sbin/syslogd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.3 2014/09/02 00:26:30 bluhm Exp $ +# $OpenBSD: Makefile,v 1.4 2014/09/03 15:56:07 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 += ktrace.out *.ktrace *.fstat +CLEANFILES += unix.* ktrace.out *.ktrace *.fstat .MAIN: all diff --git a/regress/usr.sbin/syslogd/args-client-unix.pl b/regress/usr.sbin/syslogd/args-client-unix.pl new file mode 100644 index 00000000000..6906ffc4619 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-client-unix.pl @@ -0,0 +1,20 @@ +# The client writes a message to Sys::Syslog unix 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 that the file log contains the message. + +use strict; +use warnings; + +our %args = ( + client => { + logsock => { type => "unix" }, + }, + file => { + loggrep => qr/ syslogd-regress\[\d+\]: /. get_log(), + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-maxunix.pl b/regress/usr.sbin/syslogd/args-maxunix.pl new file mode 100644 index 00000000000..783f8114008 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-maxunix.pl @@ -0,0 +1,43 @@ +# The client writes messages to MAXUNIX unix domain sockets. +# The syslogd -a writes them into a file and through a pipe. +# The syslogd -a passes them via UDP to the loghost. +# The server receives the messages on its UDP socket. +# Find the message in client, file, pipe, syslogd, server log. +# Check that the file log contains a message from every sockets. +# Check that the one socket above the limit prints an error. + +use strict; +use warnings; +use IO::Socket::UNIX; +use constant MAXUNIX => 21; + +our %args = ( + client => { + func => sub { + my $self = shift; + write_unix($self); + foreach (1..(MAXUNIX-1)) { + write_unix($self, "unix.$_"); + } + write_shutdown($self, @_); + }, + }, + syslogd => { + options => [ map { ("-a" => "unix.$_") } (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, + }, + }, + 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, + } + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index 6e18fb2e111..423a54ab9b3 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.5 2014/09/02 17:43:29 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.6 2014/09/03 15:56:07 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -68,6 +68,19 @@ sub write_shutdown { syslog(LOG_NOTICE, $downlog); } +sub write_unix { + my $self = shift; + my $path = shift || "/dev/log"; + + my $u = IO::Socket::UNIX->new( + Type => SOCK_DGRAM, + Peer => $path, + ) or die ref($self), " connect to $path unix socket failed: $!"; + my $msg = get_log(). " $path unix socket"; + print $u $msg; + print STDERR $msg, "\n"; +} + ######################################################################## # Server funcs ######################################################################## |