aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2012-08-27 12:04:27 +0200
committerPeter Andersson <[email protected]>2012-08-27 12:04:27 +0200
commit04a15afb839b28f99b2513b8276ed95e77e8ddfd (patch)
treeb4450bbcffa8c938e7b9ec62c2b4619a61596f8c /lib
parentd412be9f230027753cdc865d222a3a6103391757 (diff)
parent5472a54b7f952c08e794eb52175d3724cc2937db (diff)
downloadotp-04a15afb839b28f99b2513b8276ed95e77e8ddfd.tar.gz
otp-04a15afb839b28f99b2513b8276ed95e77e8ddfd.tar.bz2
otp-04a15afb839b28f99b2513b8276ed95e77e8ddfd.zip
Merge remote branch 'upstream/maint'
Diffstat (limited to 'lib')
-rw-r--r--lib/common_test/src/ct_framework.erl23
-rw-r--r--lib/common_test/src/ct_hooks.erl2
-rw-r--r--lib/common_test/src/ct_run.erl40
-rw-r--r--lib/common_test/src/ct_testspec.erl14
-rw-r--r--lib/common_test/src/ct_util.erl20
-rw-r--r--lib/common_test/src/ct_util.hrl1
-rw-r--r--lib/common_test/src/cth_surefire.erl2
-rw-r--r--lib/common_test/test/ct_testspec_2_SUITE.erl8
8 files changed, 76 insertions, 34 deletions
diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl
index e8d5d4708b..4d47731239 100644
--- a/lib/common_test/src/ct_framework.erl
+++ b/lib/common_test/src/ct_framework.erl
@@ -71,16 +71,13 @@ init_tc(Mod,Func,Config) ->
{skip,{require_failed_in_suite0,Reason}};
{Suite,{suite0_failed,_}=Failure} ->
{skip,Failure};
- CurrTC ->
- case CurrTC of
- undefined ->
- ct_util:set_testdata({curr_tc,[{Suite,Func}]});
- _ when is_list(CurrTC) ->
- ct_util:update_testdata(curr_tc,
- fun(Running) ->
- [{Suite,Func}|Running]
- end)
- end,
+ _ ->
+ ct_util:update_testdata(curr_tc,
+ fun(undefined) ->
+ [{Suite,Func}];
+ (Running) ->
+ [{Suite,Func}|Running]
+ end, [create]),
case ct_util:read_suite_data({seq,Suite,Func}) of
undefined ->
init_tc1(Mod,Suite,Func,Config);
@@ -671,13 +668,15 @@ end_tc(Mod,Func,TCPid,Result,Args,Return) ->
%% reset the curr_tc state, or delete this TC from the list of
%% executing cases (if in a parallel group)
ClearCurrTC = fun(Running = [_,_|_]) ->
- lists:delete({Mod,Func},Running);
+ lists:keydelete(Func,2,Running);
({_,{suite0_failed,_}}) ->
undefined;
([{_,CurrTC}]) when CurrTC == Func ->
undefined;
(undefined) ->
- undefined
+ undefined;
+ (Unexpected) ->
+ exit({error,{reset_curr_tc,{Mod,Func},Unexpected}})
end,
ct_util:update_testdata(curr_tc,ClearCurrTC),
diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl
index d0432b604d..1bcc63738e 100644
--- a/lib/common_test/src/ct_hooks.erl
+++ b/lib/common_test/src/ct_hooks.erl
@@ -48,7 +48,7 @@
%% @doc Called before any suites are started
-spec init(State :: term()) -> ok |
- {error, Reason :: term()}.
+ {fail, Reason :: term()}.
init(Opts) ->
call(get_new_hooks(Opts, undefined) ++ get_builtin_hooks(Opts),
ok, init, []).
diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl
index a202ca15e2..faf5786a54 100644
--- a/lib/common_test/src/ct_run.erl
+++ b/lib/common_test/src/ct_run.erl
@@ -70,7 +70,7 @@
enable_builtin_hooks,
include = [],
auto_compile,
- silent_connections,
+ silent_connections = [],
stylesheet,
multiply_timetraps = 1,
scale_timetraps = false,
@@ -304,9 +304,9 @@ script_start1(Parent, Args) ->
%% silent connections
SilentConns =
get_start_opt(silent_connections,
- fun(["all"]) -> [];
+ fun(["all"]) -> [all];
(Conns) -> [list_to_atom(Conn) || Conn <- Conns]
- end, Args),
+ end, [], Args),
%% stylesheet
Stylesheet = get_start_opt(stylesheet,
fun([SS]) -> ?abs(SS) end, Args),
@@ -401,6 +401,9 @@ script_start2(StartOpts = #opts{vts = undefined,
AllVerbosity =
merge_keyvals([StartOpts#opts.verbosity,
SpecStartOpts#opts.verbosity]),
+ AllSilentConns =
+ merge_vals([StartOpts#opts.silent_connections,
+ SpecStartOpts#opts.silent_connections]),
Cover =
choose_val(StartOpts#opts.cover,
SpecStartOpts#opts.cover),
@@ -467,6 +470,7 @@ script_start2(StartOpts = #opts{vts = undefined,
logopts = AllLogOpts,
basic_html = BasicHtml,
verbosity = AllVerbosity,
+ silent_connections = AllSilentConns,
config = SpecStartOpts#opts.config,
event_handlers = AllEvHs,
ct_hooks = AllCTHooks,
@@ -914,9 +918,9 @@ run_test2(StartOpts) ->
%% silent connections
SilentConns = get_start_opt(silent_connections,
- fun(all) -> [];
+ fun(all) -> [all];
(Conns) -> Conns
- end, StartOpts),
+ end, [], StartOpts),
%% stylesheet
Stylesheet = get_start_opt(stylesheet,
fun(SS) -> ?abs(SS) end,
@@ -1043,6 +1047,8 @@ run_spec_file(Relaxed,
SpecOpts#opts.stylesheet),
AllVerbosity = merge_keyvals([Opts#opts.verbosity,
SpecOpts#opts.verbosity]),
+ AllSilentConns = merge_vals([Opts#opts.silent_connections,
+ SpecOpts#opts.silent_connections]),
AllConfig = merge_vals([CfgFiles, SpecOpts#opts.config]),
Cover = choose_val(Opts#opts.cover,
SpecOpts#opts.cover),
@@ -1091,6 +1097,7 @@ run_spec_file(Relaxed,
stylesheet = Stylesheet,
basic_html = BasicHtml,
verbosity = AllVerbosity,
+ silent_connections = AllSilentConns,
config = AllConfig,
event_handlers = AllEvHs,
auto_compile = AutoCompile,
@@ -1354,6 +1361,7 @@ get_data_for_node(#testspec{label = Labels,
basic_html = BHs,
stylesheet = SSs,
verbosity = VLvls,
+ silent_connections = SilentConnsList,
cover = CoverFs,
config = Cfgs,
userconfig = UsrCfgs,
@@ -1381,6 +1389,10 @@ get_data_for_node(#testspec{label = Labels,
undefined -> [];
Lvls -> Lvls
end,
+ SilentConns = case proplists:get_value(Node, SilentConnsList) of
+ undefined -> [];
+ SCs -> SCs
+ end,
Cover = proplists:get_value(Node, CoverFs),
MT = proplists:get_value(Node, MTs),
ST = proplists:get_value(Node, STs),
@@ -1398,6 +1410,7 @@ get_data_for_node(#testspec{label = Labels,
basic_html = BasicHtml,
stylesheet = Stylesheet,
verbosity = Verbosity,
+ silent_connections = SilentConns,
cover = Cover,
config = ConfigFiles,
event_handlers = EvHandlers,
@@ -1632,13 +1645,16 @@ compile_and_run(Tests, Skip, Opts, Args) ->
%% enable silent connections
case Opts#opts.silent_connections of
[] ->
- Conns = ct_util:override_silence_all_connections(),
- ct_logs:log("Silent connections", "~p", [Conns]);
- Conns when is_list(Conns) ->
- ct_util:override_silence_connections(Conns),
- ct_logs:log("Silent connections", "~p", [Conns]);
- _ ->
- ok
+ ok;
+ Conns ->
+ case lists:member(all, Conns) of
+ true ->
+ Conns1 = ct_util:override_silence_all_connections(),
+ ct_logs:log("Silent connections", "~p", [Conns1]);
+ false ->
+ ct_util:override_silence_connections(Conns),
+ ct_logs:log("Silent connections", "~p", [Conns])
+ end
end,
log_ts_names(Opts#opts.testspecs),
TestSuites = suite_tuples(Tests),
diff --git a/lib/common_test/src/ct_testspec.erl b/lib/common_test/src/ct_testspec.erl
index 7759aca16b..de63ac3b75 100644
--- a/lib/common_test/src/ct_testspec.erl
+++ b/lib/common_test/src/ct_testspec.erl
@@ -940,6 +940,12 @@ handle_data(verbosity,Node,VLvls,_Spec) when is_list(VLvls) ->
VLvls1 = lists:map(fun(VLvl = {_Cat,_Lvl}) -> VLvl;
(Lvl) -> {'$unspecified',Lvl} end, VLvls),
[{Node,VLvls1}];
+handle_data(silent_connections,Node,all,_Spec) ->
+ [{Node,[all]}];
+handle_data(silent_connections,Node,Conn,_Spec) when is_atom(Conn) ->
+ [{Node,[Conn]}];
+handle_data(silent_connections,Node,Conns,_Spec) ->
+ [{Node,Conns}];
handle_data(_Tag,Node,Data,_Spec) ->
[{Node,Data}].
@@ -947,10 +953,10 @@ handle_data(_Tag,Node,Data,_Spec) ->
should_be_added(Tag,Node,_Data,Spec) ->
if
%% list terms *without* possible duplicates here
- Tag == logdir; Tag == logopts;
- Tag == basic_html; Tag == label;
+ Tag == logdir; Tag == logopts;
+ Tag == basic_html; Tag == label;
Tag == auto_compile; Tag == stylesheet;
- Tag == verbosity ->
+ Tag == verbosity; Tag == silent_connections ->
lists:keymember(ref2node(Node,Spec#testspec.nodes),1,
read_field(Spec,Tag)) == false;
%% for terms *with* possible duplicates
@@ -1267,6 +1273,8 @@ valid_terms() ->
{basic_html,3},
{verbosity,2},
{verbosity,3},
+ {silent_connections,2},
+ {silent_connections,3},
{label,2},
{label,3},
{event_handler,2},
diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl
index efc85543ac..cf891ed043 100644
--- a/lib/common_test/src/ct_util.erl
+++ b/lib/common_test/src/ct_util.erl
@@ -39,7 +39,7 @@
delete_suite_data/0, delete_suite_data/1, match_delete_suite_data/1,
delete_testdata/0, delete_testdata/1,
set_testdata/1, get_testdata/1, get_testdata/2,
- set_testdata_async/1, update_testdata/2]).
+ set_testdata_async/1, update_testdata/2, update_testdata/3]).
-export([override_silence_all_connections/0, override_silence_connections/1,
get_overridden_silenced_connections/0,
@@ -252,7 +252,10 @@ delete_testdata(Key) ->
call({delete_testdata, Key}).
update_testdata(Key, Fun) ->
- call({update_testdata, Key, Fun}).
+ update_testdata(Key, Fun, []).
+
+update_testdata(Key, Fun, Opts) ->
+ call({update_testdata, Key, Fun, Opts}).
set_testdata(TestData) ->
call({set_testdata, TestData}).
@@ -333,7 +336,7 @@ loop(Mode,TestData,StartDir) ->
return(From,undefined)
end,
loop(From,TestData,StartDir);
- {{update_testdata,Key,Fun},From} ->
+ {{update_testdata,Key,Fun,Opts},From} ->
TestData1 =
case lists:keysearch(Key,1,TestData) of
{value,{Key,Val}} ->
@@ -341,8 +344,15 @@ loop(Mode,TestData,StartDir) ->
return(From,NewVal),
[{Key,NewVal}|lists:keydelete(Key,1,TestData)];
_ ->
- return(From,undefined),
- TestData
+ case lists:member(create,Opts) of
+ true ->
+ InitVal = Fun(undefined),
+ return(From,InitVal),
+ [{Key,InitVal}|TestData];
+ false ->
+ return(From,undefined),
+ TestData
+ end
end,
loop(From,TestData1,StartDir);
{{set_cwd,Dir},From} ->
diff --git a/lib/common_test/src/ct_util.hrl b/lib/common_test/src/ct_util.hrl
index 7015014441..7b08e78433 100644
--- a/lib/common_test/src/ct_util.hrl
+++ b/lib/common_test/src/ct_util.hrl
@@ -36,6 +36,7 @@
logopts=[],
basic_html=[],
verbosity=[],
+ silent_connections=[],
cover=[],
config=[],
userconfig=[],
diff --git a/lib/common_test/src/cth_surefire.erl b/lib/common_test/src/cth_surefire.erl
index e7bd84e51b..76b0f0b5ea 100644
--- a/lib/common_test/src/cth_surefire.erl
+++ b/lib/common_test/src/cth_surefire.erl
@@ -92,7 +92,7 @@ on_tc_fail(_TC, Res, State) ->
{fail,lists:flatten(io_lib:format("~p",[Res]))} },
State#state{ test_cases = [NewTC | tl(TCs)]}.
-on_tc_skip(Tc,{Type,Reason} = Res, State) when Type == tc_auto_skip ->
+on_tc_skip(Tc,{Type,_Reason} = Res, State) when Type == tc_auto_skip ->
do_tc_skip(Res, end_tc(Tc,[],Res,init_tc(State,[])));
on_tc_skip(_Tc, _Res, State = #state{test_cases = []}) ->
State;
diff --git a/lib/common_test/test/ct_testspec_2_SUITE.erl b/lib/common_test/test/ct_testspec_2_SUITE.erl
index 93f3520f95..681387c745 100644
--- a/lib/common_test/test/ct_testspec_2_SUITE.erl
+++ b/lib/common_test/test/ct_testspec_2_SUITE.erl
@@ -79,6 +79,10 @@ all() ->
%% {logopts,3}
%% {basic_html,2}
%% {basic_html,3}
+%% {verbosity,2}
+%% {verbosity,3}
+%% {silent_connections,2}
+%% {silent_connections,3}
%% {label,2}
%% {label,3}
%% {event_handler,2}
@@ -533,6 +537,9 @@ misc_config_terms(_Config) ->
{basic_html,n1@h1,false},
{basic_html,n2@h2,true},
+ {silent_connections,n1@h1,all},
+ {silent_connections,n2@h2,[ssh]},
+
{enable_builtin_hooks,false},
{noinput,true},
@@ -571,6 +578,7 @@ misc_config_terms(_Config) ->
Verify = #testspec{spec_dir = SpecDir,
nodes = [{undefined,Node},{x,n1@h1},{y,n2@h2}],
basic_html = [{Node,true},{n1@h1,false},{n2@h2,true}],
+ silent_connections = [{n1@h1,[all]},{n2@h2,[ssh]}],
config = [{Node,CfgA},
{n1@h1,CfgA},
{n2@h2,CfgA},