From 3bb07cad076aa5c9a7d78ef6df647ab3c311dc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 29 Jul 2008 21:22:28 +0000 Subject: [tests] Fixed tests needing php running (if not running on port 1026, search php in env[PHP] or /usr/bin/php-cgi) git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2243 152afb58-edef-0310-8abb-c4023f1b3aa9 --- tests/mod-fastcgi.t | 32 +++++++++++++++++++++++++++----- tests/mod-rewrite.t | 28 +++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t index 5ae3c994..d03ed2fc 100755 --- a/tests/mod-fastcgi.t +++ b/tests/mod-fastcgi.t @@ -7,17 +7,26 @@ BEGIN { } use strict; -use Test::More tests => 47; +use Test::More tests => 49; 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", 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} = ( <{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} = ( <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} = ( <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} = ( <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"); + $php_child = -1; +} + SKIP: { skip "no fcgi-auth found", 4 unless -x $tf->{BASEDIR}."/tests/fcgi-auth" || -x $tf->{BASEDIR}."/tests/fcgi-auth.exe"; @@ -325,3 +340,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-rewrite.t b/tests/mod-rewrite.t index 4de8c107..5cb3323e 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} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '' } ]; ok($tf->handle_http($t) == 0, 'valid request'); - + $t->{REQUEST} = ( <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(); -- cgit v1.2.1