Subject: | Another KILL vs. INT issue causing tests fail on Win32 |
Date: | Sun, 21 Jun 2009 22:59:46 +0200 |
To: | bug-RPC-XML [...] rt.cpan.org |
From: | kmx <kmx [...] volny.cz> |
diff -r -u ..\RPC-XML-0.65\t/40_server.t t/40_server.t
--- ..\RPC-XML-0.65\t/40_server.t 2009-06-13 06:03:22.000000000 +0200
+++ t/40_server.t 2009-06-21 21:51:37.077769000 +0200
@@ -25,10 +25,6 @@
(undef, $dir, undef) = File::Spec->splitpath(File::Spec->rel2abs($0));
require File::Spec->catfile($dir, 'util.pl');
-# Per RT 27778, use 'KILL' instead of 'INT' as the stop-server signal for
-# MSWin platforms:
-my $SIGNAL = ($^O eq "MSWin32") ? 'KILL' : 'INT';
-
# The organization of the test suites is such that we assume anything that
# runs before the current suite is 100%. Thus, no consistency checks on
# any other classes are done, only on the data and return values of this
@@ -110,14 +106,13 @@
is($res->value->value, 1, 'First live req: $res value test');
}
}
-kill $SIGNAL, $child;
+stop_server($child);
# Try deleting the method
ok(ref $srv->delete_method('perl.test.suite.test1'),
'delete_method return value test');
# Start the server again
-sleep 1; # To allow the old sockets time enough to go away
# Add a method that echoes back socket-peer information
$res = $srv->add_method({ name => 'perl.test.suite.peeraddr',
signature => [ 'array' ],
@@ -154,10 +149,9 @@
'Second live request: correct faultString');
}
}
-kill $SIGNAL, $child;
+stop_server($child);
# Start the server again
-sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
$bucket = 0;
$req->content(RPC::XML::request->new('perl.test.suite.peeraddr')->as_string);
@@ -184,10 +178,9 @@
'Third request: pack_sockaddr_in validates all');
}
}
-kill $SIGNAL, $child;
+stop_server($child);
# Start the server again
-sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
# Test the error-message-mixup problem reported in RT# 29351
@@ -223,7 +216,7 @@
'RT29351 live request: correct faultString');
}
}
-kill $SIGNAL, $child;
+stop_server($child);
# OK-- At this point, basic server creation and accessors have been validated.
# We've run a remote method and we've correctly failed to run an unknown remote
@@ -278,10 +271,9 @@
die "Server allocation failed, cannot continue. Message was: $srv"
unless (ref $srv);
-kill $SIGNAL, $child;
+stop_server($child);
# Start the server again
-sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
# Set the ALRM handler to something more serious, since we have passed that
@@ -307,10 +299,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -331,10 +322,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -353,10 +343,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -381,10 +370,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -407,10 +395,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -432,10 +419,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -459,10 +445,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -485,10 +470,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -513,10 +497,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -539,10 +522,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -588,10 +570,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -619,10 +600,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -649,10 +629,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -679,10 +658,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -707,10 +685,9 @@
# HTTP::Message::content might have killed it already via croak().
unless ($res) # $res was made null above if it was an error
{
- kill $SIGNAL, $child;
+ stop_server($child);
# Start the server again
- sleep 1; # To allow the old sockets time enough to go away
$child = start_server($srv);
}
@@ -727,5 +704,5 @@
}
# Don't leave any children laying around
-kill $SIGNAL, $child;
+stop_server($child);
exit;
diff -r -u ..\RPC-XML-0.65\t/50_client.t t/50_client.t
--- ..\RPC-XML-0.65\t/50_client.t 2009-06-16 00:45:26.000000000 +0200
+++ t/50_client.t 2009-06-21 22:53:27.362855000 +0200
@@ -92,8 +92,7 @@
{
# Assume that if an error occurred, the server might be in a confused
# state. Kill and restart it.
- kill 'INT', $child;
- sleep 1; # Give it time to free up the socket
+ stop_server($child);
$child = start_server($srv);
}
@@ -113,8 +112,7 @@
{
# Assume that if an error occurred, the server might be in a confused
# state. Kill and restart it.
- kill 'INT', $child;
- sleep 1; # Give it time to free up the socket
+ stop_server($child);
$child = start_server($srv);
}
@@ -132,8 +130,7 @@
{
# Assume that if an error occurred, the server might be in a confused
# state. Kill and restart it.
- kill 'INT', $child;
- sleep 1; # Give it time to free up the socket
+ stop_server($child);
$child = start_server($srv);
}
@@ -158,8 +155,7 @@
{
# Assume that if an error occurred, the server might be in a confused
# state. Kill and restart it.
- kill 'INT', $child;
- sleep 1; # Give it time to free up the socket
+ stop_server($child);
$child = start_server($srv);
}
@@ -173,8 +169,7 @@
'RPC::XML::Client::uri changes as expected');
# Kill the server long enough to add a new method
-kill 'INT', $child;
-sleep 1; # Give system enough time to reclaim resources
+stop_server($child);
use Digest::MD5;
@@ -232,6 +227,6 @@
}
# Kill the server before exiting
-kill 'INT', $child;
+stop_server($child);
exit;
diff -r -u ..\RPC-XML-0.65\t/util.pl t/util.pl
--- ..\RPC-XML-0.65\t/util.pl 2009-03-25 08:11:02.000000000 +0100
+++ t/util.pl 2009-06-21 21:47:52.965583000 +0200
@@ -24,6 +24,17 @@
}
}
+sub stop_server
+{
+ my $pid = shift;
+
+ # Per RT 27778, use 'KILL' instead of 'INT' as the stop-server signal for
+ # MSWin platforms:
+ my $SIGNAL = ($^O eq "MSWin32") ? 'KILL' : 'INT';
+ kill $SIGNAL, $pid;
+ sleep 2; # give the old sockets time to go away
+}
+
sub find_port
{
my $start_at = $_[0] || 9000;
Hi again,
after fixing KILL vs. INT issue in 40_server.t (RT 27778 fixed in
RPC-XML-0.65) I have found the same issue in 50_client.t
Please find proposed patch that adds a new function stop_server into
util.pl and makes necessary modification to 40_server.t + 50_client.t
--
kmx