Commit | Line | Data |
9c36735d |
1 | # Test to perform icmp protocol testing. |
2 | # Root access is required. |
3 | |
4 | BEGIN { |
5 | unless (eval "require Socket") { |
6 | print "1..0 \# Skip: no Socket\n"; |
7 | exit; |
8 | } |
9 | } |
10 | |
11 | use Test; |
12 | use Net::Ping; |
13 | plan tests => 2; |
14 | |
15 | # Everything loaded fine |
16 | ok 1; |
17 | |
a60c28c3 |
18 | if (($> and $^O ne 'VMS') |
19 | or (($^O eq 'MSWin32' or $^O eq 'cygwin') |
2d706fb2 |
20 | and !IsAdminUser()) |
9c36735d |
21 | or ($^O eq 'VMS' |
22 | and (`write sys\$output f\$privilege("SYSPRV")` =~ m/FALSE/))) { |
23 | skip "icmp ping requires root privileges.", 1; |
24 | } elsif ($^O eq 'MacOS') { |
25 | skip "icmp protocol not supported.", 1; |
26 | } else { |
27 | my $p = new Net::Ping "icmp"; |
28 | ok $p->ping("127.0.0.1"); |
29 | } |
2d706fb2 |
30 | |
31 | sub IsAdminUser { |
a60c28c3 |
32 | return unless $^O eq 'MSWin32' or $^O eq "cygwin"; |
2d706fb2 |
33 | return unless eval { require Win32 }; |
34 | return unless defined &Win32::IsAdminUser; |
35 | return Win32::IsAdminUser(); |
36 | } |