changeset 960:d4a0232425ee

Tests: fixed race in SCGI tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 24 Jun 2016 16:30:08 +0300
parents 508ee7ea9706
children 4993ece8620e
files scgi.t scgi_body.t scgi_cache.t scgi_gzip.t scgi_merge_params.t
diffstat 5 files changed, 17 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/scgi.t
+++ b/scgi.t
@@ -64,7 +64,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run();
+$t->run()->waitforsocket('127.0.0.1:' . port(1));
 
 ###############################################################################
 
@@ -126,8 +126,10 @@ sub scgi_daemon {
 	my $count = 0;
 
 	while (my $request = $scgi->accept()) {
+		eval { $request->read_env(); };
+		next if $@;
+
 		$count++;
-		$request->read_env();
 
 		$request->connection()->print(<<EOF);
 Location: http://localhost/redirect
--- a/scgi_body.t
+++ b/scgi_body.t
@@ -52,7 +52,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run();
+$t->run()->waitforsocket('127.0.0.1:' . port(1));
 
 ###############################################################################
 
@@ -114,7 +114,9 @@ sub scgi_daemon {
 	my $body;
 
 	while (my $request = $scgi->accept()) {
-		$request->read_env();
+		eval { $request->read_env(); };
+		next if $@;
+
 		read($request->connection, $body,
 			$request->env->{CONTENT_LENGTH});
 
--- a/scgi_cache.t
+++ b/scgi_cache.t
@@ -59,7 +59,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run();
+$t->run()->waitforsocket('127.0.0.1:' . port(1));
 
 ###############################################################################
 
@@ -93,7 +93,8 @@ sub scgi_daemon {
 	my %count;
 
 	while (my $request = $scgi->accept()) {
-		$request->read_env();
+		eval { $request->read_env(); };
+		next if $@;
 
 		my $uri = $request->env->{REQUEST_URI} || '';
 		my $c = $request->connection();
--- a/scgi_gzip.t
+++ b/scgi_gzip.t
@@ -54,7 +54,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run();
+$t->run()->waitforsocket('127.0.0.1:' . port(1));
 
 ###############################################################################
 
@@ -74,7 +74,8 @@ sub scgi_daemon {
 	my $scgi = SCGI->new($server, blocking => 1);
 
 	while (my $request = $scgi->accept()) {
-		$request->read_env();
+		eval { $request->read_env(); };
+		next if $@;
 
 		$request->connection()->print(<<EOF);
 Content-Type: text/html
--- a/scgi_merge_params.t
+++ b/scgi_merge_params.t
@@ -71,7 +71,7 @@ http {
 EOF
 
 $t->run_daemon(\&scgi_daemon);
-$t->run();
+$t->run()->waitforsocket('127.0.0.1:' . port(1));
 
 ###############################################################################
 
@@ -122,11 +122,10 @@ sub scgi_daemon {
 		or die "Can't create listening socket: $!\n";
 
 	my $scgi = SCGI->new($server, blocking => 1);
-	my $count = 0;
 
 	while (my $request = $scgi->accept()) {
-		$count++;
-		$request->read_env();
+		eval { $request->read_env(); };
+		next if $@;
 
 		my $ims = $request->env->{HTTP_IF_MODIFIED_SINCE} || '';
 		my $iums = $request->env->{HTTP_IF_UNMODIFIED_SINCE} || '';