aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test/inets_test_lib.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2011-11-28 19:45:26 +0100
committerMicael Karlberg <[email protected]>2011-11-28 19:45:26 +0100
commitef692b0461b263a2025d289c31d8f491b53311e5 (patch)
treeeac37df59766a5810027999532c443b21ccb032c /lib/inets/test/inets_test_lib.erl
parentb1b51d10ab3fe405f773d597c29a42040d53bb17 (diff)
downloadotp-ef692b0461b263a2025d289c31d8f491b53311e5.tar.gz
otp-ef692b0461b263a2025d289c31d8f491b53311e5.tar.bz2
otp-ef692b0461b263a2025d289c31d8f491b53311e5.zip
Add ssl (and crypto and public_key) ensure tests.
That is, for test cases that depend of a running ssl app, added tests that ssl is actually running (actually the key app here is crypto, since the simplest way to test if ssl works is by testing if crypto does...).
Diffstat (limited to 'lib/inets/test/inets_test_lib.erl')
-rw-r--r--lib/inets/test/inets_test_lib.erl32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/inets/test/inets_test_lib.erl b/lib/inets/test/inets_test_lib.erl
index ddb1a49394..bbed35e1f8 100644
--- a/lib/inets/test/inets_test_lib.erl
+++ b/lib/inets/test/inets_test_lib.erl
@@ -35,6 +35,7 @@
-export([check_body/1]).
-export([millis/0, millis_diff/2, hours/1, minutes/1, seconds/1, sleep/1]).
-export([oscmd/1, has_ipv6_support/1]).
+-export([ensure_started/1]).
-export([non_pc_tc_maybe_skip/4, os_based_skip/1, skip/3, fail/3]).
-export([flush/0]).
-export([start_node/1, stop_node/1]).
@@ -126,6 +127,37 @@ await_stopped(Node, N) ->
%% ----------------------------------------------------------------
+%% Ensure apps are started
+%% This to ensure we dont attempt to run teatcases on platforms
+%% where there is no working ssl app.
+
+ensure_started([]) ->
+ ok;
+ensure_started([App|Apps]) ->
+ ensure_started(App),
+ ensure_started(Apps);
+ensure_started(crypto = App) ->
+ %% We have to treat crypto in this special way because
+ %% only this function ensures that the NIF lib is actually
+ %% loaded. And only by loading that lib can we know if it
+ %% is even possible to run crypto.
+ do_ensure_started(App, fun() -> crypto:start() end);
+ensure_started(App) when is_atom(App) ->
+ do_ensure_started(App, fun() -> application:start(App) end).
+
+do_ensure_started(App, Start) when is_function(Start) ->
+ case (catch Start()) of
+ ok ->
+ ok;
+ {error, {already_started, _}} ->
+ ok;
+ Error ->
+ throw({error, {failed_starting, App, Error}})
+ end.
+
+
+
+%% ----------------------------------------------------------------
%% HTTPD starter functions
%%