diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-06-22 14:18:02 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-06-22 14:18:02 +0000 |
commit | 03c02c0390fc684c4d3e2a6b13b6e38847dabb28 (patch) | |
tree | 30a74b59f312f4d035eb26130a0128e75106bd52 | |
parent | 773af31e5e9384e3a661a73f9df49369183af810 (diff) |
Fix the relayd regression tests. Now they pass with and without
an obj directory. The relayd process can also run on a remote
machine for different timing.
-rw-r--r-- | regress/usr.sbin/relayd/Makefile | 25 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/Relayd.pm | 27 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/Remote.pm | 12 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-http-append.pl | 4 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-http-change-path.pl | 2 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-http-filter-url-file.pl | 2 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-http-hash.pl | 2 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-http-mark-marked.pl | 2 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-http-remove.pl | 2 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/funcs.pl | 4 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/remote.pl | 10 |
11 files changed, 55 insertions, 37 deletions
diff --git a/regress/usr.sbin/relayd/Makefile b/regress/usr.sbin/relayd/Makefile index 3e42d7bbd8b..caa9866a17b 100644 --- a/regress/usr.sbin/relayd/Makefile +++ b/regress/usr.sbin/relayd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.7 2013/08/11 21:01:59 bluhm Exp $ +# $OpenBSD: Makefile,v 1.8 2014/06/22 14:18:01 bluhm Exp $ # The following ports must be installed for the regression tests: # p5-IO-Socket-INET6 object interface for AF_INET and AF_INET6 domain sockets @@ -34,7 +34,7 @@ REMOTE_SSH ?= ARGS != cd ${.CURDIR} && ls args-*.pl TARGETS ?= ${ARGS} REGRESS_TARGETS = ${TARGETS:S/^/run-regress-/} -CLEANFILES += *.log *.pem relayd.conf ktrace.out stamp-* +CLEANFILES += *.log *.pem *.crt *.key relayd.conf ktrace.out stamp-* # Set variables so that make runs with and without obj directory. # Only do that if necessary to keep visible output short. @@ -64,14 +64,27 @@ run-regress-$a: $a # create the certificates for SSL -/etc/ssl/127.0.0.1.crt: - ${SUDO} openssl req -batch -new -nodes -newkey rsa -keyout /etc/ssl/private/127.0.0.1.key -subj /CN=127.0.0.1/ -x509 -out $@ +.for ip in ${REMOTE_ADDR} 127.0.0.1 +${ip}.crt: + openssl req -batch -new -nodes -newkey rsa -keyout ${ip}.key -subj /CN=${ip}/ -x509 -out $@ +.if empty (REMOTE_SSH) + ${SUDO} cp 127.0.0.1.crt /etc/ssl/ + ${SUDO} cp 127.0.0.1.key /etc/ssl/private/ +.else + scp ${REMOTE_ADDR}.crt root@${REMOTE_SSH}:/etc/ssl/ + scp ${REMOTE_ADDR}.key root@${REMOTE_SSH}:/etc/ssl/private/ +.endif +.endfor server-cert.pem: openssl req -batch -new -nodes -newkey rsa -keyout server-key.pem -subj /CN=localhost/ -x509 -out $@ -${REGRESS_TARGETS:M*ssl*} ${REGRESS_TARGETS:M*https*}: \ - /etc/ssl/127.0.0.1.crt server-cert.pem +${REGRESS_TARGETS:M*ssl*} ${REGRESS_TARGETS:M*https*}: server-cert.pem +.if empty (REMOTE_SSH) +${REGRESS_TARGETS:M*ssl*} ${REGRESS_TARGETS:M*https*}: 127.0.0.1.crt +.else +${REGRESS_TARGETS:M*ssl*} ${REGRESS_TARGETS:M*https*}: ${REMOTE_ADDR}.crt +.endif # make perl syntax check for all args files diff --git a/regress/usr.sbin/relayd/Relayd.pm b/regress/usr.sbin/relayd/Relayd.pm index d446912ab22..bdd88e08a53 100644 --- a/regress/usr.sbin/relayd/Relayd.pm +++ b/regress/usr.sbin/relayd/Relayd.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Relayd.pm,v 1.9 2014/05/12 21:30:42 andre Exp $ +# $OpenBSD: Relayd.pm,v 1.10 2014/06/22 14:18:01 bluhm Exp $ # Copyright (c) 2010-2012 Alexander Bluhm <bluhm@openbsd.org> # @@ -55,6 +55,13 @@ sub new { print $fh "table <table-$test> { $self->{connectaddr} }\n" if defined($self->{table}); + # substitute variables in config file + my $curdir = dirname($0) || "."; + my $connectport = $self->{connectport}; + my $connectaddr = $self->{connectaddr}; + my $listenaddr = $self->{listenaddr}; + my $listenport = $self->{listenport}; + my @protocol = @{$self->{protocol}}; my $proto = shift @protocol; $proto = defined($proto) ? "$proto " : ""; @@ -64,14 +71,14 @@ sub new { die ref($self), " invalid forward $self->{forward}" unless grep { /splice/ } @protocol; print $fh "${proto}protocol proto-$test {"; + # substitute variables in config file + foreach (@protocol) { + s/(\$[a-z]+)/$1/eeg; + } print $fh map { "\n\t$_" } @protocol; print $fh "\n}\n"; my @relay = @{$self->{relay}}; - my $connectport = $self->{connectport}; - my $connectaddr = $self->{connectaddr}; - my $listenaddr = $self->{listenaddr}; - my $listenport = $self->{listenport}; print $fh "relay relay-$test {"; print $fh "\n\tprotocol proto-$test" unless grep { /^protocol / } @relay; @@ -81,11 +88,9 @@ sub new { my $withssl = $self->{forwardssl} ? " with ssl" : ""; print $fh "\n\tforward$withssl to $self->{connectaddr} ". "port $self->{connectport}" unless grep { /^forward / } @relay; - my @raux = @relay; - @relay = (); - foreach my $s (@raux) { - $s =~ s/(\$\w+)/$1/eeg; - push @relay, $s; + # substitute variables in config file + foreach (@relay) { + s/(\$[a-z]+)/$1/eeg; } print $fh map { "\n\t$_" } @relay; print $fh "\n}\n"; @@ -97,7 +102,7 @@ sub up { my $self = Proc::up(shift, @_); my $timeout = shift || 10; my $regex = $self->{dryrun} || "relay_launch: "; - my $lsock = $self->loggrep(qr/$regex/, $timeout) + $self->loggrep(qr/$regex/, $timeout) or croak ref($self), " no $regex in $self->{logfile} ". "after $timeout seconds"; return $self; diff --git a/regress/usr.sbin/relayd/Remote.pm b/regress/usr.sbin/relayd/Remote.pm index 03d01f83884..f9e51b32624 100644 --- a/regress/usr.sbin/relayd/Remote.pm +++ b/regress/usr.sbin/relayd/Remote.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Remote.pm,v 1.2 2013/01/04 14:01:49 bluhm Exp $ +# $OpenBSD: Remote.pm,v 1.3 2014/06/22 14:18:01 bluhm Exp $ # Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org> # @@ -48,7 +48,7 @@ sub new { my %args = @_; $args{logfile} ||= "remote.log"; $args{up} ||= "Started"; - $args{down} ||= "parent terminating"; + $args{down} ||= $args{dryrun} ? "no actions" : "parent terminating"; $args{func} = sub { Carp::confess "$class func may not be called" }; $args{remotessh} or croak "$class remote ssh host not given"; @@ -91,13 +91,13 @@ sub child { my @sudo = $ENV{SUDO} ? "SUDO=$ENV{SUDO}" : (); my @ktrace = $ENV{KTRACE} ? "KTRACE=$ENV{KTRACE}" : (); my @relayd = $ENV{RELAYD} ? "RELAYD=$ENV{RELAYD}" : (); - my $dir = dirname($0); - $dir = getcwd() if ! $dir || $dir eq '.'; + my $curdir = dirname($0) || "."; + $curdir = getcwd() if $curdir eq '.'; my @cmd = ('ssh', @opts, $self->{remotessh}, @sudo, @ktrace, @relayd, 'perl', - '-I', $dir, "$dir/".basename($0), $self->{forward}, + '-I', $curdir, "$curdir/".basename($0), $self->{forward}, $self->{listenaddr}, $self->{connectaddr}, $self->{connectport}, - ($self->{testfile} ? "$dir/".basename($self->{testfile}) : ())); + ($self->{testfile} ? "$curdir/".basename($self->{testfile}) : ())); print STDERR "execute: @cmd\n"; exec @cmd; die "Exec @cmd failed: $!"; diff --git a/regress/usr.sbin/relayd/args-http-append.pl b/regress/usr.sbin/relayd/args-http-append.pl index 3086336d4b0..f6c00de4093 100644 --- a/regress/usr.sbin/relayd/args-http-append.pl +++ b/regress/usr.sbin/relayd/args-http-append.pl @@ -5,7 +5,7 @@ our %args = ( client => { func => \&http_client, len => 1, - loggrep => { "X-Server-Append: 127.0.0.1:.*" => 1 }, + loggrep => { 'X-Server-Append: \d+\.\d+\.\d+\.\d+:\d+$' => 1 }, }, relayd => { protocol => [ "http", @@ -15,7 +15,7 @@ our %args = ( }, server => { func => \&http_server, - loggrep => { "X-Client-Append: 127.0.0.1:.*" => 1 }, + loggrep => { 'X-Client-Append: \d+\.\d+\.\d+\.\d+:\d+$' => 1 }, }, ); diff --git a/regress/usr.sbin/relayd/args-http-change-path.pl b/regress/usr.sbin/relayd/args-http-change-path.pl index 8b1d882620c..23205c3941d 100644 --- a/regress/usr.sbin/relayd/args-http-change-path.pl +++ b/regress/usr.sbin/relayd/args-http-change-path.pl @@ -13,7 +13,7 @@ our %args = ( loggrep => { qr/relayd.conf\:.*action only supported for headers/ => 1 }, - dryrun => "relayd.conf", + dryrun => "relayd.conf:4: action only supported for headers", }, server => { noserver => 1, diff --git a/regress/usr.sbin/relayd/args-http-filter-url-file.pl b/regress/usr.sbin/relayd/args-http-filter-url-file.pl index 15266811138..823794dd365 100644 --- a/regress/usr.sbin/relayd/args-http-filter-url-file.pl +++ b/regress/usr.sbin/relayd/args-http-filter-url-file.pl @@ -12,7 +12,7 @@ our %args = ( protocol => [ "http", 'return error', 'label test_reject_label', - 'url filter file args-http-filter-url-file.in log', + 'url filter file "$curdir/args-http-filter-url-file.in" log', 'no label', ], loggrep => { diff --git a/regress/usr.sbin/relayd/args-http-hash.pl b/regress/usr.sbin/relayd/args-http-hash.pl index e14890ddefe..da557eaae84 100644 --- a/regress/usr.sbin/relayd/args-http-hash.pl +++ b/regress/usr.sbin/relayd/args-http-hash.pl @@ -15,7 +15,7 @@ our %args = ( ], relay => 'forward to <table-$test> port $connectport', loggrep => { - qr/done, \[\/query: foobar\]/ => 1, + qr/ (?:done|last write \(done\)), \[\/query: foobar\]/ => 1, qr/relay_handle_http: hash 0xfde460be/ => 1, }, }, diff --git a/regress/usr.sbin/relayd/args-http-mark-marked.pl b/regress/usr.sbin/relayd/args-http-mark-marked.pl index 971e776f71a..6aadeb6ac24 100644 --- a/regress/usr.sbin/relayd/args-http-mark-marked.pl +++ b/regress/usr.sbin/relayd/args-http-mark-marked.pl @@ -11,7 +11,7 @@ our %args = ( 'request path mark "*" with 99 marked 55', ], loggrep => { "either mark or marked" => 1 }, - dryrun => "relayd.conf", + dryrun => "relayd.conf:4: either mark or marked", }, server => { noserver => 1, diff --git a/regress/usr.sbin/relayd/args-http-remove.pl b/regress/usr.sbin/relayd/args-http-remove.pl index e8a6cac4a4c..3a87684dd8e 100644 --- a/regress/usr.sbin/relayd/args-http-remove.pl +++ b/regress/usr.sbin/relayd/args-http-remove.pl @@ -17,7 +17,7 @@ our %args = ( protocol => [ "http", 'response header remove X-Header-Foo log', ], - loggrep => { qr/done, \[X-Header-Foo: foo\s*\]/ => 1 }, + loggrep => { qr/ (?:done|last write \(done\)), \[X-Header-Foo: foo\s*\]/ => 1 }, }, server => { func => \&http_server, diff --git a/regress/usr.sbin/relayd/funcs.pl b/regress/usr.sbin/relayd/funcs.pl index 5e19cb5f415..01c24ce9ba7 100644 --- a/regress/usr.sbin/relayd/funcs.pl +++ b/regress/usr.sbin/relayd/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.10 2014/05/02 14:10:03 andre Exp $ +# $OpenBSD: funcs.pl,v 1.11 2014/06/22 14:18:01 bluhm Exp $ # Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org> # @@ -16,7 +16,7 @@ use strict; use warnings; -#no warnings 'experimental::smartmatch'; +no warnings 'experimental::smartmatch'; use feature 'switch'; use Errno; use Digest::MD5; diff --git a/regress/usr.sbin/relayd/remote.pl b/regress/usr.sbin/relayd/remote.pl index b3394d988e2..3925627e00a 100644 --- a/regress/usr.sbin/relayd/remote.pl +++ b/regress/usr.sbin/relayd/remote.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: remote.pl,v 1.3 2013/02/07 22:56:27 bluhm Exp $ +# $OpenBSD: remote.pl,v 1.4 2014/06/22 14:18:01 bluhm Exp $ # Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org> # @@ -108,7 +108,7 @@ if ($mode eq "auto") { forward => $ARGV[0], logfile => "relayd.log", testfile => $test, - %{$args{relay}}, + %{$args{relayd}}, remotessh => $ARGV[3], listenaddr => $ARGV[2], connectaddr => $ARGV[1], @@ -122,13 +122,13 @@ my $c = Client->new( connectdomain => AF_INET, connectaddr => ($mode eq "manual" ? $ARGV[1] : $r->{listenaddr}), connectport => ($mode eq "manual" ? $ARGV[2] : $r->{listenport}), -); +) unless $args{client}{noclient}; $s->run unless $args{server}{noserver}; -$c->run->up; +$c->run->up unless $args{client}{noclient}; $s->up unless $args{server}{noserver}; -$c->down; +$c->down unless $args{client}{noclient}; $s->down unless $args{server}{noserver}; $r->close_child; $r->down; |