1# The syslogd listens on 127.0.0.1 TCP socket.
2# The client writes long line into a 127.0.0.1 TCP socket.
3# The syslogd writes it into a file and through a pipe.
4# The syslogd passes it via UDP to the loghost.
5# The server receives the message on its UDP socket.
6# Find the message in client, file, syslogd, server log.
7# Check that the file log contains the truncated message.
8
9use strict;
10use warnings;
11use Socket;
12use constant MAXLINE => 8192;
13use constant MAX_UDPMSG => 1180;
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	    local $| = 1;
22	    my $msg = generate_chars(5+1+MAXLINE+1);
23	    print $msg;
24	    print STDERR "<<< $msg\n";
25	    ${$self->{syslogd}}->loggrep("tcp logger .* incomplete", 5, 1)
26		or die ref($self), " syslogd did not receive 1 incomplete";
27	    $msg = generate_chars(5+1+MAXLINE);
28	    print $msg;
29	    print STDERR "<<< $msg\n";
30	    ${$self->{syslogd}}->loggrep("tcp logger .* incomplete", 5, 2)
31		or die ref($self), " syslogd did not receive 2 incomplete";
32	    print "\n";
33	    print STDERR "<<< \n";
34	    write_shutdown($self);
35	},
36	loggrep => {
37	    qr/<<< 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ/ => 2,
38	},
39    },
40    syslogd => {
41	options => ["-T", "127.0.0.1:514"],
42	loggrep => {
43	    qr/incomplete frame, use /.(MAXLINE+7).qr/ bytes/ => 1,
44	    qr/non transparent framing, use /.(MAXLINE+7).qr/ bytes/ => 1,
45	}
46    },
47    server => {
48	# >>> <13>Jul  6 22:33:32 0123456789ABC...fgh
49	loggrep => {
50	    qr/>>> .{19} /.generate_chars(MAX_UDPMSG-20).qr/$/ => 2,
51	},
52    },
53    file => {
54	loggrep => {
55	    generate_chars(MAXLINE).qr/$/ => 2,
56	},
57    },
58    pipe => { nocheck => 1 },  # XXX syslogd ignore short writes to pipe
59    tty => { nocheck => 1 },
60);
61
621;
63