xref: /openbsd-src/regress/usr.sbin/syslogd/args-sendsyslog-console.pl (revision cef95745f781f2824ebcaf02140768575e40cd52)
1# The client kills syslogd.
2# The client writes a message with sendsyslog LOG_CONS flag.
3# Find the message in console log.
4# Create a ktrace dump of the client and check for sendsyslog.
5# Check that no syslog priority or dropped message is logged to console.
6
7use strict;
8use warnings;
9use Errno ':POSIX';
10use Sys::Syslog 'LOG_CONS';
11
12my $errno = ENOTCONN;
13
14our %args = (
15    client => {
16	func => sub {
17	    my $self = shift;
18	    ${$self->{syslogd}}->kill_syslogd('TERM');
19	    ${$self->{syslogd}}->down();
20	    sendsyslog("<123>".get_testlog(), LOG_CONS)
21		and die ref($self), " sendsyslog succeeded";
22	    sendsyslog(get_testlog(), LOG_CONS)
23		and die ref($self), " sendsyslog succeeded";
24	    foreach (qw(< <1 <12 <123 <1234)) {
25		sendsyslog($_, LOG_CONS)
26		    and die ref($self), " sendsyslog succeeded";
27		sendsyslog("$_>", LOG_CONS)
28		    and die ref($self), " sendsyslog succeeded";
29		sendsyslog("$_>foo", LOG_CONS)
30		    and die ref($self), " sendsyslog succeeded";
31	    }
32	    write_shutdown($self);
33	},
34	ktrace => {
35	    qr/CALL  (\(via syscall\) )?sendsyslog\(/ => 18,
36	    qr/GIO   fd -1 wrote /.length(get_testlog()).qr/ bytes/ => 2,
37	    qr/RET   sendsyslog -1 errno $errno / => 18,
38	},
39	loggrep => {},
40    },
41    syslogd => {
42	conffile => "/dev/null",
43	loggrep => {},
44    },
45    server => { noserver => 1 },
46    file => { nocheck => 1 },
47    pipe => { nocheck => 1 },
48    user => { nocheck => 1 },
49    console => {
50	loggrep => {
51	    get_testgrep() => 2,
52	    qr/<\d+>/ => 0,
53	    qr/dropped \d+ message/ => 0,
54	},
55    },
56);
57
581;
59