changeset 96:ecff5407867c

Tests: better handle unexpected connection close from nginx. Problem found when running test suite indefinitely against nginx with intentionally broken malloc().
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 08 Jun 2009 23:27:30 +0400
parents cbc17561ef4d
children 506586cc2f3b
files imap.t lib/Test/Nginx.pm pop3.t smtp-xclient.t smtp.t
diffstat 5 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/imap.t
+++ b/imap.t
@@ -26,6 +26,8 @@ use Test::Nginx::IMAP;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
+local $SIG{PIPE} = 'IGNORE';
+
 my $t = Test::Nginx->new()
 	->has('mail')->plan(8)
 	->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon)
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -254,7 +254,8 @@ sub http($;%) {
 	my ($request, %extra) = @_;
 	my $reply;
 	eval {
-		local $SIG{ALRM} = sub { die "alarm\n" };
+		local $SIG{ALRM} = sub { die "timeout\n" };
+		local $SIG{PIPE} = sub { die "sigpipe\n" };
 		alarm(2);
 		my $s = IO::Socket::INET->new(
 			Proto => 'tcp',
@@ -271,7 +272,7 @@ sub http($;%) {
 	};
 	alarm(0);
 	if ($@) {
-		log_in('(timeout)');
+		log_in("died: $@");
 		return undef;
 	}
 	return $reply;
--- a/pop3.t
+++ b/pop3.t
@@ -26,6 +26,8 @@ use Test::Nginx::POP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
+local $SIG{PIPE} = 'IGNORE';
+
 my $t = Test::Nginx->new()
 	->has('mail')->plan(8)
 	->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon)
--- a/smtp-xclient.t
+++ b/smtp-xclient.t
@@ -23,6 +23,8 @@ use Test::Nginx::SMTP;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
+local $SIG{PIPE} = 'IGNORE';
+
 my $t = Test::Nginx->new()->has('mail')->plan(6)
 	->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon)
 	->write_file_expand('nginx.conf', <<'EOF')->run();
--- a/smtp.t
+++ b/smtp.t
@@ -25,6 +25,8 @@ use Test::Nginx::SMTP;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
+local $SIG{PIPE} = 'IGNORE';
+
 my $t = Test::Nginx->new()
 	->has('mail')->plan(25)
 	->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon)