From ec4c840624a9a44d4d7d6b1e51e1f33a291a704b Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 20 Sep 2010 15:46:12 +0200 Subject: Add support for suite_callback in spec, command_line and interactive. Start work on suite_callback functionality. --- lib/common_test/src/ct_util.erl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/common_test/src/ct_util.erl') diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index b5ab4cbb6e..4696b3c954 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -32,7 +32,9 @@ -export([close_connections/0]). --export([save_suite_data/3, save_suite_data/2, read_suite_data/1, +-export([save_suite_data/3, save_suite_data/2, + save_suite_data_async/3, save_suite_data_async/2, + read_suite_data/1, delete_suite_data/0, delete_suite_data/1, match_delete_suite_data/1, delete_testdata/0, delete_testdata/1, set_testdata/1, get_testdata/1, update_testdata/2]). @@ -159,6 +161,11 @@ do_start(Parent,Mode,LogDir) -> ok end, {StartTime,TestLogDir} = ct_logs:init(Mode), + + %% Initiate suite_callbacks + ok = ct_suite_callback:init(Opts), + + ct_event:notify(#event{name=test_start, node=node(), data={StartTime, @@ -182,12 +189,19 @@ read_opts() -> {error,{bad_installation,Error}} end. + save_suite_data(Key, Value) -> call({save_suite_data, {Key, undefined, Value}}). save_suite_data(Key, Name, Value) -> call({save_suite_data, {Key, Name, Value}}). +save_suite_data_async(Key, Value) -> + save_suite_data_async(Key, undefined, Value). + +save_suite_data_async(Key, Name, Value) -> + cast({save_suite_data, {Key, Name, Value}}). + read_suite_data(Key) -> call({read_suite_data, Key}). @@ -308,6 +322,9 @@ loop(Mode,TestData,StartDir) -> ct_config:stop(), file:set_cwd(StartDir), return(From,ok); + {Ref, _Msg} when is_reference(Ref) -> + %% This clause is used when doing cast operations. + loop(Mode,TestData,StartDir); {get_mode,From} -> return(From,Mode), loop(Mode,TestData,StartDir); @@ -713,6 +730,9 @@ call(Msg) -> return({To,Ref},Result) -> To ! {Ref, Result}. +cast(Msg) -> + ct_util_server ! {Msg, {ct_util_server, make_ref()}}. + seconds(T) -> test_server:seconds(T). -- cgit v1.2.3 From 18b2dba61c4849fd924ace459d169d263e7e6619 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Thu, 18 Nov 2010 14:15:50 +0100 Subject: Add terminate SCB functionality --- lib/common_test/src/ct_util.erl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/common_test/src/ct_util.erl') diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index 4696b3c954..fddeff881e 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -313,6 +313,10 @@ loop(Mode,TestData,StartDir) -> ct_event:sync_notify(#event{name=test_done, node=node(), data=Time}), + Callbacks = ets:lookup_element(?suite_table, + suite_callbacks, + #suite_data.value), + ct_suite_callback:terminate(Callbacks), close_connections(ets:tab2list(?conn_table)), ets:delete(?conn_table), ets:delete(?board_table), -- cgit v1.2.3 From 8ed5c47ca047405b2c00a979a8567412e5283322 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Wed, 8 Dec 2010 17:16:49 +0100 Subject: Add so that failures in SCB:init/1 causes the entire scb scope to fail --- lib/common_test/src/ct_util.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/common_test/src/ct_util.erl') diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index fddeff881e..2f5a90a543 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -163,8 +163,14 @@ do_start(Parent,Mode,LogDir) -> {StartTime,TestLogDir} = ct_logs:init(Mode), %% Initiate suite_callbacks - ok = ct_suite_callback:init(Opts), - + case catch ct_suite_callback:init(Opts) of + ok -> + ok; + {_,SCBReason} -> + ct_logs:tc_print('Suite Callback',SCBReason,[]), + Parent ! {self(), SCBReason}, + self() ! {{stop,normal},{self(),make_ref()}} + end, ct_event:notify(#event{name=test_start, node=node(), -- cgit v1.2.3 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/ct_util.erl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/common_test/src/ct_util.erl') 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), -- cgit v1.2.3