diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-02-11 21:51:14 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-02-11 21:51:14 +0000 |
commit | 71ab3aa426be878bac97f412c6c85e452a5fb9fd (patch) | |
tree | d915d2bb2c84e32121f641fe7aa3b91a6a13ea82 /regress/usr.sbin/syslogd | |
parent | 9b370c1f48bb430ca3516e17c24305a242ec7297 (diff) |
Make syslogd tests more reliable. Allow a range of certain log
messages, in case some got lost. Slow down client when sending
multiple log messages. Sort patterns when checking log files. TLS
error messages have changed, adapt tests.
Diffstat (limited to 'regress/usr.sbin/syslogd')
-rw-r--r-- | regress/usr.sbin/syslogd/args-dropped-sighup-tcp.pl | 6 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-dropped-sighup-tls.pl | 6 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-dropped-sigterm-tcp.pl | 4 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-dropped-sigterm-tls.pl | 4 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-length-tcp.pl | 7 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-length-tls.pl | 7 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-length-udp.pl | 7 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-length-unix.pl | 7 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-length-vis.pl | 8 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/args-tls-host-bad.pl | 2 | ||||
-rw-r--r-- | regress/usr.sbin/syslogd/funcs.pl | 29 |
11 files changed, 52 insertions, 35 deletions
diff --git a/regress/usr.sbin/syslogd/args-dropped-sighup-tcp.pl b/regress/usr.sbin/syslogd/args-dropped-sighup-tcp.pl index e533e1c86ec..16a7ad30888 100644 --- a/regress/usr.sbin/syslogd/args-dropped-sighup-tcp.pl +++ b/regress/usr.sbin/syslogd/args-dropped-sighup-tcp.pl @@ -29,7 +29,7 @@ our %args = ( loggrep => { get_between2loggrep(), get_charlog() => 300, - qr/ \(dropped\)/ => 14, + qr/ \(dropped\)/ => '~14', }, }, server => { @@ -57,7 +57,7 @@ our %args = ( qr/syslogd: start/ => 1, qr/syslogd: restart/ => 1, get_charlog() => 43, - qr/syslogd: dropped 259 messages to remote loghost/ => 1, + qr/syslogd: dropped 2[56][0-9] messages to remote loghost/ => 1, }, }, file => { @@ -68,7 +68,7 @@ our %args = ( qr/syslogd: start/ => 1, qr/syslogd: restart/ => 1, get_charlog() => 300, - qr/syslogd: dropped 259 messages to remote loghost/ => 1, + qr/syslogd: dropped 2[56][0-9] messages to remote loghost/ => 1, }, }, ); diff --git a/regress/usr.sbin/syslogd/args-dropped-sighup-tls.pl b/regress/usr.sbin/syslogd/args-dropped-sighup-tls.pl index d50ef1630dc..08e6e50998e 100644 --- a/regress/usr.sbin/syslogd/args-dropped-sighup-tls.pl +++ b/regress/usr.sbin/syslogd/args-dropped-sighup-tls.pl @@ -29,7 +29,7 @@ our %args = ( loggrep => { get_between2loggrep(), get_charlog() => 300, - qr/ \(dropped\)/ => 16, + qr/ \(dropped\)/ => '~16', }, }, server => { @@ -57,7 +57,7 @@ our %args = ( qr/syslogd: start/ => 1, qr/syslogd: restart/ => 1, get_charlog() => 41, - qr/syslogd: dropped 261 messages to remote loghost/ => 1, + qr/syslogd: dropped 2[56][0-9] messages to remote loghost/ => 1, }, }, file => { @@ -68,7 +68,7 @@ our %args = ( qr/syslogd: start/ => 1, qr/syslogd: restart/ => 1, get_charlog() => 300, - qr/syslogd: dropped 261 messages to remote loghost/ => 1, + qr/syslogd: dropped 2[56][0-9] messages to remote loghost/ => 1, }, }, ); diff --git a/regress/usr.sbin/syslogd/args-dropped-sigterm-tcp.pl b/regress/usr.sbin/syslogd/args-dropped-sigterm-tcp.pl index 7e8883de6c7..3bd107874cb 100644 --- a/regress/usr.sbin/syslogd/args-dropped-sigterm-tcp.pl +++ b/regress/usr.sbin/syslogd/args-dropped-sigterm-tcp.pl @@ -28,7 +28,7 @@ our %args = ( loghost => '@tcp://localhost:$connectport', loggrep => { get_charlog() => 300, - qr/ \(dropped\)/ => 17, + qr/ \(dropped\)/ => '~17', }, }, server => { @@ -64,7 +64,7 @@ our %args = ( get_testlog() => 0, qr/syslogd: start/ => 1, get_charlog() => 300, - qr/syslogd: dropped 260 messages to remote loghost/ => 1, + qr/syslogd: dropped 2[56][0-9] messages to remote loghost/ => 1, }, }, ); diff --git a/regress/usr.sbin/syslogd/args-dropped-sigterm-tls.pl b/regress/usr.sbin/syslogd/args-dropped-sigterm-tls.pl index b425f15341f..190cd7efb12 100644 --- a/regress/usr.sbin/syslogd/args-dropped-sigterm-tls.pl +++ b/regress/usr.sbin/syslogd/args-dropped-sigterm-tls.pl @@ -28,7 +28,7 @@ our %args = ( loghost => '@tls://localhost:$connectport', loggrep => { get_charlog() => 300, - qr/ \(dropped\)/ => 19, + qr/ \(dropped\)/ => '~19', }, }, server => { @@ -64,7 +64,7 @@ our %args = ( get_testlog() => 0, qr/syslogd: start/ => 1, get_charlog() => 300, - qr/syslogd: dropped 262 messages to remote loghost/ => 1, + qr/syslogd: dropped 2[56][0-9] messages to remote loghost/ => 1, }, }, ); diff --git a/regress/usr.sbin/syslogd/args-length-tcp.pl b/regress/usr.sbin/syslogd/args-length-tcp.pl index ef937ecf5b6..da83deb39b5 100644 --- a/regress/usr.sbin/syslogd/args-length-tcp.pl +++ b/regress/usr.sbin/syslogd/args-length-tcp.pl @@ -12,8 +12,11 @@ use Socket; our %args = ( client => { connect => { domain => AF_UNSPEC, addr => "localhost", port => 514 }, - func => \&write_length, - lengths => [ 8190..8193,9000 ], + func => sub { + my $self = shift; + write_lengths($self, 8190..8193,9000); + write_log($self); + }, }, syslogd => { loghost => '@tcp://localhost:$connectport', diff --git a/regress/usr.sbin/syslogd/args-length-tls.pl b/regress/usr.sbin/syslogd/args-length-tls.pl index 1ce9501e5c9..7da418cb155 100644 --- a/regress/usr.sbin/syslogd/args-length-tls.pl +++ b/regress/usr.sbin/syslogd/args-length-tls.pl @@ -12,8 +12,11 @@ use Socket; our %args = ( client => { connect => { domain => AF_UNSPEC, addr => "localhost", port => 514 }, - func => \&write_length, - lengths => [ 8190..8193,9000 ], + func => sub { + my $self = shift; + write_lengths($self, 8190..8193,9000); + write_log($self); + }, }, syslogd => { loghost => '@tls://localhost:$connectport', diff --git a/regress/usr.sbin/syslogd/args-length-udp.pl b/regress/usr.sbin/syslogd/args-length-udp.pl index ee5b8baad16..b757146ec86 100644 --- a/regress/usr.sbin/syslogd/args-length-udp.pl +++ b/regress/usr.sbin/syslogd/args-length-udp.pl @@ -13,8 +13,11 @@ use Socket; our %args = ( client => { connect => { domain => AF_UNSPEC, addr => "localhost", port => 514 }, - func => \&write_length, - lengths => [ 8190..8193,9000 ], + func => sub { + my $self = shift; + write_lengths($self, 8190..8193,9000); + write_log($self); + }, }, syslogd => { options => ["-u"], diff --git a/regress/usr.sbin/syslogd/args-length-unix.pl b/regress/usr.sbin/syslogd/args-length-unix.pl index 787157a30f3..e84e843c75c 100644 --- a/regress/usr.sbin/syslogd/args-length-unix.pl +++ b/regress/usr.sbin/syslogd/args-length-unix.pl @@ -12,8 +12,11 @@ use Socket; our %args = ( client => { connect => { domain => AF_UNIX }, - func => \&write_length, - lengths => [ 8190..8193,9000 ], + func => sub { + my $self = shift; + write_lengths($self, 8190..8193,9000); + write_log($self); + }, }, syslogd => { loggrep => { diff --git a/regress/usr.sbin/syslogd/args-length-vis.pl b/regress/usr.sbin/syslogd/args-length-vis.pl index c11bb0b2e18..e9104d66a45 100644 --- a/regress/usr.sbin/syslogd/args-length-vis.pl +++ b/regress/usr.sbin/syslogd/args-length-vis.pl @@ -12,9 +12,11 @@ use Socket; our %args = ( client => { connect => { domain => AF_UNSPEC, addr => "localhost", port => 514 }, - func => \&write_length, - lengths => [ 8186..8195,9000 ], - tail => "foo\200", + func => sub { + my $self = shift; + write_lengths($self, [8186..8195,9000], "foo\200"), + write_log($self); + }, }, syslogd => { options => ["-u"], diff --git a/regress/usr.sbin/syslogd/args-tls-host-bad.pl b/regress/usr.sbin/syslogd/args-tls-host-bad.pl index 36208172855..4d76e52bf68 100644 --- a/regress/usr.sbin/syslogd/args-tls-host-bad.pl +++ b/regress/usr.sbin/syslogd/args-tls-host-bad.pl @@ -15,7 +15,7 @@ our %args = ( loggrep => { qr/Logging to FORWTLS \@tls:\/\/127.0.0.1:\d+/ => '>=4', qr/syslogd: loghost .* connection error: /. - qr/host `127.0.0.1' not present in server/ => '>=1', + qr/name `127.0.0.1' not present in server/ => '>=1', get_testlog() => 1, }, cacrt => "ca.crt", diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index e5d62348c89..c71abfe33fa 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.16 2015/02/11 17:28:42 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.17 2015/02/11 21:51:13 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org> # @@ -111,17 +111,21 @@ sub write_lines { foreach (1..$lines) { write_chars($self, $lenght, " $_"); - # if client is sending too fast, syslogd will not see everything - sleep .01; } } +sub write_lengths { + my $self = shift; + my ($lenghts, $tail) = ref $_[0] ? @_ : [@_]; + + write_chars($self, $lenghts, $tail); +} + sub write_chars { my $self = shift; - my @lenghts = shift || @{$self->{lengths}}; - my $tail = shift // $self->{tail}; + my ($length, $tail) = @_; - foreach my $len (@lenghts) { + foreach my $len (ref $length ? @$length : $length) { my $t = $tail // ""; substr($t, 0, length($t) - $len, "") if length($t) && length($t) > $len; @@ -138,15 +142,11 @@ sub write_chars { } $msg .= $t if length($t); write_message($self, $msg); + # if client is sending too fast, syslogd will not see everything + sleep .01; } } -sub write_length { - my $self = shift; - write_chars($self, @_); - write_log($self); -} - sub write_unix { my $self = shift; my $path = shift || "/dev/log"; @@ -268,6 +268,8 @@ sub compare($$) { return $_[0] >= $1; } elsif (/^<=(\d+)/) { return $_[0] <= $1; + } elsif (/^~(\d+)/) { + return $1 * 0.9 <= $_[0] && $_[0] <= $1 * 1.1; } die "bad compare operator: $_"; } @@ -278,7 +280,8 @@ sub check_pattern { $pattern = [ $pattern ] unless ref($pattern) eq 'ARRAY'; foreach my $pat (@$pattern) { if (ref($pat) eq 'HASH') { - while (my($re, $num) = each %$pat) { + foreach my $re (sort keys %$pat) { + my $num = $pat->{$re}; my @matches = $func->($proc, $re); compare(@matches, $num) or die "$name matches '@matches': ", |