# HG changeset patch # User Maxim Dounin # Date 1292430159 -10800 # Node ID 6e11354cae8ad4c3f637c09c22980efe2be43a6d # Parent e8546edb026749da48008170fcea97aea6458450 Tests: rework stopping to make "open socket left" alerts visible. Use SIGQUIT to stop nginx to make sure relevant checks are executed. Use separate functions to stop nginx and daemons to make it possible to stop nginx before daemons. diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -46,6 +46,7 @@ sub new { sub DESTROY { my ($self) = @_; $self->stop(); + $self->stop_daemons(); if ($ENV{TEST_NGINX_CATLOG}) { system("cat $self->{_testdir}/error.log"); } @@ -196,19 +197,25 @@ sub waitforsocket($) { sub stop() { my ($self) = @_; + return $self unless $self->{_started}; + + kill 'QUIT', `cat $self->{_testdir}/nginx.pid`; + wait; + + $self->{_started} = 0; + + return $self; +} + +sub stop_daemons() { + my ($self) = @_; + while ($self->{_daemons} && scalar @{$self->{_daemons}}) { my $p = shift @{$self->{_daemons}}; kill 'TERM', $p; wait; } - return $self unless $self->{_started}; - - kill 'TERM', `cat $self->{_testdir}/nginx.pid`; - wait; - - $self->{_started} = 0; - return $self; }