From aa7e970664271f683bccad45435ff95d8a95b2fd Mon Sep 17 00:00:00 2001 From: bluhm Date: Mon, 5 Jan 2015 18:48:31 +0000 Subject: [PATCH] Make syslogd TCP tests more reliable. Increase timeouts, shutdown write to trigger connection close, allow errors EPIPE or ECONNRESET. --- regress/usr.sbin/syslogd/args-server-tcp-close.pl | 12 +++++++++--- regress/usr.sbin/syslogd/args-server-tcp-error.pl | 10 +++++++--- regress/usr.sbin/syslogd/args-server-tcp-sendback.pl | 2 +- regress/usr.sbin/syslogd/args-sigterm.pl | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/regress/usr.sbin/syslogd/args-server-tcp-close.pl b/regress/usr.sbin/syslogd/args-server-tcp-close.pl index aba01c7db2d..55b9bd0274d 100644 --- a/regress/usr.sbin/syslogd/args-server-tcp-close.pl +++ b/regress/usr.sbin/syslogd/args-server-tcp-close.pl @@ -14,8 +14,8 @@ our %args = ( client => { func => sub { my $self = shift; - ${$self->{syslogd}}->loggrep("loghost .* connection close", 2) - or die "connection close in syslogd.log"; + ${$self->{syslogd}}->loggrep("loghost .* connection close", 5) + or die "no connection close in syslogd.log"; write_log($self, @_); }, }, @@ -29,7 +29,13 @@ our %args = ( }, server => { listen => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1" }, - func => sub {}, + func => sub { + my $self = shift; + shutdown(\*STDOUT, 1) + or die "shutdown write failed: $!"; + ${$self->{syslogd}}->loggrep("loghost .* connection close", 5) + or die "no connection close in syslogd.log"; + }, loggrep => {}, }, file => { diff --git a/regress/usr.sbin/syslogd/args-server-tcp-error.pl b/regress/usr.sbin/syslogd/args-server-tcp-error.pl index a9f3d845f1e..955684ab960 100644 --- a/regress/usr.sbin/syslogd/args-server-tcp-error.pl +++ b/regress/usr.sbin/syslogd/args-server-tcp-error.pl @@ -9,13 +9,17 @@ use strict; use warnings; use Socket; +use Errno ':POSIX'; + +my @errors = (EPIPE,ECONNRESET); +my $errors = "(". join("|", map { $! = $_ } @errors). ")"; our %args = ( client => { func => sub { my $self = shift; - ${$self->{syslogd}}->loggrep("loghost .* connection error", 2) - or die "connection error in syslogd.log"; + ${$self->{syslogd}}->loggrep("loghost .* connection error", 5) + or die "no connection error in syslogd.log"; write_log($self, @_); }, }, @@ -38,7 +42,7 @@ our %args = ( }, file => { loggrep => { - qr/syslogd: loghost .* connection error: Connection reset by peer/ + qr/syslogd: loghost .* connection error: $errors/ => 1, }, }, diff --git a/regress/usr.sbin/syslogd/args-server-tcp-sendback.pl b/regress/usr.sbin/syslogd/args-server-tcp-sendback.pl index 2677c055e33..d2637fe50fe 100644 --- a/regress/usr.sbin/syslogd/args-server-tcp-sendback.pl +++ b/regress/usr.sbin/syslogd/args-server-tcp-sendback.pl @@ -16,7 +16,7 @@ our %args = ( client => { func => sub { my $self = shift; - ${$self->{syslogd}}->loggrep("loghost .* did send .* back", 2) + ${$self->{syslogd}}->loggrep("loghost .* did send .* back", 5) or die "no send back in syslogd.log"; write_log($self, @_); }, diff --git a/regress/usr.sbin/syslogd/args-sigterm.pl b/regress/usr.sbin/syslogd/args-sigterm.pl index 180274da833..f060afc245c 100644 --- a/regress/usr.sbin/syslogd/args-sigterm.pl +++ b/regress/usr.sbin/syslogd/args-sigterm.pl @@ -33,8 +33,8 @@ our %args = ( read_between2logs($self, sub { ${$self->{syslogd}}->kill_syslogd('TERM'); my $pattern = "syslogd: exiting on signal 15"; - ${$self->{syslogd}}->loggrep("syslogd: exiting on signal 15", - 5) or die ref($self), + ${$self->{syslogd}}->loggrep("syslogd: exiting on signal 15", 5) + or die ref($self), " no 'syslogd: exiting on signal 15' between logs"; print STDERR "Signal\n"; }); -- 2.20.1