18cd3cffcSbluhm# The client writes 300 messages to Sys::Syslog native method. 28cd3cffcSbluhm# The syslogd writes it into a file and through a pipe. 38cd3cffcSbluhm# The syslogd passes it via TCP to the loghost. 48cd3cffcSbluhm# The server blocks the message on its TCP socket. 58cd3cffcSbluhm# The server waits until the client as written all messages. 68cd3cffcSbluhm# The server sends a SIGHUP to syslogd and reads messages from kernel. 78cd3cffcSbluhm# The client waits until the server has read the first message. 88cd3cffcSbluhm# Find the message in client, file, pipe, syslogd, server log. 98cd3cffcSbluhm# Check that the 300 messages are in syslogd and file log. 108cd3cffcSbluhm# Check that the dropped message is in server and file log. 118cd3cffcSbluhm 128cd3cffcSbluhmuse strict; 138cd3cffcSbluhmuse warnings; 148cd3cffcSbluhmuse Socket; 158cd3cffcSbluhm 168cd3cffcSbluhmour %args = ( 178cd3cffcSbluhm client => { 188cd3cffcSbluhm func => sub { write_between2logs(shift, sub { 198cd3cffcSbluhm my $self = shift; 208cd3cffcSbluhm write_message($self, get_secondlog()); 21e24691dcSbluhm write_lines($self, 300, 1024); 228cd3cffcSbluhm write_message($self, get_thirdlog()); 238cd3cffcSbluhm ${$self->{server}}->loggrep(get_secondlog(), 8) 248cd3cffcSbluhm or die ref($self), " server did not receive second log"; 258cd3cffcSbluhm })}, 268cd3cffcSbluhm }, 278cd3cffcSbluhm syslogd => { 288cd3cffcSbluhm loghost => '@tcp://localhost:$connectport', 298cd3cffcSbluhm loggrep => { 308cd3cffcSbluhm get_between2loggrep(), 318cd3cffcSbluhm get_charlog() => 300, 328cd3cffcSbluhm }, 338cd3cffcSbluhm }, 348cd3cffcSbluhm server => { 358cd3cffcSbluhm listen => { domain => AF_UNSPEC, proto => "tcp", addr => "localhost" }, 3691c6fcb1Sbluhm rcvbuf => 2**12, 37be4712f2Sbluhm func => sub { accept_between2logs(shift, sub { 388cd3cffcSbluhm my $self = shift; 39268e7dafSbluhm ${$self->{syslogd}}->loggrep(get_thirdlog(), 20) 40268e7dafSbluhm or die ref($self), " syslogd did not receive third log"; 418cd3cffcSbluhm ${$self->{syslogd}}->kill_syslogd('HUP'); 428cd3cffcSbluhm ${$self->{syslogd}}->loggrep("syslogd: restarted", 5) 438cd3cffcSbluhm or die ref($self), " no 'syslogd: restarted' between logs"; 448cd3cffcSbluhm # syslogd has shut down, read from kernel socket buffer 458cd3cffcSbluhm read_log($self); 468cd3cffcSbluhm })}, 478cd3cffcSbluhm loggrep => { 488cd3cffcSbluhm get_between2loggrep(), 498cd3cffcSbluhm get_secondlog() => 1, 508cd3cffcSbluhm get_thirdlog() => 0, 518579df47Sbluhm qr/syslogd\[\d+\]: start/ => 1, 528579df47Sbluhm qr/syslogd\[\d+\]: restart/ => 1, 53*9b0f623aSbluhm get_charlog() => '~95', 54*9b0f623aSbluhm qr/syslogd\[\d+\]: dropped 2[0-2][0-9] messages to remote loghost/ 558579df47Sbluhm => 1, 568cd3cffcSbluhm }, 578cd3cffcSbluhm }, 588cd3cffcSbluhm file => { 598cd3cffcSbluhm loggrep => { 608cd3cffcSbluhm get_between2loggrep(), 618cd3cffcSbluhm get_secondlog() => 1, 628cd3cffcSbluhm get_thirdlog() => 1, 638579df47Sbluhm qr/syslogd\[\d+\]: start/ => 1, 648579df47Sbluhm qr/syslogd\[\d+\]: restart/ => 1, 658cd3cffcSbluhm get_charlog() => 300, 66*9b0f623aSbluhm qr/syslogd\[\d+\]: dropped 2[0-2][0-9] messages to remote loghost/ 678579df47Sbluhm => 1, 688cd3cffcSbluhm }, 698cd3cffcSbluhm }, 708cd3cffcSbluhm); 718cd3cffcSbluhm 728cd3cffcSbluhm1; 73