aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/inets/test/httpc_SUITE.erl36
-rw-r--r--lib/inets/test/httpd_SUITE.erl39
-rw-r--r--lib/inets/test/httpd_time_test.erl8
-rw-r--r--lib/inets/test/inets_app_test.erl16
-rw-r--r--lib/inets/test/inets_test_lib.erl32
-rw-r--r--lib/inets/test/inets_test_lib.hrl9
6 files changed, 62 insertions, 78 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl
index 2b580cd95d..6e69c9a469 100644
--- a/lib/inets/test/httpc_SUITE.erl
+++ b/lib/inets/test/httpc_SUITE.erl
@@ -145,14 +145,6 @@ groups() ->
].
-
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
-
%%--------------------------------------------------------------------
%% Function: init_per_suite(Config) -> Config
%% Config - [tuple()]
@@ -226,9 +218,7 @@ init_per_testcase(initial_server_connect = Case, Config) ->
%% this test case does not work unless it does
try
begin
- ensure_started(crypto),
- ensure_started(public_key),
- ensure_started(ssl),
+ ?ENSURE_STARTED([crypto, public_key, ssl]),
inets:start(),
Config
end
@@ -267,10 +257,12 @@ init_per_testcase(Case, Timeout, Config) ->
NewConfig =
case atom_to_list(Case) of
[$s, $s, $l | _] ->
+ ?ENSURE_STARTED([crypto, public_key, ssl]),
init_per_testcase_ssl(ssl, PrivDir, SslConfFile,
[{watchdog, Dog} | TmpConfig]);
[$e, $s, $s, $l | _] ->
+ ?ENSURE_STARTED([crypto, public_key, ssl]),
init_per_testcase_ssl(essl, PrivDir, SslConfFile,
[{watchdog, Dog} | TmpConfig]);
@@ -282,7 +274,7 @@ init_per_testcase(Case, Timeout, Config) ->
inets:start(),
tsp("init_per_testcase -> "
"[proxy case] start crypto, public_key and ssl"),
- try ensure_started([crypto, public_key, ssl]) of
+ try ?ENSURE_STARTED([crypto, public_key, ssl]) of
ok ->
[{watchdog, Dog} | TmpConfig]
catch
@@ -335,8 +327,8 @@ init_per_testcase(Case, Timeout, Config) ->
end;
"ipv6_" ++ _Rest ->
- %% Ensure needed apps (crypto, public_key and ssl) started
- try ensure_started([crypto, public_key, ssl]) of
+ %% Ensure needed apps (crypto, public_key and ssl) are started
+ try ?ENSURE_STARTED([crypto, public_key, ssl]) of
ok ->
Profile = ipv6,
%% A stand-alone profile is represented by a pid()
@@ -3553,21 +3545,5 @@ dummy_ssl_server_hang_loop(_) ->
end.
-ensure_started([]) ->
- ok;
-ensure_started([App|Apps]) ->
- ensure_started(App),
- ensure_started(Apps);
-ensure_started(App) when is_atom(App) ->
- case (catch application:start(App)) of
- ok ->
- ok;
- {error, {already_started, _}} ->
- ok;
- Error ->
- throw({error, {failed_starting, App, Error}})
- end.
-
-
skip(Reason) ->
{skip, Reason}.
diff --git a/lib/inets/test/httpd_SUITE.erl b/lib/inets/test/httpd_SUITE.erl
index ba31788ccc..5b571a9649 100644
--- a/lib/inets/test/httpd_SUITE.erl
+++ b/lib/inets/test/httpd_SUITE.erl
@@ -497,6 +497,7 @@ init_per_testcase2(Case, Config) ->
_ ->
NewConfig
end;
+
_ ->
NewConfig
end,
@@ -528,7 +529,7 @@ init_per_testcase3(Case, Config) ->
application:stop(ssl),
cleanup_mnesia(),
- %% Set trace
+ %% Set trace level
case lists:reverse(atom_to_list(Case)) of
"tset_emit" ++ _Rest -> % test-cases ending with time_test
io:format(user, "~w:init_per_testcase3(~w) -> disabling trace",
@@ -581,9 +582,10 @@ init_per_testcase3(Case, Config) ->
Rest;
[X, $s, $s, $l, $_, $m, $o, $d, $_, $h, $t, $a, $c, $c, $e, $s, $s] ->
+ ?ENSURE_STARTED([crypto, public_key, ssl]),
SslTag =
case X of
- $p -> ssl; % plain
+ $p -> ssl; % Plain
$e -> essl % Erlang based ssl
end,
case inets_test_lib:start_http_server_ssl(
@@ -597,6 +599,7 @@ init_per_testcase3(Case, Config) ->
{skip, "SSL does not seem to be supported"}
end;
[X, $s, $s, $l, $_ | Rest] ->
+ ?ENSURE_STARTED([crypto, public_key, ssl]),
SslTag =
case X of
$p -> ssl;
@@ -679,36 +682,6 @@ end_per_testcase2(Case, Config) ->
%%-------------------------------------------------------------------------
%%-------------------------------------------------------------------------
-
-
-
-
-
-
-%%-------------------------------------------------------------------------
-http_1_1_ip(doc) ->
- ["HTTP/1.1"];
-http_1_1_ip(suite) ->
- [
- ip_host,
- ip_chunked,
- ip_expect,
- ip_range,
- ip_if_test,
- ip_http_trace,
- ip_http1_1_head,
- ip_mod_cgi_chunked_encoding_test
- ].
-
-%%-------------------------------------------------------------------------
-
-%%-------------------------------------------------------------------------
-
-%%-------------------------------------------------------------------------
-
-%%-------------------------------------------------------------------------
-
-%%-------------------------------------------------------------------------
ip_mod_alias(doc) ->
["Module test: mod_alias"];
ip_mod_alias(suite) ->
@@ -717,6 +690,7 @@ ip_mod_alias(Config) when is_list(Config) ->
httpd_mod:alias(ip_comm, ?IP_PORT,
?config(host, Config), ?config(node, Config)),
ok.
+
%%-------------------------------------------------------------------------
ip_mod_actions(doc) ->
["Module test: mod_actions"];
@@ -726,6 +700,7 @@ ip_mod_actions(Config) when is_list(Config) ->
httpd_mod:actions(ip_comm, ?IP_PORT,
?config(host, Config), ?config(node, Config)),
ok.
+
%%-------------------------------------------------------------------------
ip_mod_security(doc) ->
["Module test: mod_security"];
diff --git a/lib/inets/test/httpd_time_test.erl b/lib/inets/test/httpd_time_test.erl
index f86e2837f4..4e5f332122 100644
--- a/lib/inets/test/httpd_time_test.erl
+++ b/lib/inets/test/httpd_time_test.erl
@@ -344,10 +344,14 @@ await_poll_response2(SocketType, Socket, ExpStatusCode, Data) ->
receive
%% SSL receives
{ssl, Socket, NewData} ->
+ d("await_poll_response2 -> "
+ "received part (~w bytes) of the response", [sz(NewData)]),
await_poll_response2(SocketType, Socket, ExpStatusCode,
[NewData | Data]);
{ssl_closed, Socket} ->
%% We are done or we failed
+ d("await_poll_response2 -> "
+ "we are done after receiving ~w bytes data", [sz(Data)]),
validate(ExpStatusCode, SocketType, Socket,
lists:flatten(lists:reverse(Data)));
{ssl_error, Socket, Error} ->
@@ -355,10 +359,14 @@ await_poll_response2(SocketType, Socket, ExpStatusCode, Data) ->
%% TCP receives
{tcp, Socket, NewData} ->
+ d("await_poll_response2 -> "
+ "received part (~w bytes) of the response", [sz(NewData)]),
await_poll_response2(SocketType, Socket, ExpStatusCode,
[NewData | Data]);
{tcp_closed, Socket} ->
%% We are done or we failed
+ d("await_poll_response2 -> "
+ "we are done after receiving ~w bytes data", [sz(Data)]),
validate(ExpStatusCode, SocketType, Socket,
lists:flatten(lists:reverse(Data)));
{tcp_error, Socket, Error} ->
diff --git a/lib/inets/test/inets_app_test.erl b/lib/inets/test/inets_app_test.erl
index 9d7202e087..db2218f3b6 100644
--- a/lib/inets/test/inets_app_test.erl
+++ b/lib/inets/test/inets_app_test.erl
@@ -45,8 +45,7 @@ end_per_testcase(_Case, Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
all() ->
- [fields, modules, exportall, app_depend,
- undef_funcs].
+ [fields, modules, exportall, app_depend, undef_funcs].
groups() ->
[].
@@ -243,18 +242,11 @@ undef_funcs(doc) ->
undef_funcs(Config) when is_list(Config) ->
%% We need to check if there is a point to run this test.
%% On some platforms, crypto will not build, which in turn
- %% causes ssl to not to not build (at this time, this will
+ %% causes ssl to not build (at this time, this will
%% change in the future).
%% So, we first check if we can start crypto, and if not,
%% we skip this test case!
- case (catch crypto:start()) of
- ok ->
- ok;
- {error, {already_started, crypto}} ->
- ok;
- _ ->
- ?SKIP(crypto_start_check_failed)
- end,
+ ?ENSURE_STARTED(crypto),
App = inets,
AppFile = key1search(app_file, Config),
Mods = key1search(modules, AppFile),
@@ -266,7 +258,7 @@ undef_funcs(Config) when is_list(Config) ->
ok = xref:set_default(XRef,
[{verbose,false},{warnings,false}]),
XRefName = undef_funcs_make_name(App, xref_name),
- {ok, XRefName} = xref:add_release(XRef, Root, {name,XRefName}),
+ {ok, XRefName} = xref:add_release(XRef, Root, {name, XRefName}),
{ok, App} = xref:replace_application(XRef, App, EbinDir),
{ok, Undefs} = xref:analyze(XRef, undefined_function_calls),
xref:stop(XRef),
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
%%
diff --git a/lib/inets/test/inets_test_lib.hrl b/lib/inets/test/inets_test_lib.hrl
index 4dd81093a2..c578398c55 100644
--- a/lib/inets/test/inets_test_lib.hrl
+++ b/lib/inets/test/inets_test_lib.hrl
@@ -64,10 +64,11 @@
%% - Misc macros -
--define(UPDATE(K,V,C), inets_test_lib:update_config(K,V,C)).
--define(CONFIG(K,C), inets_test_lib:get_config(K,C)).
--define(HOSTNAME(), inets_test_lib:hostname()).
--define(SZ(X), inets_test_lib:sz(X)).
+-define(ENSURE_STARTED(A), inets_test_lib:ensure_started(A)).
+-define(UPDATE(K,V,C), inets_test_lib:update_config(K,V,C)).
+-define(CONFIG(K,C), inets_test_lib:get_config(K,C)).
+-define(HOSTNAME(), inets_test_lib:hostname()).
+-define(SZ(X), inets_test_lib:sz(X)).
%% - Test case macros -