From 122de3fd3ac87a9458c3b8d654741de6ad078280 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Sun, 21 Aug 2011 22:51:01 +0000 Subject: Add one more regression test for socket splicing with idle timeout. --- regress/sys/kern/splice/args-idle-timeout.pl | 18 ++++++++++++++++++ regress/sys/kern/splice/args-idle-trickle.pl | 18 ++++++++++++++++++ regress/sys/kern/splice/args-idle.pl | 17 ----------------- regress/sys/kern/splice/echo.pl | 4 ++-- regress/sys/kern/splice/funcs.pl | 7 ++++++- regress/sys/kern/splice/relay.pl | 4 ++-- regress/sys/kern/splice/remote.pl | 4 ++-- 7 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 regress/sys/kern/splice/args-idle-timeout.pl create mode 100644 regress/sys/kern/splice/args-idle-trickle.pl delete mode 100644 regress/sys/kern/splice/args-idle.pl diff --git a/regress/sys/kern/splice/args-idle-timeout.pl b/regress/sys/kern/splice/args-idle-timeout.pl new file mode 100644 index 00000000000..17f05a38f7b --- /dev/null +++ b/regress/sys/kern/splice/args-idle-timeout.pl @@ -0,0 +1,18 @@ +# test idle timeout + +use strict; +use warnings; + +our %args = ( + client => { + func => sub { sleep 1; write_char(@_); sleep 3; }, + }, + relay => { + idle => 2, + timeout => 1, + }, + len => 251, + md5 => "bc3a3f39af35fe5b1687903da2b00c7f", +); + +1; diff --git a/regress/sys/kern/splice/args-idle-trickle.pl b/regress/sys/kern/splice/args-idle-trickle.pl new file mode 100644 index 00000000000..d86c9e56175 --- /dev/null +++ b/regress/sys/kern/splice/args-idle-trickle.pl @@ -0,0 +1,18 @@ +# test non idle connection does not timeout by sending a byte every second + +use strict; +use warnings; + +our %args = ( + client => { + len => 6, + sleep => 1, + }, + relay => { + idle => 2, + }, + len => 6, + md5 => "857f2261690a2305dba03062e778a73b", +); + +1; diff --git a/regress/sys/kern/splice/args-idle.pl b/regress/sys/kern/splice/args-idle.pl deleted file mode 100644 index 7045249ce85..00000000000 --- a/regress/sys/kern/splice/args-idle.pl +++ /dev/null @@ -1,17 +0,0 @@ -# test idle timeout - -use strict; -use warnings; - -our %args = ( - client => { - func => sub { sleep 1; write_char(@_); sleep 3; }, - }, - relay => { - idle => 2, - }, - len => 251, - md5 => "bc3a3f39af35fe5b1687903da2b00c7f", -); - -1; diff --git a/regress/sys/kern/splice/echo.pl b/regress/sys/kern/splice/echo.pl index 45c8cd7da86..f46cad6312c 100755 --- a/regress/sys/kern/splice/echo.pl +++ b/regress/sys/kern/splice/echo.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: echo.pl,v 1.4 2011/07/23 23:56:08 bluhm Exp $ +# $OpenBSD: echo.pl,v 1.5 2011/08/21 22:50:59 bluhm Exp $ # Copyright (c) 2010 Alexander Bluhm # @@ -83,7 +83,7 @@ $s->{pid} = -1; # XXX hack exit if $args{nocheck}; $r->loggrep(qr/^Timeout$/) or die "no relay timeout" - if $args{relay}{idle}; + if $args{relay}{timeout}; $r->loggrep(qr/^Max$/) or die "no relay max" if $args{relay}{max} && $args{len}; diff --git a/regress/sys/kern/splice/funcs.pl b/regress/sys/kern/splice/funcs.pl index d0342fd8f6f..88501e177ae 100644 --- a/regress/sys/kern/splice/funcs.pl +++ b/regress/sys/kern/splice/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.6 2011/07/04 05:43:02 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.7 2011/08/21 22:50:59 bluhm Exp $ # Copyright (c) 2010,2011 Alexander Bluhm # @@ -31,6 +31,7 @@ use BSD::Socket::Splice qw(setsplice getsplice geterror); sub write_char { my $self = shift; my $len = shift // $self->{len} // 251; + my $sleep = $self->{sleep}; my $ctx = Digest::MD5->new(); my $char = '0'; @@ -45,6 +46,10 @@ sub write_char { when(/\n/) { print STDERR "."; $char = '0' } default { $char++ } } + if ($self->{sleep}) { + IO::Handle::flush(\*STDOUT); + sleep $self->{sleep}; + } } if ($len) { $char = "\n"; diff --git a/regress/sys/kern/splice/relay.pl b/regress/sys/kern/splice/relay.pl index cd2fe35f1fb..c7e82e4c067 100755 --- a/regress/sys/kern/splice/relay.pl +++ b/regress/sys/kern/splice/relay.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: relay.pl,v 1.4 2011/07/23 23:56:08 bluhm Exp $ +# $OpenBSD: relay.pl,v 1.5 2011/08/21 22:51:00 bluhm Exp $ # Copyright (c) 2010 Alexander Bluhm # @@ -77,7 +77,7 @@ $s->down; exit if $args{nocheck}; $r->loggrep(qr/^Timeout$/) or die "no relay timeout" - if $args{relay}{idle}; + if $args{relay}{timeout}; $r->loggrep(qr/^Max$/) or die "no relay max" if $args{relay}{max} && $args{len}; diff --git a/regress/sys/kern/splice/remote.pl b/regress/sys/kern/splice/remote.pl index 446774865d5..d3f3cc04d9c 100755 --- a/regress/sys/kern/splice/remote.pl +++ b/regress/sys/kern/splice/remote.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: remote.pl,v 1.4 2011/07/23 23:56:08 bluhm Exp $ +# $OpenBSD: remote.pl,v 1.5 2011/08/21 22:51:00 bluhm Exp $ # Copyright (c) 2010 Alexander Bluhm # @@ -129,7 +129,7 @@ $s->down; exit if $args{nocheck}; $r->loggrep(qr/^Timeout$/) or die "no relay timeout" - if $args{relay}{idle}; + if $args{relay}{timeout}; $r->loggrep(qr/^Max$/) or die "no relay max" if $args{relay}{max} && $args{len}; -- cgit v1.2.3