aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test')
-rw-r--r--lib/common_test/src/ct_run.erl45
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE.erl147
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_state_scb_SUITE.erl56
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_state_scb_SUITE.erl47
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_state_scb_SUITE.erl50
5 files changed, 330 insertions, 15 deletions
diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl
index 7d6a2f54d9..a12d4d6f18 100644
--- a/lib/common_test/src/ct_run.erl
+++ b/lib/common_test/src/ct_run.erl
@@ -172,9 +172,7 @@ script_start1(Parent, Args) ->
([]) -> true
end, false, Args),
EvHandlers = event_handler_args2opts(Args),
- SuiteCBs = get_start_opt(suite_callbacks,
- fun(CBs) -> [list_to_atom(CB) || CB <- CBs] end,
- [], Args),
+ SuiteCBs = suite_callbacks_args2opts(Args),
%% check flags and set corresponding application env variables
@@ -2076,6 +2074,33 @@ get_start_opt(Key, IfExists, IfNotExists, Args) ->
IfNotExists
end.
+suite_callbacks_args2opts(Args) ->
+ suite_callbacks_args2opts(
+ proplists:get_value(suite_callbacks, Args, []),[]).
+
+suite_callbacks_args2opts([SCB,Arg,"and"| Rest],Acc) ->
+ suite_callbacks_args2opts(Rest,[{list_to_atom(SCB),
+ parse_scb_args(Arg)}|Acc]);
+suite_callbacks_args2opts([SCB], Acc) ->
+ suite_callbacks_args2opts([SCB,"and"],Acc);
+suite_callbacks_args2opts([SCB, "and" | Rest], Acc) ->
+ suite_callbacks_args2opts(Rest,[list_to_atom(SCB)|Acc]);
+suite_callbacks_args2opts([SCB, Args], Acc) ->
+ suite_callbacks_args2opts([SCB, Args, "and"],Acc);
+suite_callbacks_args2opts([],Acc) ->
+ lists:reverse(Acc).
+
+parse_scb_args(String) ->
+ try
+ true = io_lib:printable_list(String),
+ {ok,Toks,_} = erl_scan:string(String++"."),
+ {ok, Args} = erl_parse:parse_term(Toks),
+ Args
+ catch _:_ ->
+ String
+ end.
+
+
event_handler_args2opts(Args) ->
case proplists:get_value(event_handler, Args) of
undefined ->
@@ -2205,6 +2230,20 @@ opts2args(EnvStartOpts) ->
[{event_handler_init,lists:reverse(StrsR)}];
({suite_callbacks,[]}) ->
[];
+ ({suite_callbacks,SCBs}) when is_list(SCBs) ->
+ io:format(user,"suite_callbacks: ~p",[SCBs]),
+ Strs = lists:flatmap(
+ fun({SCB,Arg}) ->
+ [atom_to_list(SCB),
+ lists:flatten(
+ io_lib:format("~p",[Arg])),
+ "and"];
+ (SCB) when is_atom(SCB) ->
+ [atom_to_list(SCB),"and"]
+ end,SCBs),
+ [_LastAnd|StrsR] = lists:reverse(Strs),
+ io:format(user,"return: ~p",[lists:reverse(StrsR)]),
+ [{suite_callbacks,lists:reverse(StrsR)}];
({Opt,As=[A|_]}) when is_atom(A) ->
[{Opt,[atom_to_list(Atom) || Atom <- As]}];
({Opt,Strs=[S|_]}) when is_list(S) ->
diff --git a/lib/common_test/test/ct_suite_callback_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE.erl
index 8d620be7ba..88ce5e0e51 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE.erl
@@ -70,17 +70,19 @@ all() ->
all(suite).
all(suite) ->
- %% lists:reverse(
+ lists:reverse(
[
one_scb, two_scb, faulty_scb_no_init, faulty_scb_exit_in_init,
faulty_scb_exit_in_init_scope_suite, minimal_scb,
- minimal_and_maximal_scb, faulty_scb_undef, scope_per_suite_scb,
- scope_per_group_scb, scope_suite_scb,
+ minimal_and_maximal_scb, faulty_scb_undef,
+ scope_per_suite_scb, scope_per_group_scb, scope_suite_scb,
+ scope_per_suite_state_scb, scope_per_group_state_scb,
+ scope_suite_state_scb,
fail_pre_suite_scb, fail_post_suite_scb, skip_pre_suite_scb,
skip_post_suite_scb, recover_post_suite_scb, update_config_scb,
- state_update_scb
+ state_update_scb, options_scb
]
- %%)
+ )
.
@@ -136,34 +138,51 @@ scope_per_group_scb(Config) when is_list(Config) ->
do_test(scope_per_group_scb, "ct_scope_per_group_scb_SUITE.erl",
[],Config).
-fail_pre_suite_scb(Config) ->
+scope_per_suite_state_scb(Config) when is_list(Config) ->
+ do_test(scope_per_suite_state_scb, "ct_scope_per_suite_state_scb_SUITE.erl",
+ [],Config).
+
+scope_suite_state_scb(Config) when is_list(Config) ->
+ do_test(scope_suite_state_scb, "ct_scope_suite_state_scb_SUITE.erl",
+ [],Config).
+
+scope_per_group_state_scb(Config) when is_list(Config) ->
+ do_test(scope_per_group_state_scb, "ct_scope_per_group_state_scb_SUITE.erl",
+ [],Config).
+
+fail_pre_suite_scb(Config) when is_list(Config) ->
do_test(fail_pre_suite_scb, "ct_scb_empty_SUITE.erl",
[fail_pre_suite_scb],Config).
-fail_post_suite_scb(Config) ->
+fail_post_suite_scb(Config) when is_list(Config) ->
do_test(fail_post_suite_scb, "ct_scb_empty_SUITE.erl",
[fail_post_suite_scb],Config).
-skip_pre_suite_scb(Config) ->
+skip_pre_suite_scb(Config) when is_list(Config) ->
do_test(skip_pre_suite_scb, "ct_scb_empty_SUITE.erl",
[skip_pre_suite_scb],Config).
-skip_post_suite_scb(Config) ->
+skip_post_suite_scb(Config) when is_list(Config) ->
do_test(skip_post_suite_scb, "ct_scb_empty_SUITE.erl",
[skip_post_suite_scb],Config).
-recover_post_suite_scb(Config) ->
+recover_post_suite_scb(Config) when is_list(Config) ->
do_test(recover_post_suite_scb, "ct_scb_fail_per_suite_SUITE.erl",
[recover_post_suite_scb],Config).
-update_config_scb(Config) ->
+update_config_scb(Config) when is_list(Config) ->
do_test(update_config_scb, "ct_update_config_SUITE.erl",
[update_config_scb],Config).
-state_update_scb(Config) ->
+state_update_scb(Config) when is_list(Config) ->
do_test(state_update_scb, "ct_scb_fail_one_skip_one_SUITE.erl",
[state_update_scb,state_update_scb],Config).
+options_scb(Config) when is_list(Config) ->
+ do_test(options_scb, "ct_scb_empty_SUITE.erl",
+ [{empty_scb,[test]}],Config).
+
+
%%%-----------------------------------------------------------------
%%% HELP FUNCTIONS
%%%-----------------------------------------------------------------
@@ -460,6 +479,83 @@ test_events(scope_per_group_scb) ->
{?eh,stop_logging,[]}
];
+test_events(scope_per_suite_state_scb) ->
+ [
+ {?eh,start_logging,{'DEF','RUNDIR'}},
+ {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
+ {?eh,tc_start,{ct_scope_per_suite_state_scb_SUITE,init_per_suite}},
+ {?eh,scb,{'_',init,[[test]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scope_per_suite_state_scb_SUITE,'$proplist','$proplist',[test]]}},
+ {?eh,tc_done,{ct_scope_per_suite_state_scb_SUITE,init_per_suite,ok}},
+
+ {?eh,tc_start,{ct_scope_per_suite_state_scb_SUITE,test_case}},
+ {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[test]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[test]]}},
+ {?eh,tc_done,{ct_scope_per_suite_state_scb_SUITE,test_case,ok}},
+
+ {?eh,tc_start,{ct_scope_per_suite_state_scb_SUITE,end_per_suite}},
+ {?eh,scb,{'_',pre_end_per_suite,
+ [ct_scope_per_suite_state_scb_SUITE,'$proplist',[test]]}},
+ {?eh,scb,{'_',post_end_per_suite,[ct_scope_per_suite_state_scb_SUITE,'$proplist','_',[test]]}},
+ {?eh,scb,{'_',terminate,[[test]]}},
+ {?eh,tc_done,{ct_scope_per_suite_state_scb_SUITE,end_per_suite,ok}},
+ {?eh,test_done,{'DEF','STOP_TIME'}},
+ {?eh,stop_logging,[]}
+ ];
+
+test_events(scope_suite_state_scb) ->
+ [
+ {?eh,start_logging,{'DEF','RUNDIR'}},
+ {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
+ {?eh,tc_start,{ct_scope_suite_state_scb_SUITE,init_per_suite}},
+ {?eh,scb,{'_',init,[[test]]}},
+ {?eh,scb,{'_',pre_init_per_suite,[ct_scope_suite_state_scb_SUITE,'$proplist',[test]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scope_suite_state_scb_SUITE,'$proplist','$proplist',[test]]}},
+ {?eh,tc_done,{ct_scope_suite_state_scb_SUITE,init_per_suite,ok}},
+
+ {?eh,tc_start,{ct_scope_suite_state_scb_SUITE,test_case}},
+ {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[test]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[test]]}},
+ {?eh,tc_done,{ct_scope_suite_state_scb_SUITE,test_case,ok}},
+
+ {?eh,tc_start,{ct_scope_suite_state_scb_SUITE,end_per_suite}},
+ {?eh,scb,{'_',pre_end_per_suite,[ct_scope_suite_state_scb_SUITE,'$proplist',[test]]}},
+ {?eh,scb,{'_',post_end_per_suite,[ct_scope_suite_state_scb_SUITE,'$proplist','_',[test]]}},
+ {?eh,scb,{'_',terminate,[[test]]}},
+ {?eh,tc_done,{ct_scope_suite_state_scb_SUITE,end_per_suite,ok}},
+ {?eh,test_done,{'DEF','STOP_TIME'}},
+ {?eh,stop_logging,[]}
+ ];
+
+test_events(scope_per_group_state_scb) ->
+ [
+ {?eh,start_logging,{'DEF','RUNDIR'}},
+ {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
+ {?eh,tc_start,{ct_scope_per_group_state_scb_SUITE,init_per_suite}},
+ {?eh,tc_done,{ct_scope_per_group_state_scb_SUITE,init_per_suite,ok}},
+
+ [{?eh,tc_start,{ct_scope_per_group_state_scb_SUITE,{init_per_group,group1,[]}}},
+ {?eh,scb,{'_',init,[[test]]}},
+ {?eh,scb,{'_',post_init_per_group,[group1,'$proplist','$proplist',[test]]}},
+ {?eh,tc_done,{ct_scope_per_group_state_scb_SUITE,{init_per_group,group1,[]},ok}},
+
+ {?eh,tc_start,{ct_scope_per_group_state_scb_SUITE,test_case}},
+ {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[test]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[test]]}},
+ {?eh,tc_done,{ct_scope_per_group_state_scb_SUITE,test_case,ok}},
+
+ {?eh,tc_start,{ct_scope_per_group_state_scb_SUITE,{end_per_group,group1,[]}}},
+ {?eh,scb,{'_',pre_end_per_group,[group1,'$proplist',[test]]}},
+ {?eh,scb,{'_',post_end_per_group,[group1,'$proplist','_',[test]]}},
+ {?eh,scb,{'_',terminate,[[test]]}},
+ {?eh,tc_done,{ct_scope_per_group_state_scb_SUITE,{end_per_group,group1,[]},ok}}],
+
+ {?eh,tc_start,{ct_scope_per_group_state_scb_SUITE,end_per_suite}},
+ {?eh,tc_done,{ct_scope_per_group_state_scb_SUITE,end_per_suite,ok}},
+ {?eh,test_done,{'DEF','STOP_TIME'}},
+ {?eh,stop_logging,[]}
+ ];
+
test_events(fail_pre_suite_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
@@ -753,6 +849,33 @@ test_events(state_update_scb) ->
{?eh,stop_logging,[]}
];
+test_events(options_scb) ->
+ [
+ {?eh,start_logging,{'DEF','RUNDIR'}},
+ {?eh,scb,{empty_scb,init,[[test]]}},
+ {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
+ {?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
+ {?eh,scb,{empty_scb,pre_init_per_suite,
+ [ct_scb_empty_SUITE,'$proplist',[test]]}},
+ {?eh,scb,{empty_scb,post_init_per_suite,
+ [ct_scb_empty_SUITE,'$proplist','$proplist',[test]]}},
+ {?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,ok}},
+
+ {?eh,tc_start,{ct_scb_empty_SUITE,test_case}},
+ {?eh,scb,{empty_scb,pre_init_per_testcase,[test_case,'$proplist',[test]]}},
+ {?eh,scb,{empty_scb,post_end_per_testcase,[test_case,'$proplist','_',[test]]}},
+ {?eh,tc_done,{ct_scb_empty_SUITE,test_case,ok}},
+
+ {?eh,tc_start,{ct_scb_empty_SUITE,end_per_suite}},
+ {?eh,scb,{empty_scb,pre_end_per_suite,
+ [ct_scb_empty_SUITE,'$proplist',[test]]}},
+ {?eh,scb,{empty_scb,post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[test]]}},
+ {?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}},
+ {?eh,test_done,{'DEF','STOP_TIME'}},
+ {?eh,scb,{empty_scb,terminate,[[test]]}},
+ {?eh,stop_logging,[]}
+ ];
+
test_events(ok) ->
ok.
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_state_scb_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_state_scb_SUITE.erl
new file mode 100644
index 0000000000..63dd767b25
--- /dev/null
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_state_scb_SUITE.erl
@@ -0,0 +1,56 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2010. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(ct_scope_per_group_state_scb_SUITE).
+
+-suite_defaults([{timetrap, {minutes, 10}}]).
+
+%% Note: This directive should only be used in test suites.
+-compile(export_all).
+
+-include("ct.hrl").
+
+%% Test server callback functions
+init_per_suite(Config) ->
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_testcase(_TestCase, Config) ->
+ Config.
+
+end_per_testcase(_TestCase, _Config) ->
+ ok.
+
+init_per_group(_GroupName, Config) ->
+ [{suite_callbacks,[{empty_scb,[test]}]}|Config].
+
+end_per_group(_GroupName, _Config) ->
+ ok.
+
+all() ->
+ [{group,group1}].
+
+groups() ->
+ [{group1,[],[test_case]}].
+
+%% Test cases starts here.
+test_case(Config) when is_list(Config) ->
+ ok.
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_state_scb_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_state_scb_SUITE.erl
new file mode 100644
index 0000000000..02a011f91b
--- /dev/null
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_state_scb_SUITE.erl
@@ -0,0 +1,47 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2010. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(ct_scope_per_suite_state_scb_SUITE).
+
+-suite_defaults([{timetrap, {minutes, 10}}]).
+
+%% Note: This directive should only be used in test suites.
+-compile(export_all).
+
+-include("ct.hrl").
+
+%% Test server callback functions
+init_per_suite(Config) ->
+ [{suite_callbacks,[{empty_scb,[test]}]}|Config].
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_testcase(_TestCase, Config) ->
+ Config.
+
+end_per_testcase(_TestCase, _Config) ->
+ ok.
+
+all() ->
+ [test_case].
+
+%% Test cases starts here.
+test_case(Config) when is_list(Config) ->
+ ok.
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_state_scb_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_state_scb_SUITE.erl
new file mode 100644
index 0000000000..869532f5cd
--- /dev/null
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_state_scb_SUITE.erl
@@ -0,0 +1,50 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2010. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(ct_scope_suite_state_scb_SUITE).
+
+-suite_defaults([{timetrap, {minutes, 10}}]).
+
+%% Note: This directive should only be used in test suites.
+-compile(export_all).
+
+-include("ct.hrl").
+
+%% Test server callback functions
+suite() ->
+ [{suite_callbacks,[{empty_scb,[test]}]}].
+
+init_per_suite(Config) ->
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_testcase(_TestCase, Config) ->
+ Config.
+
+end_per_testcase(_TestCase, _Config) ->
+ ok.
+
+all() ->
+ [test_case].
+
+%% Test cases starts here.
+test_case(Config) when is_list(Config) ->
+ ok.