aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-02-09 13:59:50 +0100
committerLukas Larsson <[email protected]>2011-02-17 16:59:39 +0100
commite34cd721545915266a00b1ec55a9a5867c8459a4 (patch)
tree8de64f1bc8b139c60d5a0e66f49427bbd78de717
parent15e8dd20b5ba2c82e683e87254f18c9af3625481 (diff)
downloadotp-e34cd721545915266a00b1ec55a9a5867c8459a4.tar.gz
otp-e34cd721545915266a00b1ec55a9a5867c8459a4.tar.bz2
otp-e34cd721545915266a00b1ec55a9a5867c8459a4.zip
Update SCBs to use a specific id/1 function for SCb overriding instead of returning it from init/1.
-rw-r--r--lib/common_test/src/ct_suite_callback.erl43
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE.erl97
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_id_scb.erl34
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_init_scb.erl6
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl26
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl4
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl4
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/id_no_init_scb.erl32
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_scb.erl6
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/recover_post_suite_scb.erl4
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/same_id_scb.erl9
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl4
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl4
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/state_update_scb.erl6
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl4
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/update_config_scb.erl4
16 files changed, 206 insertions, 81 deletions
diff --git a/lib/common_test/src/ct_suite_callback.erl b/lib/common_test/src/ct_suite_callback.erl
index 508d3b5bd6..947fa0c716 100644
--- a/lib/common_test/src/ct_suite_callback.erl
+++ b/lib/common_test/src/ct_suite_callback.erl
@@ -45,7 +45,7 @@
-spec init(State :: term()) -> ok |
{error, Reason :: term()}.
init(Opts) ->
- call([{CB, call_init, undefined} || CB <- get_new_callbacks(Opts)],
+ call([{CB, call_id, undefined} || CB <- get_new_callbacks(Opts)],
ok, init, []).
@@ -130,12 +130,16 @@ on_tc_fail(_How, {_Suite, Case, Reason}) ->
%% -------------------------------------------------------------------------
%% Internal Functions
%% -------------------------------------------------------------------------
-call_init(Mod, Config, Meta) when is_atom(Mod) ->
- call_init({Mod, []}, Config, Meta);
-call_init({Mod, State}, Config, Scope) ->
- {Id, NewState} = Mod:init(State),
- {Config, {Id, scope(Scope), {Mod, NewState}}}.
+call_id(Mod, Config, Meta) when is_atom(Mod) ->
+ call_id({Mod, []}, Config, Meta);
+call_id({Mod, Opts}, Config, Scope) ->
+ Id = catch_apply(Mod,id,[Opts], make_ref()),
+ {Config, {Id, scope(Scope), {Mod, {Id,Opts}}}}.
+call_init({Mod,{Id,Opts}},Config,_Meta) ->
+ NewState = Mod:init(Id, Opts),
+ {Config, {Mod, NewState}}.
+
call_terminate({Mod, State}, _, _) ->
catch_apply(Mod,terminate,[State], ok),
{[],{Mod,State}}.
@@ -166,19 +170,20 @@ call(Fun, Config, Meta, NoChangeRet) when is_function(Fun) ->
NewReturn -> NewReturn
end;
-call([{CB, call_init, NextFun} | Rest], Config, Meta, CBs) ->
+call([{CB, call_id, NextFun} | Rest], Config, Meta, CBs) ->
try
- {Config, {NewId, _, {Mod,_State}} = NewCB} = call_init(CB, Config, Meta),
- {NewCBs, NewRest} = case lists:keyfind(NewId, 1, CBs) of
- false when NextFun == undefined ->
- {CBs ++ [NewCB],Rest};
- ExistingCB when is_tuple(ExistingCB) ->
- {CBs, Rest};
- _ ->
- {CBs ++ [NewCB],[{NewId, NextFun} | Rest]}
- end,
- ct_logs:log("Suite Callback","Started a SCB: Mod: ~p, Id: ~p",
- [Mod,NewId]),
+ {Config, {NewId, _, _} = NewCB} = call_id(CB, Config, Meta),
+ {NewCBs, NewRest} =
+ case lists:keyfind(NewId, 1, CBs) of
+ false when NextFun =:= undefined ->
+ {CBs ++ [NewCB],
+ [{NewId, fun call_init/3} | Rest]};
+ ExistingCB when is_tuple(ExistingCB) ->
+ {CBs, Rest};
+ _ ->
+ {CBs ++ [NewCB],
+ [{NewId, fun call_init/3},{NewId,NextFun} | Rest]}
+ end,
call(NewRest, Config, Meta, NewCBs)
catch Error:Reason ->
Trace = erlang:get_stacktrace(),
@@ -237,7 +242,7 @@ terminate_if_scope_ends(CBId, Function, CBs) ->
%% Fetch callback functions
get_new_callbacks(Config, Fun) ->
lists:foldl(fun(NewCB, Acc) ->
- [{NewCB, call_init, Fun} | Acc]
+ [{NewCB, call_id, Fun} | Acc]
end, [], get_new_callbacks(Config)).
get_new_callbacks(Config) when is_list(Config) ->
diff --git a/lib/common_test/test/ct_suite_callback_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE.erl
index adb950614e..19feacad1d 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE.erl
@@ -72,7 +72,8 @@ all() ->
all(suite) ->
lists:reverse(
[
- one_scb, two_scb, faulty_scb_no_init, faulty_scb_exit_in_init,
+ one_scb, two_scb, faulty_scb_no_init, faulty_scb_id_no_init,
+ faulty_scb_exit_in_init, faulty_scb_exit_in_id,
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,
@@ -104,6 +105,11 @@ faulty_scb_no_init(Config) when is_list(Config) ->
Config,{error,"Failed to start SCB, see the "
"CT Log for details"}).
+faulty_scb_id_no_init(Config) when is_list(Config) ->
+ do_test(faulty_scb_id_no_init, "ct_scb_empty_SUITE.erl",[id_no_init_scb],
+ Config,{error,"Failed to start SCB, see the "
+ "CT Log for details"}).
+
minimal_scb(Config) when is_list(Config) ->
do_test(minimal_scb, "ct_scb_empty_SUITE.erl",[minimal_scb],Config).
@@ -126,6 +132,12 @@ faulty_scb_exit_in_init(Config) when is_list(Config) ->
{error,"Failed to start SCB, see the "
"CT Log for details"}).
+faulty_scb_exit_in_id(Config) when is_list(Config) ->
+ do_test(faulty_scb_exit_in_id, "ct_scb_empty_SUITE.erl",
+ [crash_id_scb], Config,
+ {error,"Failed to start SCB, see the "
+ "CT Log for details"}).
+
scope_per_suite_scb(Config) when is_list(Config) ->
do_test(scope_per_suite_scb, "ct_scope_per_suite_scb_SUITE.erl",
[],Config).
@@ -243,7 +255,8 @@ events_to_check(Test, N) ->
test_events(one_empty_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{empty_scb,init,[[]]}},
+ {?eh,scb,{empty_scb,id,[[]]}},
+ {?eh,scb,{empty_scb,init,[{'_','_','_'},[]]}},
{?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,
@@ -270,8 +283,10 @@ test_events(one_empty_scb) ->
test_events(two_empty_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',id,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
+ {?eh,scb,{'_',id,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
@@ -307,10 +322,21 @@ test_events(faulty_scb_no_init) ->
{?eh,stop_logging,[]}
];
+test_events(faulty_scb_id_no_init) ->
+ [
+ {?eh,start_logging,{'DEF','RUNDIR'}},
+ {?eh,scb,{'_',id,[[]]}},
+ {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
+ {negative,{?eh,tc_start,'_'},
+ {?eh,test_done,{'DEF','STOP_TIME'}}},
+ {?eh,stop_logging,[]}
+ ];
+
test_events(minimal_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
+ {negative,{?eh,scb,{'_',id,['_',[]]}},
+ {?eh,scb,{'_',init,['_',[]]}}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,ok}},
@@ -327,8 +353,10 @@ test_events(minimal_scb) ->
test_events(minimal_and_maximal_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
- {?eh,scb,{'_',init,[[]]}},
+ {negative,{?eh,scb,{'_',id,['_',[]]}},
+ {?eh,scb,{'_',init,['_',[]]}}},
+ {?eh,scb,{'_',id,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
@@ -355,7 +383,7 @@ test_events(faulty_scb_undef) ->
{failed,FailReasonStr}},
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,
@@ -378,7 +406,7 @@ test_events(faulty_scb_exit_in_init_scope_suite) ->
[{?eh,start_logging,{'DEF','RUNDIR'}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{'_',init_per_suite}},
- {?eh,scb,{empty_scb,init,[[]]}},
+ {?eh,scb,{empty_scb,init,['_',[]]}},
{?eh,tc_done,
{ct_exit_in_init_scope_suite_scb_SUITE,init_per_suite,
{failed,
@@ -401,17 +429,26 @@ test_events(faulty_scb_exit_in_init_scope_suite) ->
test_events(faulty_scb_exit_in_init) ->
[{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{empty_scb,init,[[]]}},
+ {?eh,scb,{empty_scb,init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,test_done,{'DEF','STOP_TIME'}},
{?eh,stop_logging,[]}];
+test_events(faulty_scb_exit_in_id) ->
+ [{?eh,start_logging,{'DEF','RUNDIR'}},
+ {?eh,scb,{empty_scb,id,[[]]}},
+ {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
+ {negative, {?eh,tc_start,'_'},
+ {?eh,test_done,{'DEF','STOP_TIME'}}},
+ {?eh,stop_logging,[]}];
+
test_events(scope_per_suite_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scope_per_suite_scb_SUITE,init_per_suite}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',id,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,scb,{'_',post_init_per_suite,[ct_scope_per_suite_scb_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scope_per_suite_scb_SUITE,init_per_suite,ok}},
@@ -435,7 +472,8 @@ test_events(scope_suite_scb) ->
{?eh,start_logging,{'DEF','RUNDIR'}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scope_suite_scb_SUITE,init_per_suite}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',id,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scope_suite_scb_SUITE,'$proplist',[]]}},
{?eh,scb,{'_',post_init_per_suite,[ct_scope_suite_scb_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scope_suite_scb_SUITE,init_per_suite,ok}},
@@ -462,7 +500,8 @@ test_events(scope_per_group_scb) ->
{?eh,tc_done,{ct_scope_per_group_scb_SUITE,init_per_suite,ok}},
[{?eh,tc_start,{ct_scope_per_group_scb_SUITE,{init_per_group,group1,[]}}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',id,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,scb,{'_',post_init_per_group,[group1,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scope_per_group_scb_SUITE,{init_per_group,group1,[]},ok}},
@@ -488,7 +527,8 @@ 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,{'_',id,[[test]]}},
+ {?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}},
@@ -512,7 +552,8 @@ 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,{'_',id,[[test]]}},
+ {?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}},
@@ -539,7 +580,8 @@ test_events(scope_per_group_state_scb) ->
{?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,{'_',id,[[test]]}},
+ {?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}},
@@ -563,7 +605,7 @@ test_events(scope_per_group_state_scb) ->
test_events(fail_pre_suite_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
@@ -603,7 +645,7 @@ test_events(fail_pre_suite_scb) ->
test_events(fail_post_suite_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
@@ -630,7 +672,7 @@ test_events(fail_post_suite_scb) ->
test_events(skip_pre_suite_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
@@ -653,7 +695,7 @@ test_events(skip_pre_suite_scb) ->
test_events(skip_post_suite_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
@@ -678,7 +720,7 @@ test_events(recover_post_suite_scb) ->
Suite = ct_scb_fail_per_suite_SUITE,
[
{?eh,start_logging,'_'},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{Suite,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[Suite,'$proplist','$proplist']}},
@@ -707,7 +749,7 @@ test_events(recover_post_suite_scb) ->
test_events(update_config_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_update_config_SUITE,init_per_suite}},
@@ -818,8 +860,8 @@ test_events(update_config_scb) ->
test_events(state_update_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
+ {?eh,scb,{'_',init,['_',[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{'_',init_per_suite}},
@@ -856,7 +898,7 @@ test_events(state_update_scb) ->
test_events(options_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{empty_scb,init,[[test]]}},
+ {?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,
@@ -883,8 +925,9 @@ test_events(options_scb) ->
test_events(same_id_scb) ->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
- {?eh,scb,{'_',init,[[]]}},
- {?eh,scb,{'_',init,[[]]}},
+ {?eh,scb,{'_',id,[[]]}},
+ {?eh,scb,{'_',init,[same_id_scb,[]]}},
+ {?eh,scb,{'_',id,[[]]}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_id_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_id_scb.erl
new file mode 100644
index 0000000000..2c256c46df
--- /dev/null
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_id_scb.erl
@@ -0,0 +1,34 @@
+%%
+%% %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(crash_id_scb).
+
+
+-include_lib("common_test/src/ct_util.hrl").
+-include_lib("common_test/include/ct_event.hrl").
+
+
+%% Suite Callbacks
+-export([id/1]).
+
+id(Opts) ->
+ empty_scb:id(Opts),
+ exit(diediedie).
+
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_init_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_init_scb.erl
index 683459853f..c4138bbcef 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_init_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_init_scb.erl
@@ -26,9 +26,9 @@
%% Suite Callbacks
--export([init/1]).
+-export([init/2]).
-init(Opts) ->
- empty_scb:init(Opts),
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts),
exit(diediedie).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl
index d9aa1e77e4..a82ca02d04 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl
@@ -35,7 +35,8 @@
-module(empty_scb).
%% Suite Callbacks
--export([init/1]).
+-export([id/1]).
+-export([init/2]).
-export([pre_init_per_suite/3]).
-export([post_init_per_suite/4]).
@@ -68,16 +69,23 @@
-record(state, { id = ?MODULE :: term()}).
%% @doc Always called before any other callback function. Use this to initiate
-%% any common state. It should return an ID for this SCB and a state. The ID
-%% is used to uniquly identify an SCB instance, if two SCB's return the same
-%% ID the seconds SCB is ignored. This function should NOT have any side
-%% effects as it might be called multiple times by common test.
--spec init(Opts :: proplist()) ->
+%% any common state. It should return an ID for this SCB and a state.
+-spec init(Id :: term(), Opts :: proplist()) ->
{Id :: term(), State :: #state{}}.
-init(Opts) ->
+init(Id, Opts) ->
gen_event:notify(?CT_EVMGR_REF, #event{ name = scb, node = node(),
- data = {?MODULE, init, [Opts]}}),
- {now(), Opts}.
+ data = {?MODULE, init, [Id, Opts]}}),
+ Opts.
+
+%% @doc The ID is used to uniquly identify an SCB instance, if two SCB's
+%% return the same ID the seconds SCB is ignored. This function should NOT
+%% have any side effects as it might be called multiple times by common test.
+-spec id(Opts :: proplist()) ->
+ Id :: term().
+id(Opts) ->
+ gen_event:notify(?CT_EVMGR_REF, #event{ name = scb, node = node(),
+ data = {?MODULE, id, [Opts]}}),
+ now().
%% @doc Called before init_per_suite is called. Note that this callback is
%% only called if the SCB is added before init_per_suite is run (eg. in a test
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl
index b3a3a5f94c..44c72f6795 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl
@@ -28,8 +28,8 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- empty_scb:init(Opts).
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl
index d49387ff8c..90f10d7531 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl
@@ -28,8 +28,8 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- empty_scb:init(Opts).
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State),
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/id_no_init_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/id_no_init_scb.erl
new file mode 100644
index 0000000000..11fb8d739f
--- /dev/null
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/id_no_init_scb.erl
@@ -0,0 +1,32 @@
+%%
+%% %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(id_no_init_scb).
+
+
+-include_lib("common_test/src/ct_util.hrl").
+-include_lib("common_test/include/ct_event.hrl").
+
+
+%% Suite Callbacks
+-export([id/1]).
+
+id(Opts) ->
+ empty_scb:id(Opts).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_scb.erl
index e5fdbfb8a0..b3feb1383c 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_scb.erl
@@ -26,8 +26,8 @@
%% Suite Callbacks
--export([init/1]).
+-export([init/2]).
-init(Opts) ->
- empty_scb:init(Opts).
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/recover_post_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/recover_post_suite_scb.erl
index 864a09e3d0..26468f0789 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/recover_post_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/recover_post_suite_scb.erl
@@ -28,8 +28,8 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- empty_scb:init(Opts).
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/same_id_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/same_id_scb.erl
index 6853aa52e8..0fa708d5b6 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/same_id_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/same_id_scb.erl
@@ -28,9 +28,12 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- {_,State} = empty_scb:init(Opts),
- {?MODULE,State}.
+id(Opts) ->
+ empty_scb:id(Opts),
+ ?MODULE.
+
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl
index a2e0578814..bb93ebee0f 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl
@@ -28,8 +28,8 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- empty_scb:init(Opts).
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl
index 4a0725ce2f..9818964e7f 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl
@@ -28,8 +28,8 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- empty_scb:init(Opts).
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
pre_init_per_suite(Suite, Config, State) ->
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/state_update_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/state_update_scb.erl
index 1da0f7a6e4..13c50cf1a1 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/state_update_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/state_update_scb.erl
@@ -27,9 +27,9 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- {Id,State} = empty_scb:init(Opts),
- {Id,[init|State]}.
+init(Id, Opts) ->
+ State = empty_scb:init(Id, Opts),
+ [init|State].
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State),
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl
index 9479f9d937..1cb64574c3 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl
@@ -28,8 +28,8 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- empty_scb:init(Opts).
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
pre_init_per_suite(_Suite, _Config, _State) ->
lists:flaten([1,2,[3,4]]).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/update_config_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/update_config_scb.erl
index 6f21e49656..46a027403d 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/update_config_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/update_config_scb.erl
@@ -28,8 +28,8 @@
%% Suite Callbacks
-compile(export_all).
-init(Opts) ->
- empty_scb:init(Opts).
+init(Id, Opts) ->
+ empty_scb:init(Id, Opts).
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State),