summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2016-06-22 19:29:31 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2016-06-22 19:29:31 +0000
commit49ddb8f173b41473982a40ca172be8c7881202d4 (patch)
tree8209a18bb8c49d875a7d8faadddbf129c8fea522
parent60d308a8e5d5a64d3d3dd5e333bc0ce934bd430b (diff)
Syslogd can send messages to a user, test what happens if the
terminal is blocking to receive messages. Stop the fake user terminal and look for a delayed write debug message from syslogd. This makes the test more reliable.
-rw-r--r--regress/usr.sbin/syslogd/Syslogd.pm22
-rw-r--r--regress/usr.sbin/syslogd/args-ttymsg-delay.pl9
2 files changed, 26 insertions, 5 deletions
diff --git a/regress/usr.sbin/syslogd/Syslogd.pm b/regress/usr.sbin/syslogd/Syslogd.pm
index 14be3488b76..fae55ed297f 100644
--- a/regress/usr.sbin/syslogd/Syslogd.pm
+++ b/regress/usr.sbin/syslogd/Syslogd.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Syslogd.pm,v 1.17 2015/12/30 13:15:52 bluhm Exp $
+# $OpenBSD: Syslogd.pm,v 1.18 2016/06/22 19:29:29 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
@@ -110,7 +110,7 @@ sub create_out {
my $user = $dev eq "console" ?
"/dev/console" : "syslogd-regress";
my @cmd = (@sudo, "./ttylog", $user, $file);
- open(my $ctl, '|-', @cmd)
+ $self->{"pid$dev"} = open(my $ctl, '|-', @cmd)
or die ref($self), " pipe to @cmd failed: $!";
# remember until object is destroyed, autoclose will send EOF
$self->{"ctl$dev"} = $ctl;
@@ -119,6 +119,24 @@ sub create_out {
return $self;
}
+sub ttykill {
+ my $self = shift;
+ my $dev = shift;
+ my $sig = shift;
+ my $pid = $self->{"pid$dev"}
+ or die ref($self), " no tty log pid$dev";
+
+ if (kill($sig => $pid) != 1) {
+ my $sudo = $ENV{SUDO};
+ $sudo && $!{EPERM}
+ or die ref($self), " kill $pid failed: $!";
+ my @cmd = ($sudo, '/bin/kill', "-$sig", $pid);
+ system(@cmd)
+ and die ref($self), " sudo kill $pid failed: $?";
+ }
+ return $self;
+}
+
sub child {
my $self = shift;
my @sudo = $ENV{SUDO} ? $ENV{SUDO} : ();
diff --git a/regress/usr.sbin/syslogd/args-ttymsg-delay.pl b/regress/usr.sbin/syslogd/args-ttymsg-delay.pl
index d16c2bef939..95e0364b7af 100644
--- a/regress/usr.sbin/syslogd/args-ttymsg-delay.pl
+++ b/regress/usr.sbin/syslogd/args-ttymsg-delay.pl
@@ -1,4 +1,4 @@
-# The client writes long messages to Sys::Syslog native method.
+# The client writes long messages while ttylog to user has been stopped.
# The syslogd writes it into a file and through a pipe and to tty.
# The syslogd passes it via UDP to the loghost.
# The server receives the message on its UDP socket.
@@ -13,7 +13,10 @@ our %args = (
client => {
func => sub {
my $self = shift;
- write_lines($self, 5, 900);
+ ${$self->{syslogd}}->ttykill("user", 'STOP');
+ write_lines($self, 9, 900);
+ ${$self->{syslogd}}->loggrep(qr/ttymsg delayed write/, 3);
+ ${$self->{syslogd}}->ttykill("user", 'CONT');
write_log($self);
},
},
@@ -24,7 +27,7 @@ our %args = (
},
user => {
loggrep => {
- qr/ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.* [12]$/ => 2,
+ qr/ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.* [12]/ => 2,
get_testgrep() => 1,
},
},