Subject: | Bug in test 500_ping_icmp and 510_ping_udp |
I am running under Cygwin on a machine that has the localhost IP
firewalled, and so the ICMP and UDP tests fail. Apparently there is code
to detect this in the ping_stream test, so I simply replicated it to the
ICMP and UDP tests, which were failing.
Here are the patch diffs.
Michael.
diff -u t.orig/500_ping_icmp.t t/500_ping_icmp.t
--- t.orig/500_ping_icmp.t 2007-07-30 21:32:24.000000000 -0500
+++ t/500_ping_icmp.t 2007-11-30 15:16:33.455144500 -0600
@@ -6,6 +6,17 @@
print "1..0 \# Skip: no Socket\n";
exit;
}
+ if (my $port = getservbyname('echo', 'tcp')) {
+ socket(*ECHO, &Socket::PF_INET(), &Socket::SOCK_STREAM(),
(getprotobyname 'tcp')[2]);
+ unless (connect(*ECHO, scalar &Socket::sockaddr_in($port,
&Socket::inet_aton("localhost")))) {
+ print "1..0 \# Skip: loopback tcp echo service is off ($!)\n";
+ exit;
+ }
+ close (*ECHO);
+ } else {
+ print "1..0 \# Skip: no echo port\n";
+ exit;
+ }
}
use Test;
@@ -25,7 +36,7 @@
skip "icmp protocol not supported.", 1;
} else {
my $p = new Net::Ping "icmp";
- ok $p->ping("127.0.0.1");
+ ok $p->ping("localhost");
}
sub IsAdminUser {
diff -u t.orig/510_ping_udp.t t/510_ping_udp.t
--- t.orig/510_ping_udp.t 2007-07-30 21:32:24.000000000 -0500
+++ t/510_ping_udp.t 2007-11-30 15:16:42.337405200 -0600
@@ -5,6 +5,17 @@
print "1..0 \# Skip: no Socket\n";
exit;
}
+ if (my $port = getservbyname('echo', 'tcp')) {
+ socket(*ECHO, &Socket::PF_INET(), &Socket::SOCK_STREAM(),
(getprotobyname 'tcp')[2]);
+ unless (connect(*ECHO, scalar &Socket::sockaddr_in($port,
&Socket::inet_aton("localhost")))) {
+ print "1..0 \# Skip: loopback tcp echo service is off ($!)\n";
+ exit;
+ }
+ close (*ECHO);
+ } else {
+ print "1..0 \# Skip: no echo port\n";
+ exit;
+ }
unless (getservbyname('echo', 'tcp')) {
print "1..0 \# Skip: no echo port\n";
exit;
@@ -19,4 +30,4 @@
ok 1;
my $p = new Net::Ping "udp";
-ok $p->ping("127.0.0.1");
+ok $p->ping("localhost");