summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/syslogd/funcs.pl
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2015-02-11 21:51:14 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2015-02-11 21:51:14 +0000
commit71ab3aa426be878bac97f412c6c85e452a5fb9fd (patch)
treed915d2bb2c84e32121f641fe7aa3b91a6a13ea82 /regress/usr.sbin/syslogd/funcs.pl
parent9b370c1f48bb430ca3516e17c24305a242ec7297 (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/funcs.pl')
-rw-r--r--regress/usr.sbin/syslogd/funcs.pl29
1 files changed, 16 insertions, 13 deletions
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': ",