# Test with default values, that is:
# The client writes a message to Sys::Syslog native method.
# The syslogd writes it into a file and through a pipe.
# The syslogd passes it via UDP to the loghost.
# The server receives the message on its UDP socket.
# Find the message in client, file, pipe, syslogd, server log.

use strict;
use warnings;
use Cwd;

my $foolog = getcwd()."/foo.log";
my $barlog = getcwd()."/bar.log";
my $foobarlog = getcwd()."/foobar.log";
{
    my $fh;
    open($fh, '>', $foolog) or die "Create $foolog failed: $!";
    open($fh, '>', $barlog) or die "Create $barlog failed: $!";
    open($fh, '>', $foobarlog) or die "Create $foobarlog failed: $!";
}

our %args = (
    syslogd => {
	conf => <<"EOF",
!!syslogd-regress
*.*	$foolog
!syslogd
*.*	$barlog
!*
*.*	$foobarlog
EOF
    },
);

1;

# Test with default values, that is:
# The client writes a message to Sys::Syslog native method.
# The syslogd writes it into a file and through a pipe.
# The syslogd passes it via UDP to the loghost.
# The server receives the message on its UDP socket.
# Find the message in client, file, pipe, syslogd, server log.

use strict;
use warnings;
use Cwd;

my %log;
@log{qw(foo bar foobar)} = ();
foreach my $name (keys %log) {
    $log{$name} = getcwd()."/$name.log";
    open(my $fh, '>', $log{$name})
	or die "Create $log{$name} failed: $!";
}

sub check_file {
    my ($name, $pattern) = @_;
    check_pattern($name, $log{$name}, $pattern, \&filegrep);
}

our %args = (
    syslogd => {
	conf => <<"EOF",
!!syslogd-regress
*.*	$log{foo}
!syslogd
*.*	$log{bar}
!*
*.*	$log{foobar}
EOF
    },
    check => sub {
	check_file("foo", { get_testlog() => 1, qr/syslogd: start/ => 0 });
	check_file("bar", { get_testlog() => 0, qr/syslogd: start/ => 1 });
	check_file("foobar", { get_testlog() => 0, qr/syslogd: start/ => 1 });
    },
);

1;

Check content of log files.
Check content of log files.
