aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test/src')
-rw-r--r--lib/common_test/src/ct_run.erl58
-rw-r--r--lib/common_test/src/ct_testspec.erl38
-rw-r--r--lib/common_test/src/ct_util.hrl4
3 files changed, 64 insertions, 36 deletions
diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl
index ec9351f346..7037ac7c1e 100644
--- a/lib/common_test/src/ct_run.erl
+++ b/lib/common_test/src/ct_run.erl
@@ -76,25 +76,32 @@ script_start() ->
Init = init:get_arguments(),
CtArgs = lists:takewhile(fun({ct_erl_args,_}) -> false;
(_) -> true end, Init),
- Args = case application:get_env(common_test, run_test_start_opts) of
- {ok,EnvStartOpts} ->
- %%! --- Mon May 31 22:59:29 2010 --- peppe was here!
- io:format(user, "~nEnv1:~n~p~n~n~p~n", [EnvStartOpts,opts2args(EnvStartOpts)]),
-
- merge_arguments(CtArgs ++ opts2args(EnvStartOpts));
- _ ->
- merge_arguments(CtArgs)
- end,
-
- %%! --- Mon May 31 12:32:48 2010 --- peppe was here!
- io:format(user, "~nInit:~n~p~n", [Init]),
-
- %%! --- Mon May 31 12:32:48 2010 --- peppe was here!
- io:format(user, "~nCtArgs:~n~p~n", [CtArgs]),
-
- %%! --- Mon May 31 12:32:48 2010 --- peppe was here!
- io:format(user, "~nArgs:~n~p~n", [Args]),
-
+ Args =
+ case application:get_env(common_test, run_test_start_opts) of
+ {ok,EnvStartOpts} ->
+ FlagFilter = fun(Flags) ->
+ lists:filter(fun({root,_}) -> false;
+ ({progname,_}) -> false;
+ ({home,_}) -> false;
+ ({noshell,_}) -> false;
+ ({noinput,_}) -> false;
+ (_) -> true
+ end, Flags)
+ end,
+ %% used for purpose of testing the run_test interface
+ io:format(user, "~n--------------- START ARGS ---------------~n", []),
+ io:format(user, "--- Init args:~n~p~n", [FlagFilter(Init)]),
+ io:format(user, "--- CT args:~n~p~n", [FlagFilter(CtArgs)]),
+ EnvArgs = opts2args(EnvStartOpts),
+ io:format(user, "--- Env opts -> args:~n~p~n =>~n~p~n",
+ [EnvStartOpts,EnvArgs]),
+ Merged = merge_arguments(CtArgs ++ EnvArgs),
+ io:format(user, "--- Merged args:~n~p~n", [FlagFilter(Merged)]),
+ io:format(user, "------------------------------------------~n~n", []),
+ Merged;
+ _ ->
+ merge_arguments(CtArgs)
+ end,
case proplists:get_value(help, Args) of
undefined -> script_start(Args);
_ -> script_usage()
@@ -151,9 +158,6 @@ script_start1(Parent, Args) ->
ScaleTT = get_start_opt(scale_timetraps, fun(CT) -> CT end, false, Args),
EvHandlers = event_handler_args2opts(Args),
- %%! --- Mon May 31 23:16:45 2010 --- peppe was here!
- io:format(user, "~nEvHandlers = ~p~n~n", [EvHandlers]),
-
%% check flags and set corresponding application env variables
%% ct_decrypt_key | ct_decrypt_file
@@ -603,10 +607,6 @@ run_test1(StartOpts) ->
end, Hs))
end,
- %%! --- Mon May 31 23:16:45 2010 --- peppe was here!
- io:format("~nEvHandlers = ~p~n~n", [EvHandlers]),
- io:format(user, "~nEvHandlers = ~p~n~n", [EvHandlers]),
-
%% silent connections
SilentConns = get_start_opt(silent_connections,
fun(all) -> [];
@@ -684,7 +684,7 @@ run_test1(StartOpts) ->
run_prepared(Run, Skip, Opts#opts{testspecs = Specs}, StartOpts)
end;
Specs ->
- Relaxed = get_start_opt(allow_user_term, value, false),
+ Relaxed = get_start_opt(allow_user_terms, value, false, StartOpts),
%% using testspec(s) as input for test
run_spec_file(Relaxed, Opts#opts{testspecs = Specs}, StartOpts)
end.
@@ -1855,6 +1855,8 @@ opts2args(EnvStartOpts) ->
end, UserCfg),
[_LastAnd|StrsR] = lists:reverse(lists:flatten(Strs)),
[{userconfig,lists:reverse(StrsR)}];
+ ({testcase,Case}) when is_atom(Case) ->
+ [{'case',[atom_to_list(Case)]}];
({testcase,Cases}) ->
[{'case',[atom_to_list(C) || C <- Cases]}];
({'case',Cases}) ->
@@ -1900,7 +1902,7 @@ opts2args(EnvStartOpts) ->
({Opt,As=[A|_]}) when is_atom(A) ->
[{Opt,[atom_to_list(Atom) || Atom <- As]}];
({Opt,Strs=[S|_]}) when is_list(S) ->
- [{Opt,[Strs]}];
+ [{Opt,Strs}];
({Opt,A}) when is_atom(A) ->
[{Opt,[atom_to_list(A)]}];
({Opt,I}) when is_integer(I) ->
diff --git a/lib/common_test/src/ct_testspec.erl b/lib/common_test/src/ct_testspec.erl
index 582ce5e49f..1ab9242e4b 100644
--- a/lib/common_test/src/ct_testspec.erl
+++ b/lib/common_test/src/ct_testspec.erl
@@ -17,7 +17,7 @@
%% %CopyrightEnd%
%%
-%%% @doc Common Test Framework functions handlig test specifications.
+%%% @doc Common Test Framework functions handling test specifications.
%%%
%%% <p>This module exports functions that are used within CT to
%%% scan and parse test specifikations.</p>
@@ -384,7 +384,7 @@ filter_init_terms([{init, [], _}|Ts], NewTerms, Spec)->
filter_init_terms([Term|Ts], NewTerms, Spec)->
filter_init_terms(Ts, [Term|NewTerms], Spec);
filter_init_terms([], NewTerms, Spec)->
- {NewTerms, Spec}.
+ {lists:reverse(NewTerms), Spec}.
add_option([], _, List, _)->
List;
@@ -472,6 +472,36 @@ add_tests([{cover,Node,File}|Ts],Spec) ->
add_tests([{cover,File}|Ts],Spec) ->
add_tests([{cover,all_nodes,File}|Ts],Spec);
+%% --- multiply_timetraps ---
+add_tests([{multiply_timetraps,all_nodes,MT}|Ts],Spec) ->
+ Tests = lists:map(fun(N) -> {multiply_timetraps,N,MT} end, list_nodes(Spec)),
+ add_tests(Tests++Ts,Spec);
+add_tests([{multiply_timetraps,Nodes,MT}|Ts],Spec) when is_list(Nodes) ->
+ Ts1 = separate(Nodes,multiply_timetraps,[MT],Ts,Spec#testspec.nodes),
+ add_tests(Ts1,Spec);
+add_tests([{multiply_timetraps,Node,MT}|Ts],Spec) ->
+ MTs = Spec#testspec.multiply_timetraps,
+ MTs1 = [{ref2node(Node,Spec#testspec.nodes),MT} |
+ lists:keydelete(ref2node(Node,Spec#testspec.nodes),1,MTs)],
+ add_tests(Ts,Spec#testspec{multiply_timetraps=MTs1});
+add_tests([{multiply_timetraps,MT}|Ts],Spec) ->
+ add_tests([{multiply_timetraps,all_nodes,MT}|Ts],Spec);
+
+%% --- scale_timetraps ---
+add_tests([{scale_timetraps,all_nodes,ST}|Ts],Spec) ->
+ Tests = lists:map(fun(N) -> {scale_timetraps,N,ST} end, list_nodes(Spec)),
+ add_tests(Tests++Ts,Spec);
+add_tests([{scale_timetraps,Nodes,ST}|Ts],Spec) when is_list(Nodes) ->
+ Ts1 = separate(Nodes,scale_timetraps,[ST],Ts,Spec#testspec.nodes),
+ add_tests(Ts1,Spec);
+add_tests([{scale_timetraps,Node,ST}|Ts],Spec) ->
+ STs = Spec#testspec.scale_timetraps,
+ STs1 = [{ref2node(Node,Spec#testspec.nodes),ST} |
+ lists:keydelete(ref2node(Node,Spec#testspec.nodes),1,STs)],
+ add_tests(Ts,Spec#testspec{scale_timetraps=STs1});
+add_tests([{scale_timetraps,ST}|Ts],Spec) ->
+ add_tests([{scale_timetraps,all_nodes,ST}|Ts],Spec);
+
%% --- config ---
add_tests([{config,all_nodes,Files}|Ts],Spec) ->
Tests = lists:map(fun(N) -> {config,N,Files} end, list_nodes(Spec)),
@@ -895,7 +925,3 @@ common_letters([L|Ls],Term,Count) ->
end;
common_letters([],_,Count) ->
Count.
-
-
-
-
diff --git a/lib/common_test/src/ct_util.hrl b/lib/common_test/src/ct_util.hrl
index d9c5631f88..54eed29415 100644
--- a/lib/common_test/src/ct_util.hrl
+++ b/lib/common_test/src/ct_util.hrl
@@ -36,8 +36,8 @@
userconfig=[],
event_handler=[],
include=[],
- multiply_timetraps,
- scale_timetraps,
+ multiply_timetraps=[],
+ scale_timetraps=[],
alias=[],
tests=[]}).