diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-09-02 00:26:31 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-09-02 00:26:31 +0000 |
commit | d31a63c2e89ebcec9fa967f81bc07c7fd837c2f8 (patch) | |
tree | 966fc3af3ef23708ddacc6a013acf3c0ae14033a /regress/usr.sbin/syslogd/funcs.pl | |
parent | cd715dc73ecad126f91ff303f1bf9953df6bdd7f (diff) |
Add tests that run the syslogd signal handlers.
Diffstat (limited to 'regress/usr.sbin/syslogd/funcs.pl')
-rw-r--r-- | regress/usr.sbin/syslogd/funcs.pl | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/regress/usr.sbin/syslogd/funcs.pl b/regress/usr.sbin/syslogd/funcs.pl index 55d3bfcd6b9..bc73c763237 100644 --- a/regress/usr.sbin/syslogd/funcs.pl +++ b/regress/usr.sbin/syslogd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.3 2014/08/29 21:57:17 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.4 2014/09/02 00:26:30 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -24,6 +24,7 @@ use Sys::Syslog qw(:standard :extended :macros); use IO::Socket; use IO::Socket::INET6; +my $firstlog = "syslogd regress test first message"; my $testlog = "syslogd regress test log message"; my $downlog = "syslogd regress client shutdown"; @@ -34,13 +35,29 @@ my $downlog = "syslogd regress client shutdown"; sub write_log { my $self = shift; + write_message($self, $testlog); + write_shutdown($self, @_); +} + +sub write_between2logs { + my $self = shift; + my $func = shift; + + write_message($self, $firstlog); + $func->($self, @_); + write_message($self, $testlog); + write_shutdown($self, @_); +} + +sub write_message { + my $self = shift; + if (defined($self->{connectdomain})) { - print $testlog; - print STDERR $testlog, "\n"; + print @_; + print STDERR @_, "\n"; } else { - syslog(LOG_INFO, $testlog); + syslog(LOG_INFO, @_); } - write_shutdown($self, @_); } sub write_shutdown { @@ -58,12 +75,31 @@ sub write_shutdown { sub read_log { my $self = shift; + read_message($self, $downlog, @_); +} + +sub read_between2logs { + my $self = shift; + my $func = shift; + + read_message($self, $firstlog, @_); + $func->($self, @_); + read_message($self, $testlog, @_); + read_message($self, $downlog, @_); +} + +sub read_message { + my $self = shift; + my $regex = shift; + + local $_; for (;;) { - defined(sysread(STDIN, my $line, 8194)) + # reading udp packets works only with sysread() + defined(sysread(STDIN, $_, 8194)) or die ref($self), " read log line failed: $!"; - chomp $line; - print STDERR ">>> $line\n"; - last if $line =~ /$downlog/; + chomp; + print STDERR ">>> $_\n"; + last if /$regex/; } } @@ -75,6 +111,13 @@ sub get_log { return $testlog; } +sub get_between2loggrep { + return ( + qr/$firstlog/ => 1, + qr/$testlog/ => 1, + ); +} + sub check_logs { my ($c, $r, $s, %args) = @_; |