diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-09-09 08:48:47 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-09-09 08:48:47 +0000 |
commit | 02b5a612ffd485b39d832c2989d534b1b1707063 (patch) | |
tree | 73d19ffe45322d7b3c9a5f772b5ccb133cbaaea5 /regress/usr.sbin/syslogd | |
parent | f6180bfaa203662fa7c0ebc2e48f2a05761f61df (diff) |
Test that syslogd can process 8 full size messages from sendsyslog(2)
or UDP socket or UNIX domain socket at once.
Diffstat (limited to 'regress/usr.sbin/syslogd')
-rw-r--r-- | regress/usr.sbin/syslogd/Client.pm | 5 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-bufsize-sendsyslog.pl | 49 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-bufsize-udp.pl | 50 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-bufsize-unix.pl | 49 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/funcs.pl | 13 |
5 files changed, 162 insertions, 4 deletions
diff --git a/regress/usr.sbin/syslogd/Client.pm b/regress/usr.sbin/syslogd/Client.pm index 47544606d9e..af2904d7f70 100644 --- a/regress/usr.sbin/syslogd/Client.pm +++ b/regress/usr.sbin/syslogd/Client.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Client.pm,v 1.3 2015/02/02 17:40:24 bluhm Exp $ +# $OpenBSD: Client.pm,v 1.4 2015/09/09 08:48:46 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -37,7 +37,8 @@ sub new { sub child { my $self = shift; - if (defined($self->{connectdomain})) { + if (defined($self->{connectdomain}) && + $self->{connectdomain} ne "sendsyslog") { my $cs; if ($self->{connectdomain} == AF_UNIX) { $cs = IO::Socket::UNIX->new( diff --git a/regress/usr.sbin/syslogd/args-bufsize-sendsyslog.pl b/regress/usr.sbin/syslogd/args-bufsize-sendsyslog.pl new file mode 100644 index 00000000000..b5af2f923ff --- /dev/null +++ b/regress/usr.sbin/syslogd/args-bufsize-sendsyslog.pl @@ -0,0 +1,49 @@ +# Stop syslogd. +# The client writes 8 message with 8192 with sendsyslog(2). +# Continue syslogd. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via TCP to the loghost. +# The server receives the message on its TCP socket. +# Find the message in client, file, syslogd, server log. +# Check that 8 long messages from sendsyslog(2) can be processed at once. + +use strict; +use warnings; +use Socket; +use constant MAXLINE => 8192; + +our %args = ( + client => { + connect => { domain => "sendsyslog" }, + func => sub { + my $self = shift; + ${$self->{syslogd}}->kill_syslogd('STOP'); + write_lines($self, 8, MAXLINE); + IO::Handle::flush(\*STDOUT); + ${$self->{syslogd}}->kill_syslogd('CONT'); + ${$self->{syslogd}}->loggrep(get_charlog(), 8) + or die ref($self), " syslogd did not receive all messages"; + write_shutdown($self); + }, + loggrep => { get_charlog() => 8 }, + }, + syslogd => { + loghost => '@tcp://localhost:$connectport', + loggrep => { + qr/[gs]etsockopt bufsize/ => 0, + get_charlog() => 8, + }, + }, + server => { + listen => { domain => AF_UNSPEC, proto => "tcp", addr => "localhost" }, + loggrep => { get_charlog() => 8 }, + }, + pipe => { + nocheck => 1, + }, + file => { + loggrep => { get_charlog() => 8 }, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-bufsize-udp.pl b/regress/usr.sbin/syslogd/args-bufsize-udp.pl new file mode 100644 index 00000000000..47aea6cadd2 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-bufsize-udp.pl @@ -0,0 +1,50 @@ +# Stop syslogd. +# The client writes 8 message with 8192 to a localhost IPv6 UDP socket. +# Continue syslogd. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via TCP to the loghost. +# The server receives the message on its TCP socket. +# Find the message in client, file, syslogd, server log. +# Check that 8 long UDP messages can be processed at once. + +use strict; +use warnings; +use Socket; +use constant MAXLINE => 8192; + +our %args = ( + client => { + connect => { domain => AF_INET6, addr => "::1", port => 514 }, + func => sub { + my $self = shift; + ${$self->{syslogd}}->kill_syslogd('STOP'); + write_lines($self, 8, MAXLINE); + IO::Handle::flush(\*STDOUT); + ${$self->{syslogd}}->kill_syslogd('CONT'); + ${$self->{syslogd}}->loggrep(get_charlog(), 8) + or die ref($self), " syslogd did not receive all messages"; + write_shutdown($self); + }, + loggrep => { get_charlog() => 8 }, + }, + syslogd => { + options => ["-un"], + loghost => '@tcp://localhost:$connectport', + loggrep => { + qr/[gs]etsockopt bufsize/ => 0, + get_charlog() => 8, + }, + }, + server => { + listen => { domain => AF_UNSPEC, proto => "tcp", addr => "localhost" }, + loggrep => { get_charlog() => 8 }, + }, + pipe => { + nocheck => 1, + }, + file => { + loggrep => { get_charlog() => 8 }, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/args-bufsize-unix.pl b/regress/usr.sbin/syslogd/args-bufsize-unix.pl new file mode 100644 index 00000000000..a8b30d86250 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-bufsize-unix.pl @@ -0,0 +1,49 @@ +# Stop syslogd. +# The client writes 8 message with 8192 to unix domain socket /dev/log. +# Continue syslogd. +# The syslogd writes it into a file and through a pipe. +# The syslogd passes it via TCP to the loghost. +# The server receives the message on its TCP socket. +# Find the message in client, file, syslogd, server log. +# Check that 8 long UNIX messages can be processed at once. + +use strict; +use warnings; +use Socket; +use constant MAXLINE => 8192; + +our %args = ( + client => { + connect => { domain => AF_UNIX }, + func => sub { + my $self = shift; + ${$self->{syslogd}}->kill_syslogd('STOP'); + write_lines($self, 8, MAXLINE); + IO::Handle::flush(\*STDOUT); + ${$self->{syslogd}}->kill_syslogd('CONT'); + ${$self->{syslogd}}->loggrep(get_charlog(), 8) + or die ref($self), " syslogd did not receive all messages"; + write_shutdown($self); + }, + loggrep => { get_charlog() => 8 }, + }, + syslogd => { + loghost => '@tcp://localhost:$connectport', + loggrep => { + qr/[gs]etsockopt bufsize/ => 0, + get_charlog() => 8, + }, + }, + server => { + listen => { domain => AF_UNSPEC, proto => "tcp", addr => "localhost" }, + loggrep => { get_charlog() => 8 }, + }, + pipe => { + nocheck => 1, + }, + file => { + loggrep => { get_charlog() => 8 }, + }, +); + +1; diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index 1fe21a45c16..a11b63166c1 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.23 2015/07/19 20:18:18 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.24 2015/09/09 08:48:46 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org> # @@ -85,7 +85,10 @@ sub write_message { if (defined($self->{connectdomain})) { my $msg = join("", @_); - if ($self->{connectproto} eq "udp") { + if ($self->{connectdomain} eq "sendsyslog") { + sendsyslog($msg) + or die ref($self), " sendsyslog failed: $!"; + } elsif ($self->{connectproto} eq "udp") { # writing UDP packets works only with syswrite() defined(my $n = syswrite(STDOUT, $msg)) or die ref($self), " write log line failed: $!"; @@ -101,6 +104,12 @@ sub write_message { } } +sub sendsyslog { + my $msg = shift; + require 'sys/syscall.ph'; + return syscall(&SYS_sendsyslog, $msg, length($msg)) != -1; +} + sub write_shutdown { my $self = shift; |