summaryrefslogtreecommitdiff
path: root/cpan
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-08-15 21:54:48 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-08-15 21:57:24 -0400
commit3699825258c1da4ae23bb99a254d645984fcafde (patch)
treeee79d190051a7b0e42195fda3da5a03a634378bc /cpan
parentcb54b7341c57a063184ac29ea4775c863a7a0f06 (diff)
downloadperl-3699825258c1da4ae23bb99a254d645984fcafde.tar.gz
Socket 2.015
Diffstat (limited to 'cpan')
-rw-r--r--cpan/Socket/Socket.pm4
-rw-r--r--cpan/Socket/t/getaddrinfo.t22
-rw-r--r--cpan/Socket/t/getnameinfo.t26
-rw-r--r--cpan/Socket/t/socketpair.t5
4 files changed, 32 insertions, 25 deletions
diff --git a/cpan/Socket/Socket.pm b/cpan/Socket/Socket.pm
index b1c78cc31d..a63e16d671 100644
--- a/cpan/Socket/Socket.pm
+++ b/cpan/Socket/Socket.pm
@@ -3,7 +3,7 @@ package Socket;
use strict;
{ use 5.006001; }
-our $VERSION = '2.014';
+our $VERSION = '2.015';
=head1 NAME
@@ -935,7 +935,7 @@ if( defined &getaddrinfo ) {
# family
# Borrowed from Regexp::Common::net
-my $REGEXP_IPv4_DECIMAL = qr/25[0-5]|2[0-4][0-9]|1?[0-9]{1,2}/;
+my $REGEXP_IPv4_DECIMAL = qr/25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}/;
my $REGEXP_IPv4_DOTTEDQUAD = qr/$REGEXP_IPv4_DECIMAL\.$REGEXP_IPv4_DECIMAL\.$REGEXP_IPv4_DECIMAL\.$REGEXP_IPv4_DECIMAL/;
sub fake_makeerr
diff --git a/cpan/Socket/t/getaddrinfo.t b/cpan/Socket/t/getaddrinfo.t
index 24f154c578..6f8a324dfb 100644
--- a/cpan/Socket/t/getaddrinfo.t
+++ b/cpan/Socket/t/getaddrinfo.t
@@ -101,10 +101,24 @@ SKIP: {
}
# Numeric addresses with AI_NUMERICHOST should pass (RT95758)
-{
- ( $err, @res ) = getaddrinfo( "127.0.0.1", 80, { flags => AI_NUMERICHOST } );
- ok( $err == 0, "\$err == 0 for 127.0.0.1/80/flags=AI_NUMERICHOST" ) or
- diag( "\$err is $err" );
+AI_NUMERICHOST: {
+ # Here we need a port that is open to the world. Not all places have all
+ # the ports. For example Solaris by default doesn't have http/80 in
+ # /etc/services, and that would fail. Let's try a couple of commonly open
+ # ports, and hope one of them will succeed. Conversely this means that
+ # sometimes this will fail.
+ #
+ # An alternative method would be to manually parse /etc/services and look
+ # for enabled services but that's kind of yuck, too.
+ my @port = (80, 7, 22, 25, 88, 123, 110, 389, 443, 445, 873, 2049, 3306);
+ foreach my $port ( @port ) {
+ ( $err, @res ) = getaddrinfo( "127.0.0.1", $port, { flags => AI_NUMERICHOST, socktype => SOCK_STREAM } );
+ if( $err == 0 ) {
+ ok( $err == 0, "\$err == 0 for 127.0.0.1/$port/flags=AI_NUMERICHOST" );
+ last AI_NUMERICHOST;
+ }
+ }
+ fail( "$err for 127.0.0.1/$port[-1]/flags=AI_NUMERICHOST (failed for ports @port)" );
}
# Now check that names with AI_NUMERICHOST fail
diff --git a/cpan/Socket/t/getnameinfo.t b/cpan/Socket/t/getnameinfo.t
index 035b3452b6..5ee55758ea 100644
--- a/cpan/Socket/t/getnameinfo.t
+++ b/cpan/Socket/t/getnameinfo.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 14;
+use Test::More tests => 12;
use Socket qw(:addrinfo AF_INET pack_sockaddr_in inet_aton);
@@ -21,26 +21,14 @@ is( $service, "80", '$service is 80 for NS, NIx_NOHOST' );
is( $host, "127.0.0.1", '$host is undef for NIx_NOSERV' );
is( $service, undef, '$service is 80 for NS, NIx_NOSERV' );
-# Probably "localhost" but we'd better ask the system to be sure
-my $expect_host = gethostbyaddr( inet_aton( "127.0.0.1" ), AF_INET );
-defined $expect_host or $expect_host = "127.0.0.1";
-
( $err, $host, $service ) = getnameinfo( pack_sockaddr_in( 80, inet_aton( "127.0.0.1" ) ), NI_NUMERICSERV );
cmp_ok( $err, "==", 0, '$err == 0 for {family=AF_INET,port=80,sinaddr=127.0.0.1}/NI_NUMERICSERV' );
-is( $host, $expect_host, "\$host is $expect_host for NS" );
-is( $service, "80", '$service is 80 for NS' );
-
-# Probably "www" but we'd better ask the system to be sure
-my $flags = NI_NUMERICHOST;
-my $expect_service = getservbyport( 80, "tcp" );
-unless( defined $expect_service ) {
- $expect_service = "80";
- $flags |= NI_NUMERICSERV; # don't seem to have a service name
-}
+# We can't meaningfully compare '$host' with anything specific, all we can be
+# sure is it's not empty
+ok( length $host, '$host is nonzero length for NS' );
-( $err, $host, $service ) = getnameinfo( pack_sockaddr_in( 80, inet_aton( "127.0.0.1" ) ), $flags );
-cmp_ok( $err, "==", 0, '$err == 0 for {family=AF_INET,port=80,sinaddr=127.0.0.1}/NI_NUMERICHOST[|NI_NUMERICSERV]' );
+( $err, $host, $service ) = getnameinfo( pack_sockaddr_in( 80, inet_aton( "127.0.0.1" ) ), NI_NUMERICHOST );
+cmp_ok( $err, "==", 0, '$err == 0 for {family=AF_INET,port=80,sinaddr=127.0.0.1}/NI_NUMERICHOST' );
-is( $host, "127.0.0.1", '$host is 127.0.0.1 for NH' );
-is( $service, $expect_service, "\$service is $expect_service for NH" );
+ok( length $service, '$service is nonzero length for NH' );
diff --git a/cpan/Socket/t/socketpair.t b/cpan/Socket/t/socketpair.t
index 817707a6df..823306eb66 100644
--- a/cpan/Socket/t/socketpair.t
+++ b/cpan/Socket/t/socketpair.t
@@ -35,6 +35,11 @@ BEGIN {
}
warn "Something unexpectedly hung during testing";
kill "INT", $parent or die "Kill failed: $!";
+ if( $^O eq "cygwin" ) {
+ # sometimes the above isn't enough on cygwin
+ sleep 1; # wait a little, it might have worked after all
+ system( "/bin/kill -f $parent; echo die $parent" );
+ }
exit 1;
}
}