129e70a6fSbluhm# The client kills syslogd.
28a6a3d0fSbluhm# The client writes a message with sendsyslog LOG_CONS flag.
329e70a6fSbluhm# Find the message in console log.
48a6a3d0fSbluhm# Create a ktrace dump of the client and check for sendsyslog.
5312cb899Sbluhm# Check that no syslog priority or dropped message is logged to console.
629e70a6fSbluhm
729e70a6fSbluhmuse strict;
829e70a6fSbluhmuse warnings;
929e70a6fSbluhmuse Errno ':POSIX';
1029e70a6fSbluhmuse Sys::Syslog 'LOG_CONS';
1129e70a6fSbluhm
1229e70a6fSbluhmmy $errno = ENOTCONN;
1329e70a6fSbluhm
1429e70a6fSbluhmour %args = (
1529e70a6fSbluhm    client => {
1629e70a6fSbluhm	func => sub {
1729e70a6fSbluhm	    my $self = shift;
1829e70a6fSbluhm	    ${$self->{syslogd}}->kill_syslogd('TERM');
1929e70a6fSbluhm	    ${$self->{syslogd}}->down();
208a6a3d0fSbluhm	    sendsyslog("<123>".get_testlog(), LOG_CONS)
218a6a3d0fSbluhm		and die ref($self), " sendsyslog succeeded";
228a6a3d0fSbluhm	    sendsyslog(get_testlog(), LOG_CONS)
238a6a3d0fSbluhm		and die ref($self), " sendsyslog succeeded";
24312cb899Sbluhm	    foreach (qw(< <1 <12 <123 <1234)) {
258a6a3d0fSbluhm		sendsyslog($_, LOG_CONS)
268a6a3d0fSbluhm		    and die ref($self), " sendsyslog succeeded";
278a6a3d0fSbluhm		sendsyslog("$_>", LOG_CONS)
288a6a3d0fSbluhm		    and die ref($self), " sendsyslog succeeded";
298a6a3d0fSbluhm		sendsyslog("$_>foo", LOG_CONS)
308a6a3d0fSbluhm		    and die ref($self), " sendsyslog succeeded";
31312cb899Sbluhm	    }
32312cb899Sbluhm	    write_shutdown($self);
3329e70a6fSbluhm	},
3429e70a6fSbluhm	ktrace => {
35*cef95745Santon	    qr/CALL  (\(via syscall\) )?sendsyslog\(/ => 18,
36312cb899Sbluhm	    qr/GIO   fd -1 wrote /.length(get_testlog()).qr/ bytes/ => 2,
378a6a3d0fSbluhm	    qr/RET   sendsyslog -1 errno $errno / => 18,
3829e70a6fSbluhm	},
3929e70a6fSbluhm	loggrep => {},
4029e70a6fSbluhm    },
41312cb899Sbluhm    syslogd => {
42312cb899Sbluhm	conffile => "/dev/null",
43312cb899Sbluhm	loggrep => {},
44312cb899Sbluhm    },
4529e70a6fSbluhm    server => { noserver => 1 },
4629e70a6fSbluhm    file => { nocheck => 1 },
4729e70a6fSbluhm    pipe => { nocheck => 1 },
4829e70a6fSbluhm    user => { nocheck => 1 },
49312cb899Sbluhm    console => {
50312cb899Sbluhm	loggrep => {
51312cb899Sbluhm	    get_testgrep() => 2,
52312cb899Sbluhm	    qr/<\d+>/ => 0,
53312cb899Sbluhm	    qr/dropped \d+ message/ => 0,
54312cb899Sbluhm	},
55312cb899Sbluhm    },
5629e70a6fSbluhm);
5729e70a6fSbluhm
5829e70a6fSbluhm1;
59