1# The syslogd listens on 127.0.0.1 TLS socket.
2# The client connects and closes the connection to syslogd.
3# The syslogd writes the error into a file and through a pipe.
4# Find the message in file, syslogd log.
5# Check that syslogd writes a log message about the client close.
6
7use strict;
8use warnings;
9use Socket;
10
11our %args = (
12    client => {
13	connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1",
14	    port => 514 },
15	func => sub {
16	    my $self = shift;
17	    shutdown(\*STDOUT, 1)
18		or die ref($self), " shutdown write failed: $!";
19	    ${$self->{syslogd}}->loggrep("tcp logger .* connection close", 5)
20		or die ref($self), " no connection close in syslogd.log";
21	},
22	loggrep => {
23	    qr/connect sock: 127.0.0.1 \d+/ => 1,
24	},
25    },
26    syslogd => {
27	options => ["-T", "127.0.0.1:514"],
28	loggrep => {
29	    qr/syslogd\[\d+\]: tcp logger .* accepted/ => 1,
30	    qr/syslogd\[\d+\]: tcp logger .* connection close/ => 1,
31	}
32    },
33    server => {
34	func => sub {
35	    my $self = shift;
36	    ${$self->{syslogd}}->loggrep("tcp logger .* connection close", 5)
37		or die ref($self), " no connection close in syslogd.log";
38	},
39	loggrep => {},
40    },
41    file => {
42	loggrep => {
43	    qr/syslogd\[\d+\]: tcp logger .* connection close/ => 1,
44	},
45    },
46    pipe => { nocheck => 1 },
47    tty => { nocheck => 1 },
48);
49
501;
51