X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2Fnet-hostent.t;h=abc5b9292f9895c372ea76e3f54c43c1072225de;hb=569bd3158af2276a406770e3d68e76b7da59b730;hp=4a5df80a961bc5f105cce32f4178841c4915d765;hpb=d26aeb840ae7108aad9e8d90150ae1d00c1d7836;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/lib/net-hostent.t b/t/lib/net-hostent.t index 4a5df80..abc5b92 100644 --- a/t/lib/net-hostent.t +++ b/t/lib/net-hostent.t @@ -1,11 +1,17 @@ #!./perl -w BEGIN { - chdir 't' if -d 't'; - @INC = '../lib'; + chdir 't' if -d 't'; + @INC = '../lib'; + require Config; import Config; + if ($Config{'extensions'} !~ /\bSocket\b/ && + !(($^O eq 'VMS') && $Config{d_socket})) { + print "1..0 # Test uses Socket, Socket not built\n"; + exit 0; + } } -BEGIN { $| = 1; print "1..5\n"; } +BEGIN { $| = 1; print "1..7\n"; } END {print "not ok 1\n" unless $loaded;} @@ -18,26 +24,49 @@ print "ok 1\n"; use Socket; my $h = gethost('localhost'); +print +(defined $h ? '' : 'not ') . "ok 2\n"; my $i = gethostbyaddr(inet_aton("127.0.0.1")); +print +(!defined $i ? 'not ' : '') . "ok 3\n"; print "not " if inet_ntoa($h->addr) ne "127.0.0.1"; -print "ok 2\n"; +print "ok 4\n"; print "not " if inet_ntoa($i->addr) ne "127.0.0.1"; -print "ok 3\n"; +print "ok 5\n"; # need to skip the name comparisons on Win32 because windows will # return the name of the machine instead of "localhost" when resolving # 127.0.0.1 or even "localhost" # VMS returns "LOCALHOST" under tcp/ip services V4.1 ECO 2, possibly others +# OS/390 returns localhost.YADDA.YADDA -if ($^O eq 'MSWin32') { - print "ok $_ # skipped on win32\n" for (4,5); +if ($^O eq 'MSWin32' or $^O eq 'cygwin') { + print "ok $_ # skipped on win32\n" for (6,7); } else { - print "not " if $h->name !~ /localhost/i; - print "ok 4 # ",$h->name,"\n"; + my $in_alias; + unless ($h->name =~ /^localhost(?:\..+)?$/i) { + foreach (@{$h->aliases}) { + if (/^localhost(?:\..+)?$/i) { + $in_alias = 1; + last; + } + } + print "not " unless $in_alias; + } # Else we found it as the hostname + print "ok 6 # ",$h->name, " ", join (",", @{$h->aliases}), "\n"; - print "not " if $i->name !~ /localhost/i; - print "ok 5 # ",$i->name,"\n"; + if ($in_alias) { + # If we found it in the aliases before, expect to find it there again. + foreach (@{$h->aliases}) { + if (/^localhost(?:\..+)?$/i) { + undef $in_alias; # This time, clear the flag if we see "localhost" + last; + } + } + print "not " if $in_alias; + } else { + print "not " unless $i->name =~ /^localhost(?:\..+)?$/i; + } + print "ok 7 # ",$h->name, " ", join (",", @{$h->aliases}), "\n"; }