From ade343808a1a634bd39ab1c94ecadfd070a189de Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Wed, 9 Feb 2011 15:49:32 +0100 Subject: Rename Suite Callback to Common Test Hook in code and testcases --- lib/common_test/src/Makefile | 4 +- lib/common_test/src/ct.erl | 8 +- lib/common_test/src/ct_framework.erl | 40 +- lib/common_test/src/ct_hooks.erl | 305 ++++++ lib/common_test/src/ct_hooks_lock.erl | 132 +++ lib/common_test/src/ct_run.erl | 110 +-- lib/common_test/src/ct_suite_callback.erl | 304 ------ lib/common_test/src/ct_suite_callback_lock.erl | 131 --- lib/common_test/src/ct_testspec.erl | 24 +- lib/common_test/src/ct_util.erl | 14 +- lib/common_test/src/ct_util.hrl | 2 +- lib/common_test/test/Makefile | 2 +- .../ct_error_SUITE_data/error/test/empty_scb.erl | 187 ---- lib/common_test/test/ct_hooks_SUITE.erl | 1021 ++++++++++++++++++++ .../ct_hooks_SUITE_data/cth/tests/crash_id_cth.erl | 34 + .../cth/tests/crash_init_cth.erl | 34 + .../cth/tests/ct_cth_empty_SUITE.erl | 47 + .../cth/tests/ct_cth_fail_one_skip_one_SUITE.erl | 64 ++ .../cth/tests/ct_cth_fail_per_suite_SUITE.erl | 47 + .../ct_exit_in_init_scope_suite_cth_SUITE.erl | 50 + .../cth/tests/ct_scope_per_group_cth_SUITE.erl | 56 ++ .../tests/ct_scope_per_group_state_cth_SUITE.erl | 56 ++ .../cth/tests/ct_scope_per_suite_cth_SUITE.erl | 47 + .../tests/ct_scope_per_suite_state_cth_SUITE.erl | 47 + .../cth/tests/ct_scope_per_tc_cth_SUITE.erl | 110 +++ .../cth/tests/ct_scope_suite_cth_SUITE.erl | 50 + .../cth/tests/ct_scope_suite_state_cth_SUITE.erl | 50 + .../cth/tests/ct_update_config_SUITE.erl | 56 ++ .../ct_hooks_SUITE_data/cth/tests/empty_cth.erl | 277 ++++++ .../cth/tests/fail_post_suite_cth.erl | 72 ++ .../cth/tests/fail_pre_suite_cth.erl | 72 ++ .../cth/tests/id_no_init_cth.erl | 32 + .../ct_hooks_SUITE_data/cth/tests/minimal_cth.erl | 33 + .../cth/tests/minimal_terminate_cth.erl | 38 + .../cth/tests/recover_post_suite_cth.erl | 74 ++ .../ct_hooks_SUITE_data/cth/tests/same_id_cth.erl | 75 ++ .../cth/tests/skip_post_suite_cth.erl | 72 ++ .../cth/tests/skip_pre_suite_cth.erl | 73 ++ .../cth/tests/state_update_cth.erl | 83 ++ .../ct_hooks_SUITE_data/cth/tests/undef_cth.erl | 71 ++ .../cth/tests/update_config_cth.erl | 82 ++ lib/common_test/test/ct_suite_callback_SUITE.erl | 1021 -------------------- .../scb/tests/crash_id_scb.erl | 34 - .../scb/tests/crash_init_scb.erl | 34 - .../ct_exit_in_init_scope_suite_scb_SUITE.erl | 50 - .../scb/tests/ct_scb_empty_SUITE.erl | 47 - .../scb/tests/ct_scb_fail_one_skip_one_SUITE.erl | 64 -- .../scb/tests/ct_scb_fail_per_suite_SUITE.erl | 47 - .../scb/tests/ct_scope_per_group_scb_SUITE.erl | 56 -- .../tests/ct_scope_per_group_state_scb_SUITE.erl | 56 -- .../scb/tests/ct_scope_per_suite_scb_SUITE.erl | 47 - .../tests/ct_scope_per_suite_state_scb_SUITE.erl | 47 - .../scb/tests/ct_scope_per_tc_scb_SUITE.erl | 110 --- .../scb/tests/ct_scope_suite_scb_SUITE.erl | 50 - .../scb/tests/ct_scope_suite_state_scb_SUITE.erl | 50 - .../scb/tests/ct_update_config_SUITE.erl | 56 -- .../scb/tests/empty_scb.erl | 277 ------ .../scb/tests/fail_post_suite_scb.erl | 72 -- .../scb/tests/fail_pre_suite_scb.erl | 72 -- .../scb/tests/id_no_init_scb.erl | 32 - .../scb/tests/minimal_scb.erl | 33 - .../scb/tests/minimal_terminate_scb.erl | 38 - .../scb/tests/recover_post_suite_scb.erl | 74 -- .../scb/tests/same_id_scb.erl | 75 -- .../scb/tests/skip_post_suite_scb.erl | 72 -- .../scb/tests/skip_pre_suite_scb.erl | 73 -- .../scb/tests/state_update_scb.erl | 83 -- .../scb/tests/undef_scb.erl | 71 -- .../scb/tests/update_config_scb.erl | 82 -- 69 files changed, 3362 insertions(+), 3547 deletions(-) create mode 100644 lib/common_test/src/ct_hooks.erl create mode 100644 lib/common_test/src/ct_hooks_lock.erl delete mode 100644 lib/common_test/src/ct_suite_callback.erl delete mode 100644 lib/common_test/src/ct_suite_callback_lock.erl delete mode 100644 lib/common_test/test/ct_error_SUITE_data/error/test/empty_scb.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/crash_id_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/crash_init_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_empty_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_fail_one_skip_one_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_fail_per_suite_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_exit_in_init_scope_suite_cth_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_group_cth_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_group_state_cth_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_suite_cth_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_suite_state_cth_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_tc_cth_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_suite_cth_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_suite_state_cth_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_update_config_SUITE.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/fail_post_suite_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/fail_pre_suite_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/id_no_init_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/minimal_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/minimal_terminate_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/recover_post_suite_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/same_id_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/skip_post_suite_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/skip_pre_suite_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/state_update_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/undef_cth.erl create mode 100644 lib/common_test/test/ct_hooks_SUITE_data/cth/tests/update_config_cth.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_id_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_init_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_exit_in_init_scope_suite_scb_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_empty_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_fail_one_skip_one_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_fail_per_suite_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_scb_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_state_scb_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_scb_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_state_scb_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_tc_scb_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_scb_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_state_scb_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_update_config_SUITE.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/id_no_init_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_terminate_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/recover_post_suite_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/same_id_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/state_update_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl delete mode 100644 lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/update_config_scb.erl (limited to 'lib/common_test') diff --git a/lib/common_test/src/Makefile b/lib/common_test/src/Makefile index abf7816a91..378a7ba08c 100644 --- a/lib/common_test/src/Makefile +++ b/lib/common_test/src/Makefile @@ -68,8 +68,8 @@ MODULES= \ ct_config_plain \ ct_config_xml \ ct_slave \ - ct_suite_callback\ - ct_suite_callback_lock + ct_hooks\ + ct_hooks_lock TARGET_MODULES= $(MODULES:%=$(EBIN)/%) diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index eb0eceeb46..b0a92dcc15 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -149,7 +149,7 @@ run(TestDirs) -> %%% {repeat,N} | {duration,DurTime} | {until,StopTime} | %%% {force_stop,Bool} | {decrypt,DecryptKeyOrFile} | %%% {refresh_logs,LogDir} | {basic_html,Bool} | -%%% {suite_callbacks, SCBs} +%%% {ct_hooks, CTHs} %%% TestDirs = [string()] | string() %%% Suites = [string()] | string() %%% Cases = [atom()] | atom() @@ -177,9 +177,9 @@ run(TestDirs) -> %%% DecryptKeyOrFile = {key,DecryptKey} | {file,DecryptFile} %%% DecryptKey = string() %%% DecryptFile = string() -%%% SCBs = [SCBModule | {SCBModule, SCBInitArgs}] -%%% SCBModule = atom() -%%% SCBInitArgs = term() +%%% CTHs = [CTHModule | {CTHModule, CTHInitArgs}] +%%% CTHModule = atom() +%%% CTHInitArgs = term() %%% Result = [TestResult] | {error,Reason} %%% @doc Run tests as specified by the combination of options in Opts. %%% The options are the same as those used with the diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index d05c30f5e1..04829004f4 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -229,7 +229,7 @@ init_tc2(Mod,Func,SuiteInfo,MergeResult,Config,DoInit) -> end. ct_suite_init(Mod, Func, [Config]) when is_list(Config) -> - case ct_suite_callback:init_tc( Mod, Func, Config) of + case ct_hooks:init_tc( Mod, Func, Config) of NewConfig when is_list(NewConfig) -> {ok, [NewConfig]}; Else -> @@ -251,9 +251,9 @@ add_defaults(Mod,Func,FuncInfo,DoInit) -> (_) -> false end, SuiteInfo) of true -> - SuiteInfoNoSCB = - lists:keydelete(suite_callbacks,1,SuiteInfo), - SuiteInfo1 = merge_with_suite_defaults(Mod,SuiteInfoNoSCB), + SuiteInfoNoCTH = + lists:keydelete(ct_hooks,1,SuiteInfo), + SuiteInfo1 = merge_with_suite_defaults(Mod,SuiteInfoNoCTH), case add_defaults1(Mod,Func,FuncInfo,SuiteInfo1,DoInit) of Error = {error,_} -> {SuiteInfo1,Error}; MergedInfo -> {SuiteInfo1,MergedInfo} @@ -376,8 +376,8 @@ configure([{timetrap,off}|Rest],Info,SuiteInfo,Scope,Config) -> configure([{timetrap,Time}|Rest],Info,SuiteInfo,Scope,Config) -> Dog = test_server:timetrap(Time), configure(Rest,Info,SuiteInfo,Scope,[{watchdog,Dog}|Config]); -configure([{suite_callbacks, CB} | Rest], Info, SuiteInfo, Scope, Config) -> - configure(Rest, Info, SuiteInfo, Scope, [{suite_callbacks, CB} | Config]); +configure([{ct_hooks, Hook} | Rest], Info, SuiteInfo, Scope, Config) -> + configure(Rest, Info, SuiteInfo, Scope, [{ct_hooks, Hook} | Config]); configure([_|Rest],Info,SuiteInfo,Scope,Config) -> configure(Rest,Info,SuiteInfo,Scope,Config); configure([],_,_,_,Config) -> @@ -487,7 +487,7 @@ end_tc(Mod,Func,TCPid,Result,Args,Return) -> case get('$test_server_framework_test') of undefined -> {FinalResult,FinalNotify} = - case ct_suite_callback:end_tc( + case ct_hooks:end_tc( Mod, FuncSpec, Args, Result, Return) of '$ct_no_change' -> {FinalResult = ok,Result}; @@ -499,7 +499,7 @@ end_tc(Mod,Func,TCPid,Result,Args,Return) -> ct_event:sync_notify(#event{name=tc_done, node=node(), data={Mod,FuncSpec, - tag_scb(FinalNotify)}}); + tag_cth(FinalNotify)}}); Fun -> % send sync notification so that event handlers may print % in the log file before it gets closed @@ -545,19 +545,19 @@ tag(E = testcase_aborted_or_killed) -> tag(Other) -> Other. -tag_scb({STag,Reason}) when STag == skip; STag == skipped -> +tag_cth({STag,Reason}) when STag == skip; STag == skipped -> {skipped,Reason}; -tag_scb({fail, Reason}) -> +tag_cth({fail, Reason}) -> {failed, {error,Reason}}; -tag_scb(E = {ETag,_}) when ETag == error; ETag == 'EXIT'; +tag_cth(E = {ETag,_}) when ETag == error; ETag == 'EXIT'; ETag == timetrap_timeout; ETag == testcase_aborted -> {failed,E}; -tag_scb(E = testcase_aborted_or_killed) -> +tag_cth(E = testcase_aborted_or_killed) -> {failed,E}; -tag_scb(List) when is_list(List) -> +tag_cth(List) when is_list(List) -> ok; -tag_scb(Other) -> +tag_cth(Other) -> Other. %%%----------------------------------------------------------------- @@ -1188,13 +1188,13 @@ report(What,Data) -> {_Suite,Case,Result} = Data, case Result of {failed, _} -> - ct_suite_callback:on_tc_fail(What, Data); + ct_hooks:on_tc_fail(What, Data); {skipped,{failed,{_,init_per_testcase,_}}} -> - ct_suite_callback:on_tc_skip(tc_auto_skip, Data); + ct_hooks:on_tc_skip(tc_auto_skip, Data); {skipped,{require_failed,_}} -> - ct_suite_callback:on_tc_skip(tc_auto_skip, Data); + ct_hooks:on_tc_skip(tc_auto_skip, Data); {skipped,_} -> - ct_suite_callback:on_tc_skip(tc_user_skip, Data); + ct_hooks:on_tc_skip(tc_user_skip, Data); _Else -> ok end, @@ -1224,7 +1224,7 @@ report(What,Data) -> ct_event:sync_notify(#event{name=tc_user_skip, node=node(), data=Data}), - ct_suite_callback:on_tc_skip(What, Data), + ct_hooks:on_tc_skip(What, Data), add_to_stats(user_skipped); tc_auto_skip -> %% test case skipped because of error in init_per_suite @@ -1237,7 +1237,7 @@ report(What,Data) -> ct_event:sync_notify(#event{name=tc_auto_skip, node=node(), data=Data}), - ct_suite_callback:on_tc_skip(What, Data), + ct_hooks:on_tc_skip(What, Data), if Case /= end_per_suite, Case /= end_per_group -> add_to_stats(auto_skipped); true -> diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl new file mode 100644 index 0000000000..8e80ce8f37 --- /dev/null +++ b/lib/common_test/src/ct_hooks.erl @@ -0,0 +1,305 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-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% +%% + +%%% @doc Common Test Framework test execution control module. +%%% +%%%

This module is a proxy for calling and handling common test hooks.

+ +-module(ct_hooks). + +%% API Exports +-export([init/1]). +-export([init_tc/3]). +-export([end_tc/5]). +-export([terminate/1]). +-export([on_tc_skip/2]). +-export([on_tc_fail/2]). + +-type proplist() :: [{atom(),term()}]. + +%% If you change this, remember to update ct_util:look -> stop clause as well. +-define(config_name, ct_hooks). + +%% ------------------------------------------------------------------------- +%% API Functions +%% ------------------------------------------------------------------------- + +%% @doc Called before any suites are started +-spec init(State :: term()) -> ok | + {error, Reason :: term()}. +init(Opts) -> + call([{Hook, call_id, undefined} || Hook <- get_new_hooks(Opts)], + ok, init, []). + + +%% @doc Called after all suites are done. +-spec terminate(Hooks :: term()) -> + ok. +terminate(Hooks) -> + call([{HookId, fun call_terminate/3} || {HookId,_,_} <- Hooks], + ct_hooks_terminate_dummy, terminate, Hooks), + ok. + +%% @doc Called as each test case is started. This includes all configuration +%% tests. +-spec init_tc(Mod :: atom(), Func :: atom(), Args :: list()) -> + NewConfig :: proplist() | + {skip, Reason :: term()} | + {auto_skip, Reason :: term()} | + {fail, Reason :: term()}. +init_tc(ct_framework, _Func, Args) -> + Args; +init_tc(Mod, init_per_suite, Config) -> + Info = case catch proplists:get_value(ct_hooks, Mod:suite()) of + List when is_list(List) -> + [{ct_hooks,List}]; + _Else -> + [] + end, + call(fun call_generic/3, Config ++ Info, [pre_init_per_suite, Mod]); +init_tc(Mod, end_per_suite, Config) -> + call(fun call_generic/3, Config, [pre_end_per_suite, Mod]); +init_tc(Mod, {init_per_group, GroupName, Opts}, Config) -> + maybe_start_locker(Mod, GroupName, Opts), + call(fun call_generic/3, Config, [pre_init_per_group, GroupName]); +init_tc(_Mod, {end_per_group, GroupName, _}, Config) -> + call(fun call_generic/3, Config, [pre_end_per_group, GroupName]); +init_tc(_Mod, TC, Config) -> + call(fun call_generic/3, Config, [pre_init_per_testcase, TC]). + +%% @doc Called as each test case is completed. This includes all configuration +%% tests. +-spec end_tc(Mod :: atom(), + Func :: atom(), + Args :: list(), + Result :: term(), + Resturn :: term()) -> + NewConfig :: proplist() | + {skip, Reason :: term()} | + {auto_skip, Reason :: term()} | + {fail, Reason :: term()} | + ok. +end_tc(ct_framework, _Func, _Args, Result, _Return) -> + Result; + +end_tc(Mod, init_per_suite, Config, _Result, Return) -> + call(fun call_generic/3, Return, [post_init_per_suite, Mod, Config], + '$ct_no_change'); + +end_tc(Mod, end_per_suite, Config, Result, _Return) -> + call(fun call_generic/3, Result, [post_end_per_suite, Mod, Config], + '$ct_no_change'); + +end_tc(_Mod, {init_per_group, GroupName, _}, Config, _Result, Return) -> + call(fun call_generic/3, Return, [post_init_per_group, GroupName, Config], + '$ct_no_change'); + +end_tc(Mod, {end_per_group, GroupName, Opts}, Config, Result, _Return) -> + Res = call(fun call_generic/3, Result, + [post_end_per_group, GroupName, Config], '$ct_no_change'), + maybe_stop_locker(Mod, GroupName,Opts), + Res; + +end_tc(_Mod, TC, Config, Result, _Return) -> + call(fun call_generic/3, Result, [post_end_per_testcase, TC, Config], + '$ct_no_change'). + +on_tc_skip(How, {_Suite, Case, Reason}) -> + call(fun call_cleanup/3, {How, Reason}, [on_tc_skip, Case]). + +on_tc_fail(_How, {_Suite, Case, Reason}) -> + call(fun call_cleanup/3, Reason, [on_tc_fail, Case]). + +%% ------------------------------------------------------------------------- +%% Internal Functions +%% ------------------------------------------------------------------------- +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}}. + +call_cleanup({Mod, State}, Reason, [Function | Args]) -> + NewState = catch_apply(Mod,Function, Args ++ [Reason, State], + State), + {Reason, {Mod, NewState}}. + +call_generic({Mod, State}, Value, [Function | Args]) -> + {NewValue, NewState} = catch_apply(Mod, Function, Args ++ [Value, State], + {Value,State}), + {NewValue, {Mod, NewState}}. + +%% Generic call function +call(Fun, Config, Meta) -> + maybe_lock(), + Hooks = get_hooks(), + Res = call([{HookId,Fun} || {HookId,_, _} <- Hooks] ++ + get_new_hooks(Config, Fun), + remove(?config_name,Config), Meta, Hooks), + maybe_unlock(), + Res. + +call(Fun, Config, Meta, NoChangeRet) when is_function(Fun) -> + case call(Fun,Config,Meta) of + Config -> NoChangeRet; + NewReturn -> NewReturn + end; + +call([{Hook, call_id, NextFun} | Rest], Config, Meta, Hooks) -> + try + {Config, {NewId, _, _} = NewHook} = call_id(Hook, Config, Meta), + {NewHooks, NewRest} = + case lists:keyfind(NewId, 1, Hooks) of + false when NextFun =:= undefined -> + {Hooks ++ [NewHook], + [{NewId, fun call_init/3} | Rest]}; + ExistingHook when is_tuple(ExistingHook) -> + {Hooks, Rest}; + _ -> + {Hooks ++ [NewHook], + [{NewId, fun call_init/3},{NewId,NextFun} | Rest]} + end, + call(NewRest, Config, Meta, NewHooks) + catch Error:Reason -> + Trace = erlang:get_stacktrace(), + ct_logs:log("Suite Hook","Failed to start a CTH: ~p:~p", + [Error,{Reason,Trace}]), + call([], {fail,"Failed to start CTH" + ", see the CT Log for details"}, Meta, Hooks) + end; +call([{HookId, Fun} | Rest], Config, Meta, Hooks) -> + try + {_,Scope,ModState} = lists:keyfind(HookId, 1, Hooks), + {NewConf, NewHookInfo} = Fun(ModState, Config, Meta), + NewCalls = get_new_hooks(NewConf, Fun), + NewHooks = lists:keyreplace(HookId, 1, Hooks, {HookId, Scope, NewHookInfo}), + call(NewCalls ++ Rest, remove(?config_name, NewConf), Meta, + terminate_if_scope_ends(HookId, Meta, NewHooks)) + catch throw:{error_in_cth_call,Reason} -> + call(Rest, {fail, Reason}, Meta, + terminate_if_scope_ends(HookId, Meta, Hooks)) + end; +call([], Config, _Meta, Hooks) -> + save_suite_data_async(Hooks), + Config. + +remove(Key,List) when is_list(List) -> + [Conf || Conf <- List, is_tuple(Conf) =:= false + orelse element(1, Conf) =/= Key]; +remove(_, Else) -> + Else. + +%% Translate scopes, i.e. init_per_group,group1 -> end_per_group,group1 etc +scope([pre_init_per_testcase, TC|_]) -> + [post_end_per_testcase, TC]; +scope([pre_init_per_group, GroupName|_]) -> + [post_end_per_group, GroupName]; +scope([post_init_per_group, GroupName|_]) -> + [post_end_per_group, GroupName]; +scope([pre_init_per_suite, SuiteName|_]) -> + [post_end_per_suite, SuiteName]; +scope([post_init_per_suite, SuiteName|_]) -> + [post_end_per_suite, SuiteName]; +scope(init) -> + none. + +terminate_if_scope_ends(HookId, [Function,Tag|T], Hooks) when T =/= [] -> + terminate_if_scope_ends(HookId,[Function,Tag],Hooks); +terminate_if_scope_ends(HookId, Function, Hooks) -> + case lists:keyfind(HookId, 1, Hooks) of + {HookId, Function, _ModState} = Hook -> + terminate([Hook]), + lists:keydelete(HookId, 1, Hooks); + _ -> + Hooks + end. + +%% Fetch hook functions +get_new_hooks(Config, Fun) -> + lists:foldl(fun(NewHook, Acc) -> + [{NewHook, call_id, Fun} | Acc] + end, [], get_new_hooks(Config)). + +get_new_hooks(Config) when is_list(Config) -> + lists:flatmap(fun({?config_name, HookConfigs}) -> + HookConfigs; + (_) -> + [] + end, Config); +get_new_hooks(_Config) -> + []. + +save_suite_data_async(Hooks) -> + ct_util:save_suite_data_async(?config_name, Hooks). + +get_hooks() -> + ct_util:read_suite_data(?config_name). + +catch_apply(M,F,A, Default) -> + try + apply(M,F,A) + catch error:Reason -> + case erlang:get_stacktrace() of + %% Return the default if it was the CTH module which did not have the function. + [{M,F,A}|_] when Reason == undef -> + Default; + Trace -> + ct_logs:log("Suite Hook","Call to CTH failed: ~p:~p", + [error,{Reason,Trace}]), + throw({error_in_cth_call, + lists:flatten( + io_lib:format("~p:~p/~p CTH call failed", + [M,F,length(A)]))}) + end + end. + + +%% We need to lock around the state for parallel groups only. This is because +%% we will get several processes reading and writing the state for a single +%% cth at the same time. +maybe_start_locker(Mod,GroupName,Opts) -> + case lists:member(parallel,Opts) of + true -> + {ok, _Pid} = ct_hooks_lock:start({Mod,GroupName}); + false -> + ok + end. + +maybe_stop_locker(Mod,GroupName,Opts) -> + case lists:member(parallel,Opts) of + true -> + stopped = ct_hooks_lock:stop({Mod,GroupName}); + false -> + ok + end. + + +maybe_lock() -> + locked = ct_hooks_lock:request(). + +maybe_unlock() -> + unlocked = ct_hooks_lock:release(). diff --git a/lib/common_test/src/ct_hooks_lock.erl b/lib/common_test/src/ct_hooks_lock.erl new file mode 100644 index 0000000000..98794201bb --- /dev/null +++ b/lib/common_test/src/ct_hooks_lock.erl @@ -0,0 +1,132 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-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% +%% + +%%% @doc Common Test Framework test execution control module. +%%% +%%%

This module is a proxy for calling and handling locks in +%%% common test hooks.

+ +-module(ct_hooks_lock). + +-behaviour(gen_server). + +%% API +-export([start/1, stop/1, request/0, release/0]). + +%% gen_server callbacks +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, + terminate/2, code_change/3]). + +-define(SERVER, ?MODULE). + +-record(state, { id, locked = false, requests = [] }). + +%%%=================================================================== +%%% API +%%%=================================================================== + +%% @doc Starts the server +start(Id) -> + case gen_server:start({local, ?SERVER}, ?MODULE, Id, []) of + {error,{already_started, Pid}} -> + {ok,Pid}; + Else -> + Else + end. + +stop(Id) -> + try + gen_server:call(?SERVER, {stop,Id}) + catch exit:{noproc,_} -> + stopped + end. + +request() -> + try + gen_server:call(?SERVER,{request,self()},infinity) + catch exit:{noproc,_} -> + locked + end. + +release() -> + try + gen_server:call(?SERVER,{release,self()}) + catch exit:{noproc,_} -> + unlocked + end. + +%%%=================================================================== +%%% gen_server callbacks +%%%=================================================================== + +%% @doc Initiates the server +init(Id) -> + {ok, #state{ id = Id }}. + +%% @doc Handling call messages +handle_call({stop,Id}, _From, #state{ id = Id, requests = Reqs } = State) -> + [gen_server:reply(Req, locker_stopped) || {Req,_ReqId} <- Reqs], + {stop, normal, stopped, State}; +handle_call({stop,_Id}, _From, State) -> + {reply, stopped, State}; +handle_call({request, Pid}, _From, #state{ locked = false, + requests = [] } = State) -> + Ref = monitor(process, Pid), + {reply, locked, State#state{ locked = {true, Pid, Ref}} }; +handle_call({request, Pid}, From, #state{ requests = Reqs } = State) -> + {noreply, State#state{ requests = Reqs ++ [{From,Pid}] }}; +handle_call({release, Pid}, _From, #state{ locked = {true, Pid, Ref}, + requests = []} = State) -> + demonitor(Ref,[flush]), + {reply, unlocked, State#state{ locked = false }}; +handle_call({release, Pid}, _From, + #state{ locked = {true, Pid, Ref}, + requests = [{NextFrom,NextPid}|Rest]} = State) -> + demonitor(Ref,[flush]), + gen_server:reply(NextFrom,locked), + NextRef = monitor(process, NextPid), + {reply,unlocked,State#state{ locked = {true, NextPid, NextRef}, + requests = Rest } }; +handle_call({release, _Pid}, _From, State) -> + {reply, not_locked, State}. + +%% @doc Handling cast messages +handle_cast(_Msg, State) -> + {noreply, State}. + +%% @doc Handling all non call/cast messages +handle_info({'DOWN',Ref,process,Pid,_}, + #state{ locked = {true, Pid, Ref}, + requests = [{NextFrom,NextPid}|Rest] } = State) -> + gen_server:reply(NextFrom, locked), + NextRef = monitor(process, NextPid), + {noreply,State#state{ locked = {true, NextPid, NextRef}, + requests = Rest } }. + +%% @doc This function is called by a gen_server when it is about to terminate. +terminate(_Reason, _State) -> + ok. + +%% @doc Convert process state when code is changed +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +%% ------------------------------------------------------------------------- +%% Internal Functions +%% ------------------------------------------------------------------------- diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl index a12d4d6f18..36fccf65f3 100644 --- a/lib/common_test/src/ct_run.erl +++ b/lib/common_test/src/ct_run.erl @@ -54,7 +54,7 @@ logdir, config = [], event_handlers = [], - suite_callbacks = [], + ct_hooks = [], include = [], silent_connections, stylesheet, @@ -172,7 +172,7 @@ script_start1(Parent, Args) -> ([]) -> true end, false, Args), EvHandlers = event_handler_args2opts(Args), - SuiteCBs = suite_callbacks_args2opts(Args), + CTHooks = ct_hooks_args2opts(Args), %% check flags and set corresponding application env variables @@ -236,7 +236,7 @@ script_start1(Parent, Args) -> StartOpts = #opts{label = Label, vts = Vts, shell = Shell, cover = Cover, logdir = LogDir, event_handlers = EvHandlers, - suite_callbacks = SuiteCBs, + ct_hooks = CTHooks, include = IncludeDirs, silent_connections = SilentConns, stylesheet = Stylesheet, @@ -308,9 +308,9 @@ script_start2(StartOpts = #opts{vts = undefined, SpecStartOpts#opts.scale_timetraps), AllEvHs = merge_vals([StartOpts#opts.event_handlers, SpecStartOpts#opts.event_handlers]), - AllSuiteCBs = merge_vals( - [StartOpts#opts.suite_callbacks, - SpecStartOpts#opts.suite_callbacks]), + AllCTHooks = merge_vals( + [StartOpts#opts.ct_hooks, + SpecStartOpts#opts.ct_hooks]), AllInclude = merge_vals([StartOpts#opts.include, SpecStartOpts#opts.include]), @@ -322,7 +322,7 @@ script_start2(StartOpts = #opts{vts = undefined, logdir = LogDir, config = SpecStartOpts#opts.config, event_handlers = AllEvHs, - suite_callbacks = AllSuiteCBs, + ct_hooks = AllCTHooks, include = AllInclude, multiply_timetraps = MultTT, scale_timetraps = ScaleTT}} @@ -341,7 +341,7 @@ script_start2(StartOpts = #opts{vts = undefined, {undefined,_} -> % no testspec used case check_and_install_configfiles(InitConfig, TheLogDir, Opts#opts.event_handlers, - Opts#opts.suite_callbacks) of + Opts#opts.ct_hooks) of ok -> % go on read tests from start flags script_start3(Opts#opts{config=InitConfig, logdir=TheLogDir}, Args); @@ -353,7 +353,7 @@ script_start2(StartOpts = #opts{vts = undefined, AllConfig = merge_vals([InitConfig, Opts#opts.config]), case check_and_install_configfiles(AllConfig, TheLogDir, Opts#opts.event_handlers, - Opts#opts.suite_callbacks) of + Opts#opts.ct_hooks) of ok -> % read tests from spec {Run,Skip} = ct_testspec:prepare_tests(Terms, node()), do_run(Run, Skip, Opts#opts{config=AllConfig, @@ -369,7 +369,7 @@ script_start2(StartOpts, Args) -> LogDir = which(logdir, StartOpts#opts.logdir), case check_and_install_configfiles(InitConfig, LogDir, StartOpts#opts.event_handlers, - StartOpts#opts.suite_callbacks) of + StartOpts#opts.ct_hooks) of ok -> % go on read tests from start flags script_start3(StartOpts#opts{config=InitConfig, logdir=LogDir}, Args); @@ -377,12 +377,12 @@ script_start2(StartOpts, Args) -> Error end. -check_and_install_configfiles(Configs, LogDir, EvHandlers, SuiteCBs) -> +check_and_install_configfiles(Configs, LogDir, EvHandlers, CTHooks) -> case ct_config:check_config_files(Configs) of false -> install([{config,Configs}, {event_handler,EvHandlers}, - {suite_callbacks,SuiteCBs}], LogDir); + {ct_hooks,CTHooks}], LogDir); {value,{error,{nofile,File}}} -> {error,{cant_read_config_file,File}}; {value,{error,{wrong_config,Message}}}-> @@ -450,13 +450,13 @@ script_start4(#opts{vts = true, config = Config, event_handlers = EvHandlers, script_start4(#opts{label = Label, shell = true, config = Config, event_handlers = EvHandlers, - suite_callbacks = SuiteCBs, + ct_hooks = CTHooks, logdir = LogDir, testspecs = Specs}, _Args) -> %% label - used by ct_logs application:set_env(common_test, test_label, Label), InstallOpts = [{config,Config},{event_handler,EvHandlers}, - {suite_callbacks, SuiteCBs}], + {ct_hooks, CTHooks}], if Config == [] -> ok; true -> @@ -522,7 +522,7 @@ script_usage() -> "\n\t[-stylesheet CSSFile]" "\n\t[-cover CoverCfgFile]" "\n\t[-event_handler EvHandler1 EvHandler2 .. EvHandlerN]" - "\n\t[-suite_callbacks SuiteCB1 SuiteCB2 .. SuiteCBN]" + "\n\t[-ct_hooks CTHook1 CTHook2 .. CTHookN]" "\n\t[-include InclDir1 InclDir2 .. InclDirN]" "\n\t[-no_auto_compile]" "\n\t[-multiply_timetraps N]" @@ -541,7 +541,7 @@ script_usage() -> "\n\t[-stylesheet CSSFile]" "\n\t[-cover CoverCfgFile]" "\n\t[-event_handler EvHandler1 EvHandler2 .. EvHandlerN]" - "\n\t[-suite_callbacks SuiteCB1 SuiteCB2 .. SuiteCBN]" + "\n\t[-ct_hooks CTHook1 CTHook2 .. CTHookN]" "\n\t[-include InclDir1 InclDir2 .. InclDirN]" "\n\t[-no_auto_compile]" "\n\t[-multiply_timetraps N]" @@ -680,8 +680,8 @@ run_test1(StartOpts) -> end, Hs)) end, - %% Suite Callbacks - SuiteCBs = get_start_opt(suite_callbacks, value, [], StartOpts), + %% CT Hooks + CTHooks = get_start_opt(ct_hooks, value, [], StartOpts), %% silent connections SilentConns = get_start_opt(silent_connections, @@ -753,7 +753,7 @@ run_test1(StartOpts) -> Opts = #opts{label = Label, cover = Cover, step = Step, logdir = LogDir, config = CfgFiles, event_handlers = EvHandlers, - suite_callbacks = SuiteCBs, + ct_hooks = CTHooks, include = Include, silent_connections = SilentConns, stylesheet = Stylesheet, @@ -806,15 +806,15 @@ run_spec_file(Relaxed, AllInclude = merge_vals([Opts#opts.include, SpecOpts#opts.include]), - AllSuiteCBs = merge_vals([Opts#opts.suite_callbacks, - SpecOpts#opts.suite_callbacks]), + AllCTHooks = merge_vals([Opts#opts.ct_hooks, + SpecOpts#opts.ct_hooks]), application:set_env(common_test, include, AllInclude), case check_and_install_configfiles(AllConfig, which(logdir,LogDir), AllEvHs, - AllSuiteCBs) of + AllCTHooks) of ok -> Opts1 = Opts#opts{label = Label, cover = Cover, @@ -825,7 +825,7 @@ run_spec_file(Relaxed, testspecs = AbsSpecs, multiply_timetraps = MultTT, scale_timetraps = ScaleTT, - suite_callbacks = AllSuiteCBs}, + ct_hooks = AllCTHooks}, {Run,Skip} = ct_testspec:prepare_tests(TS, node()), reformat_result(catch do_run(Run, Skip, Opts1, StartOpts)); {error,GCFReason} -> @@ -836,11 +836,11 @@ run_spec_file(Relaxed, run_prepared(Run, Skip, Opts = #opts{logdir = LogDir, config = CfgFiles, event_handlers = EvHandlers, - suite_callbacks = SuiteCBs}, + ct_hooks = CTHooks}, StartOpts) -> LogDir1 = which(logdir, LogDir), case check_and_install_configfiles(CfgFiles, LogDir1, - EvHandlers, SuiteCBs) of + EvHandlers, CTHooks) of ok -> reformat_result(catch do_run(Run, Skip, Opts#opts{logdir = LogDir1}, StartOpts)); @@ -872,7 +872,7 @@ check_config_file(Callback, File)-> run_dir(Opts = #opts{logdir = LogDir, config = CfgFiles, event_handlers = EvHandlers, - suite_callbacks = SuiteCB }, StartOpts) -> + ct_hooks = CTHook }, StartOpts) -> LogDir1 = which(logdir, LogDir), Opts1 = Opts#opts{logdir = LogDir1}, AbsCfgFiles = @@ -895,7 +895,7 @@ run_dir(Opts = #opts{logdir = LogDir, end, CfgFiles), case install([{config,AbsCfgFiles}, {event_handler,EvHandlers}, - {suite_callbacks, SuiteCB}], LogDir1) of + {ct_hooks, CTHook}], LogDir1) of ok -> ok; {error,IReason} -> exit(IReason) end, @@ -1001,7 +1001,7 @@ run_testspec1(TestSpec) -> LogDir1 = which(logdir,Opts#opts.logdir), case check_and_install_configfiles(Opts#opts.config, LogDir1, Opts#opts.event_handlers, - Opts#opts.suite_callbacks) of + Opts#opts.ct_hooks) of ok -> Opts1 = Opts#opts{testspecs = [], logdir = LogDir1, @@ -1019,7 +1019,7 @@ get_data_for_node(#testspec{label = Labels, config = Cfgs, userconfig = UsrCfgs, event_handler = EvHs, - suite_callbacks = SuCBs, + ct_hooks = CTHooks, include = Incl, multiply_timetraps = MTs, scale_timetraps = STs}, Node) -> @@ -1034,14 +1034,14 @@ get_data_for_node(#testspec{label = Labels, ConfigFiles = [{?ct_config_txt,F} || {N,F} <- Cfgs, N==Node] ++ [CBF || {N,CBF} <- UsrCfgs, N==Node], EvHandlers = [{H,A} || {N,H,A} <- EvHs, N==Node], - SuiteCBs = [CB || {N,CB} <- SuCBs, N==Node], + FiltCTHooks = [Hook || {N,Hook} <- CTHooks, N==Node], Include = [I || {N,I} <- Incl, N==Node], #opts{label = Label, logdir = LogDir, cover = Cover, config = ConfigFiles, event_handlers = EvHandlers, - suite_callbacks = SuiteCBs, + ct_hooks = FiltCTHooks, include = Include, multiply_timetraps = MT, scale_timetraps = ST}. @@ -2074,23 +2074,23 @@ 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) -> +ct_hooks_args2opts(Args) -> + ct_hooks_args2opts( + proplists:get_value(ct_hooks, Args, []),[]). + +ct_hooks_args2opts([CTH,Arg,"and"| Rest],Acc) -> + ct_hooks_args2opts(Rest,[{list_to_atom(CTH), + parse_cth_args(Arg)}|Acc]); +ct_hooks_args2opts([CTH], Acc) -> + ct_hooks_args2opts([CTH,"and"],Acc); +ct_hooks_args2opts([CTH, "and" | Rest], Acc) -> + ct_hooks_args2opts(Rest,[list_to_atom(CTH)|Acc]); +ct_hooks_args2opts([CTH, Args], Acc) -> + ct_hooks_args2opts([CTH, Args, "and"],Acc); +ct_hooks_args2opts([],Acc) -> lists:reverse(Acc). -parse_scb_args(String) -> +parse_cth_args(String) -> try true = io_lib:printable_list(String), {ok,Toks,_} = erl_scan:string(String++"."), @@ -2228,22 +2228,22 @@ opts2args(EnvStartOpts) -> end, EHs), [_LastAnd|StrsR] = lists:reverse(lists:flatten(Strs)), [{event_handler_init,lists:reverse(StrsR)}]; - ({suite_callbacks,[]}) -> + ({ct_hooks,[]}) -> []; - ({suite_callbacks,SCBs}) when is_list(SCBs) -> - io:format(user,"suite_callbacks: ~p",[SCBs]), + ({ct_hooks,CTHs}) when is_list(CTHs) -> + io:format(user,"ct_hooks: ~p",[CTHs]), Strs = lists:flatmap( - fun({SCB,Arg}) -> - [atom_to_list(SCB), + fun({CTH,Arg}) -> + [atom_to_list(CTH), lists:flatten( io_lib:format("~p",[Arg])), "and"]; - (SCB) when is_atom(SCB) -> - [atom_to_list(SCB),"and"] - end,SCBs), + (CTH) when is_atom(CTH) -> + [atom_to_list(CTH),"and"] + end,CTHs), [_LastAnd|StrsR] = lists:reverse(Strs), io:format(user,"return: ~p",[lists:reverse(StrsR)]), - [{suite_callbacks,lists:reverse(StrsR)}]; + [{ct_hooks,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/src/ct_suite_callback.erl b/lib/common_test/src/ct_suite_callback.erl deleted file mode 100644 index a93b05b1d2..0000000000 --- a/lib/common_test/src/ct_suite_callback.erl +++ /dev/null @@ -1,304 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-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% -%% - -%%% @doc Common Test Framework test execution control module. -%%% -%%%

This module is a proxy for calling and handling suite callbacks.

- --module(ct_suite_callback). - -%% API Exports --export([init/1]). --export([init_tc/3]). --export([end_tc/5]). --export([terminate/1]). --export([on_tc_skip/2]). --export([on_tc_fail/2]). - --type proplist() :: [{atom(),term()}]. - --define(config_name, suite_callbacks). - -%% ------------------------------------------------------------------------- -%% API Functions -%% ------------------------------------------------------------------------- - -%% @doc Called before any suites are started --spec init(State :: term()) -> ok | - {error, Reason :: term()}. -init(Opts) -> - call([{CB, call_id, undefined} || CB <- get_new_callbacks(Opts)], - ok, init, []). - - -%% @doc Called after all suites are done. --spec terminate(Callbacks :: term()) -> - ok. -terminate(Callbacks) -> - call([{CBId, fun call_terminate/3} || {CBId,_,_} <- Callbacks], - ct_suite_callback_terminate_dummy, terminate, Callbacks), - ok. - -%% @doc Called as each test case is started. This includes all configuration -%% tests. --spec init_tc(Mod :: atom(), Func :: atom(), Args :: list()) -> - NewConfig :: proplist() | - {skip, Reason :: term()} | - {auto_skip, Reason :: term()} | - {fail, Reason :: term()}. -init_tc(ct_framework, _Func, Args) -> - Args; -init_tc(Mod, init_per_suite, Config) -> - Info = case catch proplists:get_value(suite_callbacks, Mod:suite()) of - List when is_list(List) -> - [{suite_callbacks,List}]; - _Else -> - [] - end, - call(fun call_generic/3, Config ++ Info, [pre_init_per_suite, Mod]); -init_tc(Mod, end_per_suite, Config) -> - call(fun call_generic/3, Config, [pre_end_per_suite, Mod]); -init_tc(Mod, {init_per_group, GroupName, Opts}, Config) -> - maybe_start_locker(Mod, GroupName, Opts), - call(fun call_generic/3, Config, [pre_init_per_group, GroupName]); -init_tc(_Mod, {end_per_group, GroupName, _}, Config) -> - call(fun call_generic/3, Config, [pre_end_per_group, GroupName]); -init_tc(_Mod, TC, Config) -> - call(fun call_generic/3, Config, [pre_init_per_testcase, TC]). - -%% @doc Called as each test case is completed. This includes all configuration -%% tests. --spec end_tc(Mod :: atom(), - Func :: atom(), - Args :: list(), - Result :: term(), - Resturn :: term()) -> - NewConfig :: proplist() | - {skip, Reason :: term()} | - {auto_skip, Reason :: term()} | - {fail, Reason :: term()} | - ok. -end_tc(ct_framework, _Func, _Args, Result, _Return) -> - Result; - -end_tc(Mod, init_per_suite, Config, _Result, Return) -> - call(fun call_generic/3, Return, [post_init_per_suite, Mod, Config], - '$ct_no_change'); - -end_tc(Mod, end_per_suite, Config, Result, _Return) -> - call(fun call_generic/3, Result, [post_end_per_suite, Mod, Config], - '$ct_no_change'); - -end_tc(_Mod, {init_per_group, GroupName, _}, Config, _Result, Return) -> - call(fun call_generic/3, Return, [post_init_per_group, GroupName, Config], - '$ct_no_change'); - -end_tc(Mod, {end_per_group, GroupName, Opts}, Config, Result, _Return) -> - Res = call(fun call_generic/3, Result, - [post_end_per_group, GroupName, Config], '$ct_no_change'), - maybe_stop_locker(Mod, GroupName,Opts), - Res; - -end_tc(_Mod, TC, Config, Result, _Return) -> - call(fun call_generic/3, Result, [post_end_per_testcase, TC, Config], - '$ct_no_change'). - -on_tc_skip(How, {_Suite, Case, Reason}) -> - call(fun call_cleanup/3, {How, Reason}, [on_tc_skip, Case]). - -on_tc_fail(_How, {_Suite, Case, Reason}) -> - call(fun call_cleanup/3, Reason, [on_tc_fail, Case]). - -%% ------------------------------------------------------------------------- -%% Internal Functions -%% ------------------------------------------------------------------------- -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}}. - -call_cleanup({Mod, State}, Reason, [Function | Args]) -> - NewState = catch_apply(Mod,Function, Args ++ [Reason, State], - State), - {Reason, {Mod, NewState}}. - -call_generic({Mod, State}, Value, [Function | Args]) -> - {NewValue, NewState} = catch_apply(Mod, Function, Args ++ [Value, State], - {Value,State}), - {NewValue, {Mod, NewState}}. - -%% Generic call function -call(Fun, Config, Meta) -> - maybe_lock(), - CBs = get_callbacks(), - Res = call([{CBId,Fun} || {CBId,_, _} <- CBs] ++ - get_new_callbacks(Config, Fun), - remove(?config_name,Config), Meta, CBs), - maybe_unlock(), - Res. - -call(Fun, Config, Meta, NoChangeRet) when is_function(Fun) -> - case call(Fun,Config,Meta) of - Config -> NoChangeRet; - NewReturn -> NewReturn - end; - -call([{CB, call_id, NextFun} | Rest], Config, Meta, CBs) -> - try - {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(), - ct_logs:log("Suite Callback","Failed to start a SCB: ~p:~p", - [Error,{Reason,Trace}]), - call([], {fail,"Failed to start SCB" - ", see the CT Log for details"}, Meta, CBs) - end; -call([{CBId, Fun} | Rest], Config, Meta, CBs) -> - try - {_,Scope,ModState} = lists:keyfind(CBId, 1, CBs), - {NewConf, NewCBInfo} = Fun(ModState, Config, Meta), - NewCalls = get_new_callbacks(NewConf, Fun), - NewCBs = lists:keyreplace(CBId, 1, CBs, {CBId, Scope, NewCBInfo}), - call(NewCalls ++ Rest, remove(?config_name, NewConf), Meta, - terminate_if_scope_ends(CBId, Meta, NewCBs)) - catch throw:{error_in_scb_call,Reason} -> - call(Rest, {fail, Reason}, Meta, - terminate_if_scope_ends(CBId, Meta, CBs)) - end; -call([], Config, _Meta, CBs) -> - save_suite_data_async(CBs), - Config. - -remove(Key,List) when is_list(List) -> - [Conf || Conf <- List, is_tuple(Conf) =:= false - orelse element(1, Conf) =/= Key]; -remove(_, Else) -> - Else. - -%% Translate scopes, i.e. init_per_group,group1 -> end_per_group,group1 etc -scope([pre_init_per_testcase, TC|_]) -> - [post_end_per_testcase, TC]; -scope([pre_init_per_group, GroupName|_]) -> - [post_end_per_group, GroupName]; -scope([post_init_per_group, GroupName|_]) -> - [post_end_per_group, GroupName]; -scope([pre_init_per_suite, SuiteName|_]) -> - [post_end_per_suite, SuiteName]; -scope([post_init_per_suite, SuiteName|_]) -> - [post_end_per_suite, SuiteName]; -scope(init) -> - none. - -terminate_if_scope_ends(CBId, [Function,Tag|T], CBs) when T =/= [] -> - terminate_if_scope_ends(CBId,[Function,Tag],CBs); -terminate_if_scope_ends(CBId, Function, CBs) -> - case lists:keyfind(CBId, 1, CBs) of - {CBId, Function, _ModState} = CB -> - terminate([CB]), - lists:keydelete(CBId, 1, CBs); - _ -> - CBs - end. - -%% Fetch callback functions -get_new_callbacks(Config, Fun) -> - lists:foldl(fun(NewCB, Acc) -> - [{NewCB, call_id, Fun} | Acc] - end, [], get_new_callbacks(Config)). - -get_new_callbacks(Config) when is_list(Config) -> - lists:flatmap(fun({?config_name, CallbackConfigs}) -> - CallbackConfigs; - (_) -> - [] - end, Config); -get_new_callbacks(_Config) -> - []. - -save_suite_data_async(CBs) -> - ct_util:save_suite_data_async(?config_name, CBs). - -get_callbacks() -> - ct_util:read_suite_data(?config_name). - -catch_apply(M,F,A, Default) -> - try - apply(M,F,A) - catch error:Reason -> - case erlang:get_stacktrace() of - %% Return the default if it was the SCB module which did not have the function. - [{M,F,A}|_] when Reason == undef -> - Default; - Trace -> - ct_logs:log("Suite Callback","Call to SCB failed: ~p:~p", - [error,{Reason,Trace}]), - throw({error_in_scb_call, - lists:flatten( - io_lib:format("~p:~p/~p SCB call failed", - [M,F,length(A)]))}) - end - end. - - -%% We need to lock around the state for parallel groups only. This is because -%% we will get several processes reading and writing the state for a single -%% scb at the same time. -maybe_start_locker(Mod,GroupName,Opts) -> - case lists:member(parallel,Opts) of - true -> - {ok, _Pid} = ct_suite_callback_lock:start({Mod,GroupName}); - false -> - ok - end. - -maybe_stop_locker(Mod,GroupName,Opts) -> - case lists:member(parallel,Opts) of - true -> - stopped = ct_suite_callback_lock:stop({Mod,GroupName}); - false -> - ok - end. - - -maybe_lock() -> - locked = ct_suite_callback_lock:request(). - -maybe_unlock() -> - unlocked = ct_suite_callback_lock:release(). diff --git a/lib/common_test/src/ct_suite_callback_lock.erl b/lib/common_test/src/ct_suite_callback_lock.erl deleted file mode 100644 index 84dafd1e42..0000000000 --- a/lib/common_test/src/ct_suite_callback_lock.erl +++ /dev/null @@ -1,131 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-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% -%% - -%%% @doc Common Test Framework test execution control module. -%%% -%%%

This module is a proxy for calling and handling locks in suite callbacks.

- --module(ct_suite_callback_lock). - --behaviour(gen_server). - -%% API --export([start/1, stop/1, request/0, release/0]). - -%% gen_server callbacks --export([init/1, handle_call/3, handle_cast/2, handle_info/2, - terminate/2, code_change/3]). - --define(SERVER, ?MODULE). - --record(state, { id, locked = false, requests = [] }). - -%%%=================================================================== -%%% API -%%%=================================================================== - -%% @doc Starts the server -start(Id) -> - case gen_server:start({local, ?SERVER}, ?MODULE, Id, []) of - {error,{already_started, Pid}} -> - {ok,Pid}; - Else -> - Else - end. - -stop(Id) -> - try - gen_server:call(?SERVER, {stop,Id}) - catch exit:{noproc,_} -> - stopped - end. - -request() -> - try - gen_server:call(?SERVER,{request,self()},infinity) - catch exit:{noproc,_} -> - locked - end. - -release() -> - try - gen_server:call(?SERVER,{release,self()}) - catch exit:{noproc,_} -> - unlocked - end. - -%%%=================================================================== -%%% gen_server callbacks -%%%=================================================================== - -%% @doc Initiates the server -init(Id) -> - {ok, #state{ id = Id }}. - -%% @doc Handling call messages -handle_call({stop,Id}, _From, #state{ id = Id, requests = Reqs } = State) -> - [gen_server:reply(Req, locker_stopped) || {Req,_ReqId} <- Reqs], - {stop, normal, stopped, State}; -handle_call({stop,_Id}, _From, State) -> - {reply, stopped, State}; -handle_call({request, Pid}, _From, #state{ locked = false, - requests = [] } = State) -> - Ref = monitor(process, Pid), - {reply, locked, State#state{ locked = {true, Pid, Ref}} }; -handle_call({request, Pid}, From, #state{ requests = Reqs } = State) -> - {noreply, State#state{ requests = Reqs ++ [{From,Pid}] }}; -handle_call({release, Pid}, _From, #state{ locked = {true, Pid, Ref}, - requests = []} = State) -> - demonitor(Ref,[flush]), - {reply, unlocked, State#state{ locked = false }}; -handle_call({release, Pid}, _From, - #state{ locked = {true, Pid, Ref}, - requests = [{NextFrom,NextPid}|Rest]} = State) -> - demonitor(Ref,[flush]), - gen_server:reply(NextFrom,locked), - NextRef = monitor(process, NextPid), - {reply,unlocked,State#state{ locked = {true, NextPid, NextRef}, - requests = Rest } }; -handle_call({release, _Pid}, _From, State) -> - {reply, not_locked, State}. - -%% @doc Handling cast messages -handle_cast(_Msg, State) -> - {noreply, State}. - -%% @doc Handling all non call/cast messages -handle_info({'DOWN',Ref,process,Pid,_}, - #state{ locked = {true, Pid, Ref}, - requests = [{NextFrom,NextPid}|Rest] } = State) -> - gen_server:reply(NextFrom, locked), - NextRef = monitor(process, NextPid), - {noreply,State#state{ locked = {true, NextPid, NextRef}, - requests = Rest } }. - -%% @doc This function is called by a gen_server when it is about to terminate. -terminate(_Reason, _State) -> - ok. - -%% @doc Convert process state when code is changed -code_change(_OldVsn, State, _Extra) -> - {ok, State}. - -%% ------------------------------------------------------------------------- -%% Internal Functions -%% ------------------------------------------------------------------------- diff --git a/lib/common_test/src/ct_testspec.erl b/lib/common_test/src/ct_testspec.erl index 942241da6c..db1d4c5fb0 100644 --- a/lib/common_test/src/ct_testspec.erl +++ b/lib/common_test/src/ct_testspec.erl @@ -625,19 +625,19 @@ add_tests([{event_handler,Node,H,Args}|Ts],Spec) when is_atom(H) -> Node1 = ref2node(Node,Spec#testspec.nodes), add_tests(Ts,Spec#testspec{event_handler=[{Node1,H,Args}|EvHs]}); -%% --- suite_callbacks -- -add_tests([{suite_callbacks, all_nodes, CBs} | Ts], Spec) -> - Tests = [{suite_callbacks,N,CBs} || N <- list_nodes(Spec)], +%% --- ct_hooks -- +add_tests([{ct_hooks, all_nodes, Hooks} | Ts], Spec) -> + Tests = [{ct_hooks,N,Hooks} || N <- list_nodes(Spec)], add_tests(Tests ++ Ts, Spec); -add_tests([{suite_callbacks, Node, [CB|CBs]}|Ts], Spec) -> - SuiteCbs = Spec#testspec.suite_callbacks, +add_tests([{ct_hooks, Node, [Hook|Hooks]}|Ts], Spec) -> + SuiteCbs = Spec#testspec.ct_hooks, Node1 = ref2node(Node,Spec#testspec.nodes), - add_tests([{suite_callbacks, Node, CBs} | Ts], - Spec#testspec{suite_callbacks = [{Node1,CB} | SuiteCbs]}); -add_tests([{suite_callbacks, _Node, []}|Ts], Spec) -> + add_tests([{ct_hooks, Node, Hooks} | Ts], + Spec#testspec{ct_hooks = [{Node1,Hook} | SuiteCbs]}); +add_tests([{ct_hooks, _Node, []}|Ts], Spec) -> add_tests(Ts, Spec); -add_tests([{suite_callbacks, CBs}|Ts], Spec) -> - add_tests([{suite_callbacks, all_nodes, CBs}|Ts], Spec); +add_tests([{ct_hooks, Hooks}|Ts], Spec) -> + add_tests([{ct_hooks, all_nodes, Hooks}|Ts], Spec); %% --- include --- add_tests([{include,all_nodes,InclDirs}|Ts],Spec) -> @@ -1065,8 +1065,8 @@ valid_terms() -> {event_handler,2}, {event_handler,3}, {event_handler,4}, - {suite_callbacks,2}, - {suite_callbacks,3}, + {ct_hooks,2}, + {ct_hooks,3}, {multiply_timetraps,2}, {multiply_timetraps,3}, {scale_timetraps,2}, diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index 2f5a90a543..45146de57c 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -162,13 +162,13 @@ do_start(Parent,Mode,LogDir) -> end, {StartTime,TestLogDir} = ct_logs:init(Mode), - %% Initiate suite_callbacks - case catch ct_suite_callback:init(Opts) of + %% Initiate ct_hooks + case catch ct_hooks:init(Opts) of ok -> ok; - {_,SCBReason} -> - ct_logs:tc_print('Suite Callback',SCBReason,[]), - Parent ! {self(), SCBReason}, + {_,CTHReason} -> + ct_logs:tc_print('Suite Callback',CTHReason,[]), + Parent ! {self(), CTHReason}, self() ! {{stop,normal},{self(),make_ref()}} end, @@ -320,9 +320,9 @@ loop(Mode,TestData,StartDir) -> node=node(), data=Time}), Callbacks = ets:lookup_element(?suite_table, - suite_callbacks, + ct_hooks, #suite_data.value), - ct_suite_callback:terminate(Callbacks), + ct_hooks:terminate(Callbacks), close_connections(ets:tab2list(?conn_table)), ets:delete(?conn_table), ets:delete(?board_table), diff --git a/lib/common_test/src/ct_util.hrl b/lib/common_test/src/ct_util.hrl index 99f029bc0e..4ed29bdcd1 100644 --- a/lib/common_test/src/ct_util.hrl +++ b/lib/common_test/src/ct_util.hrl @@ -36,7 +36,7 @@ config=[], userconfig=[], event_handler=[], - suite_callbacks=[], + ct_hooks=[], include=[], multiply_timetraps=[], scale_timetraps=[], diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index 28be9f56f1..be4b4c32b8 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -41,7 +41,7 @@ MODULES= \ ct_config_SUITE \ ct_master_SUITE \ ct_misc_1_SUITE \ - ct_suite_callback_SUITE + ct_hooks_SUITE ERL_FILES= $(MODULES:%=%.erl) diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/empty_scb.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/empty_scb.erl deleted file mode 100644 index 41808b4f1d..0000000000 --- a/lib/common_test/test/ct_error_SUITE_data/error/test/empty_scb.erl +++ /dev/null @@ -1,187 +0,0 @@ -%% -%% %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% -%% - -%%% @doc Common Test Example Suite Callback module. -%%% -%%%

This module gives an example of a common test SCB (Suite CallBack). -%%% There are many ways to add a SCB to a test run, you can do it either in -%%% the command line using -suite_callback, in a test spec using -%%% {suite_callback,M} or in the suite it self by returning suite_callback -%%% from either suite/0, init_per_suite/1, init_per_group/2 and -%%% init_per_testcase/2. The scope of the SCB is determined by where is it -%%% started. If it is started in the command line or test spec then it will -%%% be stopped at the end of all tests. If it is started in init_per_suite, -%%% it will be stopped after end_per_suite and so on. See terminate -%%% documentation for a table describing the scoping machanics. -%%% -%%% All of callbacks except init/1 in a SCB are optional.

- --module(empty_scb). - -%% Suite Callbacks --export([init/1]). - --export([pre_init_suite/3]). --export([post_init_suite/3]). --export([pre_end_suite/3]). --export([post_end_suite/3]). - --export([pre_init_group/3]). --export([post_init_group/3]). --export([pre_end_group/3]). --export([post_end_group/3]). - --export([pre_init_tc/3]). --export([post_end_tc/3]). - --export([on_tc_fail/3]). - --export([terminate/2]). - --type proplist() :: list({atom(),term()}). --type config() :: proplist(). --type reason() :: term(). --type skip_or_fail() :: {skip, reason()} | - {auto_skip, reason()} | - {fail, reason()}. - --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()) -> - {Id :: term(), State :: #state{}}. -init(Opts) -> - {?MODULE, #state{ }}. - -%% @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 -%% specification, suite/0 function etc). -%% You can change the config in the this function. --spec pre_init_suite(Suite :: atom(), - Config :: config(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -pre_init_suite(Suite,Config,State) -> - {Config, State}. - -%% @doc Called after init_per_suite. -%% you can change the config in this function. --spec post_init_suite(Suite :: atom(), - Config :: config(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -post_init_suite(Suite,Config,State) -> - {Config, State}. - -%% @doc Called before end_per_suite. Note that the config cannot be -%% changed here, only the status of the suite. --spec pre_end_suite(Suite :: atom(), - Config :: config(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -pre_end_suite(Suite,Config,State) -> {Config, State}. - -%% @doc Called after end_per_suite. Note that the config cannot be -%% changed here, only the status of the suite. --spec post_end_suite(Suite :: atom(), - Config :: config(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -post_end_suite(Suite,Config,State) -> {Config, State}. - -%% @doc Called before each init_per_group. -%% You can change the config in this function. --spec pre_init_group(Group :: atom(), - Config :: config(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -pre_init_group(Group,Config,State) -> {Config, State}. - -%% @doc Called after each init_per_group. -%% You can change the config in this function. --spec post_init_group(Group :: atom(), - Config :: config(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -post_init_group(Group,Config,State) -> {Config, State}. - -%% @doc Called after each end_per_group. Note that the config cannot be -%% changed here, only the status of the group. --spec pre_end_group(Group :: atom(), - Config :: config(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -pre_end_group(Group,Config,State) -> {Config, State}. - -%% @doc Called after each end_per_group. Note that the config cannot be -%% changed here, only the status of the group. --spec post_end_group(Group :: atom(), - Config :: config(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -post_end_group(Group,Config,State) -> {Config, State}. - -%% @doc Called before each test case. -%% You can change the config in this function. --spec pre_init_tc(TC :: atom(), - Config :: config(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -pre_init_tc(TC,Config,State) -> {Config, State}. - -%% @doc Called after each test case. Note that the config cannot be -%% changed here, only the status of the test case. --spec post_end_tc(TC :: atom(), - Config :: config(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -post_end_tc(TC,Config,State) -> {Config, State}. - -%% @doc Called after post_init_suite, post_end_suite, post_init_group, -%% post_end_group and post_end_tc if the suite, group or test case failed. -%% This function should be used for extra cleanup which might be needed. -%% It is not possible to modify the config or the status of the test run. --spec on_tc_fail(TC :: init_per_suite | end_per_suite | - init_per_group | end_per_group | atom(), - Config :: config(), State :: #state{}) -> - ok. -on_tc_fail(_TC, _Config, _State) -> - ok. - -%% @doc Called when the scope of the SCB is done, this depends on -%% when the SCB was specified. This translation table describes when this -%% function is called. -%% -%% | Started in | terminate called | -%% |---------------------|-------------------------| -%% | command_line | after all tests are run | -%% | test spec | after all tests are run | -%% | suite/0 | after SUITE is done | -%% | init_per_suite/1 | after SUITE is done | -%% | init_per_group/2 | after group is done | -%% | init_per_testcase/2 | after test case is done | -%% |-----------------------------------------------| -%% --spec terminate(Config :: proplist(), State :: #state{}) -> - term(). -terminate(Config,State) -> {Config, State}. diff --git a/lib/common_test/test/ct_hooks_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE.erl new file mode 100644 index 0000000000..1e187aa205 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE.erl @@ -0,0 +1,1021 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2009-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% +%% + +%%%------------------------------------------------------------------- +%%% File: ct_error_SUITE +%%% +%%% Description: +%%% Test various errors in Common Test suites. +%%% +%%% The suites used for the test are located in the data directory. +%%%------------------------------------------------------------------- +-module(ct_hooks_SUITE). + +-compile(export_all). + +-include_lib("test_server/include/test_server.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + +-define(eh, ct_test_support_eh). + +%%-------------------------------------------------------------------- +%% TEST SERVER CALLBACK FUNCTIONS +%%-------------------------------------------------------------------- + +%%-------------------------------------------------------------------- +%% Description: Since Common Test starts another Test Server +%% instance, the tests need to be performed on a separate node (or +%% there will be clashes with logging processes etc). +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + DataDir = ?config(data_dir, Config), + TestDir = filename:join(DataDir,"cth/tests/"), + CTHs = filelib:wildcard(filename:join(TestDir,"*_cth.erl")), + io:format("CTHs: ~p",[CTHs]), + [io:format("Compiling ~p: ~p", + [FileName,compile:file(FileName,[{outdir,TestDir},debug_info])]) || + FileName <- CTHs], + ct_test_support:init_per_suite([{path_dirs,[TestDir]} | Config]). + +end_per_suite(Config) -> + ct_test_support:end_per_suite(Config). + +init_per_testcase(TestCase, Config) -> + ct_test_support:init_per_testcase(TestCase, Config). + +end_per_testcase(TestCase, Config) -> + ct_test_support:end_per_testcase(TestCase, Config). + + +suite() -> + [{timetrap,{seconds,20}}]. + +all() -> + all(suite). + +all(suite) -> + lists:reverse( + [ + one_cth, two_cth, faulty_cth_no_init, faulty_cth_id_no_init, + faulty_cth_exit_in_init, faulty_cth_exit_in_id, + faulty_cth_exit_in_init_scope_suite, minimal_cth, + minimal_and_maximal_cth, faulty_cth_undef, + scope_per_suite_cth, scope_per_group_cth, scope_suite_cth, + scope_per_suite_state_cth, scope_per_group_state_cth, + scope_suite_state_cth, + fail_pre_suite_cth, fail_post_suite_cth, skip_pre_suite_cth, + skip_post_suite_cth, recover_post_suite_cth, update_config_cth, + state_update_cth, options_cth, same_id_cth, + fail_n_skip_with_minimal_cth + ] + ) + . + + +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- + +%%%----------------------------------------------------------------- +%%% +one_cth(Config) when is_list(Config) -> + do_test(one_empty_cth, "ct_cth_empty_SUITE.erl",[empty_cth], Config). + +two_cth(Config) when is_list(Config) -> + do_test(two_empty_cth, "ct_cth_empty_SUITE.erl",[empty_cth,empty_cth], + Config). + +faulty_cth_no_init(Config) when is_list(Config) -> + do_test(faulty_cth_no_init, "ct_cth_empty_SUITE.erl",[askjhdkljashdkaj], + Config,{error,"Failed to start CTH, see the " + "CT Log for details"}). + +faulty_cth_id_no_init(Config) when is_list(Config) -> + do_test(faulty_cth_id_no_init, "ct_cth_empty_SUITE.erl",[id_no_init_cth], + Config,{error,"Failed to start CTH, see the " + "CT Log for details"}). + +minimal_cth(Config) when is_list(Config) -> + do_test(minimal_cth, "ct_cth_empty_SUITE.erl",[minimal_cth],Config). + +minimal_and_maximal_cth(Config) when is_list(Config) -> + do_test(minimal_and_maximal_cth, "ct_cth_empty_SUITE.erl", + [minimal_cth, empty_cth],Config). + +faulty_cth_undef(Config) when is_list(Config) -> + do_test(faulty_cth_undef, "ct_cth_empty_SUITE.erl", + [undef_cth],Config). + +faulty_cth_exit_in_init_scope_suite(Config) when is_list(Config) -> + do_test(faulty_cth_exit_in_init_scope_suite, + "ct_exit_in_init_scope_suite_cth_SUITE.erl", + [],Config). + +faulty_cth_exit_in_init(Config) when is_list(Config) -> + do_test(faulty_cth_exit_in_init, "ct_cth_empty_SUITE.erl", + [crash_init_cth], Config, + {error,"Failed to start CTH, see the " + "CT Log for details"}). + +faulty_cth_exit_in_id(Config) when is_list(Config) -> + do_test(faulty_cth_exit_in_id, "ct_cth_empty_SUITE.erl", + [crash_id_cth], Config, + {error,"Failed to start CTH, see the " + "CT Log for details"}). + +scope_per_suite_cth(Config) when is_list(Config) -> + do_test(scope_per_suite_cth, "ct_scope_per_suite_cth_SUITE.erl", + [],Config). + +scope_suite_cth(Config) when is_list(Config) -> + do_test(scope_suite_cth, "ct_scope_suite_cth_SUITE.erl", + [],Config). + +scope_per_group_cth(Config) when is_list(Config) -> + do_test(scope_per_group_cth, "ct_scope_per_group_cth_SUITE.erl", + [],Config). + +scope_per_suite_state_cth(Config) when is_list(Config) -> + do_test(scope_per_suite_state_cth, "ct_scope_per_suite_state_cth_SUITE.erl", + [],Config). + +scope_suite_state_cth(Config) when is_list(Config) -> + do_test(scope_suite_state_cth, "ct_scope_suite_state_cth_SUITE.erl", + [],Config). + +scope_per_group_state_cth(Config) when is_list(Config) -> + do_test(scope_per_group_state_cth, "ct_scope_per_group_state_cth_SUITE.erl", + [],Config). + +fail_pre_suite_cth(Config) when is_list(Config) -> + do_test(fail_pre_suite_cth, "ct_cth_empty_SUITE.erl", + [fail_pre_suite_cth],Config). + +fail_post_suite_cth(Config) when is_list(Config) -> + do_test(fail_post_suite_cth, "ct_cth_empty_SUITE.erl", + [fail_post_suite_cth],Config). + +skip_pre_suite_cth(Config) when is_list(Config) -> + do_test(skip_pre_suite_cth, "ct_cth_empty_SUITE.erl", + [skip_pre_suite_cth],Config). + +skip_post_suite_cth(Config) when is_list(Config) -> + do_test(skip_post_suite_cth, "ct_cth_empty_SUITE.erl", + [skip_post_suite_cth],Config). + +recover_post_suite_cth(Config) when is_list(Config) -> + do_test(recover_post_suite_cth, "ct_cth_fail_per_suite_SUITE.erl", + [recover_post_suite_cth],Config). + +update_config_cth(Config) when is_list(Config) -> + do_test(update_config_cth, "ct_update_config_SUITE.erl", + [update_config_cth],Config). + +state_update_cth(Config) when is_list(Config) -> + do_test(state_update_cth, "ct_cth_fail_one_skip_one_SUITE.erl", + [state_update_cth,state_update_cth],Config). + +options_cth(Config) when is_list(Config) -> + do_test(options_cth, "ct_cth_empty_SUITE.erl", + [{empty_cth,[test]}],Config). + +same_id_cth(Config) when is_list(Config) -> + do_test(same_id_cth, "ct_cth_empty_SUITE.erl", + [same_id_cth,same_id_cth],Config). + +fail_n_skip_with_minimal_cth(Config) when is_list(Config) -> + do_test(fail_n_skip_with_minimal_cth, "ct_cth_fail_one_skip_one_SUITE.erl", + [minimal_terminate_cth],Config). + +%%%----------------------------------------------------------------- +%%% HELP FUNCTIONS +%%%----------------------------------------------------------------- + +do_test(Tag, SWC, CTHs, Config) -> + do_test(Tag, SWC, CTHs, Config, ok). +do_test(Tag, SWC, CTHs, Config, {error,_} = Res) -> + do_test(Tag, SWC, CTHs, Config, Res, 1); +do_test(Tag, SWC, CTHs, Config, Res) -> + do_test(Tag, SWC, CTHs, Config, Res, 2). + +do_test(Tag, SuiteWildCard, CTHs, Config, Res, EC) -> + + DataDir = ?config(data_dir, Config), + Suites = filelib:wildcard( + filename:join([DataDir,"cth/tests",SuiteWildCard])), + {Opts,ERPid} = setup([{suite,Suites}, + {ct_hooks,CTHs},{label,Tag}], Config), + Res = ct_test_support:run(Opts, Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(Tag, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = events_to_check(Tag, EC), + ok = ct_test_support:verify_events(TestEvents, Events, Config). + +setup(Test, Config) -> + Opts0 = ct_test_support:get_opts(Config), + Level = ?config(trace_level, Config), + EvHArgs = [{cbm,ct_test_support},{trace_level,Level}], + Opts = Opts0 ++ [{event_handler,{?eh,EvHArgs}}|Test], + ERPid = ct_test_support:start_event_receiver(Config), + {Opts,ERPid}. + +reformat(Events, EH) -> + ct_test_support:reformat(Events, EH). +%reformat(Events, _EH) -> +% Events. + +%%%----------------------------------------------------------------- +%%% TEST EVENTS +%%%----------------------------------------------------------------- +events_to_check(Test) -> + %% 2 tests (ct:run_test + script_start) is default + events_to_check(Test, 2). + +events_to_check(_, 0) -> + []; +events_to_check(Test, N) -> + test_events(Test) ++ events_to_check(Test, N-1). + +test_events(one_empty_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{empty_cth,id,[[]]}}, + {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{empty_cth,pre_init_per_suite, + [ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{empty_cth,post_init_per_suite, + [ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,test_case}}, + {?eh,cth,{empty_cth,pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {?eh,cth,{empty_cth,post_end_per_testcase,[test_case,'$proplist','_',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}}, + {?eh,cth,{empty_cth,pre_end_per_suite, + [ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{empty_cth,post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{empty_cth,terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(two_empty_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}}, + {?eh,cth,{'_',post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(faulty_cth_no_init) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(faulty_cth_id_no_init) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {negative,{?eh,tc_start,'_'}, + {?eh,test_done,{'DEF','STOP_TIME'}}}, + {?eh,stop_logging,[]} + ]; + +test_events(minimal_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {negative,{?eh,cth,{'_',id,['_',[]]}}, + {?eh,cth,{'_',init,['_',[]]}}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,test_case}}, + {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}}, + {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(minimal_and_maximal_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {negative,{?eh,cth,{'_',id,['_',[]]}}, + {?eh,cth,{'_',init,['_',[]]}}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(faulty_cth_undef) -> + FailReasonStr = "undef_cth:pre_init_per_suite/3 CTH call failed", + FailReason = {ct_cth_empty_SUITE,init_per_suite, + {failed,FailReasonStr}}, + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite, + {failed, {error,FailReasonStr}}}}, + {?eh,cth,{'_',on_tc_fail,'_'}}, + + {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case, + {failed, FailReason}}}, + {?eh,cth,{'_',on_tc_skip,'_'}}, + + {?eh,tc_auto_skip,{ct_cth_empty_SUITE,end_per_suite, + {failed, FailReason}}}, + {?eh,cth,{'_',on_tc_skip,'_'}}, + + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(faulty_cth_exit_in_init_scope_suite) -> + [{?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{'_',init_per_suite}}, + {?eh,cth,{empty_cth,init,['_',[]]}}, + {?eh,tc_done, + {ct_exit_in_init_scope_suite_cth_SUITE,init_per_suite, + {failed, + {error, + "Failed to start CTH, see the CT Log for details"}}}}, + {?eh,tc_auto_skip, + {ct_exit_in_init_scope_suite_cth_SUITE,test_case, + {failed, + {ct_exit_in_init_scope_suite_cth_SUITE,init_per_suite, + {failed, + "Failed to start CTH, see the CT Log for details"}}}}}, + {?eh,tc_auto_skip, + {ct_exit_in_init_scope_suite_cth_SUITE,end_per_suite, + {failed, + {ct_exit_in_init_scope_suite_cth_SUITE,init_per_suite, + {failed, + "Failed to start CTH, see the CT Log for details"}}}}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]}]; + +test_events(faulty_cth_exit_in_init) -> + [{?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{empty_cth,init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]}]; + +test_events(faulty_cth_exit_in_id) -> + [{?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{empty_cth,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_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_scope_per_suite_cth_SUITE,init_per_suite}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_scope_per_suite_cth_SUITE,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_scope_per_suite_cth_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_scope_per_suite_cth_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, + {?eh,tc_done,{ct_scope_per_suite_cth_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_scope_per_suite_cth_SUITE,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite, + [ct_scope_per_suite_cth_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_suite,[ct_scope_per_suite_cth_SUITE,'$proplist','_',[]]}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,tc_done,{ct_scope_per_suite_cth_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(scope_suite_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_scope_suite_cth_SUITE,init_per_suite}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_scope_suite_cth_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_scope_suite_cth_SUITE,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_scope_suite_cth_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_scope_suite_cth_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, + {?eh,tc_done,{ct_scope_suite_cth_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_scope_suite_cth_SUITE,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite,[ct_scope_suite_cth_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_suite,[ct_scope_suite_cth_SUITE,'$proplist','_',[]]}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,tc_done,{ct_scope_suite_cth_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(scope_per_group_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_scope_per_group_cth_SUITE,init_per_suite}}, + {?eh,tc_done,{ct_scope_per_group_cth_SUITE,init_per_suite,ok}}, + + [{?eh,tc_start,{ct_scope_per_group_cth_SUITE,{init_per_group,group1,[]}}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,cth,{'_',post_init_per_group,[group1,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_scope_per_group_cth_SUITE,{init_per_group,group1,[]},ok}}, + + {?eh,tc_start,{ct_scope_per_group_cth_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, + {?eh,tc_done,{ct_scope_per_group_cth_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_scope_per_group_cth_SUITE,{end_per_group,group1,[]}}}, + {?eh,cth,{'_',pre_end_per_group,[group1,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_group,[group1,'$proplist','_',[]]}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,tc_done,{ct_scope_per_group_cth_SUITE,{end_per_group,group1,[]},ok}}], + + {?eh,tc_start,{ct_scope_per_group_cth_SUITE,end_per_suite}}, + {?eh,tc_done,{ct_scope_per_group_cth_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(scope_per_suite_state_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_scope_per_suite_state_cth_SUITE,init_per_suite}}, + {?eh,cth,{'_',id,[[test]]}}, + {?eh,cth,{'_',init,['_',[test]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_scope_per_suite_state_cth_SUITE,'$proplist','$proplist',[test]]}}, + {?eh,tc_done,{ct_scope_per_suite_state_cth_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_scope_per_suite_state_cth_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[test]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[test]]}}, + {?eh,tc_done,{ct_scope_per_suite_state_cth_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_scope_per_suite_state_cth_SUITE,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite, + [ct_scope_per_suite_state_cth_SUITE,'$proplist',[test]]}}, + {?eh,cth,{'_',post_end_per_suite,[ct_scope_per_suite_state_cth_SUITE,'$proplist','_',[test]]}}, + {?eh,cth,{'_',terminate,[[test]]}}, + {?eh,tc_done,{ct_scope_per_suite_state_cth_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(scope_suite_state_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_scope_suite_state_cth_SUITE,init_per_suite}}, + {?eh,cth,{'_',id,[[test]]}}, + {?eh,cth,{'_',init,['_',[test]]}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_scope_suite_state_cth_SUITE,'$proplist',[test]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_scope_suite_state_cth_SUITE,'$proplist','$proplist',[test]]}}, + {?eh,tc_done,{ct_scope_suite_state_cth_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_scope_suite_state_cth_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[test]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[test]]}}, + {?eh,tc_done,{ct_scope_suite_state_cth_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_scope_suite_state_cth_SUITE,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite,[ct_scope_suite_state_cth_SUITE,'$proplist',[test]]}}, + {?eh,cth,{'_',post_end_per_suite,[ct_scope_suite_state_cth_SUITE,'$proplist','_',[test]]}}, + {?eh,cth,{'_',terminate,[[test]]}}, + {?eh,tc_done,{ct_scope_suite_state_cth_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(scope_per_group_state_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,init_per_suite}}, + {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,init_per_suite,ok}}, + + [{?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,{init_per_group,group1,[]}}}, + {?eh,cth,{'_',id,[[test]]}}, + {?eh,cth,{'_',init,['_',[test]]}}, + {?eh,cth,{'_',post_init_per_group,[group1,'$proplist','$proplist',[test]]}}, + {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,{init_per_group,group1,[]},ok}}, + + {?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[test]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[test]]}}, + {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,{end_per_group,group1,[]}}}, + {?eh,cth,{'_',pre_end_per_group,[group1,'$proplist',[test]]}}, + {?eh,cth,{'_',post_end_per_group,[group1,'$proplist','_',[test]]}}, + {?eh,cth,{'_',terminate,[[test]]}}, + {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,{end_per_group,group1,[]},ok}}], + + {?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,end_per_suite}}, + {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(fail_pre_suite_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + + + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist', + {fail,"Test failure"},[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite, + {failed, {error,"Test failure"}}}}, + {?eh,cth,{'_',on_tc_fail, + [init_per_suite,{failed,"Test failure"},[]]}}, + + + {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case, + {failed,{ct_cth_empty_SUITE,init_per_suite, + {failed,"Test failure"}}}}}, + {?eh,cth,{'_',on_tc_skip, + [test_case, {tc_auto_skip, + {failed, {ct_cth_empty_SUITE, init_per_suite, + {failed, "Test failure"}}}},[]]}}, + + + {?eh,tc_auto_skip, {ct_cth_empty_SUITE, end_per_suite, + {failed, {ct_cth_empty_SUITE, init_per_suite, + {failed, "Test failure"}}}}}, + {?eh,cth,{'_',on_tc_skip, + [end_per_suite, {tc_auto_skip, + {failed, {ct_cth_empty_SUITE, init_per_suite, + {failed, "Test failure"}}}},[]]}}, + + + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth, {'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(fail_post_suite_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite, + {failed,{error,"Test failure"}}}}, + {?eh,cth,{'_',on_tc_fail,[init_per_suite, {failed,"Test failure"}, []]}}, + + {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case, + {failed,{ct_cth_empty_SUITE,init_per_suite, + {failed,"Test failure"}}}}}, + {?eh,cth,{'_',on_tc_skip,[test_case,{tc_auto_skip,'_'},[]]}}, + + {?eh,tc_auto_skip, {ct_cth_empty_SUITE, end_per_suite, + {failed, {ct_cth_empty_SUITE, init_per_suite, + {failed, "Test failure"}}}}}, + {?eh,cth,{'_',on_tc_skip,[end_per_suite,{tc_auto_skip,'_'},[]]}}, + + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth, {'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(skip_pre_suite_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist',{skip,"Test skip"},[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,{skipped,"Test skip"}}}, + {?eh,cth,{'_',on_tc_skip, + [init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}}, + + {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case,"Test skip"}}, + {?eh,cth,{'_',on_tc_skip,[test_case,{tc_auto_skip,"Test skip"},[]]}}, + + {?eh,tc_auto_skip, {ct_cth_empty_SUITE, end_per_suite,"Test skip"}}, + {?eh,cth,{'_',on_tc_skip,[end_per_suite,{tc_auto_skip,"Test skip"},[]]}}, + + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth, {'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(skip_post_suite_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,{skipped,"Test skip"}}}, + {?eh,cth,{'_',on_tc_skip, + [init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}}, + + {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case,"Test skip"}}, + {?eh,cth,{'_',on_tc_skip,[test_case,{tc_auto_skip,"Test skip"},[]]}}, + + {?eh,tc_auto_skip, {ct_cth_empty_SUITE, end_per_suite,"Test skip"}}, + {?eh,cth,{'_',on_tc_skip,[end_per_suite,{tc_auto_skip,"Test skip"},[]]}}, + + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(recover_post_suite_cth) -> + Suite = ct_cth_fail_per_suite_SUITE, + [ + {?eh,start_logging,'_'}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{Suite,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite,[Suite,'$proplist','$proplist']}}, + {?eh,cth,{'_',post_init_per_suite,[Suite,contains([tc_status]), + {'EXIT',{'_','_'}},[]]}}, + {?eh,tc_done,{Suite,init_per_suite,ok}}, + + {?eh,tc_start,{Suite,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase, + [test_case, not_contains([tc_status]),[]]}}, + {?eh,cth,{'_',post_end_per_testcase, + [test_case, contains([tc_status]),'_',[]]}}, + {?eh,tc_done,{Suite,test_case,ok}}, + + {?eh,tc_start,{Suite,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite, + [Suite,not_contains([tc_status]),[]]}}, + {?eh,cth,{'_',post_end_per_suite, + [Suite,not_contains([tc_status]),'_',[]]}}, + {?eh,tc_done,{Suite,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(update_config_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + + {?eh,tc_start,{ct_update_config_SUITE,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite, + [ct_update_config_SUITE,contains([]),[]]}}, + {?eh,cth,{'_',post_init_per_suite, + [ct_update_config_SUITE, + '$proplist', + contains( + [init_per_suite, + pre_init_per_suite]), + []]}}, + {?eh,tc_done,{ct_update_config_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_update_config_SUITE, {init_per_group,group1,[]}}}, + {?eh,cth,{'_',pre_init_per_group, + [group1,contains( + [post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + []]}}, + {?eh,cth,{'_',post_init_per_group, + [group1, + contains( + [post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + contains( + [init_per_group, + pre_init_per_group, + post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + []]}}, + {?eh,tc_done,{ct_update_config_SUITE,{init_per_group,group1,[]},ok}}, + + {?eh,tc_start,{ct_update_config_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase, + [test_case,contains( + [post_init_per_group, + init_per_group, + pre_init_per_group, + post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + []]}}, + {?eh,cth,{'_',post_end_per_testcase, + [test_case,contains( + [init_per_testcase, + pre_init_per_testcase, + post_init_per_group, + init_per_group, + pre_init_per_group, + post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + ok,[]]}}, + {?eh,tc_done,{ct_update_config_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_update_config_SUITE, {end_per_group,group1,[]}}}, + {?eh,cth,{'_',pre_end_per_group, + [group1,contains( + [post_init_per_group, + init_per_group, + pre_init_per_group, + post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + []]}}, + {?eh,cth,{'_',post_end_per_group, + [group1, + contains( + [pre_end_per_group, + post_init_per_group, + init_per_group, + pre_init_per_group, + post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + ok,[]]}}, + {?eh,tc_done,{ct_update_config_SUITE,{end_per_group,group1,[]},ok}}, + + {?eh,tc_start,{ct_update_config_SUITE,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite, + [ct_update_config_SUITE,contains( + [post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + []]}}, + {?eh,cth,{'_',post_end_per_suite, + [ct_update_config_SUITE,contains( + [pre_end_per_suite, + post_init_per_suite, + init_per_suite, + pre_init_per_suite]), + '_',[]]}}, + {?eh,tc_done,{ct_update_config_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{'_',terminate,[contains( + [post_end_per_suite, + pre_end_per_suite, + post_init_per_suite, + init_per_suite, + pre_init_per_suite])]}}, + {?eh,stop_logging,[]} + ]; + +test_events(state_update_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{'_',init_per_suite}}, + + {?eh,tc_done,{'_',end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{'_',terminate,[contains( + [post_end_per_suite,pre_end_per_suite, + post_end_per_group,pre_end_per_group, + {not_in_order, + [post_end_per_testcase,pre_init_per_testcase, + on_tc_skip,post_end_per_testcase, + pre_init_per_testcase,on_tc_fail, + post_end_per_testcase,pre_init_per_testcase] + }, + post_init_per_group,pre_init_per_group, + post_init_per_suite,pre_init_per_suite, + init])]}}, + {?eh,cth,{'_',terminate,[contains( + [post_end_per_suite,pre_end_per_suite, + post_end_per_group,pre_end_per_group, + {not_in_order, + [post_end_per_testcase,pre_init_per_testcase, + on_tc_skip,post_end_per_testcase, + pre_init_per_testcase,on_tc_fail, + post_end_per_testcase,pre_init_per_testcase] + }, + post_init_per_group,pre_init_per_group, + post_init_per_suite,pre_init_per_suite, + init] + )]}}, + {?eh,stop_logging,[]} + ]; + +test_events(options_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{empty_cth,init,['_',[test]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{empty_cth,pre_init_per_suite, + [ct_cth_empty_SUITE,'$proplist',[test]]}}, + {?eh,cth,{empty_cth,post_init_per_suite, + [ct_cth_empty_SUITE,'$proplist','$proplist',[test]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,test_case}}, + {?eh,cth,{empty_cth,pre_init_per_testcase,[test_case,'$proplist',[test]]}}, + {?eh,cth,{empty_cth,post_end_per_testcase,[test_case,'$proplist','_',[test]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}}, + {?eh,cth,{empty_cth,pre_end_per_suite, + [ct_cth_empty_SUITE,'$proplist',[test]]}}, + {?eh,cth,{empty_cth,post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[test]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{empty_cth,terminate,[[test]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(same_id_cth) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,cth,{'_',init,[same_id_cth,[]]}}, + {?eh,cth,{'_',id,[[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}}, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {negative, + {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_init_per_suite, + [ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}}, + {negative, + {?eh,cth,{'_',post_init_per_suite, + [ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,test_case}}, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {negative, + {?eh,cth,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}}, + {negative, + {?eh,cth,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}}}, + + {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}}, + {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {negative, + {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}}, + {?eh,cth,{'_',post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}}}, + {negative, + {?eh,cth,{'_',post_end_per_suite, + [ct_cth_empty_SUITE,'$proplist','_',[]]}}, + {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(fail_n_skip_with_minimal_cth) -> + [{?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,cth,{'_',init,['_',[]]}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,tc_start,{'_',init_per_suite}}, + + {?eh,tc_done,{'_',end_per_suite,ok}}, + {?eh,cth,{'_',terminate,[[]]}}, + {?eh,stop_logging,[]} + ]; + +test_events(ok) -> + ok. + + +%% test events help functions +contains(List) -> + fun(Proplist) when is_list(Proplist) -> + contains(List,Proplist) + end. + +contains([{not_in_order,List}|T],Rest) -> + contains_parallel(List,Rest), + contains(T,Rest); +contains([{Ele,Pos}|T] = L,[H|T2]) -> + case element(Pos,H) of + Ele -> + contains(T,T2); + _ -> + contains(L,T2) + end; +contains([Ele|T],[{Ele,_}|T2])-> + contains(T,T2); +contains([Ele|T],[Ele|T2])-> + contains(T,T2); +contains(List,[_|T]) -> + contains(List,T); +contains([],_) -> + match. + +contains_parallel([Key | T], Elems) -> + contains([Key],Elems), + contains_parallel(T,Elems); +contains_parallel([],_Elems) -> + match. + +not_contains(List) -> + fun(Proplist) when is_list(Proplist) -> + [] = [Ele || {Ele,_} <- Proplist, + Test <- List, + Test =:= Ele] + end. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/crash_id_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/crash_id_cth.erl new file mode 100644 index 0000000000..02c36e378c --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/crash_id_cth.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_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-export([id/1]). + +id(Opts) -> + empty_cth:id(Opts), + exit(diediedie). + diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/crash_init_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/crash_init_cth.erl new file mode 100644 index 0000000000..6ed23565f6 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/crash_init_cth.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_init_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-export([init/2]). + +init(Id, Opts) -> + empty_cth:init(Id, Opts), + exit(diediedie). + diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_empty_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_empty_SUITE.erl new file mode 100644 index 0000000000..499069b382 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_empty_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_cth_empty_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. + +all() -> + [test_case]. + +%% Test cases starts here. +test_case(Config) when is_list(Config) -> + ok. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_fail_one_skip_one_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_fail_one_skip_one_SUITE.erl new file mode 100644 index 0000000000..017812c719 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_fail_one_skip_one_SUITE.erl @@ -0,0 +1,64 @@ +%% +%% %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_cth_fail_one_skip_one_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_group(_Group,Config) -> + Config. + +end_per_group(_Group,_Config) -> + ok. + +init_per_testcase(test_case2, Config) -> + {skip,"skip it"}; +init_per_testcase(_TestCase, Config) -> + Config. + +end_per_testcase(_TestCase, _Config) -> + ok. + +groups() -> + [{group1,[parallel],[{group2,[parallel],[test_case1,test_case2,test_case3]}]}]. + +all() -> + [{group,group1}]. + +%% Test cases starts here. +test_case1(Config) -> + ok = nok. + +test_case2(Config) -> + ok. + +test_case3(Config) -> + ok. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_fail_per_suite_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_fail_per_suite_SUITE.erl new file mode 100644 index 0000000000..136a15ec96 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_cth_fail_per_suite_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_cth_fail_per_suite_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) -> + ok = nok. + +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_hooks_SUITE_data/cth/tests/ct_exit_in_init_scope_suite_cth_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_exit_in_init_scope_suite_cth_SUITE.erl new file mode 100644 index 0000000000..42be0a659e --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_exit_in_init_scope_suite_cth_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_exit_in_init_scope_suite_cth_SUITE). + +-suite_defaults([{timetrap, {minutes, 10}}]). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%% Test server callback functions +suite() -> + [{ct_hooks,[crash_init_cth]}]. + +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. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_group_cth_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_group_cth_SUITE.erl new file mode 100644 index 0000000000..628bca774c --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_group_cth_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_cth_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) -> + [{ct_hooks,[empty_cth]}|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_hooks_SUITE_data/cth/tests/ct_scope_per_group_state_cth_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_group_state_cth_SUITE.erl new file mode 100644 index 0000000000..14ea52bf8c --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_group_state_cth_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_cth_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) -> + [{ct_hooks,[{empty_cth,[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_hooks_SUITE_data/cth/tests/ct_scope_per_suite_cth_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_suite_cth_SUITE.erl new file mode 100644 index 0000000000..5c1658be44 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_suite_cth_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_cth_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) -> + [{ct_hooks,[empty_cth]}|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_hooks_SUITE_data/cth/tests/ct_scope_per_suite_state_cth_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_suite_state_cth_SUITE.erl new file mode 100644 index 0000000000..96d00e3b28 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_suite_state_cth_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_cth_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) -> + [{ct_hooks,[{empty_cth,[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_hooks_SUITE_data/cth/tests/ct_scope_per_tc_cth_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_tc_cth_SUITE.erl new file mode 100644 index 0000000000..fa632444c5 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_per_tc_cth_SUITE.erl @@ -0,0 +1,110 @@ +%% +%% %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_tc_cth_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 +%%-------------------------------------------------------------------- +%% @doc +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% +%% @spec init_per_suite(Config) -> Config +%% @end +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% @doc +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Cleanup after the whole suite +%% +%% @spec end_per_suite(Config) -> _ +%% @end +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ok. + +%%-------------------------------------------------------------------- +%% @doc +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Initiation before each test case +%% +%% @spec init_per_testcase(TestCase, Config) -> Config +%% @end +%%-------------------------------------------------------------------- +init_per_testcase(_TestCase, Config) -> + [{ct_hooks,[empty_cth]}|Config]. + +%%-------------------------------------------------------------------- +%% @doc +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Cleanup after each test case +%% +%% @spec end_per_testcase(TestCase, Config) -> _ +%% @end +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% @doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% +%% Returns a list of all test cases in this test suite +%% +%% @spec all() -> TestCases +%% @end +%%-------------------------------------------------------------------- +all() -> + [test_case]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- +test_case(Config) when is_list(Config) -> + ok. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_suite_cth_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_suite_cth_SUITE.erl new file mode 100644 index 0000000000..988a0969ca --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_suite_cth_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_cth_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() -> + [{ct_hooks,[empty_cth]}]. + +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. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_suite_state_cth_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_suite_state_cth_SUITE.erl new file mode 100644 index 0000000000..18b68fbcdc --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_scope_suite_state_cth_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_cth_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() -> + [{ct_hooks,[{empty_cth,[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. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_update_config_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_update_config_SUITE.erl new file mode 100644 index 0000000000..57fea347f6 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_update_config_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_update_config_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) -> + [{init_per_suite,now()}|Config]. + +end_per_suite(_Config) -> + ok. + +init_per_testcase(_TestCase, Config) -> + [{init_per_testcase,now()}|Config]. + +end_per_testcase(_TestCase, _Config) -> + ok. + +init_per_group(GroupName, Config) -> + [{init_per_group,now()}|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_hooks_SUITE_data/cth/tests/empty_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl new file mode 100644 index 0000000000..7654a7ee2f --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl @@ -0,0 +1,277 @@ +%% +%% %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% +%% + +%%% @doc Common Test Example Suite Callback module. +%%% +%%%

This module gives an example of a common test CTH (Common Test Hook). +%%% There are many ways to add a CTH to a test run, you can do it either in +%%% the command line using -ct_hook, in a test spec using +%%% {ct_hook,M} or in the suite it self by returning ct_hook +%%% from either suite/0, init_per_suite/1, init_per_group/2 and +%%% init_per_testcase/2. The scope of the CTH is determined by where is it +%%% started. If it is started in the command line or test spec then it will +%%% be stopped at the end of all tests. If it is started in init_per_suite, +%%% it will be stopped after end_per_suite and so on. See terminate +%%% documentation for a table describing the scoping machanics. +%%% +%%% All of callbacks except init/1 in a CTH are optional.

+ +-module(empty_cth). + +%% CT Hooks +-export([id/1]). +-export([init/2]). + +-export([pre_init_per_suite/3]). +-export([post_init_per_suite/4]). +-export([pre_end_per_suite/3]). +-export([post_end_per_suite/4]). + +-export([pre_init_per_group/3]). +-export([post_init_per_group/4]). +-export([pre_end_per_group/3]). +-export([post_end_per_group/4]). + +-export([pre_init_per_testcase/3]). +-export([post_end_per_testcase/4]). + +-export([on_tc_fail/3]). +-export([on_tc_skip/3]). + +-export([terminate/1]). + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + +-type proplist() :: list({atom(),term()}). +-type config() :: proplist(). +-type reason() :: term(). +-type skip_or_fail() :: {skip, reason()} | + {auto_skip, reason()} | + {fail, reason()}. + +-record(state, { id = ?MODULE :: term()}). + +%% @doc Always called before any other callback function. Use this to initiate +%% any common state. It should return an state for this CTH. +-spec init(Id :: term(), Opts :: proplist()) -> + {Id :: term(), State :: #state{}}. +init(Id, Opts) -> + gen_event:notify(?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, init, [Id, Opts]}}), + Opts. + +%% @doc The ID is used to uniquly identify an CTH instance, if two CTH's +%% return the same ID the seconds CTH 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 = cth, node = node(), + data = {?MODULE, id, [Opts]}}), + now(). + +%% @doc Called before init_per_suite is called. Note that this callback is +%% only called if the CTH is added before init_per_suite is run (eg. in a test +%% specification, suite/0 function etc). +%% You can change the config in the this function. +-spec pre_init_per_suite(Suite :: atom(), + Config :: config(), + State :: #state{}) -> + {config() | skip_or_fail(), NewState :: #state{}}. +pre_init_per_suite(Suite,Config,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, pre_init_per_suite, + [Suite,Config,State]}}), + {Config, State}. + +%% @doc Called after init_per_suite. +%% you can change the return value in this function. +-spec post_init_per_suite(Suite :: atom(), + Config :: config(), + Return :: config() | skip_or_fail(), + State :: #state{}) -> + {config() | skip_or_fail(), NewState :: #state{}}. +post_init_per_suite(Suite,Config,Return,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, post_init_per_suite, + [Suite,Config,Return,State]}}), + {Return, State}. + +%% @doc Called before end_per_suite. The config/state can be changed here, +%% though it will only affect the *end_per_suite function. +-spec pre_end_per_suite(Suite :: atom(), + Config :: config() | skip_or_fail(), + State :: #state{}) -> + {ok | skip_or_fail(), NewState :: #state{}}. +pre_end_per_suite(Suite,Config,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, pre_end_per_suite, + [Suite,Config,State]}}), + {Config, State}. + +%% @doc Called after end_per_suite. Note that the config cannot be +%% changed here, only the status of the suite. +-spec post_end_per_suite(Suite :: atom(), + Config :: config(), + Return :: term(), + State :: #state{}) -> + {ok | skip_or_fail(), NewState :: #state{}}. +post_end_per_suite(Suite,Config,Return,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, post_end_per_suite, + [Suite,Config,Return,State]}}), + {Return, State}. + +%% @doc Called before each init_per_group. +%% You can change the config in this function. +-spec pre_init_per_group(Group :: atom(), + Config :: config(), + State :: #state{}) -> + {config() | skip_or_fail(), NewState :: #state{}}. +pre_init_per_group(Group,Config,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, pre_init_per_group, + [Group,Config,State]}}), + {Config, State}. + +%% @doc Called after each init_per_group. +%% You can change the return value in this function. +-spec post_init_per_group(Group :: atom(), + Config :: config(), + Return :: config() | skip_or_fail(), + State :: #state{}) -> + {config() | skip_or_fail(), NewState :: #state{}}. +post_init_per_group(Group,Config,Return,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, post_init_per_group, + [Group,Config,Return,State]}}), + {Return, State}. + +%% @doc Called after each end_per_group. The config/state can be changed here, +%% though it will only affect the *end_per_group functions. +-spec pre_end_per_group(Group :: atom(), + Config :: config() | skip_or_fail(), + State :: #state{}) -> + {ok | skip_or_fail(), NewState :: #state{}}. +pre_end_per_group(Group,Config,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, pre_end_per_group, + [Group,Config,State]}}), + {Config, State}. + +%% @doc Called after each end_per_group. Note that the config cannot be +%% changed here, only the status of the group. +-spec post_end_per_group(Group :: atom(), + Config :: config(), + Return :: term(), + State :: #state{}) -> + {ok | skip_or_fail(), NewState :: #state{}}. +post_end_per_group(Group,Config,Return,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, post_end_per_group, + [Group,Config,Return,State]}}), + {Return, State}. + +%% @doc Called before each test case. +%% You can change the config in this function. +-spec pre_init_per_testcase(TC :: atom(), + Config :: config(), + State :: #state{}) -> + {config() | skip_or_fail(), NewState :: #state{}}. +pre_init_per_testcase(TC,Config,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, pre_init_per_testcase, + [TC,Config,State]}}), + {Config, State}. + +%% @doc Called after each test case. Note that the config cannot be +%% changed here, only the status of the test case. +-spec post_end_per_testcase(TC :: atom(), + Config :: config(), + Return :: term(), + State :: #state{}) -> + {ok | skip_or_fail(), NewState :: #state{}}. +post_end_per_testcase(TC,Config,Return,State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, post_end_per_testcase, + [TC,Config,Return,State]}}), + {Return, State}. + +%% @doc Called after post_init_per_suite, post_end_per_suite, post_init_per_group, +%% post_end_per_group and post_end_per_tc if the suite, group or test case failed. +%% This function should be used for extra cleanup which might be needed. +%% It is not possible to modify the config or the status of the test run. +-spec on_tc_fail(TC :: init_per_suite | end_per_suite | + init_per_group | end_per_group | atom(), + Reason :: term(), State :: #state{}) -> + NewState :: #state{}. +on_tc_fail(TC, Reason, State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, on_tc_fail, + [TC,Reason,State]}}), + State. + +%% @doc Called when a test case is skipped by either user action +%% or due to an init function failing. Test case can be +%% end_per_suite, init_per_group, end_per_group and the actual test cases. +-spec on_tc_skip(TC :: end_per_suite | + init_per_group | end_per_group | atom(), + {tc_auto_skip, {failed, {Mod :: atom(), Function :: atom(), Reason :: term()}}} | + {tc_user_skip, {skipped, Reason :: term()}}, + State :: #state{}) -> + NewState :: #state{}. +on_tc_skip(TC, Reason, State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, on_tc_skip, + [TC,Reason,State]}}), + State. + +%% @doc Called when the scope of the CTH is done, this depends on +%% when the CTH was specified. This translation table describes when this +%% function is called. +%% +%% | Started in | terminate called | +%% |---------------------|-------------------------| +%% | command_line | after all tests are run | +%% | test spec | after all tests are run | +%% | suite/0 | after SUITE is done | +%% | init_per_suite/1 | after SUITE is done | +%% | init_per_group/2 | after group is done | +%% |-----------------------------------------------| +%% +-spec terminate(State :: #state{}) -> + term(). +terminate(State) -> + gen_event:notify( + ?CT_EVMGR_REF, #event{ name = cth, node = node(), + data = {?MODULE, terminate, [State]}}), + ok. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/fail_post_suite_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/fail_post_suite_cth.erl new file mode 100644 index 0000000000..b4c26259a6 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/fail_post_suite_cth.erl @@ -0,0 +1,72 @@ +%% +%% %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(fail_post_suite_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-compile(export_all). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + +pre_init_per_suite(Suite, Config, State) -> + empty_cth:pre_init_per_suite(Suite,Config,State). + +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State), + {{fail, "Test failure"}, State}. + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State). + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State). + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State). + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State). + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State). + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State). + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State). + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State). + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State). + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State). + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/fail_pre_suite_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/fail_pre_suite_cth.erl new file mode 100644 index 0000000000..acf80a1b2e --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/fail_pre_suite_cth.erl @@ -0,0 +1,72 @@ +%% +%% %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(fail_pre_suite_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-compile(export_all). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + +pre_init_per_suite(Suite, Config, State) -> + empty_cth:pre_init_per_suite(Suite,Config,State), + {{fail, "Test failure"}, State}. + +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State). + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State). + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State). + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State). + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State). + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State). + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State). + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State). + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State). + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State). + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State). + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/id_no_init_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/id_no_init_cth.erl new file mode 100644 index 0000000000..58ed400e1c --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/id_no_init_cth.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_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-export([id/1]). + +id(Opts) -> + empty_cth:id(Opts). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/minimal_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/minimal_cth.erl new file mode 100644 index 0000000000..a18f4bf2f3 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/minimal_cth.erl @@ -0,0 +1,33 @@ +%% +%% %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(minimal_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-export([init/2]). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/minimal_terminate_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/minimal_terminate_cth.erl new file mode 100644 index 0000000000..79cd55f68e --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/minimal_terminate_cth.erl @@ -0,0 +1,38 @@ +%% +%% %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(minimal_terminate_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-export([init/2]). +-export([terminate/1]). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + +terminate(State) -> + empty_cth:terminate(State). + + diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/recover_post_suite_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/recover_post_suite_cth.erl new file mode 100644 index 0000000000..01a932bd59 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/recover_post_suite_cth.erl @@ -0,0 +1,74 @@ +%% +%% %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(recover_post_suite_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-compile(export_all). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + +pre_init_per_suite(Suite, Config, State) -> + empty_cth:pre_init_per_suite(Suite,Config,State). + +post_init_per_suite(Suite,Config,{'EXIT',Reason} = Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State), + {lists:keydelete(tc_status,1,Config),State}; +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State). + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State). + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State). + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State). + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State). + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State). + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State). + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State). + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State). + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State). + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State). + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/same_id_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/same_id_cth.erl new file mode 100644 index 0000000000..acfb93fe26 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/same_id_cth.erl @@ -0,0 +1,75 @@ +%% +%% %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(same_id_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-compile(export_all). + +id(Opts) -> + empty_cth:id(Opts), + ?MODULE. + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + +pre_init_per_suite(Suite, Config, State) -> + empty_cth:pre_init_per_suite(Suite,Config,State). + +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State). + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State). + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State). + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State). + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State). + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State). + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State). + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State). + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State). + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State). + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State). + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/skip_post_suite_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/skip_post_suite_cth.erl new file mode 100644 index 0000000000..6d4605b33b --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/skip_post_suite_cth.erl @@ -0,0 +1,72 @@ +%% +%% %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(skip_post_suite_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-compile(export_all). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + +pre_init_per_suite(Suite, Config, State) -> + empty_cth:pre_init_per_suite(Suite,Config,State). + +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State), + {{skip, "Test skip"}, State}. + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State). + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State). + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State). + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State). + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State). + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State). + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State). + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State). + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State). + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State). + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/skip_pre_suite_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/skip_pre_suite_cth.erl new file mode 100644 index 0000000000..49efd0d0cd --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/skip_pre_suite_cth.erl @@ -0,0 +1,73 @@ +%% +%% %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(skip_pre_suite_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-compile(export_all). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + + +pre_init_per_suite(Suite, Config, State) -> + empty_cth:pre_init_per_suite(Suite,Config,State), + {{skip, "Test skip"}, State}. + +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State). + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State). + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State). + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State). + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State). + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State). + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State). + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State). + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State). + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State). + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State). + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/state_update_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/state_update_cth.erl new file mode 100644 index 0000000000..53d75e6ce3 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/state_update_cth.erl @@ -0,0 +1,83 @@ +%% +%% %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(state_update_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + +%% CT Hooks +-compile(export_all). + +init(Id, Opts) -> + State = empty_cth:init(Id, Opts), + [init|State]. + +pre_init_per_suite(Suite, Config, State) -> + empty_cth:pre_init_per_suite(Suite,Config,State), + {Config, [pre_init_per_suite|State]}. + +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State), + {Config, [post_init_per_suite|State]}. + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State), + {Config, [pre_end_per_suite|State]}. + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State), + {Return, [post_end_per_suite|State]}. + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State), + {Config, [pre_init_per_group|State]}. + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State), + {Return, [post_init_per_group|State]}. + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State), + {Config, [pre_end_per_group|State]}. + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State), + {Return, [post_end_per_group|State]}. + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State), + {Config, [pre_init_per_testcase|State]}. + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State), + {Return, [post_end_per_testcase|State]}. + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State), + [on_tc_fail|State]. + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State), + [on_tc_skip|State]. + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/undef_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/undef_cth.erl new file mode 100644 index 0000000000..4c44ef025b --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/undef_cth.erl @@ -0,0 +1,71 @@ +%% +%% %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(undef_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-compile(export_all). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + +pre_init_per_suite(_Suite, _Config, _State) -> + lists:flaten([1,2,[3,4]]). + +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State). + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State). + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State). + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State). + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State). + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State). + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State). + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State). + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State). + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State). + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State). + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/update_config_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/update_config_cth.erl new file mode 100644 index 0000000000..788ef2cec2 --- /dev/null +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/update_config_cth.erl @@ -0,0 +1,82 @@ +%% +%% %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(update_config_cth). + + +-include_lib("common_test/src/ct_util.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + + +%% CT Hooks +-compile(export_all). + +init(Id, Opts) -> + empty_cth:init(Id, Opts). + +pre_init_per_suite(Suite, Config, State) -> + empty_cth:pre_init_per_suite(Suite,Config,State), + {[{pre_init_per_suite,now()}|Config],State}. + +post_init_per_suite(Suite,Config,Return,State) -> + empty_cth:post_init_per_suite(Suite,Config,Return,State), + {[{post_init_per_suite,now()}|Return],State}. + +pre_end_per_suite(Suite,Config,State) -> + empty_cth:pre_end_per_suite(Suite,Config,State), + {[{pre_end_per_suite,now()}|Config],State}. + +post_end_per_suite(Suite,Config,Return,State) -> + empty_cth:post_end_per_suite(Suite,Config,Return,State), + NewConfig = [{post_end_per_suite,now()}|Config], + {NewConfig,NewConfig}. + +pre_init_per_group(Group,Config,State) -> + empty_cth:pre_init_per_group(Group,Config,State), + {[{pre_init_per_group,now()}|Config],State}. + +post_init_per_group(Group,Config,Return,State) -> + empty_cth:post_init_per_group(Group,Config,Return,State), + {[{post_init_per_group,now()}|Return],State}. + +pre_end_per_group(Group,Config,State) -> + empty_cth:pre_end_per_group(Group,Config,State), + {[{pre_end_per_group,now()}|Config],State}. + +post_end_per_group(Group,Config,Return,State) -> + empty_cth:post_end_per_group(Group,Config,Return,State), + {[{post_end_per_group,now()}|Config],State}. + +pre_init_per_testcase(TC,Config,State) -> + empty_cth:pre_init_per_testcase(TC,Config,State), + {[{pre_init_per_testcase,now()}|Config],State}. + +post_end_per_testcase(TC,Config,Return,State) -> + empty_cth:post_end_per_testcase(TC,Config,Return,State), + {[{post_end_per_testcase,now()}|Config],State}. + +on_tc_fail(TC, Reason, State) -> + empty_cth:on_tc_fail(TC,Reason,State). + +on_tc_skip(TC, Reason, State) -> + empty_cth:on_tc_skip(TC,Reason,State). + +terminate(State) -> + empty_cth:terminate(State). diff --git a/lib/common_test/test/ct_suite_callback_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE.erl deleted file mode 100644 index 67f3cf430a..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE.erl +++ /dev/null @@ -1,1021 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009-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% -%% - -%%%------------------------------------------------------------------- -%%% File: ct_error_SUITE -%%% -%%% Description: -%%% Test various errors in Common Test suites. -%%% -%%% The suites used for the test are located in the data directory. -%%%------------------------------------------------------------------- --module(ct_suite_callback_SUITE). - --compile(export_all). - --include_lib("test_server/include/test_server.hrl"). --include_lib("common_test/include/ct_event.hrl"). - --define(eh, ct_test_support_eh). - -%%-------------------------------------------------------------------- -%% TEST SERVER CALLBACK FUNCTIONS -%%-------------------------------------------------------------------- - -%%-------------------------------------------------------------------- -%% Description: Since Common Test starts another Test Server -%% instance, the tests need to be performed on a separate node (or -%% there will be clashes with logging processes etc). -%%-------------------------------------------------------------------- -init_per_suite(Config) -> - DataDir = ?config(data_dir, Config), - TestDir = filename:join(DataDir,"scb/tests/"), - SCBs = filelib:wildcard(filename:join(TestDir,"*_scb.erl")), - io:format("SCBs: ~p",[SCBs]), - [io:format("Compiling ~p: ~p", - [FileName,compile:file(FileName,[{outdir,TestDir},debug_info])]) || - FileName <- SCBs], - ct_test_support:init_per_suite([{path_dirs,[TestDir]} | Config]). - -end_per_suite(Config) -> - ct_test_support:end_per_suite(Config). - -init_per_testcase(TestCase, Config) -> - ct_test_support:init_per_testcase(TestCase, Config). - -end_per_testcase(TestCase, Config) -> - ct_test_support:end_per_testcase(TestCase, Config). - - -suite() -> - [{timetrap,{seconds,20}}]. - -all() -> - all(suite). - -all(suite) -> - lists:reverse( - [ - 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, - 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, options_scb, same_id_scb, - fail_n_skip_with_minimal_scb - ] - ) - . - - -%%-------------------------------------------------------------------- -%% TEST CASES -%%-------------------------------------------------------------------- - -%%%----------------------------------------------------------------- -%%% -one_scb(Config) when is_list(Config) -> - do_test(one_empty_scb, "ct_scb_empty_SUITE.erl",[empty_scb], Config). - -two_scb(Config) when is_list(Config) -> - do_test(two_empty_scb, "ct_scb_empty_SUITE.erl",[empty_scb,empty_scb], - Config). - -faulty_scb_no_init(Config) when is_list(Config) -> - do_test(faulty_scb_no_init, "ct_scb_empty_SUITE.erl",[askjhdkljashdkaj], - 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). - -minimal_and_maximal_scb(Config) when is_list(Config) -> - do_test(minimal_and_maximal_scb, "ct_scb_empty_SUITE.erl", - [minimal_scb, empty_scb],Config). - -faulty_scb_undef(Config) when is_list(Config) -> - do_test(faulty_scb_undef, "ct_scb_empty_SUITE.erl", - [undef_scb],Config). - -faulty_scb_exit_in_init_scope_suite(Config) when is_list(Config) -> - do_test(faulty_scb_exit_in_init_scope_suite, - "ct_exit_in_init_scope_suite_scb_SUITE.erl", - [],Config). - -faulty_scb_exit_in_init(Config) when is_list(Config) -> - do_test(faulty_scb_exit_in_init, "ct_scb_empty_SUITE.erl", - [crash_init_scb], 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). - -scope_suite_scb(Config) when is_list(Config) -> - do_test(scope_suite_scb, "ct_scope_suite_scb_SUITE.erl", - [],Config). - -scope_per_group_scb(Config) when is_list(Config) -> - do_test(scope_per_group_scb, "ct_scope_per_group_scb_SUITE.erl", - [],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) 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) 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) 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) 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) when is_list(Config) -> - do_test(update_config_scb, "ct_update_config_SUITE.erl", - [update_config_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). - -same_id_scb(Config) when is_list(Config) -> - do_test(same_id_scb, "ct_scb_empty_SUITE.erl", - [same_id_scb,same_id_scb],Config). - -fail_n_skip_with_minimal_scb(Config) when is_list(Config) -> - do_test(fail_n_skip_with_minimal_scb, "ct_scb_fail_one_skip_one_SUITE.erl", - [minimal_terminate_scb],Config). - -%%%----------------------------------------------------------------- -%%% HELP FUNCTIONS -%%%----------------------------------------------------------------- - -do_test(Tag, SWC, SCBs, Config) -> - do_test(Tag, SWC, SCBs, Config, ok). -do_test(Tag, SWC, SCBs, Config, {error,_} = Res) -> - do_test(Tag, SWC, SCBs, Config, Res, 1); -do_test(Tag, SWC, SCBs, Config, Res) -> - do_test(Tag, SWC, SCBs, Config, Res, 2). - -do_test(Tag, SuiteWildCard, SCBs, Config, Res, EC) -> - - DataDir = ?config(data_dir, Config), - Suites = filelib:wildcard( - filename:join([DataDir,"scb/tests",SuiteWildCard])), - {Opts,ERPid} = setup([{suite,Suites}, - {suite_callbacks,SCBs},{label,Tag}], Config), - Res = ct_test_support:run(Opts, Config), - Events = ct_test_support:get_events(ERPid, Config), - - ct_test_support:log_events(Tag, - reformat(Events, ?eh), - ?config(priv_dir, Config)), - - TestEvents = events_to_check(Tag, EC), - ok = ct_test_support:verify_events(TestEvents, Events, Config). - -setup(Test, Config) -> - Opts0 = ct_test_support:get_opts(Config), - Level = ?config(trace_level, Config), - EvHArgs = [{cbm,ct_test_support},{trace_level,Level}], - Opts = Opts0 ++ [{event_handler,{?eh,EvHArgs}}|Test], - ERPid = ct_test_support:start_event_receiver(Config), - {Opts,ERPid}. - -reformat(Events, EH) -> - ct_test_support:reformat(Events, EH). -%reformat(Events, _EH) -> -% Events. - -%%%----------------------------------------------------------------- -%%% TEST EVENTS -%%%----------------------------------------------------------------- -events_to_check(Test) -> - %% 2 tests (ct:run_test + script_start) is default - events_to_check(Test, 2). - -events_to_check(_, 0) -> - []; -events_to_check(Test, N) -> - test_events(Test) ++ events_to_check(Test, N-1). - -test_events(one_empty_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?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, - [ct_scb_empty_SUITE,'$proplist',[]]}}, - {?eh,scb,{empty_scb,post_init_per_suite, - [ct_scb_empty_SUITE,'$proplist','$proplist',[]]}}, - {?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',[]]}}, - {?eh,scb,{empty_scb,post_end_per_testcase,[test_case,'$proplist','_',[]]}}, - {?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',[]]}}, - {?eh,scb,{empty_scb,post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb,{empty_scb,terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(two_empty_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?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',[]]}}, - {?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}}, - {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}}, - {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,ok}}, - - {?eh,tc_start,{ct_scb_empty_SUITE,test_case}}, - {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, - {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, - {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,test_case,ok}}, - - {?eh,tc_start,{ct_scb_empty_SUITE,end_per_suite}}, - {?eh,scb,{'_',pre_end_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}}, - {?eh,scb,{'_',pre_end_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}}, - {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(faulty_scb_no_init) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?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'}}, - {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}}, - - {?eh,tc_start,{ct_scb_empty_SUITE,test_case}}, - {?eh,tc_done,{ct_scb_empty_SUITE,test_case,ok}}, - - {?eh,tc_start,{ct_scb_empty_SUITE,end_per_suite}}, - {?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,stop_logging,[]} - ]; - -test_events(minimal_and_maximal_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {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',[]]}}, - {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,ok}}, - - {?eh,tc_start,{ct_scb_empty_SUITE,test_case}}, - {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,test_case,ok}}, - - {?eh,tc_start,{ct_scb_empty_SUITE,end_per_suite}}, - {?eh,scb,{'_',pre_end_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(faulty_scb_undef) -> - FailReasonStr = "undef_scb:pre_init_per_suite/3 SCB call failed", - FailReason = {ct_scb_empty_SUITE,init_per_suite, - {failed,FailReasonStr}}, - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?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, - {failed, {error,FailReasonStr}}}}, - {?eh,scb,{'_',on_tc_fail,'_'}}, - - {?eh,tc_auto_skip,{ct_scb_empty_SUITE,test_case, - {failed, FailReason}}}, - {?eh,scb,{'_',on_tc_skip,'_'}}, - - {?eh,tc_auto_skip,{ct_scb_empty_SUITE,end_per_suite, - {failed, FailReason}}}, - {?eh,scb,{'_',on_tc_skip,'_'}}, - - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,stop_logging,[]} - ]; - -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,tc_done, - {ct_exit_in_init_scope_suite_scb_SUITE,init_per_suite, - {failed, - {error, - "Failed to start SCB, see the CT Log for details"}}}}, - {?eh,tc_auto_skip, - {ct_exit_in_init_scope_suite_scb_SUITE,test_case, - {failed, - {ct_exit_in_init_scope_suite_scb_SUITE,init_per_suite, - {failed, - "Failed to start SCB, see the CT Log for details"}}}}}, - {?eh,tc_auto_skip, - {ct_exit_in_init_scope_suite_scb_SUITE,end_per_suite, - {failed, - {ct_exit_in_init_scope_suite_scb_SUITE,init_per_suite, - {failed, - "Failed to start SCB, see the CT Log for details"}}}}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,stop_logging,[]}]; - -test_events(faulty_scb_exit_in_init) -> - [{?eh,start_logging,{'DEF','RUNDIR'}}, - {?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,{'_',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}}, - - {?eh,tc_start,{ct_scope_per_suite_scb_SUITE,test_case}}, - {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, - {?eh,tc_done,{ct_scope_per_suite_scb_SUITE,test_case,ok}}, - - {?eh,tc_start,{ct_scope_per_suite_scb_SUITE,end_per_suite}}, - {?eh,scb,{'_',pre_end_per_suite, - [ct_scope_per_suite_scb_SUITE,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_suite,[ct_scope_per_suite_scb_SUITE,'$proplist','_',[]]}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,tc_done,{ct_scope_per_suite_scb_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,stop_logging,[]} - ]; - -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,{'_',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}}, - - {?eh,tc_start,{ct_scope_suite_scb_SUITE,test_case}}, - {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, - {?eh,tc_done,{ct_scope_suite_scb_SUITE,test_case,ok}}, - - {?eh,tc_start,{ct_scope_suite_scb_SUITE,end_per_suite}}, - {?eh,scb,{'_',pre_end_per_suite,[ct_scope_suite_scb_SUITE,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_suite,[ct_scope_suite_scb_SUITE,'$proplist','_',[]]}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,tc_done,{ct_scope_suite_scb_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,stop_logging,[]} - ]; - -test_events(scope_per_group_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,tc_start,{ct_scope_per_group_scb_SUITE,init_per_suite}}, - {?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,{'_',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}}, - - {?eh,tc_start,{ct_scope_per_group_scb_SUITE,test_case}}, - {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, - {?eh,tc_done,{ct_scope_per_group_scb_SUITE,test_case,ok}}, - - {?eh,tc_start,{ct_scope_per_group_scb_SUITE,{end_per_group,group1,[]}}}, - {?eh,scb,{'_',pre_end_per_group,[group1,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_group,[group1,'$proplist','_',[]]}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,tc_done,{ct_scope_per_group_scb_SUITE,{end_per_group,group1,[]},ok}}], - - {?eh,tc_start,{ct_scope_per_group_scb_SUITE,end_per_suite}}, - {?eh,tc_done,{ct_scope_per_group_scb_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?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,{'_',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}}, - - {?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,{'_',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}}, - - {?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,{'_',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}}, - - {?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'}}, - {?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',[]]}}, - {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist', - {fail,"Test failure"},[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite, - {failed, {error,"Test failure"}}}}, - {?eh,scb,{'_',on_tc_fail, - [init_per_suite,{failed,"Test failure"},[]]}}, - - - {?eh,tc_auto_skip,{ct_scb_empty_SUITE,test_case, - {failed,{ct_scb_empty_SUITE,init_per_suite, - {failed,"Test failure"}}}}}, - {?eh,scb,{'_',on_tc_skip, - [test_case, {tc_auto_skip, - {failed, {ct_scb_empty_SUITE, init_per_suite, - {failed, "Test failure"}}}},[]]}}, - - - {?eh,tc_auto_skip, {ct_scb_empty_SUITE, end_per_suite, - {failed, {ct_scb_empty_SUITE, init_per_suite, - {failed, "Test failure"}}}}}, - {?eh,scb,{'_',on_tc_skip, - [end_per_suite, {tc_auto_skip, - {failed, {ct_scb_empty_SUITE, init_per_suite, - {failed, "Test failure"}}}},[]]}}, - - - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb, {'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(fail_post_suite_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?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',[]]}}, - {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite, - {failed,{error,"Test failure"}}}}, - {?eh,scb,{'_',on_tc_fail,[init_per_suite, {failed,"Test failure"}, []]}}, - - {?eh,tc_auto_skip,{ct_scb_empty_SUITE,test_case, - {failed,{ct_scb_empty_SUITE,init_per_suite, - {failed,"Test failure"}}}}}, - {?eh,scb,{'_',on_tc_skip,[test_case,{tc_auto_skip,'_'},[]]}}, - - {?eh,tc_auto_skip, {ct_scb_empty_SUITE, end_per_suite, - {failed, {ct_scb_empty_SUITE, init_per_suite, - {failed, "Test failure"}}}}}, - {?eh,scb,{'_',on_tc_skip,[end_per_suite,{tc_auto_skip,'_'},[]]}}, - - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb, {'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(skip_pre_suite_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?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',[]]}}, - {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist',{skip,"Test skip"},[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,{skipped,"Test skip"}}}, - {?eh,scb,{'_',on_tc_skip, - [init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}}, - - {?eh,tc_auto_skip,{ct_scb_empty_SUITE,test_case,"Test skip"}}, - {?eh,scb,{'_',on_tc_skip,[test_case,{tc_auto_skip,"Test skip"},[]]}}, - - {?eh,tc_auto_skip, {ct_scb_empty_SUITE, end_per_suite,"Test skip"}}, - {?eh,scb,{'_',on_tc_skip,[end_per_suite,{tc_auto_skip,"Test skip"},[]]}}, - - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb, {'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(skip_post_suite_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?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',[]]}}, - {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,{skipped,"Test skip"}}}, - {?eh,scb,{'_',on_tc_skip, - [init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}}, - - {?eh,tc_auto_skip,{ct_scb_empty_SUITE,test_case,"Test skip"}}, - {?eh,scb,{'_',on_tc_skip,[test_case,{tc_auto_skip,"Test skip"},[]]}}, - - {?eh,tc_auto_skip, {ct_scb_empty_SUITE, end_per_suite,"Test skip"}}, - {?eh,scb,{'_',on_tc_skip,[end_per_suite,{tc_auto_skip,"Test skip"},[]]}}, - - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(recover_post_suite_scb) -> - Suite = ct_scb_fail_per_suite_SUITE, - [ - {?eh,start_logging,'_'}, - {?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']}}, - {?eh,scb,{'_',post_init_per_suite,[Suite,contains([tc_status]), - {'EXIT',{'_','_'}},[]]}}, - {?eh,tc_done,{Suite,init_per_suite,ok}}, - - {?eh,tc_start,{Suite,test_case}}, - {?eh,scb,{'_',pre_init_per_testcase, - [test_case, not_contains([tc_status]),[]]}}, - {?eh,scb,{'_',post_end_per_testcase, - [test_case, contains([tc_status]),'_',[]]}}, - {?eh,tc_done,{Suite,test_case,ok}}, - - {?eh,tc_start,{Suite,end_per_suite}}, - {?eh,scb,{'_',pre_end_per_suite, - [Suite,not_contains([tc_status]),[]]}}, - {?eh,scb,{'_',post_end_per_suite, - [Suite,not_contains([tc_status]),'_',[]]}}, - {?eh,tc_done,{Suite,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(update_config_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?eh,scb,{'_',init,['_',[]]}}, - {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - - {?eh,tc_start,{ct_update_config_SUITE,init_per_suite}}, - {?eh,scb,{'_',pre_init_per_suite, - [ct_update_config_SUITE,contains([]),[]]}}, - {?eh,scb,{'_',post_init_per_suite, - [ct_update_config_SUITE, - '$proplist', - contains( - [init_per_suite, - pre_init_per_suite]), - []]}}, - {?eh,tc_done,{ct_update_config_SUITE,init_per_suite,ok}}, - - {?eh,tc_start,{ct_update_config_SUITE, {init_per_group,group1,[]}}}, - {?eh,scb,{'_',pre_init_per_group, - [group1,contains( - [post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - []]}}, - {?eh,scb,{'_',post_init_per_group, - [group1, - contains( - [post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - contains( - [init_per_group, - pre_init_per_group, - post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - []]}}, - {?eh,tc_done,{ct_update_config_SUITE,{init_per_group,group1,[]},ok}}, - - {?eh,tc_start,{ct_update_config_SUITE,test_case}}, - {?eh,scb,{'_',pre_init_per_testcase, - [test_case,contains( - [post_init_per_group, - init_per_group, - pre_init_per_group, - post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - []]}}, - {?eh,scb,{'_',post_end_per_testcase, - [test_case,contains( - [init_per_testcase, - pre_init_per_testcase, - post_init_per_group, - init_per_group, - pre_init_per_group, - post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - ok,[]]}}, - {?eh,tc_done,{ct_update_config_SUITE,test_case,ok}}, - - {?eh,tc_start,{ct_update_config_SUITE, {end_per_group,group1,[]}}}, - {?eh,scb,{'_',pre_end_per_group, - [group1,contains( - [post_init_per_group, - init_per_group, - pre_init_per_group, - post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - []]}}, - {?eh,scb,{'_',post_end_per_group, - [group1, - contains( - [pre_end_per_group, - post_init_per_group, - init_per_group, - pre_init_per_group, - post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - ok,[]]}}, - {?eh,tc_done,{ct_update_config_SUITE,{end_per_group,group1,[]},ok}}, - - {?eh,tc_start,{ct_update_config_SUITE,end_per_suite}}, - {?eh,scb,{'_',pre_end_per_suite, - [ct_update_config_SUITE,contains( - [post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - []]}}, - {?eh,scb,{'_',post_end_per_suite, - [ct_update_config_SUITE,contains( - [pre_end_per_suite, - post_init_per_suite, - init_per_suite, - pre_init_per_suite]), - '_',[]]}}, - {?eh,tc_done,{ct_update_config_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb,{'_',terminate,[contains( - [post_end_per_suite, - pre_end_per_suite, - post_init_per_suite, - init_per_suite, - pre_init_per_suite])]}}, - {?eh,stop_logging,[]} - ]; - -test_events(state_update_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?eh,scb,{'_',init,['_',[]]}}, - {?eh,scb,{'_',init,['_',[]]}}, - {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,tc_start,{'_',init_per_suite}}, - - {?eh,tc_done,{'_',end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb,{'_',terminate,[contains( - [post_end_per_suite,pre_end_per_suite, - post_end_per_group,pre_end_per_group, - {not_in_order, - [post_end_per_testcase,pre_init_per_testcase, - on_tc_skip,post_end_per_testcase, - pre_init_per_testcase,on_tc_fail, - post_end_per_testcase,pre_init_per_testcase] - }, - post_init_per_group,pre_init_per_group, - post_init_per_suite,pre_init_per_suite, - init])]}}, - {?eh,scb,{'_',terminate,[contains( - [post_end_per_suite,pre_end_per_suite, - post_end_per_group,pre_end_per_group, - {not_in_order, - [post_end_per_testcase,pre_init_per_testcase, - on_tc_skip,post_end_per_testcase, - pre_init_per_testcase,on_tc_fail, - post_end_per_testcase,pre_init_per_testcase] - }, - post_init_per_group,pre_init_per_group, - post_init_per_suite,pre_init_per_suite, - init] - )]}}, - {?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(same_id_scb) -> - [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?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',[]]}}, - {negative, - {?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}}, - {?eh,scb,{'_',post_init_per_suite, - [ct_scb_empty_SUITE,'$proplist','$proplist',[]]}}}, - {negative, - {?eh,scb,{'_',post_init_per_suite, - [ct_scb_empty_SUITE,'$proplist','$proplist',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,ok}}}, - - {?eh,tc_start,{ct_scb_empty_SUITE,test_case}}, - {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, - {negative, - {?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}}, - {negative, - {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,test_case,ok}}}, - - {?eh,tc_start,{ct_scb_empty_SUITE,end_per_suite}}, - {?eh,scb,{'_',pre_end_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}}, - {negative, - {?eh,scb,{'_',pre_end_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}}, - {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}}}, - {negative, - {?eh,scb,{'_',post_end_per_suite, - [ct_scb_empty_SUITE,'$proplist','_',[]]}}, - {?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(fail_n_skip_with_minimal_scb) -> - [{?eh,start_logging,{'DEF','RUNDIR'}}, - {?eh,scb,{'_',init,['_',[]]}}, - {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,tc_start,{'_',init_per_suite}}, - - {?eh,tc_done,{'_',end_per_suite,ok}}, - {?eh,scb,{'_',terminate,[[]]}}, - {?eh,stop_logging,[]} - ]; - -test_events(ok) -> - ok. - - -%% test events help functions -contains(List) -> - fun(Proplist) when is_list(Proplist) -> - contains(List,Proplist) - end. - -contains([{not_in_order,List}|T],Rest) -> - contains_parallel(List,Rest), - contains(T,Rest); -contains([{Ele,Pos}|T] = L,[H|T2]) -> - case element(Pos,H) of - Ele -> - contains(T,T2); - _ -> - contains(L,T2) - end; -contains([Ele|T],[{Ele,_}|T2])-> - contains(T,T2); -contains([Ele|T],[Ele|T2])-> - contains(T,T2); -contains(List,[_|T]) -> - contains(List,T); -contains([],_) -> - match. - -contains_parallel([Key | T], Elems) -> - contains([Key],Elems), - contains_parallel(T,Elems); -contains_parallel([],_Elems) -> - match. - -not_contains(List) -> - fun(Proplist) when is_list(Proplist) -> - [] = [Ele || {Ele,_} <- Proplist, - Test <- List, - Test =:= Ele] - end. 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 deleted file mode 100644 index 2c256c46df..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_id_scb.erl +++ /dev/null @@ -1,34 +0,0 @@ -%% -%% %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 deleted file mode 100644 index c4138bbcef..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/crash_init_scb.erl +++ /dev/null @@ -1,34 +0,0 @@ -%% -%% %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_init_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --export([init/2]). - -init(Id, Opts) -> - empty_scb:init(Id, Opts), - exit(diediedie). - diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_exit_in_init_scope_suite_scb_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_exit_in_init_scope_suite_scb_SUITE.erl deleted file mode 100644 index bfaeb7ca3a..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_exit_in_init_scope_suite_scb_SUITE.erl +++ /dev/null @@ -1,50 +0,0 @@ -%% -%% %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_exit_in_init_scope_suite_scb_SUITE). - --suite_defaults([{timetrap, {minutes, 10}}]). - -%% Note: This directive should only be used in test suites. --compile(export_all). - --include_lib("common_test/include/ct.hrl"). - -%% Test server callback functions -suite() -> - [{suite_callbacks,[crash_init_scb]}]. - -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. diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_empty_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_empty_SUITE.erl deleted file mode 100644 index 0eb40bce00..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_empty_SUITE.erl +++ /dev/null @@ -1,47 +0,0 @@ -%% -%% %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_scb_empty_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. - -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_scb_fail_one_skip_one_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_fail_one_skip_one_SUITE.erl deleted file mode 100644 index 593bd4a534..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_fail_one_skip_one_SUITE.erl +++ /dev/null @@ -1,64 +0,0 @@ -%% -%% %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_scb_fail_one_skip_one_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_group(_Group,Config) -> - Config. - -end_per_group(_Group,_Config) -> - ok. - -init_per_testcase(test_case2, Config) -> - {skip,"skip it"}; -init_per_testcase(_TestCase, Config) -> - Config. - -end_per_testcase(_TestCase, _Config) -> - ok. - -groups() -> - [{group1,[parallel],[{group2,[parallel],[test_case1,test_case2,test_case3]}]}]. - -all() -> - [{group,group1}]. - -%% Test cases starts here. -test_case1(Config) -> - ok = nok. - -test_case2(Config) -> - ok. - -test_case3(Config) -> - ok. diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_fail_per_suite_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_fail_per_suite_SUITE.erl deleted file mode 100644 index dfc7c37e8d..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scb_fail_per_suite_SUITE.erl +++ /dev/null @@ -1,47 +0,0 @@ -%% -%% %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_scb_fail_per_suite_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) -> - ok = nok. - -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_per_group_scb_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_scb_SUITE.erl deleted file mode 100644 index 8df4a6d522..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_scb_SUITE.erl +++ /dev/null @@ -1,56 +0,0 @@ -%% -%% %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_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]}|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_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 deleted file mode 100644 index 63dd767b25..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_group_state_scb_SUITE.erl +++ /dev/null @@ -1,56 +0,0 @@ -%% -%% %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_scb_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_scb_SUITE.erl deleted file mode 100644 index 5492243b1b..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_scb_SUITE.erl +++ /dev/null @@ -1,47 +0,0 @@ -%% -%% %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_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]}|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_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 deleted file mode 100644 index 02a011f91b..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_suite_state_scb_SUITE.erl +++ /dev/null @@ -1,47 +0,0 @@ -%% -%% %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_per_tc_scb_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_tc_scb_SUITE.erl deleted file mode 100644 index d99e741553..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_per_tc_scb_SUITE.erl +++ /dev/null @@ -1,110 +0,0 @@ -%% -%% %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_tc_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 -%%-------------------------------------------------------------------- -%% @doc -%% Config - [tuple()] -%% A list of key/value pairs, holding the test case configuration. -%% -%% Initiation before the whole suite -%% -%% Note: This function is free to add any key/value pairs to the Config -%% variable, but should NOT alter/remove any existing entries. -%% -%% @spec init_per_suite(Config) -> Config -%% @end -%%-------------------------------------------------------------------- -init_per_suite(Config) -> - Config. - -%%-------------------------------------------------------------------- -%% @doc -%% Config - [tuple()] -%% A list of key/value pairs, holding the test case configuration. -%% -%% Cleanup after the whole suite -%% -%% @spec end_per_suite(Config) -> _ -%% @end -%%-------------------------------------------------------------------- -end_per_suite(_Config) -> - ok. - -%%-------------------------------------------------------------------- -%% @doc -%% Case - atom() -%% Name of the test case that is about to be run. -%% Config - [tuple()] -%% A list of key/value pairs, holding the test case configuration. -%% -%% Initiation before each test case -%% -%% Note: This function is free to add any key/value pairs to the Config -%% variable, but should NOT alter/remove any existing entries. -%% Initiation before each test case -%% -%% @spec init_per_testcase(TestCase, Config) -> Config -%% @end -%%-------------------------------------------------------------------- -init_per_testcase(_TestCase, Config) -> - [{suite_callbacks,[empty_scb]}|Config]. - -%%-------------------------------------------------------------------- -%% @doc -%% Case - atom() -%% Name of the test case that is about to be run. -%% Config - [tuple()] -%% A list of key/value pairs, holding the test case configuration. -%% -%% Cleanup after each test case -%% -%% @spec end_per_testcase(TestCase, Config) -> _ -%% @end -%%-------------------------------------------------------------------- -end_per_testcase(_TestCase, _Config) -> - ok. - -%%-------------------------------------------------------------------- -%% @doc -%% TestCases - [Case] -%% Case - atom() -%% Name of a test case. -%% -%% Returns a list of all test cases in this test suite -%% -%% @spec all() -> TestCases -%% @end -%%-------------------------------------------------------------------- -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_scb_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_scb_SUITE.erl deleted file mode 100644 index 7598c911b1..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_scb_SUITE.erl +++ /dev/null @@ -1,50 +0,0 @@ -%% -%% %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_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]}]. - -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. 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 deleted file mode 100644 index 869532f5cd..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_scope_suite_state_scb_SUITE.erl +++ /dev/null @@ -1,50 +0,0 @@ -%% -%% %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. diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_update_config_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_update_config_SUITE.erl deleted file mode 100644 index 57fea347f6..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/ct_update_config_SUITE.erl +++ /dev/null @@ -1,56 +0,0 @@ -%% -%% %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_update_config_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) -> - [{init_per_suite,now()}|Config]. - -end_per_suite(_Config) -> - ok. - -init_per_testcase(_TestCase, Config) -> - [{init_per_testcase,now()}|Config]. - -end_per_testcase(_TestCase, _Config) -> - ok. - -init_per_group(GroupName, Config) -> - [{init_per_group,now()}|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/empty_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl deleted file mode 100644 index a82ca02d04..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl +++ /dev/null @@ -1,277 +0,0 @@ -%% -%% %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% -%% - -%%% @doc Common Test Example Suite Callback module. -%%% -%%%

This module gives an example of a common test SCB (Suite CallBack). -%%% There are many ways to add a SCB to a test run, you can do it either in -%%% the command line using -suite_callback, in a test spec using -%%% {suite_callback,M} or in the suite it self by returning suite_callback -%%% from either suite/0, init_per_suite/1, init_per_group/2 and -%%% init_per_testcase/2. The scope of the SCB is determined by where is it -%%% started. If it is started in the command line or test spec then it will -%%% be stopped at the end of all tests. If it is started in init_per_suite, -%%% it will be stopped after end_per_suite and so on. See terminate -%%% documentation for a table describing the scoping machanics. -%%% -%%% All of callbacks except init/1 in a SCB are optional.

- --module(empty_scb). - -%% Suite Callbacks --export([id/1]). --export([init/2]). - --export([pre_init_per_suite/3]). --export([post_init_per_suite/4]). --export([pre_end_per_suite/3]). --export([post_end_per_suite/4]). - --export([pre_init_per_group/3]). --export([post_init_per_group/4]). --export([pre_end_per_group/3]). --export([post_end_per_group/4]). - --export([pre_init_per_testcase/3]). --export([post_end_per_testcase/4]). - --export([on_tc_fail/3]). --export([on_tc_skip/3]). - --export([terminate/1]). - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - --type proplist() :: list({atom(),term()}). --type config() :: proplist(). --type reason() :: term(). --type skip_or_fail() :: {skip, reason()} | - {auto_skip, reason()} | - {fail, reason()}. - --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. --spec init(Id :: term(), Opts :: proplist()) -> - {Id :: term(), State :: #state{}}. -init(Id, Opts) -> - gen_event:notify(?CT_EVMGR_REF, #event{ name = scb, node = node(), - 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 -%% specification, suite/0 function etc). -%% You can change the config in the this function. --spec pre_init_per_suite(Suite :: atom(), - Config :: config(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -pre_init_per_suite(Suite,Config,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, pre_init_per_suite, - [Suite,Config,State]}}), - {Config, State}. - -%% @doc Called after init_per_suite. -%% you can change the return value in this function. --spec post_init_per_suite(Suite :: atom(), - Config :: config(), - Return :: config() | skip_or_fail(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -post_init_per_suite(Suite,Config,Return,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, post_init_per_suite, - [Suite,Config,Return,State]}}), - {Return, State}. - -%% @doc Called before end_per_suite. The config/state can be changed here, -%% though it will only affect the *end_per_suite function. --spec pre_end_per_suite(Suite :: atom(), - Config :: config() | skip_or_fail(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -pre_end_per_suite(Suite,Config,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, pre_end_per_suite, - [Suite,Config,State]}}), - {Config, State}. - -%% @doc Called after end_per_suite. Note that the config cannot be -%% changed here, only the status of the suite. --spec post_end_per_suite(Suite :: atom(), - Config :: config(), - Return :: term(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -post_end_per_suite(Suite,Config,Return,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, post_end_per_suite, - [Suite,Config,Return,State]}}), - {Return, State}. - -%% @doc Called before each init_per_group. -%% You can change the config in this function. --spec pre_init_per_group(Group :: atom(), - Config :: config(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -pre_init_per_group(Group,Config,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, pre_init_per_group, - [Group,Config,State]}}), - {Config, State}. - -%% @doc Called after each init_per_group. -%% You can change the return value in this function. --spec post_init_per_group(Group :: atom(), - Config :: config(), - Return :: config() | skip_or_fail(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -post_init_per_group(Group,Config,Return,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, post_init_per_group, - [Group,Config,Return,State]}}), - {Return, State}. - -%% @doc Called after each end_per_group. The config/state can be changed here, -%% though it will only affect the *end_per_group functions. --spec pre_end_per_group(Group :: atom(), - Config :: config() | skip_or_fail(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -pre_end_per_group(Group,Config,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, pre_end_per_group, - [Group,Config,State]}}), - {Config, State}. - -%% @doc Called after each end_per_group. Note that the config cannot be -%% changed here, only the status of the group. --spec post_end_per_group(Group :: atom(), - Config :: config(), - Return :: term(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -post_end_per_group(Group,Config,Return,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, post_end_per_group, - [Group,Config,Return,State]}}), - {Return, State}. - -%% @doc Called before each test case. -%% You can change the config in this function. --spec pre_init_per_testcase(TC :: atom(), - Config :: config(), - State :: #state{}) -> - {config() | skip_or_fail(), NewState :: #state{}}. -pre_init_per_testcase(TC,Config,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, pre_init_per_testcase, - [TC,Config,State]}}), - {Config, State}. - -%% @doc Called after each test case. Note that the config cannot be -%% changed here, only the status of the test case. --spec post_end_per_testcase(TC :: atom(), - Config :: config(), - Return :: term(), - State :: #state{}) -> - {ok | skip_or_fail(), NewState :: #state{}}. -post_end_per_testcase(TC,Config,Return,State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, post_end_per_testcase, - [TC,Config,Return,State]}}), - {Return, State}. - -%% @doc Called after post_init_per_suite, post_end_per_suite, post_init_per_group, -%% post_end_per_group and post_end_per_tc if the suite, group or test case failed. -%% This function should be used for extra cleanup which might be needed. -%% It is not possible to modify the config or the status of the test run. --spec on_tc_fail(TC :: init_per_suite | end_per_suite | - init_per_group | end_per_group | atom(), - Reason :: term(), State :: #state{}) -> - NewState :: #state{}. -on_tc_fail(TC, Reason, State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, on_tc_fail, - [TC,Reason,State]}}), - State. - -%% @doc Called when a test case is skipped by either user action -%% or due to an init function failing. Test case can be -%% end_per_suite, init_per_group, end_per_group and the actual test cases. --spec on_tc_skip(TC :: end_per_suite | - init_per_group | end_per_group | atom(), - {tc_auto_skip, {failed, {Mod :: atom(), Function :: atom(), Reason :: term()}}} | - {tc_user_skip, {skipped, Reason :: term()}}, - State :: #state{}) -> - NewState :: #state{}. -on_tc_skip(TC, Reason, State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, on_tc_skip, - [TC,Reason,State]}}), - State. - -%% @doc Called when the scope of the SCB is done, this depends on -%% when the SCB was specified. This translation table describes when this -%% function is called. -%% -%% | Started in | terminate called | -%% |---------------------|-------------------------| -%% | command_line | after all tests are run | -%% | test spec | after all tests are run | -%% | suite/0 | after SUITE is done | -%% | init_per_suite/1 | after SUITE is done | -%% | init_per_group/2 | after group is done | -%% |-----------------------------------------------| -%% --spec terminate(State :: #state{}) -> - term(). -terminate(State) -> - gen_event:notify( - ?CT_EVMGR_REF, #event{ name = scb, node = node(), - data = {?MODULE, terminate, [State]}}), - ok. 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 deleted file mode 100644 index 44c72f6795..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl +++ /dev/null @@ -1,72 +0,0 @@ -%% -%% %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(fail_post_suite_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --compile(export_all). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - -pre_init_per_suite(Suite, Config, State) -> - empty_scb:pre_init_per_suite(Suite,Config,State). - -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State), - {{fail, "Test failure"}, State}. - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State). - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State). - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State). - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State). - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State). - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State). - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State). - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State). - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State). - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State). - -terminate(State) -> - empty_scb:terminate(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 deleted file mode 100644 index 90f10d7531..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl +++ /dev/null @@ -1,72 +0,0 @@ -%% -%% %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(fail_pre_suite_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --compile(export_all). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - -pre_init_per_suite(Suite, Config, State) -> - empty_scb:pre_init_per_suite(Suite,Config,State), - {{fail, "Test failure"}, State}. - -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State). - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State). - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State). - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State). - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State). - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State). - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State). - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State). - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State). - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State). - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State). - -terminate(State) -> - empty_scb:terminate(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 deleted file mode 100644 index 11fb8d739f..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/id_no_init_scb.erl +++ /dev/null @@ -1,32 +0,0 @@ -%% -%% %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 deleted file mode 100644 index b3feb1383c..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_scb.erl +++ /dev/null @@ -1,33 +0,0 @@ -%% -%% %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(minimal_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --export([init/2]). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_terminate_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_terminate_scb.erl deleted file mode 100644 index 3f76d2f47d..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/minimal_terminate_scb.erl +++ /dev/null @@ -1,38 +0,0 @@ -%% -%% %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(minimal_terminate_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --export([init/2]). --export([terminate/1]). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - -terminate(State) -> - empty_scb:terminate(State). - - 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 deleted file mode 100644 index 26468f0789..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/recover_post_suite_scb.erl +++ /dev/null @@ -1,74 +0,0 @@ -%% -%% %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(recover_post_suite_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --compile(export_all). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - -pre_init_per_suite(Suite, Config, State) -> - empty_scb:pre_init_per_suite(Suite,Config,State). - -post_init_per_suite(Suite,Config,{'EXIT',Reason} = Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State), - {lists:keydelete(tc_status,1,Config),State}; -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State). - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State). - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State). - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State). - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State). - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State). - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State). - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State). - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State). - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State). - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State). - -terminate(State) -> - empty_scb:terminate(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 deleted file mode 100644 index 0fa708d5b6..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/same_id_scb.erl +++ /dev/null @@ -1,75 +0,0 @@ -%% -%% %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(same_id_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --compile(export_all). - -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). - -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State). - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State). - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State). - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State). - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State). - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State). - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State). - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State). - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State). - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State). - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State). - -terminate(State) -> - empty_scb:terminate(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 deleted file mode 100644 index bb93ebee0f..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl +++ /dev/null @@ -1,72 +0,0 @@ -%% -%% %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(skip_post_suite_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --compile(export_all). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - -pre_init_per_suite(Suite, Config, State) -> - empty_scb:pre_init_per_suite(Suite,Config,State). - -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State), - {{skip, "Test skip"}, State}. - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State). - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State). - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State). - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State). - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State). - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State). - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State). - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State). - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State). - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State). - -terminate(State) -> - empty_scb:terminate(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 deleted file mode 100644 index 9818964e7f..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl +++ /dev/null @@ -1,73 +0,0 @@ -%% -%% %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(skip_pre_suite_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --compile(export_all). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - - -pre_init_per_suite(Suite, Config, State) -> - empty_scb:pre_init_per_suite(Suite,Config,State), - {{skip, "Test skip"}, State}. - -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State). - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State). - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State). - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State). - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State). - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State). - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State). - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State). - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State). - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State). - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State). - -terminate(State) -> - empty_scb:terminate(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 deleted file mode 100644 index 13c50cf1a1..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/state_update_scb.erl +++ /dev/null @@ -1,83 +0,0 @@ -%% -%% %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(state_update_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - -%% Suite Callbacks --compile(export_all). - -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), - {Config, [pre_init_per_suite|State]}. - -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State), - {Config, [post_init_per_suite|State]}. - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State), - {Config, [pre_end_per_suite|State]}. - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State), - {Return, [post_end_per_suite|State]}. - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State), - {Config, [pre_init_per_group|State]}. - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State), - {Return, [post_init_per_group|State]}. - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State), - {Config, [pre_end_per_group|State]}. - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State), - {Return, [post_end_per_group|State]}. - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State), - {Config, [pre_init_per_testcase|State]}. - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State), - {Return, [post_end_per_testcase|State]}. - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State), - [on_tc_fail|State]. - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State), - [on_tc_skip|State]. - -terminate(State) -> - empty_scb:terminate(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 deleted file mode 100644 index 1cb64574c3..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl +++ /dev/null @@ -1,71 +0,0 @@ -%% -%% %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(undef_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --compile(export_all). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - -pre_init_per_suite(_Suite, _Config, _State) -> - lists:flaten([1,2,[3,4]]). - -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State). - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State). - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State). - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State). - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State). - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State). - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State). - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State). - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State). - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State). - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State). - -terminate(State) -> - empty_scb:terminate(State). 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 deleted file mode 100644 index 46a027403d..0000000000 --- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/update_config_scb.erl +++ /dev/null @@ -1,82 +0,0 @@ -%% -%% %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(update_config_scb). - - --include_lib("common_test/src/ct_util.hrl"). --include_lib("common_test/include/ct_event.hrl"). - - -%% Suite Callbacks --compile(export_all). - -init(Id, Opts) -> - empty_scb:init(Id, Opts). - -pre_init_per_suite(Suite, Config, State) -> - empty_scb:pre_init_per_suite(Suite,Config,State), - {[{pre_init_per_suite,now()}|Config],State}. - -post_init_per_suite(Suite,Config,Return,State) -> - empty_scb:post_init_per_suite(Suite,Config,Return,State), - {[{post_init_per_suite,now()}|Return],State}. - -pre_end_per_suite(Suite,Config,State) -> - empty_scb:pre_end_per_suite(Suite,Config,State), - {[{pre_end_per_suite,now()}|Config],State}. - -post_end_per_suite(Suite,Config,Return,State) -> - empty_scb:post_end_per_suite(Suite,Config,Return,State), - NewConfig = [{post_end_per_suite,now()}|Config], - {NewConfig,NewConfig}. - -pre_init_per_group(Group,Config,State) -> - empty_scb:pre_init_per_group(Group,Config,State), - {[{pre_init_per_group,now()}|Config],State}. - -post_init_per_group(Group,Config,Return,State) -> - empty_scb:post_init_per_group(Group,Config,Return,State), - {[{post_init_per_group,now()}|Return],State}. - -pre_end_per_group(Group,Config,State) -> - empty_scb:pre_end_per_group(Group,Config,State), - {[{pre_end_per_group,now()}|Config],State}. - -post_end_per_group(Group,Config,Return,State) -> - empty_scb:post_end_per_group(Group,Config,Return,State), - {[{post_end_per_group,now()}|Config],State}. - -pre_init_per_testcase(TC,Config,State) -> - empty_scb:pre_init_per_testcase(TC,Config,State), - {[{pre_init_per_testcase,now()}|Config],State}. - -post_end_per_testcase(TC,Config,Return,State) -> - empty_scb:post_end_per_testcase(TC,Config,Return,State), - {[{post_end_per_testcase,now()}|Config],State}. - -on_tc_fail(TC, Reason, State) -> - empty_scb:on_tc_fail(TC,Reason,State). - -on_tc_skip(TC, Reason, State) -> - empty_scb:on_tc_skip(TC,Reason,State). - -terminate(State) -> - empty_scb:terminate(State). -- cgit v1.2.3