1# Test to perform udp protocol testing. 2 3use strict; 4use Config; 5 6sub isWindowsVista { 7 return unless $^O eq 'MSWin32' or $^O eq "cygwin"; 8 return unless eval { require Win32 }; 9 return unless defined &Win32::GetOSVersion(); 10 11 #is this Vista or later? 12 my ($string, $major, $minor, $build, $id) = Win32::GetOSVersion(); 13 return $build >= 6; 14} 15 16use Test::More tests => 3; 17BEGIN {use_ok('Net::Ping')}; 18 19SKIP: { 20 skip "No udp echo port", 2 unless getservbyname('echo', 'udp'); 21 skip "udp ping blocked by Window's default settings", 2 if isWindowsVista(); 22 skip "No getprotobyname", 2 unless $Config{d_getpbyname}; 23 skip "Not allowed on $^O", 2 if $^O =~ /^(hpux|irix|aix)$/; 24 my $p = new Net::Ping "udp"; 25 # message_type can't be used 26 eval { 27 $p->message_type(); 28 }; 29 like($@, qr/message type only supported on 'icmp' protocol/, "message_type() API only concern 'icmp' protocol"); 30 is($p->ping("127.0.0.1"), 1); 31} 32