This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Changes: correct mis-indentation introduced in dc7c5368d1
[perl5.git] / dist / Net-Ping / t / 110_icmp_inst.t
CommitLineData
505f3f16
JH
1# Test to make sure object can be instantiated for icmp protocol.
2# Root access is required to actually perform icmp testing.
3
a2a978ac 4BEGIN {
49afa5f6
JH
5 unless (eval "require Socket") {
6 print "1..0 \# Skip: no Socket\n";
7 exit;
8 }
a2a978ac
JH
9}
10
505f3f16
JH
11use Test;
12use Net::Ping;
13plan tests => 2;
14
15# Everything loaded fine
16ok 1;
17
f569508e 18if (($> and $^O ne 'VMS' and $^O ne 'cygwin')
0bd43963 19 or ($^O eq 'MSWin32'
2d706fb2 20 and !IsAdminUser())
b757f218
JH
21 or ($^O eq 'VMS'
22 and (`write sys\$output f\$privilege("SYSPRV")` =~ m/FALSE/))) {
ddbbf559 23 skip "icmp ping requires root privileges.", 1;
e69a2255
JH
24} elsif ($^O eq 'MacOS') {
25 skip "icmp protocol not supported.", 1;
ddbbf559
JH
26} else {
27 my $p = new Net::Ping "icmp";
28 ok !!$p;
29}
2d706fb2
JD
30
31sub IsAdminUser {
32 return unless $^O eq 'MSWin32';
33 return unless eval { require Win32 };
34 return unless defined &Win32::IsAdminUser;
35 return Win32::IsAdminUser();
36}