500_ping_icmp.t

来自「source of perl for linux application,」· T 代码 · 共 37 行

T
37
字号
# Test to perform icmp protocol testing.# Root access is required.BEGIN {  unless (eval "require Socket") {    print "1..0 \# Skip: no Socket\n";    exit;  }}use Test;use Net::Ping;plan tests => 2;# Everything loaded fineok 1;if (($> and $^O ne 'VMS')    or (($^O eq 'MSWin32' or $^O eq 'cygwin')        and !IsAdminUser())    or ($^O eq 'VMS'        and (`write sys\$output f\$privilege("SYSPRV")` =~ m/FALSE/))) {  skip "icmp ping requires root privileges.", 1;} elsif ($^O eq 'MacOS') {  skip "icmp protocol not supported.", 1;} else {  my $p = new Net::Ping "icmp";  ok $p->ping("127.0.0.1");}sub IsAdminUser {  return unless $^O eq 'MSWin32' or $^O eq "cygwin";  return unless eval { require Win32 };  return unless defined &Win32::IsAdminUser;  return Win32::IsAdminUser();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?