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 error 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 => "tls", addr => "127.0.0.1",
14	    port => 6514 },
15	func => sub {
16	    my $self = shift;
17	    delete $self->{ts};
18	    shutdown(\*STDOUT, 1)
19		or die ref($self), " shutdown write failed: $!";
20	    ${$self->{syslogd}}->loggrep("tls logger .* connection close", 5)
21		or die ref($self), " no connection close in syslogd.log";
22	},
23	loggrep => {
24	    qr/connect sock: 127.0.0.1 \d+/ => 1,
25	},
26    },
27    syslogd => {
28	options => ["-S", "127.0.0.1:6514"],
29	loggrep => {
30	    qr/syslogd\[\d+\]: tls logger .* accepted/ => 1,
31	    qr/syslogd\[\d+\]: tls logger .* connection close/ => 1,
32	},
33    },
34    server => {
35	func => sub {
36	    my $self = shift;
37	    ${$self->{syslogd}}->loggrep("tls logger .* connection close", 5)
38		or die ref($self), " no connection close in syslogd.log";
39	},
40	loggrep => {},
41    },
42    file => {
43	loggrep => {
44	    qr/syslogd\[\d+\]: tls logger .* connection close/ => 1,
45	},
46    },
47    pipe => { nocheck => 1 },
48    tty => { nocheck => 1 },
49);
50
511;
52