Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests that need the Internet #24

Merged
merged 2 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion t/190_alarm.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use Test::More tests => 6;
BEGIN {use_ok 'Net::Ping'};

# Hopefully this is never a routeable host
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "172.29.249.249";
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "192.0.2.0";

eval {
my $timeout = 11;
Expand Down
2 changes: 1 addition & 1 deletion t/200_ping_tcp.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BEGIN {
}

# Hopefully this is never a routeable host
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "172.29.249.249";
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "192.0.2.0";

# Remote network test using tcp protocol.
#
Expand Down
13 changes: 6 additions & 7 deletions t/400_ping_syn.t
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use strict;

BEGIN {
if ($ENV{PERL_CORE}) {
unless ($ENV{PERL_TEST_Net_Ping}) {
print "1..0 # Skip: network dependent test\n";
exit;
}
if ($ENV{NO_NETWORK_TESTING} ||
($ENV{PERL_CORE} && !$ENV{PERL_TEST_Net_Ping})) {
print "1..0 # Skip: network dependent test\n";
exit;
}
unless (eval "require Socket") {
print "1..0 \# Skip: no Socket\n";
Expand All @@ -30,10 +29,10 @@ BEGIN {
# connection to remote networks, but you still want the tests
# to pass, use the following:
#
# $ PERL_CORE=1 make test
# $ NO_NETWORK_TESTING=1 make test

# Hopefully this is never a routeable host
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "172.29.249.249";
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "192.0.2.0";

# Try a few remote servers
my %webs = (
Expand Down
13 changes: 6 additions & 7 deletions t/410_syn_host.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
use strict;

BEGIN {
if ($ENV{PERL_CORE}) {
unless ($ENV{PERL_TEST_Net_Ping}) {
print "1..0 # Skip: network dependent test\n";
exit;
}
if ($ENV{NO_NETWORK_TESTING} ||
($ENV{PERL_CORE} && !$ENV{PERL_TEST_Net_Ping})) {
print "1..0 # Skip: network dependent test\n";
exit;
}
unless (eval "require Socket") {
print "1..0 \# Skip: no Socket\n";
Expand All @@ -31,13 +30,13 @@ BEGIN {
# connection to remote networks, but you still want the tests
# to pass, use the following:
#
# $ PERL_CORE=1 make test
# $ NO_NETWORK_TESTING=1 make test

# Try a few remote servers
my %webs;
BEGIN {
# Hopefully this is never a routeable host
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "172.29.249.249";
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "192.0.2.0";

%webs = (
$fail_ip => 0,
Expand Down
13 changes: 6 additions & 7 deletions t/420_ping_syn_port.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
use strict;

BEGIN {
if ($ENV{PERL_CORE}) {
unless ($ENV{PERL_TEST_Net_Ping}) {
print "1..0 # Skip: network dependent test\n";
exit;
}
if ($ENV{NO_NETWORK_TESTING} ||
($ENV{PERL_CORE} && !$ENV{PERL_TEST_Net_Ping})) {
print "1..0 # Skip: network dependent test\n";
exit;
}
unless (eval "require Socket") {
print "1..0 \# Skip: no Socket\n";
Expand All @@ -31,10 +30,10 @@ BEGIN {
# connection to remote networks, but you still want the tests
# to pass, use the following:
#
# $ PERL_CORE=1 make test
# $ NO_NETWORK_TESTING=1 make test

# Hopefully this is never a routeable host
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "172.29.249.249";
my $fail_ip = $ENV{NET_PING_FAIL_IP} || "192.0.2.0";

# Try a few remote servers
my %webs;
Expand Down
1 change: 1 addition & 0 deletions t/500_ping_icmp.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ BEGIN {
}

my $is_devel = $ENV{PERL_CORE} || -d ".git" ? 1 : 0;
$ENV{TEST_PING_HOST} = "127.0.0.1" if $ENV{NO_NETWORK_TESTING};
# Note this rawsocket test code is considered anti-social in p5p and was removed in
# their variant.
# See http://nntp.perl.org/group/perl.perl5.porters/240707
Expand Down
3 changes: 2 additions & 1 deletion t/501_ping_icmpv6.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ BEGIN {
}

my $is_devel = $ENV{PERL_CORE} || -d ".git" ? 1 : 0;
$ENV{TEST_PING6_HOST} = "::1" if $ENV{NO_NETWORK_TESTING};
if (!Net::Ping::_isroot()) {
my $file = __FILE__;
my $lib = $ENV{PERL_CORE} ? '-I../../lib' : '-Mblib';
Expand Down Expand Up @@ -59,7 +60,7 @@ SKIP: {
my $rightip = "2001:4860:4860::8888"; # pingable ip of google's dnsserver
# for a firewalled ipv6 network try an optional local ipv6 host
$rightip = $ENV{TEST_PING6_HOST} if $ENV{TEST_PING6_HOST};
my $wrongip = "2001:4860:4860::1234"; # non existing ip
my $wrongip = "2001:db8::"; # non existing ip
# diag "Pinging existing IPv6 ";
my $result = $p->ping($rightip);
if ($result == 1) {
Expand Down