From: bluhm Date: Fri, 7 Apr 2017 15:49:46 +0000 (+0000) Subject: Adapt test to new syslogd's local message priority. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2722e17aea56910ef407203cee9eef53c6c35a63;p=openbsd Adapt test to new syslogd's local message priority. --- diff --git a/regress/usr.sbin/syslogd/args-selector-syslog.pl b/regress/usr.sbin/syslogd/args-selector-syslog.pl index e9808ffd13d..303361e78f0 100644 --- a/regress/usr.sbin/syslogd/args-selector-syslog.pl +++ b/regress/usr.sbin/syslogd/args-selector-syslog.pl @@ -11,10 +11,12 @@ use warnings; use Sys::Syslog; my %selector2messages = ( - "syslog.*" => [qw{ start .*accepted .*close exiting.* }], - "syslog.debug" => [qw{ start .*accepted .*close exiting.* }], - "syslog.info" => [qw{ start .*accepted .*close exiting.* }], - "syslog.notice" => [qw{ exiting.* }], + "syslog.*" => + [qw{ start .*accepted .*close .*accepted .*peer exiting.* }], + "syslog.debug" => + [qw{ start .*accepted .*close .*accepted .*peer exiting.* }], + "syslog.info" => [qw{ start .*peer exiting.* }], + "syslog.notice" => [qw{ .*peer exiting.* }], "syslog.warning" => [qw{ exiting.* }], "syslog.err" => [qw{ exiting.* }], "syslog.crit" => [], @@ -25,7 +27,25 @@ my %selector2messages = ( our %args = ( client => { - logsock => { type => "tcp", host => "127.0.0.1", port => 514 }, + connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1", + port => 514 }, + redo => 2, + func => sub { + my $self = shift; + $self->{redo}--; + if ($self->{redo}) { + write_message($self, get_testlog()); + IO::Handle::flush(\*STDOUT); + ${$self->{syslogd}}->loggrep(get_testgrep(), 2); + } else { + write_message($self, get_testlog()); + 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: $!"; + write_shutdown($self); + } + }, }, syslogd => { options => ["-T", "127.0.0.1:514"], diff --git a/regress/usr.sbin/syslogd/args-sighup-config.pl b/regress/usr.sbin/syslogd/args-sighup-config.pl index 597b1b17574..cdf23e8fb60 100644 --- a/regress/usr.sbin/syslogd/args-sighup-config.pl +++ b/regress/usr.sbin/syslogd/args-sighup-config.pl @@ -44,6 +44,13 @@ our %args = ( })}, loggrep => { get_between2loggrep() }, }, + file => { + loggrep => { + qr/syslogd\[\d+\]: start/ => 2, + qr/syslogd\[\d+\]: restart/ => 0, + qr/syslogd\[\d+\]: exiting/ => 1, + }, + }, ); 1; diff --git a/regress/usr.sbin/syslogd/args-sighup.pl b/regress/usr.sbin/syslogd/args-sighup.pl index 4912af12fc5..ebf2df68d96 100644 --- a/regress/usr.sbin/syslogd/args-sighup.pl +++ b/regress/usr.sbin/syslogd/args-sighup.pl @@ -54,6 +54,13 @@ our %args = ( check_pattern($name, $file, $pattern, \&filegrep); } }, + file => { + loggrep => { + qr/syslogd\[\d+\]: start/ => 0, + qr/syslogd\[\d+\]: restart/ => 1, + qr/syslogd\[\d+\]: exiting/ => 1, + }, + }, ); 1; diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index e9fd6923526..e296b3ebcb9 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.31 2017/04/06 16:56:44 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.32 2017/04/07 15:49:46 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm # @@ -297,11 +297,11 @@ sub selector2loggrep { foreach my $sel (sort keys %s2m) { my @m = @{$s2m{$sel}}; my %msg; - @msg{@m} = (); + $msg{$_}++ foreach (@m); my %nomsg = %allmsg; delete @nomsg{@m}; push @loggrep, { - (map { qr/: $_$/ => 1 } sort keys %msg), + (map { qr/: $_$/ => $msg{$_} } sort keys %msg), (map { qr/: $_$/ => 0 } sort keys %nomsg), }; }