diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-05-22 15:01:17 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-05-22 15:01:17 +0000 |
commit | 024d0751e9b1fcc40a90e2fc57ca424babeb5ee9 (patch) | |
tree | 6b5d8a207143fc7c41237e5d8a4bcc770045bd46 | |
parent | ecdc03979598bf9cb38b3576ff9f7ce6812c4a23 (diff) |
In the sendsyslog-dropped test the client has to write a log message
before syslogd is running. To fix a race in regress, delay the
syslogd startup until the message has been written. For debugging
add the process class to all die messages.
20 files changed, 45 insertions, 41 deletions
diff --git a/regress/usr.sbin/syslogd/args-client-tcp-close.pl b/regress/usr.sbin/syslogd/args-client-tcp-close.pl index abdb1c1dcc9..631147940a3 100644 --- a/regress/usr.sbin/syslogd/args-client-tcp-close.pl +++ b/regress/usr.sbin/syslogd/args-client-tcp-close.pl @@ -15,9 +15,9 @@ our %args = ( func => sub { my $self = shift; shutdown(\*STDOUT, 1) - or die "shutdown write failed: $!"; + or die ref($self), " shutdown write failed: $!"; ${$self->{syslogd}}->loggrep("tcp logger .* connection close", 5) - or die "no connection close in syslogd.log"; + or die ref($self), " no connection close in syslogd.log"; }, loggrep => { qr/connect sock: 127.0.0.1 \d+/ => 1, @@ -34,7 +34,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("tcp logger .* connection close", 5) - or die "no connection close in syslogd.log"; + or die ref($self), " no connection close in syslogd.log"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl b/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl index f876f812d5c..f6927cd3887 100644 --- a/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl +++ b/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl @@ -25,7 +25,7 @@ our %args = ( Proto => "tcp", PeerAddr => "127.0.0.1", PeerPort => 514, - ) or die "id $i tcp socket connect failed: $!"; + ) or die ref($self), " 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") diff --git a/regress/usr.sbin/syslogd/args-client-tcp-error.pl b/regress/usr.sbin/syslogd/args-client-tcp-error.pl index 427cacd71e1..c6315c1f0d9 100644 --- a/regress/usr.sbin/syslogd/args-client-tcp-error.pl +++ b/regress/usr.sbin/syslogd/args-client-tcp-error.pl @@ -19,7 +19,7 @@ our %args = ( func => sub { my $self = shift; setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0)) - or die "set socket linger failed: $!"; + or die ref($self), " set socket linger failed: $!"; }, loggrep => { qr/connect sock: 127.0.0.1 \d+/ => 1, @@ -36,7 +36,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("tcp logger .* connection error", 5) - or die "no connection error in syslogd.log"; + or die ref($self), " no connection error in syslogd.log"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-client-tls-close.pl b/regress/usr.sbin/syslogd/args-client-tls-close.pl index a53ffc93c54..45ab65a9893 100644 --- a/regress/usr.sbin/syslogd/args-client-tls-close.pl +++ b/regress/usr.sbin/syslogd/args-client-tls-close.pl @@ -15,9 +15,9 @@ our %args = ( func => sub { my $self = shift; shutdown(\*STDOUT, 1) - or die "shutdown write failed: $!"; + or die ref($self), " shutdown write failed: $!"; ${$self->{syslogd}}->loggrep("tls logger .* connection close", 5) - or die "no connection close in syslogd.log"; + or die ref($self), " no connection close in syslogd.log"; }, loggrep => { qr/connect sock: 127.0.0.1 \d+/ => 1, @@ -34,7 +34,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("tls logger .* connection close", 5) - or die "no connection close in syslogd.log"; + or die ref($self), " no connection close in syslogd.log"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-client-tls-error.pl b/regress/usr.sbin/syslogd/args-client-tls-error.pl index 15d8ea7b9b0..10024e5da99 100644 --- a/regress/usr.sbin/syslogd/args-client-tls-error.pl +++ b/regress/usr.sbin/syslogd/args-client-tls-error.pl @@ -19,7 +19,7 @@ our %args = ( func => sub { my $self = shift; setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0)) - or die "set socket linger failed: $!"; + or die ref($self), " set socket linger failed: $!"; }, loggrep => { qr/connect sock: 127.0.0.1 \d+/ => 1, @@ -36,7 +36,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("tls logger .* connection error", 5) - or die "no connection error in syslogd.log"; + or die ref($self), " no connection error in syslogd.log"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-client-tls-tcp.pl b/regress/usr.sbin/syslogd/args-client-tls-tcp.pl index 3b28db4fa17..75c84ed107f 100644 --- a/regress/usr.sbin/syslogd/args-client-tls-tcp.pl +++ b/regress/usr.sbin/syslogd/args-client-tls-tcp.pl @@ -17,7 +17,7 @@ our %args = ( my $self = shift; print "Writing cleartext into a TLS connection is a bad idea\n"; ${$self->{syslogd}}->loggrep("tls logger .* connection error", 5) - or die "no connection error in syslogd.log"; + or die ref($self), " no connection error in syslogd.log"; }, loggrep => { qr/connect sock: 127.0.0.1 \d+/ => 1, @@ -34,7 +34,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("tls logger .* connection error", 5) - or die "no connection error in syslogd.log"; + or die ref($self), " no connection error in syslogd.log"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-selector-syslog.pl b/regress/usr.sbin/syslogd/args-selector-syslog.pl index 5d2169a97a1..7eb2e6092d6 100644 --- a/regress/usr.sbin/syslogd/args-selector-syslog.pl +++ b/regress/usr.sbin/syslogd/args-selector-syslog.pl @@ -43,7 +43,7 @@ our %args = ( IO::Handle::flush(\*STDOUT); ${$self->{syslogd}}->loggrep(get_testgrep(), 2); setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0)) - or die "set socket linger failed: $!"; + or die ref($self), " set socket linger failed: $!"; write_shutdown($self); } }, diff --git a/regress/usr.sbin/syslogd/args-sendsyslog-dropped.pl b/regress/usr.sbin/syslogd/args-sendsyslog-dropped.pl index e9806d74910..40291e2ac9a 100644 --- a/regress/usr.sbin/syslogd/args-sendsyslog-dropped.pl +++ b/regress/usr.sbin/syslogd/args-sendsyslog-dropped.pl @@ -19,7 +19,7 @@ our %args = ( func => sub { write_between2logs(shift, sub { my $self = shift; ${$self->{syslogd}}->loggrep(qr/syslogd: started/, 5) - or die "syslogd started not in syslogd.log"; + or die ref($self), " syslogd started not in syslogd.log"; })}, ktrace => { qr/CALL sendsyslog\(/ => '>=2', diff --git a/regress/usr.sbin/syslogd/args-server-tcp-close.pl b/regress/usr.sbin/syslogd/args-server-tcp-close.pl index 8f5ca5f9ec6..34bca243232 100644 --- a/regress/usr.sbin/syslogd/args-server-tcp-close.pl +++ b/regress/usr.sbin/syslogd/args-server-tcp-close.pl @@ -15,7 +15,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("loghost .* connection close", 5) - or die "no connection close in syslogd.log"; + or die ref($self), " no connection close in syslogd.log"; write_log($self); }, }, @@ -32,9 +32,9 @@ our %args = ( func => sub { my $self = shift; shutdown(\*STDOUT, 1) - or die "shutdown write failed: $!"; + or die ref($self), " shutdown write failed: $!"; ${$self->{syslogd}}->loggrep("loghost .* connection close", 5) - or die "no connection close in syslogd.log"; + or die ref($self), " no connection close in syslogd.log"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-server-tcp-error.pl b/regress/usr.sbin/syslogd/args-server-tcp-error.pl index 292f3cced80..4681c6876e7 100644 --- a/regress/usr.sbin/syslogd/args-server-tcp-error.pl +++ b/regress/usr.sbin/syslogd/args-server-tcp-error.pl @@ -19,7 +19,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("loghost .* connection error", 5) - or die "no connection error in syslogd.log"; + or die ref($self), " no connection error in syslogd.log"; write_log($self); }, }, @@ -36,7 +36,7 @@ our %args = ( func => sub { my $self = shift; setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0)) - or die "set socket linger failed: $!"; + or die ref($self), " set socket linger failed: $!"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-server-tcp-reconnect.pl b/regress/usr.sbin/syslogd/args-server-tcp-reconnect.pl index dc921b34e9f..8bcb711ea03 100644 --- a/regress/usr.sbin/syslogd/args-server-tcp-reconnect.pl +++ b/regress/usr.sbin/syslogd/args-server-tcp-reconnect.pl @@ -19,7 +19,7 @@ our %args = ( func => sub { write_between2logs(shift, sub { my $self = shift; ${$self->{syslogd}}->loggrep($errors, 5) - or die "no $errors in syslogd.log"; + or die ref($self), " no $errors in syslogd.log"; })}, }, syslogd => { @@ -36,9 +36,9 @@ our %args = ( my $self = shift; $self->close(); shutdown(\*STDOUT, 1) - or die "shutdown write failed: $!"; + or die ref($self), " shutdown write failed: $!"; ${$self->{syslogd}}->loggrep($errors, 5) - or die "no $errors in syslogd.log"; + or die ref($self), " no $errors in syslogd.log"; $self->listen(); })}, loggrep => { diff --git a/regress/usr.sbin/syslogd/args-server-tcp-sendback.pl b/regress/usr.sbin/syslogd/args-server-tcp-sendback.pl index b1bd834eaa9..fad00baa982 100644 --- a/regress/usr.sbin/syslogd/args-server-tcp-sendback.pl +++ b/regress/usr.sbin/syslogd/args-server-tcp-sendback.pl @@ -17,7 +17,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("loghost .* did send .* back", 5) - or die "no send back in syslogd.log"; + or die ref($self), " no send back in syslogd.log"; write_log($self); }, }, diff --git a/regress/usr.sbin/syslogd/args-server-tls-close.pl b/regress/usr.sbin/syslogd/args-server-tls-close.pl index 9873f68cc9c..eb62da860d7 100644 --- a/regress/usr.sbin/syslogd/args-server-tls-close.pl +++ b/regress/usr.sbin/syslogd/args-server-tls-close.pl @@ -15,7 +15,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("loghost .* connection close", 5) - or die "no connection close in syslogd.log"; + or die ref($self), " no connection close in syslogd.log"; write_log($self); }, }, @@ -32,9 +32,9 @@ our %args = ( func => sub { my $self = shift; shutdown(\*STDOUT, 1) - or die "shutdown write failed: $!"; + or die ref($self), " shutdown write failed: $!"; ${$self->{syslogd}}->loggrep("loghost .* connection close", 5) - or die "no connection close in syslogd.log"; + or die ref($self), " no connection close in syslogd.log"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-server-tls-error.pl b/regress/usr.sbin/syslogd/args-server-tls-error.pl index 9dc003084f1..4c9fe6ca9a8 100644 --- a/regress/usr.sbin/syslogd/args-server-tls-error.pl +++ b/regress/usr.sbin/syslogd/args-server-tls-error.pl @@ -19,7 +19,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("loghost .* connection error", 5) - or die "no connection error in syslogd.log"; + or die ref($self), " no connection error in syslogd.log"; write_log($self); }, }, @@ -36,7 +36,7 @@ our %args = ( func => sub { my $self = shift; setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0)) - or die "set socket linger failed: $!"; + or die ref($self), " set socket linger failed: $!"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-server-tls-reconnect.pl b/regress/usr.sbin/syslogd/args-server-tls-reconnect.pl index 4bbdf3e6b04..097501ac2fb 100644 --- a/regress/usr.sbin/syslogd/args-server-tls-reconnect.pl +++ b/regress/usr.sbin/syslogd/args-server-tls-reconnect.pl @@ -19,7 +19,7 @@ our %args = ( func => sub { write_between2logs(shift, sub { my $self = shift; ${$self->{syslogd}}->loggrep($errors, 5) - or die "no $errors in syslogd.log"; + or die ref($self), " no $errors in syslogd.log"; })}, }, syslogd => { @@ -38,9 +38,9 @@ our %args = ( my $self = shift; $self->close(); shutdown(\*STDOUT, 1) - or die "shutdown write failed: $!"; + or die ref($self), " shutdown write failed: $!"; ${$self->{syslogd}}->loggrep($errors, 5) - or die "no $errors in syslogd.log"; + or die ref($self), " no $errors in syslogd.log"; $self->listen(); })}, loggrep => { diff --git a/regress/usr.sbin/syslogd/args-server-tls-sendback.pl b/regress/usr.sbin/syslogd/args-server-tls-sendback.pl index 671651b5186..8f9d11843d4 100644 --- a/regress/usr.sbin/syslogd/args-server-tls-sendback.pl +++ b/regress/usr.sbin/syslogd/args-server-tls-sendback.pl @@ -17,7 +17,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("loghost .* did send .* back", 5) - or die "no send back in syslogd.log"; + or die ref($self), " no send back in syslogd.log"; write_log($self); }, }, diff --git a/regress/usr.sbin/syslogd/args-server-tls-tcp.pl b/regress/usr.sbin/syslogd/args-server-tls-tcp.pl index 95684318ce3..b7ff61f2b9b 100644 --- a/regress/usr.sbin/syslogd/args-server-tls-tcp.pl +++ b/regress/usr.sbin/syslogd/args-server-tls-tcp.pl @@ -15,7 +15,7 @@ our %args = ( func => sub { my $self = shift; ${$self->{syslogd}}->loggrep("loghost .* connection error", 5) - or die "no connection error in syslogd.log"; + or die ref($self), " no connection error in syslogd.log"; write_log($self); }, }, @@ -33,7 +33,7 @@ our %args = ( my $self = shift; print "Writing cleartext into a TLS connection is a bad idea\n"; ${$self->{syslogd}}->loggrep("loghost .* connection error", 5) - or die "no connection error in syslogd.log"; + or die ref($self), " no connection error in syslogd.log"; }, loggrep => {}, }, diff --git a/regress/usr.sbin/syslogd/args-sync-tcp.pl b/regress/usr.sbin/syslogd/args-sync-tcp.pl index aa5e638c62a..e3b11811268 100644 --- a/regress/usr.sbin/syslogd/args-sync-tcp.pl +++ b/regress/usr.sbin/syslogd/args-sync-tcp.pl @@ -51,7 +51,7 @@ our %args = ( ${$self->{syslogd}}->loggrep(get_thirdlog(), 30) or die ref($self), " syslogd did not receive third log"; shutdown(\*STDOUT, 1) - or die "shutdown write failed: $!"; + or die ref($self), " shutdown write failed: $!"; })}, loggrep => { qr/Accepted/ => 2, diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index 8bc47ec4b31..26a1dba3f87 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.34 2017/11/27 16:53:04 sthen Exp $ +# $OpenBSD: funcs.pl,v 1.35 2018/05/22 15:01:16 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org> # @@ -87,8 +87,8 @@ sub write_message { my $msg = join("", @_); if ($self->{connectdomain} eq "sendsyslog") { my $flags = $self->{connect}{flags} || 0; - sendsyslog($msg, $flags) or die ref($self), - " sendsyslog failed: $!"; + sendsyslog($msg, $flags) + or die ref($self), " sendsyslog failed: $!"; } elsif ($self->{connectproto} eq "udp") { # writing UDP packets works only with syswrite() defined(my $n = syswrite(STDOUT, $msg)) diff --git a/regress/usr.sbin/syslogd/syslogd.pl b/regress/usr.sbin/syslogd/syslogd.pl index 196d6d1690c..82333b33f1e 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.9 2016/05/03 19:13:04 bluhm Exp $ +# $OpenBSD: syslogd.pl,v 1.10 2018/05/22 15:01:16 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -100,7 +100,11 @@ $c = Client->new( ) unless $args{client}{noclient}; ($rc, $c) = ($c, $rc) if $rc; # chain client -> rsyslogd -> syslogd -$c->run->up if !$args{client}{noclient} && $c->{early}; +if (!$args{client}{noclient} && $c->{early}) { + $c->run->up; + $c->loggrep(get_firstlog(), 10) + or die ref($c), " no first log during early startup"; +} $r->run unless $r->{late}; $s->run->up unless $args{server}{noserver}; $r->run if $r->{late}; |