|
|
13b96b |
From ab3c25e921e15aa2923d509a9317610a1e9f1d4e Mon Sep 17 00:00:00 2001
|
|
|
13b96b |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
13b96b |
Date: Wed, 18 Nov 2020 08:42:00 +0100
|
|
|
13b96b |
Subject: [PATCH 2/2] Disable all network tests with NO_NETWORK_TESTING=1
|
|
|
13b96b |
MIME-Version: 1.0
|
|
|
13b96b |
Content-Type: text/plain; charset=UTF-8
|
|
|
13b96b |
Content-Transfer-Encoding: 8bit
|
|
|
13b96b |
|
|
|
13b96b |
If a host cannot resolve the host names, the tests fail like:
|
|
|
13b96b |
|
|
|
13b96b |
getaddrinfo(www.google.com.,,AF_INET) failed - Temporary failure in name resolution at /builddir/build/BUILD/Net-Ping-2.74/blib/lib/Net/Ping.pm line 1925.
|
|
|
13b96b |
|
|
|
13b96b |
The tests recommend setting PERL_CORE=1, but PERL_CORE has a different
|
|
|
13b96b |
meaning.
|
|
|
13b96b |
|
|
|
13b96b |
This patch recognizes a NO_NETWORK_TESTING environment variable to
|
|
|
13b96b |
skip non-localhost tests. This is alike to Test::RequiresInternet. The
|
|
|
13b96b |
patch also coerces the remaining tests to use loopback addresses
|
|
|
13b96b |
instead.
|
|
|
13b96b |
|
|
|
13b96b |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
13b96b |
---
|
|
|
13b96b |
t/400_ping_syn.t | 11 +++++------
|
|
|
13b96b |
t/410_syn_host.t | 11 +++++------
|
|
|
13b96b |
t/420_ping_syn_port.t | 11 +++++------
|
|
|
13b96b |
t/500_ping_icmp.t | 1 +
|
|
|
13b96b |
t/501_ping_icmpv6.t | 1 +
|
|
|
13b96b |
5 files changed, 17 insertions(+), 18 deletions(-)
|
|
|
13b96b |
|
|
|
13b96b |
diff --git a/t/400_ping_syn.t b/t/400_ping_syn.t
|
|
|
13b96b |
index 8409aae..4e22e7c 100644
|
|
|
13b96b |
--- a/t/400_ping_syn.t
|
|
|
13b96b |
+++ b/t/400_ping_syn.t
|
|
|
13b96b |
@@ -1,11 +1,10 @@
|
|
|
13b96b |
use strict;
|
|
|
13b96b |
|
|
|
13b96b |
BEGIN {
|
|
|
13b96b |
- if ($ENV{PERL_CORE}) {
|
|
|
13b96b |
- unless ($ENV{PERL_TEST_Net_Ping}) {
|
|
|
13b96b |
- print "1..0 # Skip: network dependent test\n";
|
|
|
13b96b |
- exit;
|
|
|
13b96b |
- }
|
|
|
13b96b |
+ if ($ENV{NO_NETWORK_TESTING} ||
|
|
|
13b96b |
+ ($ENV{PERL_CORE} && !$ENV{PERL_TEST_Net_Ping})) {
|
|
|
13b96b |
+ print "1..0 # Skip: network dependent test\n";
|
|
|
13b96b |
+ exit;
|
|
|
13b96b |
}
|
|
|
13b96b |
unless (eval "require Socket") {
|
|
|
13b96b |
print "1..0 \# Skip: no Socket\n";
|
|
|
13b96b |
@@ -30,7 +29,7 @@ BEGIN {
|
|
|
13b96b |
# connection to remote networks, but you still want the tests
|
|
|
13b96b |
# to pass, use the following:
|
|
|
13b96b |
#
|
|
|
13b96b |
-# $ PERL_CORE=1 make test
|
|
|
13b96b |
+# $ NO_NETWORK_TESTING=1 make test
|
|
|
13b96b |
|
|
|
13b96b |
# Hopefully this is never a routeable host
|
|
|
13b96b |
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "192.0.2.0";
|
|
|
13b96b |
diff --git a/t/410_syn_host.t b/t/410_syn_host.t
|
|
|
13b96b |
index 15948e2..5d58bda 100644
|
|
|
13b96b |
--- a/t/410_syn_host.t
|
|
|
13b96b |
+++ b/t/410_syn_host.t
|
|
|
13b96b |
@@ -2,11 +2,10 @@
|
|
|
13b96b |
use strict;
|
|
|
13b96b |
|
|
|
13b96b |
BEGIN {
|
|
|
13b96b |
- if ($ENV{PERL_CORE}) {
|
|
|
13b96b |
- unless ($ENV{PERL_TEST_Net_Ping}) {
|
|
|
13b96b |
- print "1..0 # Skip: network dependent test\n";
|
|
|
13b96b |
- exit;
|
|
|
13b96b |
- }
|
|
|
13b96b |
+ if ($ENV{NO_NETWORK_TESTING} ||
|
|
|
13b96b |
+ ($ENV{PERL_CORE} && !$ENV{PERL_TEST_Net_Ping})) {
|
|
|
13b96b |
+ print "1..0 # Skip: network dependent test\n";
|
|
|
13b96b |
+ exit;
|
|
|
13b96b |
}
|
|
|
13b96b |
unless (eval "require Socket") {
|
|
|
13b96b |
print "1..0 \# Skip: no Socket\n";
|
|
|
13b96b |
@@ -31,7 +30,7 @@ BEGIN {
|
|
|
13b96b |
# connection to remote networks, but you still want the tests
|
|
|
13b96b |
# to pass, use the following:
|
|
|
13b96b |
#
|
|
|
13b96b |
-# $ PERL_CORE=1 make test
|
|
|
13b96b |
+# $ NO_NETWORK_TESTING=1 make test
|
|
|
13b96b |
|
|
|
13b96b |
# Try a few remote servers
|
|
|
13b96b |
my %webs;
|
|
|
13b96b |
diff --git a/t/420_ping_syn_port.t b/t/420_ping_syn_port.t
|
|
|
13b96b |
index 53c153f..6b8d19a 100644
|
|
|
13b96b |
--- a/t/420_ping_syn_port.t
|
|
|
13b96b |
+++ b/t/420_ping_syn_port.t
|
|
|
13b96b |
@@ -2,11 +2,10 @@
|
|
|
13b96b |
use strict;
|
|
|
13b96b |
|
|
|
13b96b |
BEGIN {
|
|
|
13b96b |
- if ($ENV{PERL_CORE}) {
|
|
|
13b96b |
- unless ($ENV{PERL_TEST_Net_Ping}) {
|
|
|
13b96b |
- print "1..0 # Skip: network dependent test\n";
|
|
|
13b96b |
- exit;
|
|
|
13b96b |
- }
|
|
|
13b96b |
+ if ($ENV{NO_NETWORK_TESTING} ||
|
|
|
13b96b |
+ ($ENV{PERL_CORE} && !$ENV{PERL_TEST_Net_Ping})) {
|
|
|
13b96b |
+ print "1..0 # Skip: network dependent test\n";
|
|
|
13b96b |
+ exit;
|
|
|
13b96b |
}
|
|
|
13b96b |
unless (eval "require Socket") {
|
|
|
13b96b |
print "1..0 \# Skip: no Socket\n";
|
|
|
13b96b |
@@ -31,7 +30,7 @@ BEGIN {
|
|
|
13b96b |
# connection to remote networks, but you still want the tests
|
|
|
13b96b |
# to pass, use the following:
|
|
|
13b96b |
#
|
|
|
13b96b |
-# $ PERL_CORE=1 make test
|
|
|
13b96b |
+# $ NO_NETWORK_TESTING=1 make test
|
|
|
13b96b |
|
|
|
13b96b |
# Hopefully this is never a routeable host
|
|
|
13b96b |
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "192.0.2.0";
|
|
|
13b96b |
diff --git a/t/500_ping_icmp.t b/t/500_ping_icmp.t
|
|
|
13b96b |
index dea6588..7e45cc4 100644
|
|
|
13b96b |
--- a/t/500_ping_icmp.t
|
|
|
13b96b |
+++ b/t/500_ping_icmp.t
|
|
|
13b96b |
@@ -19,6 +19,7 @@ BEGIN {
|
|
|
13b96b |
}
|
|
|
13b96b |
|
|
|
13b96b |
my $is_devel = $ENV{PERL_CORE} || -d ".git" ? 1 : 0;
|
|
|
13b96b |
+$ENV{TEST_PING_HOST} = "127.0.0.1" if $ENV{NO_NETWORK_TESTING};
|
|
|
13b96b |
# Note this rawsocket test code is considered anti-social in p5p and was removed in
|
|
|
13b96b |
# their variant.
|
|
|
13b96b |
# See http://nntp.perl.org/group/perl.perl5.porters/240707
|
|
|
13b96b |
diff --git a/t/501_ping_icmpv6.t b/t/501_ping_icmpv6.t
|
|
|
13b96b |
index 165824f..9b5b8b8 100644
|
|
|
13b96b |
--- a/t/501_ping_icmpv6.t
|
|
|
13b96b |
+++ b/t/501_ping_icmpv6.t
|
|
|
13b96b |
@@ -19,6 +19,7 @@ BEGIN {
|
|
|
13b96b |
}
|
|
|
13b96b |
|
|
|
13b96b |
my $is_devel = $ENV{PERL_CORE} || -d ".git" ? 1 : 0;
|
|
|
13b96b |
+$ENV{TEST_PING6_HOST} = "::1" if $ENV{NO_NETWORK_TESTING};
|
|
|
13b96b |
if (!Net::Ping::_isroot()) {
|
|
|
13b96b |
my $file = __FILE__;
|
|
|
13b96b |
my $lib = $ENV{PERL_CORE} ? '-I../../lib' : '-Mblib';
|
|
|
13b96b |
--
|
|
|
13b96b |
2.25.4
|
|
|
13b96b |
|