args-server-tcp-error.pl revision 1.2
1# The TCP server aborts the connection to syslogd. 2# The client writes a message to Sys::Syslog native method. 3# The syslogd writes it into a file and through a pipe. 4# The syslogd passes it via IPv4 TCP to an explicit loghost. 5# The server receives the message on its TCP socket. 6# Find the message in client, pipe, syslogd log. 7# Check that syslogd writes a log message about the server error. 8 9use strict; 10use warnings; 11use Socket; 12use Errno ':POSIX'; 13 14my @errors = (EPIPE,ECONNRESET); 15my $errors = "(". join("|", map { $! = $_ } @errors). ")"; 16 17our %args = ( 18 client => { 19 func => sub { 20 my $self = shift; 21 ${$self->{syslogd}}->loggrep("loghost .* connection error", 5) 22 or die "no connection error in syslogd.log"; 23 write_log($self, @_); 24 }, 25 }, 26 syslogd => { 27 loghost => '@tcp://127.0.0.1:$connectport', 28 loggrep => { 29 qr/Logging to FORWTCP \@tcp:\/\/127.0.0.1:\d+/ => '>=4', 30 get_testlog() => 1, 31 qr/syslogd: loghost .* connection error/ => 2, 32 }, 33 }, 34 server => { 35 listen => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1" }, 36 func => sub { 37 my $self = shift; 38 setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0)) 39 or die "set socket linger failed: $!"; 40 }, 41 loggrep => {}, 42 }, 43 file => { 44 loggrep => { 45 qr/syslogd: loghost .* connection error: $errors/ 46 => 1, 47 }, 48 }, 49); 50 511; 52