diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-08-20 20:52:15 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-08-20 20:52:15 +0000 |
commit | 1b4a57a4896c5679fa685859e91023ac9ae211cb (patch) | |
tree | c4b76deb6ea58cebb3a2e2c0a5cf6bfa8a212e14 /regress/usr.sbin/syslogd/Client.pm | |
parent | cccbc9159117fab4fadcfa53efe484ef47e4623f (diff) |
Run syslogd regressions tests. As only one syslogd can run per
machine, each test kills any syslogd first. At the end the system's
syslogd gets restarted.
The test framework runs a client, and a server, and a syslogd. The
messages are passed via the log socket or via UDP from the client
to syslogd. From there UDP transport is used to reach the server.
All processes write log files where the message has to show up.
The test arguments are kept in the args-*.pl files.
The content of a log file, the data sent to a pipe process and what
the server received are checked. The invocation of the sendsyslog(2)
syscall is checked with ktrace, the open file descriptors of syslogd
are checked with fstat.
Diffstat (limited to 'regress/usr.sbin/syslogd/Client.pm')
-rw-r--r-- | regress/usr.sbin/syslogd/Client.pm | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/regress/usr.sbin/syslogd/Client.pm b/regress/usr.sbin/syslogd/Client.pm new file mode 100644 index 00000000000..0de6e78ca4a --- /dev/null +++ b/regress/usr.sbin/syslogd/Client.pm @@ -0,0 +1,62 @@ +# $OpenBSD: Client.pm,v 1.1.1.1 2014/08/20 20:52:14 bluhm Exp $ + +# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use strict; +use warnings; + +package Client; +use parent 'Proc'; +use Carp; +use IO::Socket::INET6; +use Sys::Syslog qw(:standard :extended :macros); + +sub new { + my $class = shift; + my %args = @_; + $args{ktracefile} ||= "client.ktrace"; + $args{logfile} ||= "client.log"; + $args{up} ||= "Openlog"; + my $self = Proc::new($class, %args); + return $self; +} + +sub child { + my $self = shift; + + if ($self->{connectdomain}) { + my $cs = IO::Socket::INET6->new( + Proto => "udp", + Domain => $self->{connectdomain}, + PeerAddr => $self->{connectaddr}, + PeerPort => $self->{connectport}, + ) or die ref($self), " socket connect failed: $!"; + print STDERR "connect sock: ",$cs->sockhost()," ", + $cs->sockport(),"\n"; + print STDERR "connect peer: ",$cs->peerhost()," ", + $cs->peerport(),"\n"; + + *STDIN = *STDOUT = $self->{cs} = $cs; + } + + if ($self->{logsock}) { + setlogsock($self->{logsock}) + or die ref($self), " setlogsock failed: $!"; + } + # we take LOG_UUCP as it is not used nowadays + openlog("syslogd-regress", "ndelay,perror,pid", LOG_UUCP); +} + +1; |