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 "set socket linger failed: $!"; 23 }, 24 loggrep => { 25 qr/connect sock: 127.0.0.1 \d+/ => 1, 26 }, 27 }, 28 syslogd => { 29 options => ["-T", "127.0.0.1:514"], 30 loggrep => { 31 qr/syslogd: tcp logger .* accept/ => 1, 32 qr/syslogd: tcp logger .* connection error/ => 1, 33 }, 34 }, 35 server => { 36 func => sub { 37 my $self = shift; 38 ${$self->{syslogd}}->loggrep("tcp logger .* connection error", 5) 39 or die "no connection error in syslogd.log"; 40 }, 41 loggrep => {}, 42 }, 43 file => { 44 loggrep => { 45 qr/syslogd: tcp logger .* connection error: $errors/ => 1, 46 }, 47 }, 48 pipe => { nocheck => 1 }, 49 tty => { nocheck => 1 }, 50); 51 521; 53