# HG changeset patch # User Maxim Dounin # Date 1244489250 -14400 # Node ID ecff5407867c5cc497e21747a2eb385b4c3bbcb2 # Parent cbc17561ef4d7d8522721179cdb205951d605d8f Tests: better handle unexpected connection close from nginx. Problem found when running test suite indefinitely against nginx with intentionally broken malloc(). diff --git a/imap.t b/imap.t --- 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) diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- 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; diff --git a/pop3.t b/pop3.t --- 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) diff --git a/smtp-xclient.t b/smtp-xclient.t --- 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(); diff --git a/smtp.t b/smtp.t --- 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)