@INC = '../lib';
}
-use Test::More tests => 7;
+use Test::More;
BEGIN {
require Config; import Config;
{
plan skip_all => "Test uses Socket, Socket not built";
}
+ if ($^O eq 'MacOS') {
+ plan skip_all => "Test relies on resolution of localhost, fails on Mac OS";
+ }
}
+use Test::More tests => 7;
BEGIN { use_ok 'Net::hostent' }
# Remind me to add this to Test::More.
-sub BAILOUT {
- print "Bail Out! @_\n";
- exit;
+sub DIE {
+ print "# @_\n";
+ exit 1;
}
# test basic resolution of localhost <-> 127.0.0.1
my $h = gethost('localhost');
ok(defined $h, "gethost('localhost')") ||
- BAILOUT("Can't continue without working gethost: $!");
+ DIE("Can't continue without working gethost: $!");
is( inet_ntoa($h->addr), "127.0.0.1", 'addr from gethost' );
my $i = gethostbyaddr(inet_aton("127.0.0.1"));
ok(defined $i, "gethostbyaddr('127.0.0.1')") ||
- BAILOUT("Can't continue without working gethostbyaddr: $!");
+ DIE("Can't continue without working gethostbyaddr: $!");
is( inet_ntoa($i->addr), "127.0.0.1", 'addr from gethostbyaddr' );
# 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
+# - VMS returns "LOCALHOST" under tcp/ip services V4.1 ECO 2, possibly others
+# - OS/390 returns localhost.YADDA.YADDA
SKIP: {
skip "Windows will return the machine name instead of 'localhost'", 2
if $^O eq 'MSWin32' or $^O eq 'NetWare' or $^O eq 'cygwin';
+ print "# name = " . $h->name . ", aliases = " . join (",", @{$h->aliases}) . "\n";
+
my $in_alias;
unless ($h->name =~ /^localhost(?:\..+)?$/i) {
foreach (@{$h->aliases}) {
last;
}
}
+ ok( $in_alias );
+ } else {
+ ok( 1 );
}
- unless( ok( $in_alias ) ) {
- print "# ",$h->name, " ", join (",", @{$h->aliases}), "\n";
- }
-
if ($in_alias) {
# If we found it in the aliases before, expect to find it there again.
foreach (@{$h->aliases}) {
}
else {
ok( !$in_alias );
- print "# ",$h->name, " ", join (",", @{$h->aliases}), "\n";
+ print "# " . $h->name . " " . join (",", @{$h->aliases}) . "\n";
}
}