diff options
Diffstat (limited to 'regress/usr.sbin/syslogd/args-client-tcp-deferred.pl')
-rw-r--r-- | regress/usr.sbin/syslogd/args-client-tcp-deferred.pl | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl b/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl new file mode 100644 index 00000000000..f876f812d5c --- /dev/null +++ b/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl @@ -0,0 +1,65 @@ +# The syslogd listens on 127.0.0.1 TCP socket. +# The client creates connections to syslogd TCP socket until it blocks. +# The client writes to all sockets and closes them. +# Wait until syslogd has slots to accept all sockets. +# Find the message in client, file, pipe, syslogd, server log. +# Check the messages end up in the log file. + +use strict; +use warnings; +use IO::Socket::INET6; + +our %args = ( + client => { + connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1", + port => 514 }, + func => sub { + my $self = shift; + local $| = 1; + my @s; + $s[0] = \*STDOUT; + # open additional connections until syslogd deferres + for (my $i = 1; $i <= 30; $i++) { + $s[$i] = IO::Socket::INET6->new( + Domain => AF_INET, + Proto => "tcp", + PeerAddr => "127.0.0.1", + PeerPort => 514, + ) or die "id $i tcp socket connect failed: $!"; + print STDERR "<<< id $i tcp connected\n"; + ${$self->{syslogd}}->loggrep("tcp logger .* accepted", 1, $i); + ${$self->{syslogd}}->loggrep("accept deferred") + and last; + } + write_tcp($self, \*STDOUT, 0); + for (my $i = 1; $i < @s; $i++) { + my $fh = $s[$i]; + write_tcp($self, $fh, $i); + # close connection so that others can be accepted + close($fh); + } + ${$self->{syslogd}}->loggrep(qr/tcp logger .* use \d+ bytes/, 10, + scalar @s) + or die ref($self), " syslogd did not use connections"; + write_shutdown($self); + }, + }, + syslogd => { + options => ["-T", "127.0.0.1:514"], + rlimit => { + RLIMIT_NOFILE => 30, + }, + loggrep => { + qr/tcp logger .* accepted/ => '>=10', + qr/tcp logger .* use \d+ bytes/ => '>=10', + qr/tcp logger .* connection close/ => '>=10', + }, + }, + file => { + loggrep => { + get_testgrep() => '>=10', + }, + }, +); + +1; |