summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2011-04-22 02:06:01 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2011-04-22 02:06:01 +0000
commitfd673519a909627616fe2d945531b71c8e62588e (patch)
tree638f4f4e3d9cc01798974e4e7cb7477bb095d74e /regress
parent9281bac9f50df7113c0424c1f685d6b37d279978 (diff)
Make the socket splicing regression tests architecture independent
by using the perl module BSD::Socket::Splice from ports. Tested on i386 and sparc64.
Diffstat (limited to 'regress')
-rw-r--r--regress/sys/kern/splice/Makefile17
-rwxr-xr-xregress/sys/kern/splice/error-EBUSY.pl2
-rwxr-xr-xregress/sys/kern/splice/error-ENOTCONN.pl2
-rwxr-xr-xregress/sys/kern/splice/error-EOPNOTSUPP.pl2
-rwxr-xr-xregress/sys/kern/splice/error-EPROTONOSUPPORT.pl2
-rwxr-xr-xregress/sys/kern/splice/error-max-EINVAL.pl2
-rwxr-xr-xregress/sys/kern/splice/error-splice-EBADF.pl2
-rwxr-xr-xregress/sys/kern/splice/error-splice-EBUSY.pl2
-rwxr-xr-xregress/sys/kern/splice/error-splice-EINVAL.pl2
-rwxr-xr-xregress/sys/kern/splice/error-splice-ENOTCONN.pl2
-rwxr-xr-xregress/sys/kern/splice/error-splice-ENOTSOCK.pl2
-rwxr-xr-xregress/sys/kern/splice/error-splice-EOPNOTSUPP.pl2
-rwxr-xr-xregress/sys/kern/splice/error-splice-EPROTONOSUPPORT.pl2
-rw-r--r--regress/sys/kern/splice/funcs.pl17
14 files changed, 28 insertions, 30 deletions
diff --git a/regress/sys/kern/splice/Makefile b/regress/sys/kern/splice/Makefile
index 390da442f89..579808ad19e 100644
--- a/regress/sys/kern/splice/Makefile
+++ b/regress/sys/kern/splice/Makefile
@@ -1,8 +1,9 @@
-# $OpenBSD: Makefile,v 1.1 2011/01/07 22:06:08 bluhm Exp $
+# $OpenBSD: Makefile,v 1.2 2011/04/22 02:06:00 bluhm Exp $
-# The following ports must be installed for the args-* regression test:
-# p5-IO-Socket-INET6 object interface for AF_INET and AF_INET6 domain sockets
-# p5-Socket6 Perl defines relating to AF_INET6 sockets
+# The following ports must be installed for the regression tests:
+# p5-BSD-Socket-Splice perl interface to OpenBSD socket splicing
+# p5-IO-Socket-INET6 object interface for AF_INET and AF_INET6 domain sockets
+# p5-Socket6 Perl defines relating to AF_INET6 sockets
ERRS != ls error-*.pl
ARGS != ls args-*.pl
@@ -15,9 +16,9 @@ CLEANFILES = *.log ktrace.out
# a local and remote ip address for the tcp connections. To control
# the remote machine you need a hostname for ssh to log in. All the
# test files must be in the same directory local and remote.
-#LOCAL_ADDR ?=
-#REMOTE_ADDR ?=
-#REMOTE_SSH ?=
+LOCAL_ADDR ?=
+REMOTE_ADDR ?=
+REMOTE_SSH ?=
# The error tests try to splice unsuitable sockets and check the
# kernel error code.
@@ -40,7 +41,7 @@ run-regress-$e: $e
run-regress-$a: $a
time perl relay.pl copy $a
time perl relay.pl splice $a
-.if REMOTE_SSH
+.if ! empty (REMOTE_SSH)
time perl remote.pl copy ${LOCAL_ADDR} ${REMOTE_ADDR} ${REMOTE_SSH} $a
time perl remote.pl splice ${LOCAL_ADDR} ${REMOTE_ADDR} ${REMOTE_SSH} $a
.endif
diff --git a/regress/sys/kern/splice/error-EBUSY.pl b/regress/sys/kern/splice/error-EBUSY.pl
index e75431413ea..1f72809d214 100755
--- a/regress/sys/kern/splice/error-EBUSY.pl
+++ b/regress/sys/kern/splice/error-EBUSY.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-ENOTCONN.pl b/regress/sys/kern/splice/error-ENOTCONN.pl
index b08fb9cecb8..4c980d74252 100755
--- a/regress/sys/kern/splice/error-ENOTCONN.pl
+++ b/regress/sys/kern/splice/error-ENOTCONN.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $s = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-EOPNOTSUPP.pl b/regress/sys/kern/splice/error-EOPNOTSUPP.pl
index 916f92d96b9..4d5831dc500 100755
--- a/regress/sys/kern/splice/error-EOPNOTSUPP.pl
+++ b/regress/sys/kern/splice/error-EOPNOTSUPP.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $s = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-EPROTONOSUPPORT.pl b/regress/sys/kern/splice/error-EPROTONOSUPPORT.pl
index 612f81a64fe..652ad8b92e4 100755
--- a/regress/sys/kern/splice/error-EPROTONOSUPPORT.pl
+++ b/regress/sys/kern/splice/error-EPROTONOSUPPORT.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $s = IO::Socket::INET->new(
Proto => "udp",
diff --git a/regress/sys/kern/splice/error-max-EINVAL.pl b/regress/sys/kern/splice/error-max-EINVAL.pl
index d26525f17c5..7d62dc4374c 100755
--- a/regress/sys/kern/splice/error-max-EINVAL.pl
+++ b/regress/sys/kern/splice/error-max-EINVAL.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-splice-EBADF.pl b/regress/sys/kern/splice/error-splice-EBADF.pl
index 53b30ecfc84..aae12871856 100755
--- a/regress/sys/kern/splice/error-splice-EBADF.pl
+++ b/regress/sys/kern/splice/error-splice-EBADF.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-splice-EBUSY.pl b/regress/sys/kern/splice/error-splice-EBUSY.pl
index dd0f169d6f1..797f183fc07 100755
--- a/regress/sys/kern/splice/error-splice-EBUSY.pl
+++ b/regress/sys/kern/splice/error-splice-EBUSY.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-splice-EINVAL.pl b/regress/sys/kern/splice/error-splice-EINVAL.pl
index c36b2f80e3e..7d95d703011 100755
--- a/regress/sys/kern/splice/error-splice-EINVAL.pl
+++ b/regress/sys/kern/splice/error-splice-EINVAL.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-splice-ENOTCONN.pl b/regress/sys/kern/splice/error-splice-ENOTCONN.pl
index a20a8171ac8..51984f4b412 100755
--- a/regress/sys/kern/splice/error-splice-ENOTCONN.pl
+++ b/regress/sys/kern/splice/error-splice-ENOTCONN.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-splice-ENOTSOCK.pl b/regress/sys/kern/splice/error-splice-ENOTSOCK.pl
index 228536efafb..2c035e767ea 100755
--- a/regress/sys/kern/splice/error-splice-ENOTSOCK.pl
+++ b/regress/sys/kern/splice/error-splice-ENOTSOCK.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-splice-EOPNOTSUPP.pl b/regress/sys/kern/splice/error-splice-EOPNOTSUPP.pl
index 843da7b37fc..2bf6000dced 100755
--- a/regress/sys/kern/splice/error-splice-EOPNOTSUPP.pl
+++ b/regress/sys/kern/splice/error-splice-EOPNOTSUPP.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/error-splice-EPROTONOSUPPORT.pl b/regress/sys/kern/splice/error-splice-EPROTONOSUPPORT.pl
index 20fb388c9e3..50eb4f63ee1 100755
--- a/regress/sys/kern/splice/error-splice-EPROTONOSUPPORT.pl
+++ b/regress/sys/kern/splice/error-splice-EPROTONOSUPPORT.pl
@@ -3,7 +3,7 @@
use Errno;
use IO::Socket;
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice "SO_SPLICE";
my $sl = IO::Socket::INET->new(
Proto => "tcp",
diff --git a/regress/sys/kern/splice/funcs.pl b/regress/sys/kern/splice/funcs.pl
index e294e403c69..570ec605558 100644
--- a/regress/sys/kern/splice/funcs.pl
+++ b/regress/sys/kern/splice/funcs.pl
@@ -1,4 +1,4 @@
-# $OpenBSD: funcs.pl,v 1.4 2011/03/13 01:27:23 bluhm Exp $
+# $OpenBSD: funcs.pl,v 1.5 2011/04/22 02:06:00 bluhm Exp $
# Copyright (c) 2010,2011 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -22,7 +22,7 @@ use Digest::MD5;
use IO::Socket qw(sockatmark);
use Socket;
use Time::HiRes qw(time alarm sleep);
-use constant SO_SPLICE => 0x1023;
+use BSD::Socket::Splice qw(setsplice getsplice geterror);
########################################################################
# Client funcs
@@ -188,10 +188,8 @@ sub relay_splice {
my $splicelen;
my $shortsplice = 0;
do {
- my $splicemax = $max ? $max - $len : 0; # XXX should be quad
- # XXX this works for i386 only
- my $sosplice = pack('iii', fileno(STDOUT), $splicemax, 0);
- setsockopt(STDIN, SOL_SOCKET, SO_SPLICE, $sosplice)
+ my $splicemax = $max ? $max - $len : 0;
+ setsplice(\*STDIN, \*STDOUT, $splicemax)
or die ref($self), " splice stdin to stdout failed: $!";
if ($self->{readblocking}) {
@@ -214,14 +212,13 @@ sub relay_splice {
or die ref($self), " select failed: $!";
}
- my $error = getsockopt(STDIN, SOL_SOCKET, SO_ERROR)
+ defined(my $error = geterror(\*STDIN))
or die ref($self), " get error from stdin failed: $!";
- $! = unpack('i', $error)
+ $! = $error
and die ref($self), " splice failed: $!";
- $sosplice = getsockopt(STDIN, SOL_SOCKET, SO_SPLICE)
+ defined($splicelen = getsplice(\*STDIN))
or die ref($self), " get splice len from stdin failed: $!";
- $splicelen = unpack('ii', $sosplice); # XXX should be quad
print STDERR "SPLICELEN: ", $splicelen, "\n";
!$max || $splicelen <= $splicemax
or die ref($self), " splice len $splicelen ".