1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# The syslogd listens on 127.0.0.1 TCP socket.
# The client writes three lines into a 127.0.0.1 TCP socket in a single chunk.
# 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 file, pipe, syslogd, server log.
# Check that the file log contains all messages.
use strict;
use warnings;
use Socket;
my %threegrep = (
get_firstlog() => 1,
get_secondlog() => 1,
get_thirdlog() => 1,
);
our %args = (
client => {
connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1",
port => 514 },
func => sub {
my $self = shift;
my $msg = get_firstlog()."\n".get_secondlog()."\n".get_thirdlog();
write_message($self, $msg);
${$self->{syslogd}}->loggrep(get_thirdlog(), 5)
or die ref($self), " syslogd did not receive third log";
write_shutdown($self);
},
loggrep => {},
},
syslogd => {
options => ["-T", "127.0.0.1:514"],
loggrep => {
%threegrep,
qr/tcp logger .* non transparent framing, use \d+ bytes/ => 3,
},
},
server => { loggrep => \%threegrep },
file => { loggrep => \%threegrep },
pipe => { loggrep => \%threegrep },
tty => { loggrep => \%threegrep },
);
1;
|