Skip Menu |

This queue is for tickets about the Net-Ping CPAN distribution.

Report information
The Basics
Id: 31116
Status: resolved
Priority: 0/
Queue: Net-Ping

People
Owner: Nobody in particular
Requestors: MIKEKING [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.33
Fixed in: (no value)



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");
On Fri Nov 30 16:23:30 2007, MIKEKING wrote: Show quoted text
> 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");
I added the changes to t/510_ping_udp.t to Net-Ping-2.34. I need to look into the ICMP patch a bit more. Steve
The icmp check looks ok, but there could more failure reasons. I just TODO'd it, and provided support for local a TEST_PING_HOST override on firewalls. -- Reini Urban