1# Test to perform icmp protocol testing.
2# Root access is required.
3
4use strict;
5use Config;
6
7use Test::More;
8BEGIN {
9  unless (eval "require Socket") {
10    plan skip_all => 'no Socket';
11  }
12  unless ($Config{d_getpbyname}) {
13    plan skip_all => 'no getprotobyname';
14  }
15}
16
17BEGIN {use_ok('Net::Ping')};
18
19SKIP: {
20  skip "icmp ping requires root privileges.", 1
21    if !Net::Ping::_isroot() or $^O eq 'MSWin32';
22  my $p = new Net::Ping "icmp";
23  my $result = $p->ping("127.0.0.1");
24  if ($result == 1) {
25    is($result, 1, "icmp ping 127.0.0.1");
26  } else {
27  TODO: {
28      local $TODO = "icmp firewalled?";
29      is($result, 1, "icmp ping 127.0.0.1");
30    }
31  }
32}
33
34done_testing;
35