Subject: | Make tests run offline |
Hello!
There has been a bug report against the Debian package
of Net::DNS v0.66.
make test failed without internet access. While I could not
reproduce the failure reported there yet, I found another failure
when running make test with my interface down.
t/01-resolver.t called some network functions to test for
private ip addresses before checking for online tests being
disabled.
The patch attached should fix that. Please have a look at it. I would
be glad to hear back about it.
Regards,
Florian Hinzmann
Subject: | do-not-fail-make-test-offline.patch |
Index: libnet-dns-perl/t/01-resolver.t
===================================================================
--- libnet-dns-perl.orig/t/01-resolver.t 2010-03-18 09:12:46.000000000 +0100
+++ libnet-dns-perl/t/01-resolver.t 2010-03-18 09:32:55.000000000 +0100
@@ -63,34 +63,35 @@
-# Some people try to run these on private address space."
-
-use Net::IP;
-
-use IO::Socket::INET;
-
-my $sock = IO::Socket::INET->new(PeerAddr => '193.0.14.129', # k.root-servers.net.
- PeerPort => '53',
- Proto => 'udp');
-
-
-my $ip=Net::IP->new(inet_ntoa($sock->sockaddr));
SKIP: {
+ # Test first, if we want online tests at all.
skip 'Online tests disabled.', 3
unless -e 't/online.enabled';
skip 'Online tests disabled.', 3
if -e 't/online.disabled';
+
+ # Some people try to run these on private address space - test for this case and skip.
+ use Net::IP;
+ use IO::Socket::INET;
+
+ my $sock = IO::Socket::INET->new(PeerAddr => '193.0.14.129', # k.root-servers.net.
+ PeerPort => '53',
+ Proto => 'udp');
+
+ my $ip=Net::IP->new(inet_ntoa($sock->sockaddr));
+
skip 'Tests may not run succesful from private IP('.$ip->ip() .')', 3
if ($ip->iptype() ne "PUBLIC");
+
my $res = Net::DNS::Resolver->new;
$res->nameservers('a.t.net-dns.org');
- my $ip = ($res->nameservers)[0];
+ $ip = ($res->nameservers)[0];
is($ip, '10.0.1.128', 'Nameservers() looks up IP.') or
diag ($res->errorstring . $res->print) ;