summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2008-07-29 21:22:28 +0000
committerStefan Bühler <stbuehler@web.de>2008-07-29 21:22:28 +0000
commit3bb07cad076aa5c9a7d78ef6df647ab3c311dc04 (patch)
treefea63bd30718da7a841118a788739de57a794516
parentcbd40dc44bed9537fd02c3c1608de68e055c2962 (diff)
downloadlighttpd-git-3bb07cad076aa5c9a7d78ef6df647ab3c311dc04.tar.gz
[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
-rw-r--r--NEWS1
-rwxr-xr-xtests/mod-fastcgi.t32
-rwxr-xr-xtests/mod-rewrite.t28
3 files changed, 53 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index b8b53163..3976aef2 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,7 @@ NEWS
* fix scgi HTTP/1.* status parsing (#1638), found by met@uberstats.com
* [tests] fixed system, use foreground daemons and waitpid
* [tests] removed pidfile from test system
+ * [tests] fixed tests needing php running (if not running on port 1026, search php in env[PHP] or /usr/bin/php-cgi)
- 1.4.19 - 2008-03-10
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} = ( <<EOF
GET /phpinfo.php HTTP/1.0
@@ -161,7 +170,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 +182,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 +194,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,6 +208,12 @@ EOF
}
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";
$tf->{CONFIGFILE} = 'fastcgi-auth.conf';
@@ -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} = ( <<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();