aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2017-10-16 15:26:44 +0200
committerLukas Larsson <[email protected]>2017-10-16 17:25:32 +0200
commitc97216ecdd9e684f6f6e3bfee8fae8e2e8933f13 (patch)
treebf6f84c7ded09e9650414105628f28308a7fd447 /lib
parent4c9acce498df83106fb6b36e70386d3468673ce9 (diff)
downloadotp-c97216ecdd9e684f6f6e3bfee8fae8e2e8933f13.tar.gz
otp-c97216ecdd9e684f6f6e3bfee8fae8e2e8933f13.tar.bz2
otp-c97216ecdd9e684f6f6e3bfee8fae8e2e8933f13.zip
jinterface: Skip tests when hostname cannot be resolved
Check that the hostname can be resolved by the native resolver. What normally has happened when it cannot is that gethostname() returned a fqdn and `hostname -s` is not part of /etc/hosts. This is solved on the erlang side by adding `hostname -s` to inet_db, but java does not have a similar mechanism, so it fails when it tries to connect to `hostname -s`. This caused jinterface tests to fail when run in such an environment, and travis-ci recently started doing this.
Diffstat (limited to 'lib')
-rw-r--r--lib/jinterface/test/jinterface_SUITE.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/jinterface/test/jinterface_SUITE.erl b/lib/jinterface/test/jinterface_SUITE.erl
index 73851f47e0..8c6a6368a9 100644
--- a/lib/jinterface/test/jinterface_SUITE.erl
+++ b/lib/jinterface/test/jinterface_SUITE.erl
@@ -176,11 +176,29 @@ init_per_suite(Config) when is_list(Config) ->
{error,bad_name} -> false;
P -> filelib:is_dir(P) end of
true ->
- jitu:init_all(Config);
+ case hostname_resolves() of
+ true ->
+ jitu:init_all(Config);
+ Skip ->
+ Skip
+ end;
false ->
{skip,"No jinterface application"}
end.
+%% Check if inet:gethostname() can be resolved by
+%% the native resolver. If it can, we know that
+%% jinterface name resolution works. If it cannot
+%% jinterface tests will fail.
+hostname_resolves() ->
+ {ok, HN} = inet:gethostname(),
+ case inet_gethost_native:gethostbyname(HN) of
+ {ok, _} ->
+ true;
+ _ ->
+ {skip, "Cannot resolve short hostname, add " ++ HN ++ " to /etc/hosts"}
+ end.
+
end_per_suite(Config) when is_list(Config) ->
jitu:finish_all(Config).