args-client-tls-error.pl revision 1.5
1# The syslogd listens on 127.0.0.1 TLS socket.
2# The client connects and aborts 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 error.
6
7use strict;
8use warnings;
9use Socket;
10use Errno ':POSIX';
11
12my @errors = (ECONNRESET);
13my $errors = "(". join("|", map { $! = $_ } @errors). ")";
14
15our %args = (
16    client => {
17	connect => { domain => AF_INET, proto => "tls", addr => "127.0.0.1",
18	    port => 6514 },
19	func => sub {
20	    my $self = shift;
21	    setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0))
22		or die ref($self), " set socket linger failed: $!";
23	},
24	loggrep => {
25	    qr/connect sock: 127.0.0.1 \d+/ => 1,
26	},
27    },
28    syslogd => {
29	options => ["-S", "127.0.0.1:6514"],
30	loggrep => {
31	    qr/syslogd\[\d+\]: tls logger .* accept/ => 1,
32	    qr/syslogd\[\d+\]: tls logger .* connection error/ => 1,
33	},
34    },
35    server => {
36	func => sub {
37	    my $self = shift;
38	    ${$self->{syslogd}}->loggrep("tls logger .* connection error", 5)
39		or die ref($self), " no connection error in syslogd.log";
40	},
41	loggrep => {},
42    },
43    file => {
44	loggrep => {
45	    qr/syslogd\[\d+\]: tls logger .* connection error: /.
46		qr/read failed: .*$errors/ => 1,
47	},
48    },
49    pipe => { nocheck => 1, },
50    tty => { nocheck => 1, },
51);
52
531;
54