summaryrefslogtreecommitdiff
path: root/regress/sys/kern/sosplice/tcp/args-relay-read-forked.pl
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2013-01-03 17:36:40 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2013-01-03 17:36:40 +0000
commit439f9b4a840f88141347e1dd7e9ee5bb43589307 (patch)
treec32594a76889878a276c61c8eed78bd82c6f05ac /regress/sys/kern/sosplice/tcp/args-relay-read-forked.pl
parent2ce7bb12a1f7d2fbfd4f40267a189c00bef845a0 (diff)
Reengineer the socket splicing regression tests:
- Move the tests from splice to new sosplice directory for consistent naming. - Split the API tests and the TCP splicing tests into separate directories. - Create some tests for the upcoming UDP splicing. - Tests can be run in obj directories now. - The API tests can run both on a local and on a remote machine now. - Fix the forking TCP tests which splice and read or write simultaneously. - Bunch of little fixes for races in the tests. - Deduplicate code, move checks into common functions.
Diffstat (limited to 'regress/sys/kern/sosplice/tcp/args-relay-read-forked.pl')
-rw-r--r--regress/sys/kern/sosplice/tcp/args-relay-read-forked.pl39
1 files changed, 39 insertions, 0 deletions
diff --git a/regress/sys/kern/sosplice/tcp/args-relay-read-forked.pl b/regress/sys/kern/sosplice/tcp/args-relay-read-forked.pl
new file mode 100644
index 00000000000..374e07c26ee
--- /dev/null
+++ b/regress/sys/kern/sosplice/tcp/args-relay-read-forked.pl
@@ -0,0 +1,39 @@
+# test concurrent read and splice
+
+use strict;
+use warnings;
+use POSIX;
+use Time::HiRes;
+
+our %args = (
+ client => {
+ len => 2**20,
+ },
+ relay => {
+ nonblocking => 1,
+ func => sub {
+ defined(my $pid = fork())
+ or die "relay func: fork failed: $!";
+ if ($pid == 0) {
+ my $n;
+ do {
+ $n = sysread(STDIN, my $buf, 10);
+ } while (!defined($n) || $n);
+ POSIX::_exit(0);
+ }
+ # give the userland a moment to read, even if splicing
+ sleep .1;
+ relay(@_);
+ kill 9, $pid;
+ },
+ # As sysread() may extract data from the socket before splicing starts,
+ # the spliced content length is not reliable. Disable the checks.
+ nocheck => 1,
+ },
+ server => {
+ func => sub { sleep 2; read_stream(@_); },
+ nocheck => 1,
+ },
+ len => 1048576,
+ md5 => '6649bbec13f3d7efaedf01c0cfa54f88',
+);