xref: /openbsd-src/regress/usr.sbin/syslogd/args-maxunix.pl (revision bb7ea376b3b95bf0e689c799c1e5c542e041bf34)
1fa51160fSbluhm# The client writes messages to MAXUNIX unix domain sockets.
2fa51160fSbluhm# The syslogd -a writes them into a file and through a pipe.
3fa51160fSbluhm# The syslogd -a passes them via UDP to the loghost.
4fa51160fSbluhm# The server receives the messages on its UDP socket.
5fa51160fSbluhm# Find the message in client, file, pipe, syslogd, server log.
6ac8221f6Sbluhm# Check that the file log contains a message from every socket.
7ac8221f6Sbluhm# Check that no error is printed.
8fa51160fSbluhm
9fa51160fSbluhmuse strict;
10fa51160fSbluhmuse warnings;
11*bb7ea376Sbluhmuse Sys::Hostname;
12fa51160fSbluhmuse IO::Socket::UNIX;
13fa51160fSbluhmuse constant MAXUNIX => 21;
14fa51160fSbluhm
15*bb7ea376Sbluhm(my $host = hostname()) =~ s/\..*//;
16*bb7ea376Sbluhm
17fa51160fSbluhmour %args = (
18fa51160fSbluhm    client => {
19fa51160fSbluhm	func => sub {
20fa51160fSbluhm	    my $self = shift;
21*bb7ea376Sbluhm	    write_unix($self, "/dev/log");
22fa51160fSbluhm	    foreach (1..(MAXUNIX-1)) {
23*bb7ea376Sbluhm		write_unix($self, "unix-$_.sock", $_);
24fa51160fSbluhm	    }
25*bb7ea376Sbluhm	    ${$self->{syslogd}}->loggrep(get_testgrep(), 5, MAXUNIX)
269f5e6548Sbluhm		or die ref($self), " syslogd did not receive complete line";
278cd3cffcSbluhm	    write_shutdown($self);
28fa51160fSbluhm	},
29fa51160fSbluhm    },
30fa51160fSbluhm    syslogd => {
31ac8221f6Sbluhm	options => [ map { ("-a" => "unix-$_.sock") } (1..(MAXUNIX-1)) ],
32fa51160fSbluhm	loggrep => {
33ac8221f6Sbluhm	    qr/out of descriptors/ => 0,
34fa51160fSbluhm	},
35fa51160fSbluhm    },
36fa51160fSbluhm    file => {
37fa51160fSbluhm	loggrep => {
38*bb7ea376Sbluhm	    qr/ $host .* unix socket: /.get_testgrep() => MAXUNIX,
39*bb7ea376Sbluhm	    "/dev/log unix socket" => 1,
40*bb7ea376Sbluhm	    (map { " $_ unix socket: ".get_testgrep() => 1 } 1..MAXUNIX-1),
41*bb7ea376Sbluhm	    MAXUNIX." unix socket: ".get_testgrep() => 0,
427fb7f4f4Sbluhm	},
43fa51160fSbluhm    },
44fa51160fSbluhm);
45fa51160fSbluhm
46fa51160fSbluhm1;
47