aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test/src')
-rw-r--r--lib/common_test/src/Makefile4
-rw-r--r--lib/common_test/src/ct.erl8
-rw-r--r--lib/common_test/src/ct_framework.erl40
-rw-r--r--lib/common_test/src/ct_hooks.erl (renamed from lib/common_test/src/ct_suite_callback.erl)131
-rw-r--r--lib/common_test/src/ct_hooks_lock.erl (renamed from lib/common_test/src/ct_suite_callback_lock.erl)5
-rw-r--r--lib/common_test/src/ct_run.erl110
-rw-r--r--lib/common_test/src/ct_testspec.erl24
-rw-r--r--lib/common_test/src/ct_util.erl14
-rw-r--r--lib/common_test/src/ct_util.hrl2
9 files changed, 170 insertions, 168 deletions
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 <code>Opts</code>.
%%% 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_suite_callback.erl b/lib/common_test/src/ct_hooks.erl
index a93b05b1d2..8e80ce8f37 100644
--- a/lib/common_test/src/ct_suite_callback.erl
+++ b/lib/common_test/src/ct_hooks.erl
@@ -19,9 +19,9 @@
%%% @doc Common Test Framework test execution control module.
%%%
-%%% <p>This module is a proxy for calling and handling suite callbacks.</p>
+%%% <p>This module is a proxy for calling and handling common test hooks.</p>
--module(ct_suite_callback).
+-module(ct_hooks).
%% API Exports
-export([init/1]).
@@ -33,7 +33,8 @@
-type proplist() :: [{atom(),term()}].
--define(config_name, suite_callbacks).
+%% If you change this, remember to update ct_util:look -> stop clause as well.
+-define(config_name, ct_hooks).
%% -------------------------------------------------------------------------
%% API Functions
@@ -43,16 +44,16 @@
-spec init(State :: term()) -> ok |
{error, Reason :: term()}.
init(Opts) ->
- call([{CB, call_id, undefined} || CB <- get_new_callbacks(Opts)],
+ call([{Hook, call_id, undefined} || Hook <- get_new_hooks(Opts)],
ok, init, []).
%% @doc Called after all suites are done.
--spec terminate(Callbacks :: term()) ->
+-spec terminate(Hooks :: term()) ->
ok.
-terminate(Callbacks) ->
- call([{CBId, fun call_terminate/3} || {CBId,_,_} <- Callbacks],
- ct_suite_callback_terminate_dummy, terminate, Callbacks),
+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
@@ -65,9 +66,9 @@ terminate(Callbacks) ->
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
+ Info = case catch proplists:get_value(ct_hooks, Mod:suite()) of
List when is_list(List) ->
- [{suite_callbacks,List}];
+ [{ct_hooks,List}];
_Else ->
[]
end,
@@ -155,10 +156,10 @@ call_generic({Mod, State}, Value, [Function | Args]) ->
%% 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),
+ Hooks = get_hooks(),
+ Res = call([{HookId,Fun} || {HookId,_, _} <- Hooks] ++
+ get_new_hooks(Config, Fun),
+ remove(?config_name,Config), Meta, Hooks),
maybe_unlock(),
Res.
@@ -168,42 +169,42 @@ call(Fun, Config, Meta, NoChangeRet) when is_function(Fun) ->
NewReturn -> NewReturn
end;
-call([{CB, call_id, NextFun} | Rest], Config, Meta, CBs) ->
+call([{Hook, call_id, NextFun} | Rest], Config, Meta, Hooks) ->
try
- {Config, {NewId, _, _} = NewCB} = call_id(CB, Config, Meta),
- {NewCBs, NewRest} =
- case lists:keyfind(NewId, 1, CBs) of
+ {Config, {NewId, _, _} = NewHook} = call_id(Hook, Config, Meta),
+ {NewHooks, NewRest} =
+ case lists:keyfind(NewId, 1, Hooks) of
false when NextFun =:= undefined ->
- {CBs ++ [NewCB],
+ {Hooks ++ [NewHook],
[{NewId, fun call_init/3} | Rest]};
- ExistingCB when is_tuple(ExistingCB) ->
- {CBs, Rest};
+ ExistingHook when is_tuple(ExistingHook) ->
+ {Hooks, Rest};
_ ->
- {CBs ++ [NewCB],
+ {Hooks ++ [NewHook],
[{NewId, fun call_init/3},{NewId,NextFun} | Rest]}
end,
- call(NewRest, Config, Meta, NewCBs)
+ call(NewRest, Config, Meta, NewHooks)
catch Error:Reason ->
Trace = erlang:get_stacktrace(),
- ct_logs:log("Suite Callback","Failed to start a SCB: ~p:~p",
+ ct_logs:log("Suite Hook","Failed to start a CTH: ~p:~p",
[Error,{Reason,Trace}]),
- call([], {fail,"Failed to start SCB"
- ", see the CT Log for details"}, Meta, CBs)
+ call([], {fail,"Failed to start CTH"
+ ", see the CT Log for details"}, Meta, Hooks)
end;
-call([{CBId, Fun} | Rest], Config, Meta, CBs) ->
+call([{HookId, Fun} | Rest], Config, Meta, Hooks) ->
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}),
+ {_,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(CBId, Meta, NewCBs))
- catch throw:{error_in_scb_call,Reason} ->
+ terminate_if_scope_ends(HookId, Meta, NewHooks))
+ catch throw:{error_in_cth_call,Reason} ->
call(Rest, {fail, Reason}, Meta,
- terminate_if_scope_ends(CBId, Meta, CBs))
+ terminate_if_scope_ends(HookId, Meta, Hooks))
end;
-call([], Config, _Meta, CBs) ->
- save_suite_data_async(CBs),
+call([], Config, _Meta, Hooks) ->
+ save_suite_data_async(Hooks),
Config.
remove(Key,List) when is_list(List) ->
@@ -226,36 +227,36 @@ scope([post_init_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);
+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);
_ ->
- CBs
+ Hooks
end.
-%% Fetch callback functions
-get_new_callbacks(Config, Fun) ->
- lists:foldl(fun(NewCB, Acc) ->
- [{NewCB, call_id, Fun} | Acc]
- end, [], get_new_callbacks(Config)).
+%% 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_callbacks(Config) when is_list(Config) ->
- lists:flatmap(fun({?config_name, CallbackConfigs}) ->
- CallbackConfigs;
+get_new_hooks(Config) when is_list(Config) ->
+ lists:flatmap(fun({?config_name, HookConfigs}) ->
+ HookConfigs;
(_) ->
[]
end, Config);
-get_new_callbacks(_Config) ->
+get_new_hooks(_Config) ->
[].
-save_suite_data_async(CBs) ->
- ct_util:save_suite_data_async(?config_name, CBs).
+save_suite_data_async(Hooks) ->
+ ct_util:save_suite_data_async(?config_name, Hooks).
-get_callbacks() ->
+get_hooks() ->
ct_util:read_suite_data(?config_name).
catch_apply(M,F,A, Default) ->
@@ -263,15 +264,15 @@ catch_apply(M,F,A, Default) ->
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.
+ %% 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 Callback","Call to SCB failed: ~p:~p",
+ ct_logs:log("Suite Hook","Call to CTH failed: ~p:~p",
[error,{Reason,Trace}]),
- throw({error_in_scb_call,
+ throw({error_in_cth_call,
lists:flatten(
- io_lib:format("~p:~p/~p SCB call failed",
+ io_lib:format("~p:~p/~p CTH call failed",
[M,F,length(A)]))})
end
end.
@@ -279,11 +280,11 @@ catch_apply(M,F,A, Default) ->
%% 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.
+%% cth 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});
+ {ok, _Pid} = ct_hooks_lock:start({Mod,GroupName});
false ->
ok
end.
@@ -291,14 +292,14 @@ maybe_start_locker(Mod,GroupName,Opts) ->
maybe_stop_locker(Mod,GroupName,Opts) ->
case lists:member(parallel,Opts) of
true ->
- stopped = ct_suite_callback_lock:stop({Mod,GroupName});
+ stopped = ct_hooks_lock:stop({Mod,GroupName});
false ->
ok
end.
maybe_lock() ->
- locked = ct_suite_callback_lock:request().
+ locked = ct_hooks_lock:request().
maybe_unlock() ->
- unlocked = ct_suite_callback_lock:release().
+ unlocked = ct_hooks_lock:release().
diff --git a/lib/common_test/src/ct_suite_callback_lock.erl b/lib/common_test/src/ct_hooks_lock.erl
index 84dafd1e42..98794201bb 100644
--- a/lib/common_test/src/ct_suite_callback_lock.erl
+++ b/lib/common_test/src/ct_hooks_lock.erl
@@ -19,9 +19,10 @@
%%% @doc Common Test Framework test execution control module.
%%%
-%%% <p>This module is a proxy for calling and handling locks in suite callbacks.</p>
+%%% <p>This module is a proxy for calling and handling locks in
+%%% common test hooks.</p>
--module(ct_suite_callback_lock).
+-module(ct_hooks_lock).
-behaviour(gen_server).
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_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=[],