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