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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# The syslogd listens on 127.0.0.1 TCP socket.
# The client creates connections to syslogd TCP socket until it blocks.
# The client writes to all sockets and closes them.
# Wait until syslogd has slots to accept all sockets.
# Find the message in client, file, pipe, syslogd, server log.
# Check the messages end up in the log file.
use strict;
use warnings;
use IO::Socket::INET6;
our %args = (
client => {
connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1",
port => 514 },
func => sub {
my $self = shift;
local $| = 1;
my @s;
$s[0] = \*STDOUT;
# open additional connections until syslogd deferres
for (my $i = 1; $i <= 30; $i++) {
$s[$i] = IO::Socket::INET6->new(
Domain => AF_INET,
Proto => "tcp",
PeerAddr => "127.0.0.1",
PeerPort => 514,
) or die "id $i tcp socket connect failed: $!";
print STDERR "<<< id $i tcp connected\n";
${$self->{syslogd}}->loggrep("tcp logger .* accepted", 1, $i);
${$self->{syslogd}}->loggrep("accept deferred")
and last;
}
write_tcp($self, \*STDOUT, 0);
for (my $i = 1; $i < @s; $i++) {
my $fh = $s[$i];
write_tcp($self, $fh, $i);
# close connection so that others can be accepted
close($fh);
}
${$self->{syslogd}}->loggrep(qr/tcp logger .* use \d+ bytes/, 10,
scalar @s)
or die ref($self), " syslogd did not use connections";
write_shutdown($self);
},
},
syslogd => {
options => ["-T", "127.0.0.1:514"],
rlimit => {
RLIMIT_NOFILE => 30,
},
loggrep => {
qr/tcp logger .* accepted/ => '>=10',
qr/tcp logger .* use \d+ bytes/ => '>=10',
qr/tcp logger .* connection close/ => '>=10',
},
},
file => {
loggrep => {
get_testgrep() => '>=10',
},
},
);
1;
|