diff options
Diffstat (limited to 'tests')
35 files changed, 320 insertions, 145 deletions
diff --git a/tests/404-handler.conf b/tests/404-handler.conf index 65f2e5e..f1cd28e 100644 --- a/tests/404-handler.conf +++ b/tests/404-handler.conf @@ -3,7 +3,6 @@ debug.log-response-header = "enable" debug.log-request-header = "enable" server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" ## bind to port (default: 80) server.port = 2048 diff --git a/tests/LightyTest.pm b/tests/LightyTest.pm index 6e3f5c2..8d814de 100755 --- a/tests/LightyTest.pm +++ b/tests/LightyTest.pm @@ -6,6 +6,7 @@ use IO::Socket; use Test::More; use Socket; use Cwd 'abs_path'; +use POSIX ":sys_wait_h"; sub mtime { my $file = shift; @@ -30,14 +31,17 @@ sub new { if (mtime($self->{BASEDIR}.'/src/lighttpd') > mtime($self->{BASEDIR}.'/build/lighttpd')) { - $self->{LIGHTTPD_PATH} = $self->{BASEDIR}.'/src/lighttpd'; - $self->{MODULES_PATH} = $self->{BASEDIR}.'/src/.libs'; + $self->{BINDIR} = $self->{BASEDIR}.'/src'; + if (mtime($self->{BASEDIR}.'/src/.libs')) { + $self->{MODULES_PATH} = $self->{BASEDIR}.'/src/.libs'; + } else { + $self->{MODULES_PATH} = $self->{BASEDIR}.'/src'; + } } else { - $self->{LIGHTTPD_PATH} = $self->{BASEDIR}.'/build/lighttpd'; + $self->{BINDIR} = $self->{BASEDIR}.'/build'; $self->{MODULES_PATH} = $self->{BASEDIR}.'/build'; } - $self->{LIGHTTPD_PIDFILE} = $self->{TESTDIR}.'/tmp/lighttpd/lighttpd.pid'; - $self->{PIDOF_PIDFILE} = $self->{TESTDIR}.'/tmp/lighttpd/pidof.pid'; + $self->{LIGHTTPD_PATH} = $self->{BINDIR}.'/lighttpd'; $self->{PORT} = 2048; my ($name, $aliases, $addrtype, $net) = gethostbyaddr(inet_aton("127.0.0.1"), AF_INET); @@ -66,59 +70,73 @@ sub listening_on { sub stop_proc { my $self = shift; - open F, $self->{LIGHTTPD_PIDFILE} or return -1; - my $pid = <F>; - close F; + my $pid = $self->{LIGHTTPD_PID}; + if (defined $pid && $pid != -1) { + kill('TERM', $pid) or return -1; + return -1 if ($pid != waitpid($pid, 0)); + } else { + diag("Process not started, nothing to stop"); + return -1; + } + + return 0; +} + +sub wait_for_port_with_proc { + my $self = shift; + my $port = shift; + my $child = shift; - if (defined $pid) { - kill('TERM',$pid) or return -1; + while (0 == $self->listening_on($port)) { select(undef, undef, undef, 0.1); + + # the process is gone, we failed + if (0 != waitpid($child, WNOHANG)) { + return -1; + } } return 0; } - sub start_proc { my $self = shift; # kill old proc if necessary - $self->stop_proc; + #$self->stop_proc; # pre-process configfile if necessary # $ENV{'SRCDIR'} = $self->{BASEDIR}.'/tests'; + $ENV{'PORT'} = $self->{PORT}; - unlink($self->{LIGHTTPD_PIDFILE}); + my $cmdline = $self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}; if (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'strace') { - system("strace -tt -s 512 -o strace ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." &"); + $cmdline = "strace -tt -s 512 -o strace ".$cmdline; } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'truss') { - system("/usr/dtrctkit/bin/dtruss -d -e ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." 2> strace &"); + $cmdline = "truss -a -l -w all -v all -o strace ".$cmdline; + } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'gdb') { + $cmdline = "gdb --batch --ex 'run' --ex 'bt' --args ".$cmdline." > gdb.out"; } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'valgrind') { - system("valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --log-file=valgrind ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." &"); - } else { - system($self->{LIGHTTPD_PATH}." -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}); + $cmdline = "valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --log-file=valgrind ".$cmdline; } - - select(undef, undef, undef, 0.1); - if (not -e $self->{LIGHTTPD_PIDFILE} or 0 == kill 0, `cat $self->{LIGHTTPD_PIDFILE}`) { - select(undef, undef, undef, 2); - } - - unlink($self->{TESTDIR}."/tmp/cfg.file"); - - # no pidfile, we failed - if (not -e $self->{LIGHTTPD_PIDFILE}) { - diag(sprintf('Could not find pidfile: %s', $self->{LIGHTTPD_PIDFILE})); + # diag("starting lighttpd at :".$self->{PORT}.", cmdline: ".$cmdline ); + my $child = fork(); + if (not defined $child) { + diag("Fork failed"); return -1; } + if ($child == 0) { + exec $cmdline or die($?); + } - # the process is gone, we failed - if (0 == kill 0, `cat $self->{LIGHTTPD_PIDFILE}`) { - diag(sprintf('the process referenced by %s is not up', $self->{LIGHTTPD_PIDFILE})); + if (0 != $self->wait_for_port_with_proc($self->{PORT}, $child)) { + diag(sprintf('The process %i is not up', $child)); return -1; } + $self->{LIGHTTPD_PID} = $child; + 0; } @@ -131,6 +149,7 @@ sub handle_http { my @request = $t->{REQUEST}; my @response = $t->{RESPONSE}; + my $is_debug = $ENV{"TRACE_HTTP"}; my $remote = IO::Socket::INET->new(Proto => "tcp", @@ -144,20 +163,27 @@ sub handle_http { $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; - print $remote $_.$BLANK; + print $remote $_.$BLANK; + diag("<< ".$_) if $is_debug; } + shutdown($remote, 1); # I've stopped writing data + diag("... done") if $is_debug; my $lines = ""; + diag("receiving response") if $is_debug; # read everything while(<$remote>) { $lines .= $_; + diag(">> ".$_) if $is_debug; } + diag("... done") if $is_debug; close $remote; @@ -187,18 +213,24 @@ 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", - $h, $resp_hdr{$h}, $2)); +# diag(sprintf("header '%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 '$line'\n")); + diag(sprintf("unexpected line '%s'\n", $line)); return -1; } } } + if (not defined($resp_line)) { + diag(sprintf("empty response\n")); + return -1; + } + $t->{etag} = $resp_hdr{'etag'}; $t->{date} = $resp_hdr{'date'}; @@ -227,7 +259,7 @@ sub handle_http { return -1; } } else { - diag(sprintf("unexpected resp_line '$resp_line'\n")); + diag(sprintf("unexpected resp_line '%s'\n", $resp_line)); return -1; } @@ -237,7 +269,9 @@ sub handle_http { diag(sprintf("body failed: expected '%s', got '%s'\n", $href->{'HTTP-Content'}, $resp_body)); return -1; } - } elsif (defined $href->{'-HTTP-Content'}) { + } + + if (defined $href->{'-HTTP-Content'}) { if (defined $resp_body && $resp_body ne '') { diag(sprintf("body failed: expected empty body, got '%s'\n", $resp_body)); return -1; @@ -245,7 +279,6 @@ sub handle_http { } foreach (keys %{ $href }) { - ## filter special keys next if $_ eq 'HTTP-Protocol'; next if $_ eq 'HTTP-Status'; next if $_ eq 'HTTP-Content'; @@ -257,7 +290,6 @@ sub handle_http { my $key_inverted = 0; if (substr($k, 0, 1) eq '+') { - ## the key has to exist, but the value is ignored $k = substr($k, 1); $verify_value = 0; } elsif (substr($k, 0, 1) eq '-') { @@ -265,11 +297,11 @@ sub handle_http { $k = substr($k, 1); $key_inverted = 1; $verify_value = 0; ## skip the value check - } + } if ($key_inverted) { if (defined $resp_hdr{$k}) { - diag(sprintf("required header '%s' is missing\n", $k)); + diag(sprintf("header '%s' MUST not be set\n", $k)); return -1; } } else { @@ -297,12 +329,38 @@ sub handle_http { # we should have sucked up everything if (defined $lines) { - diag(sprintf("unexpected lines '$lines'\n")); + diag(sprintf("unexpected lines '%s'\n", $lines)); return -1; } return 0; } - -1; +sub spawnfcgi { + my ($self, $binary, $port) = @_; + my $child = fork(); + if (not defined $child) { + diag("Couldn't fork\n"); + return -1; + } + if ($child == 0) { + my $cmd = $self->{BINDIR}.'/spawn-fcgi -n -p '.$port.' -f "'.$binary.'"'; + exec $cmd 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)); + return -1; + } + return $child; + } +} + +sub endspawnfcgi { + my ($self, $pid) = @_; + return -1 if (-1 == $pid); + kill(2, $pid); + waitpid($pid, 0); + return 0; +} + +1; diff --git a/tests/Makefile.am b/tests/Makefile.am index c353730..2472741 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -38,12 +38,11 @@ CONFS=fastcgi-10.conf \ mod-auth.t \ mod-cgi.t \ mod-compress.t \ + mod-compress.conf \ mod-fastcgi.t \ mod-redirect.t \ mod-rewrite.t \ mod-userdir.t \ - env-variables.t \ - env-variables.conf \ symlink.t \ request.t \ mod-ssi.t \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 4a792b1..04562fb 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. +# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -52,7 +52,7 @@ am__fcgi_responder_SOURCES_DIST = fcgi-responder.c @CHECK_WITH_FASTCGI_TRUE@ fcgi-responder.$(OBJEXT) fcgi_responder_OBJECTS = $(am_fcgi_responder_OBJECTS) fcgi_responder_DEPENDENCIES = -DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ @@ -103,6 +103,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -137,6 +138,7 @@ MKDIR_P = @MKDIR_P@ MYSQL_CONFIG = @MYSQL_CONFIG@ MYSQL_INCLUDE = @MYSQL_INCLUDE@ MYSQL_LIBS = @MYSQL_LIBS@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -149,6 +151,7 @@ PCRECONFIG = @PCRECONFIG@ PCRE_LIB = @PCRE_LIB@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ +SED = @SED@ SENDFILE_LIB = @SENDFILE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -251,12 +254,11 @@ CONFS = fastcgi-10.conf \ mod-auth.t \ mod-cgi.t \ mod-compress.t \ + mod-compress.conf \ mod-fastcgi.t \ mod-redirect.t \ mod-rewrite.t \ mod-userdir.t \ - env-variables.t \ - env-variables.conf \ symlink.t \ request.t \ mod-ssi.t \ @@ -435,8 +437,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -461,8 +463,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ @@ -472,13 +474,12 @@ ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ - here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique diff --git a/tests/SConscript b/tests/SConscript index 07c76c9..4ce7e1e 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -23,6 +23,7 @@ extra_dist = Split('fastcgi-10.conf \ mod-auth.t \ mod-cgi.t \ mod-compress.t \ + mod-compress.conf \ mod-fastcgi.t \ mod-redirect.t \ mod-userdir.t \ diff --git a/tests/bug-06.conf b/tests/bug-06.conf index 3cc7525..cf6abb4 100644 --- a/tests/bug-06.conf +++ b/tests/bug-06.conf @@ -1,5 +1,4 @@ server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" ## bind to port (default: 80) server.port = 2048 diff --git a/tests/bug-12.conf b/tests/bug-12.conf index cd72bf8..5394d8c 100644 --- a/tests/bug-12.conf +++ b/tests/bug-12.conf @@ -1,5 +1,4 @@ server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" ## bind to port (default: 80) server.port = 2048 diff --git a/tests/condition.conf b/tests/condition.conf index 63b8fad..900b9c4 100644 --- a/tests/condition.conf +++ b/tests/condition.conf @@ -3,7 +3,6 @@ debug.log-request-handling = "enable" debug.log-condition-handling = "enable" server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" ## bind to port (default: 80) server.port = 2048 diff --git a/tests/core-404-handler.t b/tests/core-404-handler.t index 599ade2..599ade2 100644..100755 --- a/tests/core-404-handler.t +++ b/tests/core-404-handler.t diff --git a/tests/docroot/123/Makefile.in b/tests/docroot/123/Makefile.in index 50a31cb..7a35f0e 100644 --- a/tests/docroot/123/Makefile.in +++ b/tests/docroot/123/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. +# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -67,6 +67,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -101,6 +102,7 @@ MKDIR_P = @MKDIR_P@ MYSQL_CONFIG = @MYSQL_CONFIG@ MYSQL_INCLUDE = @MYSQL_INCLUDE@ MYSQL_LIBS = @MYSQL_LIBS@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -113,6 +115,7 @@ PCRECONFIG = @PCRECONFIG@ PCRE_LIB = @PCRE_LIB@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ +SED = @SED@ SENDFILE_LIB = @SENDFILE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ diff --git a/tests/docroot/Makefile.in b/tests/docroot/Makefile.in index db2368a..32adbbe 100644 --- a/tests/docroot/Makefile.in +++ b/tests/docroot/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. +# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -79,6 +79,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -113,6 +114,7 @@ MKDIR_P = @MKDIR_P@ MYSQL_CONFIG = @MYSQL_CONFIG@ MYSQL_INCLUDE = @MYSQL_INCLUDE@ MYSQL_LIBS = @MYSQL_LIBS@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -125,6 +127,7 @@ PCRECONFIG = @PCRECONFIG@ PCRE_LIB = @PCRE_LIB@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ +SED = @SED@ SENDFILE_LIB = @SENDFILE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -308,8 +311,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -334,8 +337,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ @@ -345,13 +348,12 @@ ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ - here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique diff --git a/tests/docroot/www/Makefile.am b/tests/docroot/www/Makefile.am index 7c8aa55..3ee4ea2 100644 --- a/tests/docroot/www/Makefile.am +++ b/tests/docroot/www/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST=cgi.php cgi.pl dummydir index.html index.txt phpinfo.php \ +EXTRA_DIST=cgi.php cgi.pl index.html index.txt phpinfo.php \ redirect.php cgi-pathinfo.pl get-env.php get-server-env.php \ nph-status.pl prefix.fcgi get-header.pl ssi.shtml get-post-len.pl \ exec-date.shtml index.html~ 404.fcgi 404.html 404.pl send404.pl crlfcrash.pl diff --git a/tests/docroot/www/Makefile.in b/tests/docroot/www/Makefile.in index 7597926..44d55bd 100644 --- a/tests/docroot/www/Makefile.in +++ b/tests/docroot/www/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. +# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -79,6 +79,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -113,6 +114,7 @@ MKDIR_P = @MKDIR_P@ MYSQL_CONFIG = @MYSQL_CONFIG@ MYSQL_INCLUDE = @MYSQL_INCLUDE@ MYSQL_LIBS = @MYSQL_LIBS@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -125,6 +127,7 @@ PCRECONFIG = @PCRECONFIG@ PCRE_LIB = @PCRE_LIB@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ +SED = @SED@ SENDFILE_LIB = @SENDFILE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -193,7 +196,7 @@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -EXTRA_DIST = cgi.php cgi.pl dummydir index.html index.txt phpinfo.php \ +EXTRA_DIST = cgi.php cgi.pl index.html index.txt phpinfo.php \ redirect.php cgi-pathinfo.pl get-env.php get-server-env.php \ nph-status.pl prefix.fcgi get-header.pl ssi.shtml get-post-len.pl \ exec-date.shtml index.html~ 404.fcgi 404.html 404.pl send404.pl crlfcrash.pl @@ -313,8 +316,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -339,8 +342,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ @@ -350,13 +353,12 @@ ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ - here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique diff --git a/tests/docroot/www/expire/Makefile.in b/tests/docroot/www/expire/Makefile.in index 94c066a..89098cd 100644 --- a/tests/docroot/www/expire/Makefile.in +++ b/tests/docroot/www/expire/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. +# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -67,6 +67,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -101,6 +102,7 @@ MKDIR_P = @MKDIR_P@ MYSQL_CONFIG = @MYSQL_CONFIG@ MYSQL_INCLUDE = @MYSQL_INCLUDE@ MYSQL_LIBS = @MYSQL_LIBS@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -113,6 +115,7 @@ PCRECONFIG = @PCRECONFIG@ PCRE_LIB = @PCRE_LIB@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ +SED = @SED@ SENDFILE_LIB = @SENDFILE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ diff --git a/tests/docroot/www/get-env.php b/tests/docroot/www/get-env.php index 8af72a6..cd7fa04 100644 --- a/tests/docroot/www/get-env.php +++ b/tests/docroot/www/get-env.php @@ -1,3 +1,4 @@ <?php - print $_ENV[$_GET["env"]]; + $env = $_GET["env"]; + print isset($_ENV[$env]) ? $_ENV[$env] : ''; ?> diff --git a/tests/docroot/www/go/Makefile.in b/tests/docroot/www/go/Makefile.in index 0263d24..ab21c41 100644 --- a/tests/docroot/www/go/Makefile.in +++ b/tests/docroot/www/go/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. +# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -67,6 +67,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -101,6 +102,7 @@ MKDIR_P = @MKDIR_P@ MYSQL_CONFIG = @MYSQL_CONFIG@ MYSQL_INCLUDE = @MYSQL_INCLUDE@ MYSQL_LIBS = @MYSQL_LIBS@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -113,6 +115,7 @@ PCRECONFIG = @PCRECONFIG@ PCRE_LIB = @PCRE_LIB@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ +SED = @SED@ SENDFILE_LIB = @SENDFILE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ diff --git a/tests/docroot/www/indexfile/Makefile.in b/tests/docroot/www/indexfile/Makefile.in index ca9fa35..9327c13 100644 --- a/tests/docroot/www/indexfile/Makefile.in +++ b/tests/docroot/www/indexfile/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. +# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -67,6 +67,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -101,6 +102,7 @@ MKDIR_P = @MKDIR_P@ MYSQL_CONFIG = @MYSQL_CONFIG@ MYSQL_INCLUDE = @MYSQL_INCLUDE@ MYSQL_LIBS = @MYSQL_LIBS@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -113,6 +115,7 @@ PCRECONFIG = @PCRECONFIG@ PCRE_LIB = @PCRE_LIB@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ +SED = @SED@ SENDFILE_LIB = @SENDFILE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ diff --git a/tests/env-variables.conf b/tests/env-variables.conf deleted file mode 100644 index 043e788..0000000 --- a/tests/env-variables.conf +++ /dev/null @@ -1 +0,0 @@ -server.document-root = env.CWD diff --git a/tests/env-variables.t b/tests/env-variables.t deleted file mode 100644 index ee48ee9..0000000 --- a/tests/env-variables.t +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/perl -BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s,/[^/]+$,/,; - unshift @INC, $srcdir; -} - -use strict; -use IO::Socket; -use Test::More tests => 2; -use LightyTest; - -my $tf = LightyTest->new(); -$tf->{CONFIGFILE} = 'env-variables.conf'; - -TODO: { - local $TODO = 'we still crash on undefined environment variables'; - ok($tf->start_proc == 0, "Starting lighttpd"); - ok($tf->stop_proc == 0, "Stopping lighttpd"); -}; diff --git a/tests/fastcgi-10.conf b/tests/fastcgi-10.conf index c13d564..f313b41 100644 --- a/tests/fastcgi-10.conf +++ b/tests/fastcgi-10.conf @@ -1,5 +1,4 @@ server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" ## bind to port (default: 80) server.port = 2048 diff --git a/tests/fastcgi-13.conf b/tests/fastcgi-13.conf index 6ef0386..418170b 100644 --- a/tests/fastcgi-13.conf +++ b/tests/fastcgi-13.conf @@ -1,5 +1,4 @@ server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" debug.log-request-header = "enable" debug.log-response-header = "enable" @@ -85,7 +84,7 @@ fastcgi.server = ( ".php" => ( "grisu" => ( "host" => "127.0.0.1", "port" => 1048, - "bin-path" => "/usr/bin/php-cgi", + "bin-path" => env.PHP, "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), ) ) diff --git a/tests/fastcgi-auth.conf b/tests/fastcgi-auth.conf index 00b0060..fadc37c 100644 --- a/tests/fastcgi-auth.conf +++ b/tests/fastcgi-auth.conf @@ -1,5 +1,4 @@ server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" debug.log-request-header = "enable" debug.log-response-header = "enable" @@ -90,6 +89,7 @@ fastcgi.server = ( "/" => ( "bin-path" => env.SRCDIR + "/fcgi-auth", "mode" => "authorizer", "docroot" => env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/", + "check-local" => "disable", ) ) diff --git a/tests/fastcgi-responder.conf b/tests/fastcgi-responder.conf index be5a97e..6a78242 100644 --- a/tests/fastcgi-responder.conf +++ b/tests/fastcgi-responder.conf @@ -1,5 +1,4 @@ server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" #debug.log-request-header = "enable" #debug.log-response-header = "enable" diff --git a/tests/lighttpd.conf b/tests/lighttpd.conf index 71a37fe..b4a90c4 100644 --- a/tests/lighttpd.conf +++ b/tests/lighttpd.conf @@ -3,7 +3,6 @@ debug.log-request-header = "enable" debug.log-response-header = "enable" debug.log-condition-handling = "enable" server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" ## 64 Mbyte ... nice limit server.max-request-size = 65000 @@ -218,4 +217,5 @@ $HTTP["cookie"] =~ "empty-ref" { $HTTP["host"] == "etag.example.org" { static-file.etags = "disable" + compress.filetype = () } diff --git a/tests/lowercase.conf b/tests/lowercase.conf index 557a703..ae91005 100644 --- a/tests/lowercase.conf +++ b/tests/lowercase.conf @@ -1,5 +1,4 @@ server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" ## bind to port (default: 80) server.port = 2048 diff --git a/tests/mod-compress.conf b/tests/mod-compress.conf new file mode 100644 index 0000000..02da904 --- /dev/null +++ b/tests/mod-compress.conf @@ -0,0 +1,32 @@ +debug.log-request-handling = "enable" +debug.log-response-header = "disable" +debug.log-request-header = "disable" + +server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" +server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" + +## bind to port (default: 80) +server.port = 2048 + +## bind to localhost (default: all interfaces) +server.bind = "localhost" +server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" +server.name = "www.example.org" + +server.modules = ( + "mod_compress" +) + +######################## MODULE CONFIG ############################ + +mimetype.assign = ( + ".html" => "text/html", + ".txt" => "text/plain", +) + +$HTTP["host"] == "cache.example.org" { + compress.cache-dir = env.SRCDIR + "/tmp/lighttpd/cache/compress/" +} +compress.filetype = ("text/plain", "text/html") + +compress.allowed-encodings = ( "gzip", "deflate" ) diff --git a/tests/mod-compress.t b/tests/mod-compress.t index 4fa66db..63f3d2a 100755 --- a/tests/mod-compress.t +++ b/tests/mod-compress.t @@ -8,12 +8,14 @@ BEGIN { use strict; use IO::Socket; -use Test::More tests => 10; +use Test::More tests => 11; use LightyTest; my $tf = LightyTest->new(); my $t; +$tf->{CONFIGFILE} = 'mod-compress.conf'; + ok($tf->start_proc == 0, "Starting lighttpd") or die(); $t->{REQUEST} = ( <<EOF @@ -88,5 +90,14 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Type' => "text/plain" } ]; ok($tf->handle_http($t) == 0, 'Empty Accept-Encoding'); +$t->{REQUEST} = ( <<EOF +GET /index.txt HTTP/1.0 +Accept-Encoding: bzip2, gzip, deflate +Host: cache.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Encoding' => 'gzip', 'Content-Type' => "text/plain" } ]; +ok($tf->handle_http($t) == 0, 'bzip2 requested but disabled'); + ok($tf->stop_proc == 0, "Stopping lighttpd"); diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t index 44b4b03..f0ae0b4 100755 --- a/tests/mod-fastcgi.t +++ b/tests/mod-fastcgi.t @@ -7,17 +7,27 @@ BEGIN { } use strict; -use Test::More tests => 47; +use Test::More tests => 50; use LightyTest; my $tf = LightyTest->new(); my $t; +my $php_child = -1; + +my $phpbin = (defined $ENV{'PHP'} ? $ENV{'PHP'} : '/usr/bin/php-cgi'); +$ENV{'PHP'} = $phpbin; + +SKIP: { + skip "PHP already running on port 1026", 1 if $tf->listening_on(1026); + skip "no php binary found", 1 unless -x $phpbin; + ok(-1 != ($php_child = $tf->spawnfcgi($phpbin, 1026)), "Spawning php"); +} SKIP: { skip "no PHP running on port 1026", 29 unless $tf->listening_on(1026); - ok($tf->start_proc == 0, "Starting lighttpd") or die(); + ok($tf->start_proc == 0, "Starting lighttpd") or goto cleanup; $t->{REQUEST} = ( <<EOF GET /phpinfo.php HTTP/1.0 @@ -65,7 +75,7 @@ Host: www.example.org EOF ); $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/get-server-env.php' } ]; - ok($tf->handle_http($t) == 0, '$_SERVER["PHP_SELF"]'); + ok($tf->handle_http($t) == 0, '$_SERVER["SCRIPT_NAME"]'); $t->{REQUEST} = ( <<EOF GET /get-server-env.php/foo?env=PATH_INFO HTTP/1.0 @@ -161,7 +171,7 @@ EOF $tf->{CONFIGFILE} = 'fastcgi-10.conf'; - ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); + ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or goto cleanup; $t->{REQUEST} = ( <<EOF GET /get-server-env.php?env=SERVER_NAME HTTP/1.0 Host: zzz.example.org @@ -173,7 +183,7 @@ EOF ok($tf->stop_proc == 0, "Stopping lighttpd"); $tf->{CONFIGFILE} = 'bug-06.conf'; - ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); + ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or goto cleanup; $t->{REQUEST} = ( <<EOF GET /indexfile/ HTTP/1.0 Host: www.example.org @@ -185,7 +195,7 @@ EOF ok($tf->stop_proc == 0, "Stopping lighttpd"); $tf->{CONFIGFILE} = 'bug-12.conf'; - ok($tf->start_proc == 0, "Starting lighttpd with bug-12.conf") or die(); + ok($tf->start_proc == 0, "Starting lighttpd with bug-12.conf") or goto cleanup; $t->{REQUEST} = ( <<EOF POST /indexfile/abc HTTP/1.0 Host: www.example.org @@ -199,7 +209,13 @@ EOF } SKIP: { - skip "no fcgi-auth found", 4 unless -x $tf->{BASEDIR}."/tests/fcgi-auth" || -x $tf->{BASEDIR}."/tests/fcgi-auth.exe"; + skip "PHP not started, cannot stop it", 1 unless $php_child != -1; + ok(0 == $tf->endspawnfcgi($php_child), "Stopping php"); + $php_child = -1; +} + +SKIP: { + skip "no fcgi-auth found", 5 unless -x $tf->{BASEDIR}."/tests/fcgi-auth" || -x $tf->{BASEDIR}."/tests/fcgi-auth.exe"; $tf->{CONFIGFILE} = 'fastcgi-auth.conf'; ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); @@ -219,11 +235,19 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; ok($tf->handle_http($t) == 0, 'FastCGI - Auth'); + $t->{REQUEST} = ( <<EOF +GET /expire/access.txt?ok HTTP/1.0 +Host: www.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; + ok($tf->handle_http($t) == 0, 'FastCGI - Auth in subdirectory'); + ok($tf->stop_proc == 0, "Stopping lighttpd"); } SKIP: { - skip "no php found", 5 unless -x "/usr/bin/php-cgi"; + skip "no php found", 5 unless -x $phpbin; $tf->{CONFIGFILE} = 'fastcgi-13.conf'; ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); $t->{REQUEST} = ( <<EOF @@ -325,3 +349,10 @@ EOF ok($tf->stop_proc == 0, "Stopping lighttpd"); } +exit 0; + +cleanup: ; + +$tf->endspawnfcgi($php_child) if $php_child != -1; + +die(); diff --git a/tests/mod-proxy.t b/tests/mod-proxy.t index b43c465..0c7283e 100755 --- a/tests/mod-proxy.t +++ b/tests/mod-proxy.t @@ -8,13 +8,23 @@ BEGIN { use strict; use IO::Socket; -use Test::More tests => 6; +use Test::More tests => 9; use LightyTest; my $tf_real = LightyTest->new(); my $tf_proxy = LightyTest->new(); my $t; +my $php_child = -1; + +my $phpbin = (defined $ENV{'PHP'} ? $ENV{'PHP'} : '/usr/bin/php-cgi'); +$ENV{'PHP'} = $phpbin; + +SKIP: { + skip "PHP already running on port 1026", 1 if $tf_real->listening_on(1026); + skip "no php binary found", 1 unless -x $phpbin; + ok(-1 != ($php_child = $tf_real->spawnfcgi($phpbin, 1026)), "Spawning php"); +} ## we need two procs ## 1. the real webserver @@ -22,15 +32,13 @@ my $t; $tf_real->{PORT} = 2048; $tf_real->{CONFIGFILE} = 'lighttpd.conf'; -$tf_real->{LIGHTTPD_PIDFILE} = $tf_real->{TESTDIR}.'/tmp/lighttpd/lighttpd.pid'; $tf_proxy->{PORT} = 2050; $tf_proxy->{CONFIGFILE} = 'proxy.conf'; -$tf_proxy->{LIGHTTPD_PIDFILE} = $tf_proxy->{TESTDIR}.'/tmp/lighttpd/lighttpd-proxy.pid'; -ok($tf_real->start_proc == 0, "Starting lighttpd") or die(); +ok($tf_real->start_proc == 0, "Starting lighttpd") or goto cleanup; -ok($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or die(); +ok($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or goto cleanup; $t->{REQUEST} = ( <<EOF GET /index.html HTTP/1.0 @@ -48,6 +56,31 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Server' => 'Apache 1.3.29' } ]; ok($tf_proxy->handle_http($t) == 0, 'drop Server from real server'); +SKIP: { + skip "no PHP running on port 1026", 1 unless $tf_real->listening_on(1026); + $t->{REQUEST} = ( <<EOF +GET /rewrite/all/some+test%3axxx%20with%20space HTTP/1.0 +Host: www.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/some+test%3axxx%20with%20space' } ]; + ok($tf_proxy->handle_http($t) == 0, 'rewrited urls work with encoded path'); +} + ok($tf_proxy->stop_proc == 0, "Stopping lighttpd proxy"); ok($tf_real->stop_proc == 0, "Stopping lighttpd"); + +SKIP: { + skip "PHP not started, cannot stop it", 1 unless $php_child != -1; + ok(0 == $tf_real->endspawnfcgi($php_child), "Stopping php"); + $php_child = -1; +} + +exit 0; + +cleanup: + +$tf_real->endspawnfcgi($php_child) if $php_child != -1; + +die(); diff --git a/tests/mod-rewrite.t b/tests/mod-rewrite.t index 4de8c10..5cb3323 100755 --- a/tests/mod-rewrite.t +++ b/tests/mod-rewrite.t @@ -8,17 +8,25 @@ BEGIN { use strict; use IO::Socket; -use Test::More tests => 5; +use Test::More tests => 7; use LightyTest; my $tf = LightyTest->new(); my $t; +my $php_child = -1; +my $phpbin = (defined $ENV{'PHP'} ? $ENV{'PHP'} : '/usr/bin/php-cgi'); + +SKIP: { + skip "PHP already running on port 1026", 1 if $tf->listening_on(1026); + skip "no php binary found", 1 unless -x $phpbin; + ok(-1 != ($php_child = $tf->spawnfcgi($phpbin, 1026)), "Spawning php"); +} SKIP: { skip "no PHP running on port 1026", 5 unless $tf->listening_on(1026); - ok($tf->start_proc == 0, "Starting lighttpd") or die(); + ok($tf->start_proc == 0, "Starting lighttpd") or goto cleanup; $t->{REQUEST} = ( <<EOF GET /rewrite/foo HTTP/1.0 @@ -27,7 +35,7 @@ EOF ); $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '' } ]; ok($tf->handle_http($t) == 0, 'valid request'); - + $t->{REQUEST} = ( <<EOF GET /rewrite/foo?a=b HTTP/1.0 Host: www.example.org @@ -46,3 +54,17 @@ EOF ok($tf->stop_proc == 0, "Stopping lighttpd"); } + +SKIP: { + skip "PHP not started, cannot stop it", 1 unless $php_child != -1; + ok(0 == $tf->endspawnfcgi($php_child), "Stopping php"); +} + + +exit 0; + +cleanup: ; + +$tf->endspawnfcgi($php_child) if $php_child != -1; + +die(); diff --git a/tests/proxy.conf b/tests/proxy.conf index 2d1ab0d..769cf69 100644 --- a/tests/proxy.conf +++ b/tests/proxy.conf @@ -1,5 +1,4 @@ server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd-proxy.pid" ## bind to port (default: 80) server.port = 2050 @@ -123,7 +122,8 @@ url.access-deny = ( "~", ".inc") url.redirect = ( "^/redirect/$" => "http://localhost:2048/" ) url.rewrite = ( "^/rewrite/foo($|\?.+)" => "/indexfile/rewrite.php$1", - "^/rewrite/bar(?:$|\?(.+))" => "/indexfile/rewrite.php?bar&$1" ) + "^/rewrite/bar(?:$|\?(.+))" => "/indexfile/rewrite.php?bar&$1", + "^/rewrite/all(/.*)$" => "/indexfile/rewrite.php?$1" ) expire.url = ( "/expire/access" => "access 2 hours", "/expire/modification" => "access plus 1 seconds 2 minutes") diff --git a/tests/request.t b/tests/request.t index d2c8819..ab4f2d2 100755 --- a/tests/request.t +++ b/tests/request.t @@ -101,7 +101,7 @@ Connection: close Expect: 100-continue EOF ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417, '-HTTP-Content' => ''} ]; +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417 } ]; ok($tf->handle_http($t) == 0, 'Continue, Expect'); ## ranges diff --git a/tests/run-tests.pl b/tests/run-tests.pl index 818f1c2..54cf7bf 100755 --- a/tests/run-tests.pl +++ b/tests/run-tests.pl @@ -3,17 +3,18 @@ use strict; use Test::Harness qw(&runtests $verbose); -$verbose = (defined $ENV{'VERBOSE'} ? $ENV{'VERBOSE'} : 0);; +$verbose = (defined $ENV{'VERBOSE'} ? $ENV{'VERBOSE'} : 0); +my $tests = (defined $ENV{'TESTS'} ? $ENV{'TESTS'} : ''); my $srcdir = (defined $ENV{'srcdir'} ? $ENV{'srcdir'} : '.'); opendir DIR, $srcdir; my (@fs, $f); while ($f = readdir(DIR)) { - if ($f =~ /\.t$/) { + if ($f =~ /^(.*)\.t$/) { + next if ($tests ne '' and $tests !~ /(^|\s+)$1(\s+|$)/); push @fs, $srcdir.'/'.$f; } } closedir DIR; runtests @fs; - diff --git a/tests/symlink.t b/tests/symlink.t index 9b275bd..9b275bd 100644..100755 --- a/tests/symlink.t +++ b/tests/symlink.t diff --git a/tests/var-include.conf b/tests/var-include.conf index 4cf6113..6b42bb0 100644 --- a/tests/var-include.conf +++ b/tests/var-include.conf @@ -3,7 +3,6 @@ debug.log-request-handling = "enable" debug.log-condition-handling = "enable" server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" ## bind to port (default: 80) server.port = 2048 |