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