1# Run client before starting syslogd.
2# The client writes 101 messages to kernel log stash.
3# The client writes one message before and one after syslogd is started.
4# The kernel writes a sendsyslog(2) error message to the log socket.
5# Start syslogd, it reads the error and the second message from the log socket.
6# Find the kernel error message in file, syslogd, server log.
7# Check that the first message got lost.
8# Check that at least 80 messages were stashed in kernel.
9# Check that the 101th message was lost.
10
11use strict;
12use warnings;
13
14use constant LOGSTASH_SIZE => 100;
15
16our %args = (
17    client => {
18	early => 1,
19	func => sub {
20	    my $self = shift;
21	    write_message($self, "stash $_") foreach (0..LOGSTASH_SIZE);
22	    write_between2logs($self, sub {
23		my $self = shift;
24		${$self->{syslogd}}->loggrep(qr/syslogd: started/, 5)
25		    or die ref($self), " syslogd started not in syslogd.log";
26	})},
27    },
28    syslogd => {
29	loggrep => {
30	    qr/syslogd\[\d+\]: start/ => 1,
31	    get_firstlog() => 0,
32	    qr/syslogd-regress\[\d+\]: stash 0/ => 1,
33	    qr/syslogd-regress\[\d+\]: stash 80/ => 1,
34	    qr/syslogd-regress\[\d+\]: stash 100/ => 0,
35	    qr/sendsyslog: dropped \d+ messages?/ => 1,
36	    qr/syslogd\[\d+\]: running/ => 1,
37	    get_testgrep() => 1,
38	},
39    },
40    server => {
41	loggrep => {
42	    qr/syslogd\[\d+\]: start/ => 1,
43	    get_firstlog() => 0,
44	    qr/syslogd-regress\[\d+\]: stash 0/ => 1,
45	    qr/syslogd-regress\[\d+\]: stash 80/ => 1,
46	    qr/syslogd-regress\[\d+\]: stash 100/ => 0,
47	    qr/sendsyslog: dropped \d+ messages?/ => 1,
48	    qr/syslogd\[\d+\]: running/ => 1,
49	    get_testgrep() => 1,
50	},
51    },
52    file => {
53	loggrep => {
54	    qr/syslogd\[\d+\]: start/ => 1,
55	    get_firstlog() => 0,
56	    qr/syslogd-regress\[\d+\]: stash 0/ => 1,
57	    qr/syslogd-regress\[\d+\]: stash 80/ => 1,
58	    qr/syslogd-regress\[\d+\]: stash 100/ => 0,
59	    qr/sendsyslog: dropped \d+ messages?/ => 1,
60	    qr/syslogd\[\d+\]: running/ => 1,
61	    get_testgrep() => 1,
62	},
63    },
64);
65
661;
67