1# The syslogd listens on 127.0.0.1 TCP socket. 2# The client connects and aborts the connection to syslogd. 3# The syslogd writes the error into a file and through a pipe. 4# Find the message in file, syslogd log. 5# Check that syslogd writes a log message about the client error. 6 7use strict; 8use warnings; 9use Socket; 10use Errno ':POSIX'; 11 12my @errors = (ECONNRESET); 13my $errors = "(". join("|", map { $! = $_ } @errors). ")"; 14 15our %args = ( 16 client => { 17 connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1", 18 port => 514 }, 19 func => sub { 20 my $self = shift; 21 setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0)) 22 or die ref($self), " set socket linger failed: $!"; 23 ${$self->{syslogd}}->loggrep("tcp logger .* accept", 5) 24 or die ref($self), " no accept in syslogd.log"; 25 }, 26 loggrep => { 27 qr/connect sock: 127.0.0.1 \d+/ => 1, 28 }, 29 }, 30 syslogd => { 31 options => ["-T", "127.0.0.1:514"], 32 loggrep => { 33 qr/syslogd\[\d+\]: tcp logger .* accept/ => 1, 34 qr/syslogd\[\d+\]: tcp logger .* connection error/ => 1, 35 }, 36 }, 37 server => { 38 func => sub { 39 my $self = shift; 40 ${$self->{syslogd}}->loggrep("tcp logger .* connection error", 5) 41 or die ref($self), " no connection error in syslogd.log"; 42 }, 43 loggrep => {}, 44 }, 45 file => { 46 loggrep => { 47 qr/syslogd\[\d+\]: tcp logger .* connection error: $errors/ => 1, 48 }, 49 }, 50 pipe => { nocheck => 1 }, 51 tty => { nocheck => 1 }, 52); 53 541; 55