1e24691dcSbluhm# The client writes 300 long messages to UDP socket. 2e24691dcSbluhm# The syslogd writes it into a file and through a pipe. 3e24691dcSbluhm# The syslogd does a TCP reconnect and passes it to loghost. 4e24691dcSbluhm# The server blocks the message on its TCP socket. 5e24691dcSbluhm# The server waits until the client has written all messages. 6e24691dcSbluhm# The server closes the TCP connection and accepts a new one. 7e24691dcSbluhm# The server receives the messages on its new accepted TCP socket. 8e24691dcSbluhm# This way the server receives a block of messages that is truncated 9e24691dcSbluhm# at the beginning and at the end. 10e24691dcSbluhm# Find the message in client, file, pipe, syslogd, server log. 11e24691dcSbluhm# Check that the server does not get lines that are cut in the middle. 12e24691dcSbluhm 13e24691dcSbluhmuse strict; 14e24691dcSbluhmuse warnings; 15e24691dcSbluhmuse Socket; 16e24691dcSbluhm 17e24691dcSbluhmour %args = ( 18e24691dcSbluhm client => { 19e24691dcSbluhm connect => { domain => AF_UNSPEC, addr => "localhost", port => 514 }, 20e24691dcSbluhm func => sub { write_between2logs(shift, sub { 21e24691dcSbluhm my $self = shift; 22e24691dcSbluhm write_message($self, get_secondlog()); 23*ac8221f6Sbluhm write_lines($self, 300, 2000); 24e24691dcSbluhm write_message($self, get_thirdlog()); 25e24691dcSbluhm ${$self->{server}}->loggrep("Accepted", 5, 2) 26e24691dcSbluhm or die ref($self), " server did not receive second log"; 27e24691dcSbluhm })}, 28e24691dcSbluhm }, 29e24691dcSbluhm syslogd => { 30e24691dcSbluhm options => ["-u"], 31e24691dcSbluhm loghost => '@tcp://127.0.0.1:$connectport', 32e24691dcSbluhm loggrep => { 33e24691dcSbluhm get_between2loggrep(), 34e24691dcSbluhm get_charlog() => 300, 35e24691dcSbluhm qr/dropped partial message/ => 1, 36e24691dcSbluhm }, 37e24691dcSbluhm }, 38e24691dcSbluhm server => { 39e24691dcSbluhm listen => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1" }, 40e24691dcSbluhm redo => 0, 41e24691dcSbluhm func => sub { read_between2logs(shift, sub { 42e24691dcSbluhm my $self = shift; 43e24691dcSbluhm if ($self->{redo}) { 44e24691dcSbluhm $self->{redo}--; 45e24691dcSbluhm return; 46e24691dcSbluhm } 47*ac8221f6Sbluhm ${$self->{syslogd}}->loggrep(get_thirdlog(), 40) 48268e7dafSbluhm or die ref($self), " syslogd did not receive third log"; 49e24691dcSbluhm shutdown(\*STDOUT, 1) 50e24691dcSbluhm or die "shutdown write failed: $!"; 51e24691dcSbluhm $self->{redo}++; 52e24691dcSbluhm })}, 53e24691dcSbluhm loggrep => { 54e24691dcSbluhm qr/Accepted/ => 2, 55e24691dcSbluhm get_between2loggrep(), 56e24691dcSbluhm get_secondlog() => 0, 57e24691dcSbluhm get_thirdlog() => 0, 58e24691dcSbluhm qr/>>> [0-9A-Za-z]{10}/ => 0, 59e24691dcSbluhm }, 60e24691dcSbluhm }, 61e24691dcSbluhm file => { 62e24691dcSbluhm loggrep => { 63e24691dcSbluhm get_between2loggrep(), 64e24691dcSbluhm get_secondlog() => 1, 65e24691dcSbluhm get_thirdlog() => 1, 66e24691dcSbluhm get_charlog() => 300, 67e24691dcSbluhm }, 68e24691dcSbluhm }, 69e24691dcSbluhm); 70e24691dcSbluhm 71e24691dcSbluhm1; 72