diff options
author | Arno Töll <arno@debian.org> | 2012-11-21 23:03:58 +0100 |
---|---|---|
committer | Arno Töll <arno@debian.org> | 2012-11-21 23:03:58 +0100 |
commit | 985230456afb0b945234dfac919a6ece3df4a715 (patch) | |
tree | 8f820570c0f78de9a32888317a48163721da923a /tests | |
parent | ae5d7c9fce70d39274e4da707f384021f6ec46d4 (diff) | |
download | lighttpd-985230456afb0b945234dfac919a6ece3df4a715.tar.gz |
Imported Upstream version 1.4.26upstream/1.4.26
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/LightyTest.pm | 90 | ||||
-rw-r--r-- | tests/Makefile.in | 21 | ||||
-rw-r--r-- | tests/docroot/123/Makefile.in | 2 | ||||
-rw-r--r-- | tests/docroot/Makefile.in | 6 | ||||
-rw-r--r-- | tests/docroot/www/Makefile.in | 6 | ||||
-rw-r--r-- | tests/docroot/www/expire/Makefile.in | 2 | ||||
-rw-r--r-- | tests/docroot/www/go/Makefile.in | 2 | ||||
-rw-r--r-- | tests/docroot/www/indexfile/Makefile.in | 2 | ||||
-rwxr-xr-x | tests/request.t | 11 | ||||
-rwxr-xr-x | tests/run-tests.pl | 2 |
10 files changed, 82 insertions, 62 deletions
diff --git a/tests/LightyTest.pm b/tests/LightyTest.pm index 19f0162..ebdfd36 100755 --- a/tests/LightyTest.pm +++ b/tests/LightyTest.pm @@ -76,7 +76,7 @@ sub stop_proc { kill('TERM', $pid) or return -1; return -1 if ($pid != waitpid($pid, 0)); } else { - diag("Process not started, nothing to stop"); + diag("\nProcess not started, nothing to stop"); return -1; } @@ -98,7 +98,7 @@ sub wait_for_port_with_proc { return -1; } if (0 >= $timeout) { - diag("Timeout while trying to connect; killing child"); + diag("\nTimeout while trying to connect; killing child"); kill('TERM', $child); return -1; } @@ -128,10 +128,10 @@ sub start_proc { } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'valgrind') { $cmdline = "valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --log-file=valgrind ".$cmdline; } - # diag("starting lighttpd at :".$self->{PORT}.", cmdline: ".$cmdline ); + # diag("\nstarting lighttpd at :".$self->{PORT}.", cmdline: ".$cmdline ); my $child = fork(); if (not defined $child) { - diag("Fork failed"); + diag("\nFork failed"); return -1; } if ($child == 0) { @@ -139,7 +139,7 @@ sub start_proc { } if (0 != $self->wait_for_port_with_proc($self->{PORT}, $child)) { - diag(sprintf('The process %i is not up', $child)); + diag(sprintf('\nThe process %i is not up', $child)); return -1; } @@ -157,6 +157,7 @@ sub handle_http { my @request = $t->{REQUEST}; my @response = $t->{RESPONSE}; + my $slow = defined $t->{SLOWREQUEST}; my $is_debug = $ENV{"TRACE_HTTP"}; my $remote = @@ -165,33 +166,56 @@ sub handle_http { PeerPort => $self->{PORT}); if (not defined $remote) { - diag("connect failed: $!"); + diag("\nconnect failed: $!"); return -1; } $remote->autoflush(1); - diag("sending request header to ".$host.":".$self->{PORT}) if $is_debug; - foreach(@request) { - # pipeline requests - s/\r//g; - s/\n/$EOL/g; + if (!$slow) { + diag("\nsending request header to ".$host.":".$self->{PORT}) if $is_debug; + foreach(@request) { + # pipeline requests + s/\r//g; + s/\n/$EOL/g; - print $remote $_.$BLANK; - diag("<< ".$_) if $is_debug; + print $remote $_.$BLANK; + diag("\n<< ".$_) if $is_debug; + } + shutdown($remote, 1); # I've stopped writing data + } else { + diag("\nsending request header to ".$host.":".$self->{PORT}) if $is_debug; + foreach(@request) { + # pipeline requests + chomp; + s/\r//g; + s/\n/$EOL/g; + + print $remote $_; + diag("<< ".$_."\n") if $is_debug; + select(undef, undef, undef, 0.1); + print $remote "\015"; + select(undef, undef, undef, 0.1); + print $remote "\012"; + select(undef, undef, undef, 0.1); + print $remote "\015"; + select(undef, undef, undef, 0.1); + print $remote "\012"; + select(undef, undef, undef, 0.1); + } + } - shutdown($remote, 1); # I've stopped writing data - diag("... done") if $is_debug; + diag("\n... done") if $is_debug; my $lines = ""; - diag("receiving response") if $is_debug; + diag("\nreceiving response") if $is_debug; # read everything while(<$remote>) { $lines .= $_; diag(">> ".$_) if $is_debug; } - diag("... done") if $is_debug; + diag("\n... done") if $is_debug; close $remote; @@ -209,7 +233,7 @@ sub handle_http { (my $line, $lines) = split($EOL, $lines, 2); # header finished - last if(length($line) == 0); + last if(!defined $line or length($line) == 0); if ($ln == 0) { # response header @@ -221,21 +245,21 @@ sub handle_http { (my $h = $1) =~ tr/[A-Z]/[a-z]/; if (defined $resp_hdr{$h}) { -# diag(sprintf("header '%s' is duplicated: '%s' and '%s'\n", +# diag(sprintf("\nheader '%s' is duplicated: '%s' and '%s'\n", # $h, $resp_hdr{$h}, $2)); $resp_hdr{$h} .= ', '.$2; } else { $resp_hdr{$h} = $2; } } else { - diag(sprintf("unexpected line '%s'\n", $line)); + diag(sprintf("\nunexpected line '%s'", $line)); return -1; } } } if (not defined($resp_line)) { - diag(sprintf("empty response\n")); + diag(sprintf("\nempty response")); return -1; } @@ -259,29 +283,29 @@ sub handle_http { # check conditions if ($resp_line =~ /^(HTTP\/1\.[01]) ([0-9]{3}) .+$/) { if ($href->{'HTTP-Protocol'} ne $1) { - diag(sprintf("proto failed: expected '%s', got '%s'\n", $href->{'HTTP-Protocol'}, $1)); + diag(sprintf("\nproto failed: expected '%s', got '%s'", $href->{'HTTP-Protocol'}, $1)); return -1; } if ($href->{'HTTP-Status'} ne $2) { - diag(sprintf("status failed: expected '%s', got '%s'\n", $href->{'HTTP-Status'}, $2)); + diag(sprintf("\nstatus failed: expected '%s', got '%s'", $href->{'HTTP-Status'}, $2)); return -1; } } else { - diag(sprintf("unexpected resp_line '%s'\n", $resp_line)); + diag(sprintf("\nunexpected resp_line '%s'", $resp_line)); return -1; } if (defined $href->{'HTTP-Content'}) { $resp_body = "" unless defined $resp_body; if ($href->{'HTTP-Content'} ne $resp_body) { - diag(sprintf("body failed: expected '%s', got '%s'\n", $href->{'HTTP-Content'}, $resp_body)); + diag(sprintf("\nbody failed: expected '%s', got '%s'", $href->{'HTTP-Content'}, $resp_body)); return -1; } } if (defined $href->{'-HTTP-Content'}) { if (defined $resp_body && $resp_body ne '') { - diag(sprintf("body failed: expected empty body, got '%s'\n", $resp_body)); + diag(sprintf("\nbody failed: expected empty body, got '%s'", $resp_body)); return -1; } } @@ -309,12 +333,12 @@ sub handle_http { if ($key_inverted) { if (defined $resp_hdr{$k}) { - diag(sprintf("header '%s' MUST not be set\n", $k)); + diag(sprintf("\nheader '%s' MUST not be set", $k)); return -1; } } else { if (not defined $resp_hdr{$k}) { - diag(sprintf("required header '%s' is missing\n", $k)); + diag(sprintf("\nrequired header '%s' is missing", $k)); return -1; } } @@ -322,12 +346,12 @@ sub handle_http { if ($verify_value) { if ($href->{$_} =~ /^\/(.+)\/$/) { if ($resp_hdr{$k} !~ /$1/) { - diag(sprintf("response-header failed: expected '%s', got '%s', regex: %s\n", + diag(sprintf("\nresponse-header failed: expected '%s', got '%s', regex: %s", $href->{$_}, $resp_hdr{$k}, $1)); return -1; } } elsif ($href->{$_} ne $resp_hdr{$k}) { - diag(sprintf("response-header failed: expected '%s', got '%s'\n", + diag(sprintf("\nresponse-header failed: expected '%s', got '%s'", $href->{$_}, $resp_hdr{$k})); return -1; } @@ -337,7 +361,7 @@ sub handle_http { # we should have sucked up everything if (defined $lines) { - diag(sprintf("unexpected lines '%s'\n", $lines)); + diag(sprintf("\nunexpected lines '%s'", $lines)); return -1; } @@ -348,7 +372,7 @@ sub spawnfcgi { my ($self, $binary, $port) = @_; my $child = fork(); if (not defined $child) { - diag("Couldn't fork\n"); + diag("\nCouldn't fork"); return -1; } if ($child == 0) { @@ -362,7 +386,7 @@ sub spawnfcgi { exec $binary or die($?); } else { if (0 != $self->wait_for_port_with_proc($port, $child)) { - diag(sprintf('The process %i is not up (port %i, %s)', $child, $port, $binary)); + diag(sprintf("\nThe process %i is not up (port %i, %s)", $child, $port, $binary)); return -1; } return $child; diff --git a/tests/Makefile.in b/tests/Makefile.in index 0f2bba5..2a15119 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -104,21 +104,8 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ distdir ETAGS = etags CTAGS = ctags -# If stdout is a non-dumb tty, use colors. If test -t is not supported, -# then this fails; a conservative approach. Of course do not redirect -# stdout here, just stderr. am__tty_colors = \ -red=; grn=; lgn=; blu=; std=; \ -test "X$(AM_COLOR_TESTS)" != Xno \ -&& test "X$$TERM" != Xdumb \ -&& { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \ -&& { \ - red='[0;31m'; \ - grn='[0;32m'; \ - lgn='[1;32m'; \ - blu='[1;34m'; \ - std='[m'; \ -} +red=; grn=; lgn=; blu=; std= DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ @@ -444,7 +431,7 @@ clean-libtool: # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -469,7 +456,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ diff --git a/tests/docroot/123/Makefile.in b/tests/docroot/123/Makefile.in index 48640b5..51ef0f2 100644 --- a/tests/docroot/123/Makefile.in +++ b/tests/docroot/123/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, diff --git a/tests/docroot/Makefile.in b/tests/docroot/Makefile.in index caa017c..7782a33 100644 --- a/tests/docroot/Makefile.in +++ b/tests/docroot/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -287,7 +287,7 @@ clean-libtool: # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -312,7 +312,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ diff --git a/tests/docroot/www/Makefile.in b/tests/docroot/www/Makefile.in index 4bc2422..b670fdb 100644 --- a/tests/docroot/www/Makefile.in +++ b/tests/docroot/www/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -292,7 +292,7 @@ clean-libtool: # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -317,7 +317,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ diff --git a/tests/docroot/www/expire/Makefile.in b/tests/docroot/www/expire/Makefile.in index b578612..f36fc1b 100644 --- a/tests/docroot/www/expire/Makefile.in +++ b/tests/docroot/www/expire/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, diff --git a/tests/docroot/www/go/Makefile.in b/tests/docroot/www/go/Makefile.in index cbba39f..cba6259 100644 --- a/tests/docroot/www/go/Makefile.in +++ b/tests/docroot/www/go/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, diff --git a/tests/docroot/www/indexfile/Makefile.in b/tests/docroot/www/indexfile/Makefile.in index b42f571..a255bad 100644 --- a/tests/docroot/www/indexfile/Makefile.in +++ b/tests/docroot/www/indexfile/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, diff --git a/tests/request.t b/tests/request.t index 0a35f57..1960f5d 100755 --- a/tests/request.t +++ b/tests/request.t @@ -8,7 +8,7 @@ BEGIN { use strict; use IO::Socket; -use Test::More tests => 41; +use Test::More tests => 42; use LightyTest; my $tf = LightyTest->new(); @@ -389,5 +389,14 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '' } ]; ok($tf->handle_http($t) == 0, 'Status 304 has no Content-Length (#1002)'); +$t->{REQUEST} = ( <<EOF +GET /12345.txt HTTP/1.0 +Host: 123.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain' } ]; +$t->{SLOWREQUEST} = 1; +ok($tf->handle_http($t) == 0, 'GET, slow \\r\\n\\r\\n (#2105)'); + ok($tf->stop_proc == 0, "Stopping lighttpd"); diff --git a/tests/run-tests.pl b/tests/run-tests.pl index 3650d55..6136eac 100755 --- a/tests/run-tests.pl +++ b/tests/run-tests.pl @@ -17,4 +17,4 @@ while ($f = readdir(DIR)) { } } closedir DIR; -runtests @fs; +runtests (sort @fs); |