Commit | Line | Data |
505f3f16 |
1 | BEGIN { |
ddbbf559 |
2 | if ($ENV{PERL_CORE}) { |
3 | unless ($ENV{PERL_TEST_Net_Ping}) { |
4 | print "1..0 # Skip: network dependent test\n"; |
5 | exit; |
a2a978ac |
6 | } |
ddbbf559 |
7 | } |
8 | unless (eval "require Socket") { |
9 | print "1..0 \# Skip: no Socket\n"; |
10 | exit; |
11 | } |
f569508e |
12 | unless (getservbyname('echo', 'tcp')) { |
ddbbf559 |
13 | print "1..0 \# Skip: no echo port\n"; |
14 | exit; |
15 | } |
505f3f16 |
16 | } |
17 | |
18 | # Remote network test using tcp protocol. |
19 | # |
20 | # NOTE: |
21 | # Network connectivity will be required for all tests to pass. |
22 | # Firewalls may also cause some tests to fail, so test it |
23 | # on a clear network. If you know you do not have a direct |
24 | # connection to remote networks, but you still want the tests |
25 | # to pass, use the following: |
26 | # |
27 | # $ PERL_CORE=1 make test |
28 | |
29 | use Test; |
30 | use Net::Ping; |
31 | plan tests => 13; |
32 | |
33 | # Everything loaded fine |
34 | ok 1; |
35 | |
f569508e |
36 | my $p = new Net::Ping "tcp",9; |
505f3f16 |
37 | |
38 | # new() worked? |
39 | ok !!$p; |
40 | |
41 | # Test on the default port |
42 | ok $p -> ping("localhost"); |
43 | |
44 | # Change to use the more common web port. |
45 | # This will pull from /etc/services on UNIX. |
46 | # (Make sure getservbyname works in scalar context.) |
47 | ok ($p -> {port_num} = (getservbyname("http", "tcp") || 80)); |
48 | |
49 | # Test localhost on the web port |
50 | ok $p -> ping("localhost"); |
51 | |
5d20095f |
52 | # Hopefully this is never a routeable host |
53 | ok !$p -> ping("172.29.249.249"); |
505f3f16 |
54 | |
55 | # Test a few remote servers |
56 | # Hopefully they are up when the tests are run. |
57 | |
58 | ok $p -> ping("www.geocities.com"); |
59 | ok $p -> ping("ftp.geocities.com"); |
60 | |
61 | ok $p -> ping("www.freeservers.com"); |
62 | ok $p -> ping("ftp.freeservers.com"); |
63 | |
64 | ok $p -> ping("yahoo.com"); |
65 | ok $p -> ping("www.yahoo.com"); |
66 | ok $p -> ping("www.about.com"); |