From c5275f3dc1d78ecbe1bf311b7c04c3c815a293d9 Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Wed, 3 Mar 2010 10:27:38 +0100 Subject: Added config test suite for CT --- lib/common_test/test/Makefile | 3 +- lib/common_test/test/ct_config_SUITE.erl | 167 +++++++++++++++++++++ .../test/ct_config_SUITE_data/config/cfg.cfg | 11 ++ .../config/test/config_1_SUITE.erl | 135 +++++++++++++++++ .../config/test/config_2_SUITE.erl | 59 ++++++++ 5 files changed, 374 insertions(+), 1 deletion(-) create mode 100644 lib/common_test/test/ct_config_SUITE.erl create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/cfg.cfg create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index 35ba22aa59..2b0a06871e 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -33,7 +33,8 @@ MODULES= \ ct_groups_test_2_SUITE \ ct_skip_SUITE \ ct_error_SUITE \ - ct_test_server_if_1_SUITE + ct_test_server_if_1_SUITE \ + ct_config_SUITE ERL_FILES= $(MODULES:%=%.erl) diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl new file mode 100644 index 0000000000..38c8cbe6eb --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE.erl @@ -0,0 +1,167 @@ +%% +%% %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_config_SUITE +%%% +%%% Description: +%%% Test configuration handling in Common Test suites. +%%% +%%% The suites used for the test are located in the data directory. +%%%------------------------------------------------------------------- +-module(ct_config_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) -> + Config1 = ct_test_support:init_per_suite(Config), + Config1. + +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). + +all(doc) -> + [""]; + +all(suite) -> + [ + require, + nested_keys + ]. + + +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- + +%%%----------------------------------------------------------------- +%%% +require(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + Join = fun(D, S) -> filename:join(D, "config/test/"++S) end, + Suites = [Join(DataDir, "config_1_SUITE")], + CTConfig = {config, filename:join(DataDir, "config/cfg.cfg")}, + {Opts,ERPid} = setup({suite,Suites}, Config, CTConfig), + ok = ct_test_support:run(ct, run_test, [Opts], Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(require, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = test_events(require), + ok = ct_test_support:verify_events(TestEvents, Events, Config). + +nested_keys(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + Join = fun(D, S) -> filename:join(D, "config/test/"++S) end, + Suites = [Join(DataDir, "config_2_SUITE")], + CTConfig = {config, filename:join(DataDir, "config/cfg.cfg")}, + {Opts,ERPid} = setup({suite,Suites}, Config, CTConfig), + ok = ct_test_support:run(ct, run_test, [Opts], Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(nested_keys, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = test_events(nested_keys), + ok = ct_test_support:verify_events(TestEvents, Events, Config). + +%%%----------------------------------------------------------------- +%%% HELP FUNCTIONS +%%%----------------------------------------------------------------- + +setup(Test, Config, CTConfig) -> + Opts0 = ct_test_support:get_opts(Config), + Level = ?config(trace_level, Config), + EvHArgs = [{cbm,ct_test_support},{trace_level,Level}], + Opts = Opts0 ++ [Test,{event_handler,{?eh,EvHArgs}}, CTConfig], + 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 +%%%----------------------------------------------------------------- +test_events(require) -> +[ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{1,1,8}}, + {?eh,tc_start,{config_1_SUITE,init_per_suite}}, + {?eh,tc_done,{config_1_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{config_1_SUITE,test1}}, + {?eh,tc_done,{config_1_SUITE,test1,ok}}, + {?eh,test_stats,{1,0,{0,0}}}, + {?eh,tc_start,{config_1_SUITE,test2}}, + {?eh,tc_done, + {config_1_SUITE,test2,{skipped,{config_name_already_in_use,[x1]}}}}, + {?eh,test_stats,{1,0,{1,0}}}, + {?eh,tc_start,{config_1_SUITE,test3}}, + {?eh,tc_done,{config_1_SUITE,test3,ok}}, + {?eh,test_stats,{2,0,{1,0}}}, + {?eh,tc_start,{config_1_SUITE,test4}}, + {?eh,tc_done, + {config_1_SUITE,test4,{skipped,{config_name_already_in_use,[x1,alias]}}}}, + {?eh,test_stats,{2,0,{2,0}}}, + {?eh,tc_start,{config_1_SUITE,test5}}, + {?eh,tc_done,{config_1_SUITE,test5,ok}}, + {?eh,test_stats,{3,0,{2,0}}}, + {?eh,tc_start,{config_1_SUITE,test6}}, + {?eh,tc_done,{config_1_SUITE,test6,ok}}, + {?eh,test_stats,{4,0,{2,0}}}, + {?eh,tc_start,{config_1_SUITE,test7}}, + {?eh,tc_done,{config_1_SUITE,test7,ok}}, + {?eh,test_stats,{5,0,{2,0}}}, + {?eh,tc_start,{config_1_SUITE,test8}}, + {?eh,tc_done,{config_1_SUITE,test8,ok}}, + {?eh,test_stats,{6,0,{2,0}}}, + {?eh,tc_start,{config_1_SUITE,end_per_suite}}, + {?eh,tc_done,{config_1_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} +]; + +test_events(nested_keys)-> +[]. diff --git a/lib/common_test/test/ct_config_SUITE_data/config/cfg.cfg b/lib/common_test/test/ct_config_SUITE_data/config/cfg.cfg new file mode 100644 index 0000000000..f0c1783189 --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/cfg.cfg @@ -0,0 +1,11 @@ +{x, suite}. +{gen_cfg2, + [ + {a,x}, + {b,y} + ]}. +{gen_cfg3, + [ + {v,w}, + {m,n} + ]}. \ No newline at end of file diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl new file mode 100644 index 0000000000..696014ee9f --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl @@ -0,0 +1,135 @@ +%% +%% %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% +%% +-module(config_1_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +suite() -> + [ + {timetrap, {seconds,10}}, + %% x1 doesn't exist in cfg-file! + {require, x1, x}, + {require, gen_cfg2}, + {require, alias, gen_cfg3}, + %% x1 default value + {x1, {x,suite}} + ]. + +is_exported(Module, Function, Arity)-> + Exports = Module:module_info(exports), + case lists:keyfind(Function, 1, Exports) of + false-> + false; + {Function, Arity}-> + true; + {Function, _OtherArity}-> + false + end. + +get_all_config()-> + case is_exported(ct_util, get_all_config, 0) of + true-> + {ct_util, ct_util:get_all_config()}; + false-> + {ct_config, ct_config:get_all_config()} + end. + +init_per_suite(Config) -> + {Module, Cfg} = get_all_config(), + ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + Config. + +end_per_suite(_) -> + ok. + +all() -> [test1,test2,test3,test4,test5,test6,test7,test8]. + +init_per_testcase(_, Config) -> + {Module, Cfg} = get_all_config(), + ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + Config. + +end_per_testcase(_, _) -> + ok. + +test1(_) -> + suite = ct:get_config(x1), + [{a,x},{b,y}] = ct:get_config(gen_cfg2), + [{v,w},{m,n}] = ct:get_config(alias), + ok. + +%% should get skipped +test2() -> + [{timetrap, {seconds,2}}, + {require, x1, x}, + {x1, {x,test2}}]. +test2(_) -> + test2 = ct:get_config(x1), + [{a,x},{b,y}] = ct:get_config(gen_cfg2), + [{v,w},{m,n}] = ct:get_config(alias), + ct:fail("Test should've been skipped, you shouldn't see this!"), + ok. + +test3() -> + [{timetrap, {seconds,3}}, + {require, y1, y}, + {y1, {y,test3}}]. +test3(_) -> + suite = ct:get_config(x1), + test3 = ct:get_config(y1), + [{a,x},{b,y}] = ct:get_config(gen_cfg2), + [{v,w},{m,n}] = ct:get_config(alias), + ok. + +%% should get skipped +test4() -> + [{require,alias,something}, + {alias,{something,else}}, + {require, x1, x}, + {x1, {x,test4}}]. +test4(_) -> + ct:fail("Test should've been skipped, you shouldn't see this!"), + ok. + +test5() -> + [{require,newalias,gen_cfg2}]. +test5(_) -> + A = [{a,x},{b,y}] = ct:get_config(newalias), + A = ct:get_config(gen_cfg2), + ok. + +test6(_) -> + undefined = ct:get_config(y1), + ok. + +test7() -> + [{require, y1, y}, + {y1, {y,test6}}]. +test7(_) -> + suite = ct:get_config(x1), + test6 = ct:get_config(y1), + ok. + +%% should get skipped +test8() -> + [{require, x}]. +test8(_) -> + ok. \ No newline at end of file diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl new file mode 100644 index 0000000000..25e050984a --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl @@ -0,0 +1,59 @@ +%% +%% 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(config_2_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +suite() -> + [ + {timetrap, {seconds,10}} + ]. + +is_exported(Module, Function, Arity)-> + Exports = Module:module_info(exports), + case lists:keyfind(Function, 1, Exports) of + false-> + false; + {Function, Arity}-> + true; + {Function, _OtherArity}-> + false + end. + +get_all_config()-> + case is_exported(ct_util, get_all_config, 0) of + true-> + {ct_util, ct_util:get_all_config()}; + false-> + {ct_config, ct_config:get_all_config()} + end. + +init_per_suite(Config) -> + {Module, Cfg} = get_all_config(), + ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + Config. + +end_per_suite(_) -> + ok. + +all() -> [test1]. + +init_per_testcase(_, Config) -> + {Module, Cfg} = get_all_config(), + ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + Config. + +end_per_testcase(_, _) -> + ok. + +test1(_)-> + x = ct:get_config({gen_cfg2, a}), + ok. -- cgit v1.2.3 From 5b66bed40bd374dfcaa5e5669adf338734d812a3 Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Tue, 9 Mar 2010 15:10:22 +0100 Subject: Add test suites for configuration --- lib/common_test/test/ct_config_SUITE.erl | 127 ++++++++++++--------- .../test/ct_config_SUITE_data/config/cfg.cfg | 11 -- .../test/ct_config_SUITE_data/config/config.txt | 31 +++++ .../test/ct_config_SUITE_data/config/config.xml | 27 +++++ .../config/test/config_1_SUITE.erl | 100 +++++++++------- .../config/test/config_2_SUITE.erl | 88 ++++++++++++-- .../config/test/config_driver.erl | 41 +++++++ .../config/test/config_server.erl | 87 ++++++++++++++ 8 files changed, 398 insertions(+), 114 deletions(-) delete mode 100644 lib/common_test/test/ct_config_SUITE_data/config/cfg.cfg create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/config.txt create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/config.xml create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl index 38c8cbe6eb..4ae68fbfa8 100644 --- a/lib/common_test/test/ct_config_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE.erl @@ -62,7 +62,8 @@ all(doc) -> all(suite) -> [ require, - nested_keys + userconfig_static, + userconfig_dynamic ]. @@ -74,41 +75,41 @@ all(suite) -> %%% require(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), - Join = fun(D, S) -> filename:join(D, "config/test/"++S) end, - Suites = [Join(DataDir, "config_1_SUITE")], - CTConfig = {config, filename:join(DataDir, "config/cfg.cfg")}, - {Opts,ERPid} = setup({suite,Suites}, Config, CTConfig), - ok = ct_test_support:run(ct, run_test, [Opts], Config), - Events = ct_test_support:get_events(ERPid, Config), - - ct_test_support:log_events(require, - reformat(Events, ?eh), - ?config(priv_dir, Config)), + run_test(require, + Config, + {config, filename:join(DataDir, "config/config.txt")}, + ["config_1_SUITE"]). - TestEvents = test_events(require), - ok = ct_test_support:verify_events(TestEvents, Events, Config). - -nested_keys(Config) when is_list(Config) -> +userconfig_static(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), - Join = fun(D, S) -> filename:join(D, "config/test/"++S) end, - Suites = [Join(DataDir, "config_2_SUITE")], - CTConfig = {config, filename:join(DataDir, "config/cfg.cfg")}, - {Opts,ERPid} = setup({suite,Suites}, Config, CTConfig), - ok = ct_test_support:run(ct, run_test, [Opts], Config), - Events = ct_test_support:get_events(ERPid, Config), + run_test(userconfig_static, + Config, + {userconfig, {ct_config_xml, filename:join(DataDir, "config/config.xml")}}, + ["config_1_SUITE"]). - ct_test_support:log_events(nested_keys, - reformat(Events, ?eh), - ?config(priv_dir, Config)), - - TestEvents = test_events(nested_keys), - ok = ct_test_support:verify_events(TestEvents, Events, Config). +userconfig_dynamic(Config) when is_list(Config) -> + run_test(userconfig_dynamic, + Config, + {userconfig, {config_driver, "config_server"}}, + ["config_2_SUITE"]). %%%----------------------------------------------------------------- %%% HELP FUNCTIONS %%%----------------------------------------------------------------- +run_test(Name, Config, CTConfig, SuiteNames)-> + DataDir = ?config(data_dir, Config), + Joiner = fun(Suite) -> filename:join(DataDir, "config/test/"++Suite) end, + Suites = lists:map(Joiner, SuiteNames), + {Opts,ERPid} = setup_env({suite,Suites}, Config, CTConfig), + ok = ct_test_support:run(ct, run_test, [Opts], Config), + TestEvents = ct_test_support:get_events(ERPid, Config), + ct_test_support:log_events(Name, + reformat_events(TestEvents, ?eh), + ?config(priv_dir, Config)), + ExpEvents = expected_events(Name), + ok = ct_test_support:verify_events(ExpEvents, TestEvents, Config). -setup(Test, Config, CTConfig) -> +setup_env(Test, Config, CTConfig) -> Opts0 = ct_test_support:get_opts(Config), Level = ?config(trace_level, Config), EvHArgs = [{cbm,ct_test_support},{trace_level,Level}], @@ -116,46 +117,45 @@ setup(Test, Config, CTConfig) -> ERPid = ct_test_support:start_event_receiver(Config), {Opts,ERPid}. -reformat(Events, EH) -> +reformat_events(Events, EH) -> ct_test_support:reformat(Events, EH). -%reformat(Events, _EH) -> -% Events. %%%----------------------------------------------------------------- %%% TEST EVENTS %%%----------------------------------------------------------------- -test_events(require) -> +expected_events(ReqOrUCS) when ReqOrUCS==require; ReqOrUCS==userconfig_static-> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, {?eh,start_info,{1,1,8}}, {?eh,tc_start,{config_1_SUITE,init_per_suite}}, {?eh,tc_done,{config_1_SUITE,init_per_suite,ok}}, - {?eh,tc_start,{config_1_SUITE,test1}}, - {?eh,tc_done,{config_1_SUITE,test1,ok}}, + {?eh,tc_start,{config_1_SUITE,test_get_config_simple}}, + {?eh,tc_done,{config_1_SUITE,test_get_config_simple,ok}}, {?eh,test_stats,{1,0,{0,0}}}, - {?eh,tc_start,{config_1_SUITE,test2}}, + {?eh,tc_start,{config_1_SUITE,test_get_config_nested}}, + {?eh,tc_done,{config_1_SUITE,test_get_config_nested,ok}}, + {?eh,test_stats,{2,0,{0,0}}}, + {?eh,tc_start,{config_1_SUITE,test_default_suitewide}}, + {?eh,tc_done,{config_1_SUITE,test_default_suitewide,ok}}, + {?eh,test_stats,{3,0,{0,0}}}, + {?eh,tc_start,{config_1_SUITE,test_config_name_already_in_use1}}, {?eh,tc_done, - {config_1_SUITE,test2,{skipped,{config_name_already_in_use,[x1]}}}}, - {?eh,test_stats,{1,0,{1,0}}}, - {?eh,tc_start,{config_1_SUITE,test3}}, - {?eh,tc_done,{config_1_SUITE,test3,ok}}, - {?eh,test_stats,{2,0,{1,0}}}, - {?eh,tc_start,{config_1_SUITE,test4}}, + {config_1_SUITE,test_config_name_already_in_use1,{skipped,{config_name_already_in_use,[x1]}}}}, + {?eh,test_stats,{3,0,{1,0}}}, + {?eh,tc_start,{config_1_SUITE,test_default_tclocal}}, + {?eh,tc_done,{config_1_SUITE,test_default_tclocal,ok}}, + {?eh,test_stats,{4,0,{1,0}}}, + {?eh,tc_start,{config_1_SUITE,test_config_name_already_in_use2}}, {?eh,tc_done, - {config_1_SUITE,test4,{skipped,{config_name_already_in_use,[x1,alias]}}}}, - {?eh,test_stats,{2,0,{2,0}}}, - {?eh,tc_start,{config_1_SUITE,test5}}, - {?eh,tc_done,{config_1_SUITE,test5,ok}}, - {?eh,test_stats,{3,0,{2,0}}}, - {?eh,tc_start,{config_1_SUITE,test6}}, - {?eh,tc_done,{config_1_SUITE,test6,ok}}, + {config_1_SUITE,test_config_name_already_in_use2, + {skipped,{config_name_already_in_use,[x1,alias]}}}}, {?eh,test_stats,{4,0,{2,0}}}, - {?eh,tc_start,{config_1_SUITE,test7}}, - {?eh,tc_done,{config_1_SUITE,test7,ok}}, + {?eh,tc_start,{config_1_SUITE,test_alias_tclocal}}, + {?eh,tc_done,{config_1_SUITE,test_alias_tclocal,ok}}, {?eh,test_stats,{5,0,{2,0}}}, - {?eh,tc_start,{config_1_SUITE,test8}}, - {?eh,tc_done,{config_1_SUITE,test8,ok}}, + {?eh,tc_start,{config_1_SUITE,test_get_config_undefined}}, + {?eh,tc_done,{config_1_SUITE,test_get_config_undefined,ok}}, {?eh,test_stats,{6,0,{2,0}}}, {?eh,tc_start,{config_1_SUITE,end_per_suite}}, {?eh,tc_done,{config_1_SUITE,end_per_suite,ok}}, @@ -163,5 +163,24 @@ test_events(require) -> {?eh,stop_logging,[]} ]; -test_events(nested_keys)-> -[]. +expected_events(userconfig_dynamic)-> +[ + {ct_test_support_eh,start_logging,{'DEF','RUNDIR'}}, + {ct_test_support_eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {ct_test_support_eh,start_info,{1,1,3}}, + {ct_test_support_eh,tc_start,{config_2_SUITE,init_per_suite}}, + {ct_test_support_eh,tc_done,{config_2_SUITE,init_per_suite,ok}}, + {ct_test_support_eh,tc_start,{config_2_SUITE,test_get_known_variable}}, + {ct_test_support_eh,tc_done,{config_2_SUITE,test_get_known_variable,ok}}, + {ct_test_support_eh,test_stats,{1,0,{0,0}}}, + {ct_test_support_eh,tc_start,{config_2_SUITE,test_localtime_update}}, + {ct_test_support_eh,tc_done,{config_2_SUITE,test_localtime_update,ok}}, + {ct_test_support_eh,test_stats,{2,0,{0,0}}}, + {ct_test_support_eh,tc_start,{config_2_SUITE,test_server_pid}}, + {ct_test_support_eh,tc_done,{config_2_SUITE,test_server_pid,ok}}, + {ct_test_support_eh,test_stats,{3,0,{0,0}}}, + {ct_test_support_eh,tc_start,{config_2_SUITE,end_per_suite}}, + {ct_test_support_eh,tc_done,{config_2_SUITE,end_per_suite,ok}}, + {ct_test_support_eh,test_done,{'DEF','STOP_TIME'}}, + {ct_test_support_eh,stop_logging,[]} +]. \ No newline at end of file diff --git a/lib/common_test/test/ct_config_SUITE_data/config/cfg.cfg b/lib/common_test/test/ct_config_SUITE_data/config/cfg.cfg deleted file mode 100644 index f0c1783189..0000000000 --- a/lib/common_test/test/ct_config_SUITE_data/config/cfg.cfg +++ /dev/null @@ -1,11 +0,0 @@ -{x, suite}. -{gen_cfg2, - [ - {a,x}, - {b,y} - ]}. -{gen_cfg3, - [ - {v,w}, - {m,n} - ]}. \ No newline at end of file diff --git a/lib/common_test/test/ct_config_SUITE_data/config/config.txt b/lib/common_test/test/ct_config_SUITE_data/config/config.txt new file mode 100644 index 0000000000..0424dbf92e --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/config.txt @@ -0,0 +1,31 @@ +{x, suite}. +{gen_cfg, + [ + {a,a_value}, + {b,b_value} + ]}. +{gen_cfg2, + [ + {c, "Hello, world!"}, + {d, atom_value}, + {e, {tuple,1,"third value",[]}}, + {f, []}, + {g, [1,atom,"string",13.6,{1,2,3}]} + ]}. +{gen_cfg3, + [ + {h, + [ + {i, third1}, + {j, "Third2"}, + {k, 'THIRD3'} + ]}, + {l, + [ + {m, + [ + {n, "N"}, + {o, 'O'} + ]} + ]} + ]}. \ No newline at end of file diff --git a/lib/common_test/test/ct_config_SUITE_data/config/config.xml b/lib/common_test/test/ct_config_SUITE_data/config/config.xml new file mode 100644 index 0000000000..0a3e5f2e31 --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/config.xml @@ -0,0 +1,27 @@ + + suite + + a_value + b_value + + + "Hello, world!" + atom_value + {tuple,1,"third value",[]} + [] + [1,atom,"string",13.6,{1,2,3}] + + + + third1 + "Third2" + 'THIRD3' + + + + "N" + 'O' + + + + diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl index 696014ee9f..e102c69d3d 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl @@ -16,23 +16,44 @@ %% %% %CopyrightEnd% %% + +%%%------------------------------------------------------------------- +%%% File: config_1_SUITE +%%% +%%% Description: +%%% Test suite for common_test which tests the get_config and require +%%% functionality +%%%------------------------------------------------------------------- -module(config_1_SUITE). -compile(export_all). -include_lib("common_test/include/ct.hrl"). +% The config contains variables: +% x - atom +% gen_cfg - list with two key-values tagged with a and b +% gen_cfg2 - list of five key-values tagged with c, d, e, f and g +% gen_cfg3 - list of two complex key-values taggen with: +% h: three elements inside - i, j and k +% l: m inside, contains n and o + suite() -> [ {timetrap, {seconds,10}}, %% x1 doesn't exist in cfg-file! {require, x1, x}, - {require, gen_cfg2}, - {require, alias, gen_cfg3}, + {require, gen_cfg3}, + {require, alias, gen_cfg}, %% x1 default value {x1, {x,suite}} ]. +% to get it running on development branch (without userconfig features) +% function to print full config is in the ct_util, for me it's moved to ct_config +% two following functions are only for the design period +% after merging of userconfigs to the main branch ct_config:get_all_config/0 +% should be called instead is_exported(Module, Function, Arity)-> Exports = Module:module_info(exports), case lists:keyfind(Function, 1, Exports) of @@ -53,83 +74,78 @@ get_all_config()-> end. init_per_suite(Config) -> - {Module, Cfg} = get_all_config(), - ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + %{Module, Cfg} = get_all_config(), + %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), Config. end_per_suite(_) -> ok. -all() -> [test1,test2,test3,test4,test5,test6,test7,test8]. +all() -> [test_get_config_simple, test_get_config_nested, test_default_suitewide, + test_config_name_already_in_use1, test_default_tclocal, + test_config_name_already_in_use2, test_alias_tclocal, + test_get_config_undefined]. init_per_testcase(_, Config) -> - {Module, Cfg} = get_all_config(), - ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + %{Module, Cfg} = get_all_config(), + %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), Config. end_per_testcase(_, _) -> ok. -test1(_) -> +%% test getting a simple value +test_get_config_simple(_)-> + suite = ct:get_config(x), + ok. + +%% test getting a nested value +test_get_config_nested(_)-> + a_value = ct:get_config({gen_cfg, a}), + ok. + +%% test suite-wide default value +test_default_suitewide(_)-> suite = ct:get_config(x1), - [{a,x},{b,y}] = ct:get_config(gen_cfg2), - [{v,w},{m,n}] = ct:get_config(alias), ok. %% should get skipped -test2() -> +test_config_name_already_in_use1() -> [{timetrap, {seconds,2}}, {require, x1, x}, {x1, {x,test2}}]. -test2(_) -> - test2 = ct:get_config(x1), - [{a,x},{b,y}] = ct:get_config(gen_cfg2), - [{v,w},{m,n}] = ct:get_config(alias), +test_config_name_already_in_use1(_) -> ct:fail("Test should've been skipped, you shouldn't see this!"), ok. -test3() -> +%% test defaults in a testcase +test_default_tclocal() -> [{timetrap, {seconds,3}}, {require, y1, y}, {y1, {y,test3}}]. -test3(_) -> - suite = ct:get_config(x1), +test_default_tclocal(_) -> test3 = ct:get_config(y1), - [{a,x},{b,y}] = ct:get_config(gen_cfg2), - [{v,w},{m,n}] = ct:get_config(alias), ok. %% should get skipped -test4() -> +test_config_name_already_in_use2() -> [{require,alias,something}, {alias,{something,else}}, {require, x1, x}, {x1, {x,test4}}]. -test4(_) -> +test_config_name_already_in_use2(_) -> ct:fail("Test should've been skipped, you shouldn't see this!"), ok. -test5() -> - [{require,newalias,gen_cfg2}]. -test5(_) -> - A = [{a,x},{b,y}] = ct:get_config(newalias), - A = ct:get_config(gen_cfg2), +%% test aliases +test_alias_tclocal() -> + [{require,newalias,gen_cfg}]. +test_alias_tclocal(_) -> + A = [{a,a_value},{b,b_value}] = ct:get_config(newalias), + A = ct:get_config(gen_cfg), ok. -test6(_) -> +%% test for getting undefined variables +test_get_config_undefined(_) -> undefined = ct:get_config(y1), ok. - -test7() -> - [{require, y1, y}, - {y1, {y,test6}}]. -test7(_) -> - suite = ct:get_config(x1), - test6 = ct:get_config(y1), - ok. - -%% should get skipped -test8() -> - [{require, x}]. -test8(_) -> - ok. \ No newline at end of file diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl index 25e050984a..86fd300a77 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl @@ -1,4 +1,14 @@ %% +%% %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 @@ -6,17 +16,39 @@ %% %% %CopyrightEnd% %% + +%%%------------------------------------------------------------------- +%%% File: ct_config_SUITE +%%% +%%% Description: +%%% Test suite for common_test which tests the userconfig functionality +%%%------------------------------------------------------------------- -module(config_2_SUITE). -compile(export_all). -include_lib("common_test/include/ct.hrl"). +%% This suite will be run with dynamic userconfig +%% test_driver.erl is compliant to ct_config_* callback +%% and test_server is simple server for getting runtime-changing data +%% which will return the list with the following variables: +%% localtime = the erlang:localtime() result in list [{date, Date}, {time, Time}] +%% node = erlang:node() - can be compared in the testcase +%% now = erlang:now() - easier to compare than localtime() +%% config_server_pid - pid of the config server, should NOT change! +%% config_server_vsn - .19 + suite() -> [ {timetrap, {seconds,10}} ]. +% to get it running on development branch (without userconfig features) +% function to print full config is in the ct_util, for me it's moved to ct_config +% two following functions are only for the design period +% after merging of userconfigs to the main branch ct_config:get_all_config/0 +% should be called instead is_exported(Module, Function, Arity)-> Exports = Module:module_info(exports), case lists:keyfind(Function, 1, Exports) of @@ -37,23 +69,65 @@ get_all_config()-> end. init_per_suite(Config) -> - {Module, Cfg} = get_all_config(), - ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + %{Module, Cfg} = get_all_config(), + %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), Config. end_per_suite(_) -> ok. -all() -> [test1]. +all() -> [test_get_known_variable, test_localtime_update, + test_server_pid]. init_per_testcase(_, Config) -> - {Module, Cfg} = get_all_config(), - ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + %{Module, Cfg} = get_all_config(), + %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), Config. end_per_testcase(_, _) -> ok. -test1(_)-> - x = ct:get_config({gen_cfg2, a}), +% test that usual config works +test_get_known_variable(_)-> + Node = erlang:node(), + 0.19 = ct:get_config(config_server_vsn), + Node = ct:get_config(node), + ok. + +% localtime will be updated in 5 seconds, check that +test_localtime_update(_)-> + Seconds = 5, + LT1 = ct:get_config(localtime), + timer:sleep(Seconds*1000), + LT2 = ct:reload_config(localtime), + case is_diff_ok(LT1, LT2, Seconds) of + {false, Actual, Exp}-> + ct:fail(io_lib:format("Time difference ~p is not ok, expected ~p", [Actual, Exp])); + true-> + ok + end. + +% server pid should not change +test_server_pid()-> + [{require, cfvsn, config_server_vsn}]. +test_server_pid(_)-> + Pid = ct:get_config(config_server_pid), + Pid = ct:reload_config(config_server_pid), + Vsn = ct:get_config(config_server_vsn), + % aliases remain after config reloading + Vsn = ct:get_config(cfvsn), ok. + +my_dt_to_datetime([{date, D},{time, T}])-> + {D, T}. + +is_diff_ok(DT1, DT2, Seconds)-> + GS1 = calendar:datetime_to_gregorian_seconds(my_dt_to_datetime(DT1)), + GS2 = calendar:datetime_to_gregorian_seconds(my_dt_to_datetime(DT2)), + if + GS2-GS1 > Seconds+Seconds/2; + GS2-GS1 < Seconds-Seconds/2-> + {false, GS2-GS1, Seconds}; + true-> + true + end. diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl new file mode 100644 index 0000000000..37572500c7 --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl @@ -0,0 +1,41 @@ +%% +%% %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_config_SUITE +%%% +%%% Description: +%%% Config driver used in the CT's tests (config_2_SUITE) +%%%------------------------------------------------------------------- +-module(config_driver). +-export([read_config/1, check_parameter/1]). + +read_config(ServerName)-> + ServerModule = list_to_atom(ServerName), + ServerModule:start(), + ServerModule:get_config(). + +check_parameter(ServerName)-> + ServerModule = list_to_atom(ServerName), + case code:load_file(ServerModule) of + {module, ServerModule}-> + {ok, {config, ServerName}}; + {error, nofile}-> + {nok, {wrong_config, "File not found: " ++ ServerName ++ ".beam"}} + end. diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl new file mode 100644 index 0000000000..0ee0bcfc22 --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl @@ -0,0 +1,87 @@ +%% +%% %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_config_SUITE +%%% +%%% Description: +%%% Config server used in the CT's tests (config_2_SUITE) +%%%------------------------------------------------------------------- +-module(config_server). +-export([start/0, stop/0, init/1, get_config/0, loop/0]). + +-define(REGISTERED_NAME, ct_test_config_server). +-define(vsn, 0.19). + +start()-> + case whereis(?REGISTERED_NAME) of + undefined-> + spawn(?MODULE, init, [?REGISTERED_NAME]), + wait(); + _Pid-> + ok + end, + ?REGISTERED_NAME. + +init(Name)-> + register(Name, self()), + loop(). + +get_config()-> + call(self(), get_config). + +stop()-> + call(self(), stop). + +call(Client, Request)-> + case whereis(?REGISTERED_NAME) of + undefined-> + {error, not_started, Request}; + Pid-> + Pid ! {Client, Request}, + receive + Reply-> + {ok, Reply} + after 4000-> + {error, timeout, Request} + end + end. + +loop()-> + receive + {Pid, stop}-> + Pid ! ok; + {Pid, get_config}-> + {D,T} = erlang:localtime(), + Pid ! + [{localtime, [{date, D}, {time, T}]}, + {node, erlang:node()}, + {now, erlang:now()}, + {config_server_pid, self()}, + {config_server_vsn, ?vsn}], + ?MODULE:loop() + end. + +wait()-> + case whereis(?REGISTERED_NAME) of + undefined-> + wait(); + _Pid-> + ok + end. -- cgit v1.2.3 From e04b9be7167841c7eaefcfb7eee5b4bc2eb3a943 Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Thu, 11 Mar 2010 14:21:51 +0100 Subject: Add tests for test specifications --- lib/common_test/test/ct_config_SUITE.erl | 54 ++++++++++++++++++++-- .../config/test/config_driver.erl | 13 ++++-- 2 files changed, 60 insertions(+), 7 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl index 4ae68fbfa8..ad7c521946 100644 --- a/lib/common_test/test/ct_config_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE.erl @@ -63,7 +63,10 @@ all(suite) -> [ require, userconfig_static, - userconfig_dynamic + userconfig_dynamic, + testspec_legacy, + testspec_static, + testspec_dynamic ]. @@ -93,9 +96,52 @@ userconfig_dynamic(Config) when is_list(Config) -> {userconfig, {config_driver, "config_server"}}, ["config_2_SUITE"]). +testspec_legacy(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + make_spec(DataDir, + "config/spec_legacy.spec", + [config_1_SUITE], + [{config, filename:join(DataDir, "config/config.txt")}]), + run_test(testspec_legacy, + Config, + {spec, filename:join(DataDir, "config/spec_legacy.spec")}, + []), + file:delete(filename:join(DataDir, "config/spec_legacy.spec")). + +testspec_static(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + make_spec(DataDir, + "config/spec_static.spec", + [config_1_SUITE], + [{userconfig, {ct_config_xml, filename:join(DataDir, "config/config.xml")}}]), + run_test(testspec_static, + Config, + {spec, filename:join(DataDir, "config/spec_static.spec")}, + []), + file:delete(filename:join(DataDir, "config/spec_static.spec")). + +testspec_dynamic(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + make_spec(DataDir, "config/spec_dynamic.spec", + [config_2_SUITE], + [{userconfig, {config_driver, "config_server"}}]), + run_test(testspec_dynamic, + Config, + {spec, filename:join(DataDir, "config/spec_dynamic.spec")}, + []), + file:delete(filename:join(DataDir, "config/spec_dynamic.spec")). + %%%----------------------------------------------------------------- %%% HELP FUNCTIONS %%%----------------------------------------------------------------- +% {suites, "ct_config_SUITE_data/config/test", config_2_SUITE}. +make_spec(DataDir, Filename, Suites, Config)-> + {ok, Fd} = file:open(filename:join(DataDir, Filename), [write]), + ok = file:write(Fd, + io_lib:format("{suites, \"~sconfig/test/\", ~p}.~n", [DataDir, Suites])), + lists:foreach(fun(C)-> ok=file:write(Fd, io_lib:format("~p.~n", [C])) end, Config), + ok = file:close(Fd). + run_test(Name, Config, CTConfig, SuiteNames)-> DataDir = ?config(data_dir, Config), Joiner = fun(Suite) -> filename:join(DataDir, "config/test/"++Suite) end, @@ -123,7 +169,9 @@ reformat_events(Events, EH) -> %%%----------------------------------------------------------------- %%% TEST EVENTS %%%----------------------------------------------------------------- -expected_events(ReqOrUCS) when ReqOrUCS==require; ReqOrUCS==userconfig_static-> +expected_events(Static) when + Static == require; Static == testspec_legacy; + Static == userconfig_static; Static == testspec_static-> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, @@ -163,7 +211,7 @@ expected_events(ReqOrUCS) when ReqOrUCS==require; ReqOrUCS==userconfig_static-> {?eh,stop_logging,[]} ]; -expected_events(userconfig_dynamic)-> +expected_events(Dynamic) when Dynamic == testspec_dynamic; Dynamic == userconfig_dynamic-> [ {ct_test_support_eh,start_logging,{'DEF','RUNDIR'}}, {ct_test_support_eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl index 37572500c7..670639f7c7 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl @@ -33,9 +33,14 @@ read_config(ServerName)-> check_parameter(ServerName)-> ServerModule = list_to_atom(ServerName), - case code:load_file(ServerModule) of - {module, ServerModule}-> + case code:is_loaded(ServerModule) of + {file, _}-> {ok, {config, ServerName}}; - {error, nofile}-> - {nok, {wrong_config, "File not found: " ++ ServerName ++ ".beam"}} + false-> + case code:load_file(ServerModule) of + {module, ServerModule}-> + {ok, {config, ServerName}}; + {error, nofile}-> + {nok, {wrong_config, "File not found: " ++ ServerName ++ ".beam"}} + end end. -- cgit v1.2.3 From 9ad66edc389b04141443bc5339c9f34dfeac59f0 Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Fri, 12 Mar 2010 11:55:55 +0100 Subject: Support running cover on common_test test suites --- lib/common_test/test/ct_test_support.erl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index 6148e3280e..4aa750c37f 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -55,6 +55,12 @@ init_per_suite(Config, Level) -> test_server:fail(Reason); {ok,CTNode} -> test_server:format(0, "Node ~p started~n", [CTNode]), + IsCover = test_server:is_cover(), + if IsCover -> + cover:start(CTNode); + true-> + ok + end, DataDir = ?config(data_dir, Config), PrivDir = ?config(priv_dir, Config), @@ -87,6 +93,7 @@ end_per_suite(Config) -> CTNode = ?config(ct_node, Config), PrivDir = ?config(priv_dir, Config), true = rpc:call(CTNode, code, del_path, [filename:join(PrivDir,"")]), + cover:stop(CTNode), slave:stop(CTNode), ok. -- cgit v1.2.3 From a9c315929d96c7d0d0e5e79f8fc0ba0c7f17e94d Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Mon, 15 Mar 2010 15:26:02 +0100 Subject: Changed return value tags for config file handling Return value tags modified and various documentation updates made (work in progress). --- lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl index 670639f7c7..073cb66ac2 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_driver.erl @@ -41,6 +41,6 @@ check_parameter(ServerName)-> {module, ServerModule}-> {ok, {config, ServerName}}; {error, nofile}-> - {nok, {wrong_config, "File not found: " ++ ServerName ++ ".beam"}} + {error, {wrong_config, "File not found: " ++ ServerName ++ ".beam"}} end end. -- cgit v1.2.3 From d7c10478a2287ce3f0c9ac077d835919e2745f91 Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Thu, 18 Mar 2010 16:48:27 +0100 Subject: Rename suites for ct_config and add tests for disappearing variables Tests for disappearing variables added to ct_dynamic_SUITE. --- lib/common_test/test/ct_config_SUITE.erl | 92 ++++++----- .../config/test/config_1_SUITE.erl | 151 ------------------ .../config/test/config_2_SUITE.erl | 133 ---------------- .../config/test/config_dynamic_SUITE.erl | 172 +++++++++++++++++++++ .../config/test/config_server.erl | 16 +- .../config/test/config_static_SUITE.erl | 151 ++++++++++++++++++ 6 files changed, 379 insertions(+), 336 deletions(-) delete mode 100644 lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl delete mode 100644 lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl create mode 100644 lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl index ad7c521946..a7fa6fe52e 100644 --- a/lib/common_test/test/ct_config_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE.erl @@ -78,31 +78,31 @@ all(suite) -> %%% require(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), - run_test(require, + run_test(config_static_SUITE, Config, {config, filename:join(DataDir, "config/config.txt")}, - ["config_1_SUITE"]). + ["config_static_SUITE"]). userconfig_static(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), - run_test(userconfig_static, + run_test(config_static_SUITE, Config, {userconfig, {ct_config_xml, filename:join(DataDir, "config/config.xml")}}, - ["config_1_SUITE"]). + ["config_static_SUITE"]). userconfig_dynamic(Config) when is_list(Config) -> - run_test(userconfig_dynamic, + run_test(config_dynamic_SUITE, Config, {userconfig, {config_driver, "config_server"}}, - ["config_2_SUITE"]). + ["config_dynamic_SUITE"]). testspec_legacy(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), make_spec(DataDir, "config/spec_legacy.spec", - [config_1_SUITE], + [config_static_SUITE], [{config, filename:join(DataDir, "config/config.txt")}]), - run_test(testspec_legacy, + run_test(config_static_SUITE, Config, {spec, filename:join(DataDir, "config/spec_legacy.spec")}, []), @@ -112,9 +112,9 @@ testspec_static(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), make_spec(DataDir, "config/spec_static.spec", - [config_1_SUITE], + [config_static_SUITE], [{userconfig, {ct_config_xml, filename:join(DataDir, "config/config.xml")}}]), - run_test(testspec_static, + run_test(config_static_SUITE, Config, {spec, filename:join(DataDir, "config/spec_static.spec")}, []), @@ -123,9 +123,9 @@ testspec_static(Config) when is_list(Config) -> testspec_dynamic(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), make_spec(DataDir, "config/spec_dynamic.spec", - [config_2_SUITE], + [config_dynamic_SUITE], [{userconfig, {config_driver, "config_server"}}]), - run_test(testspec_dynamic, + run_test(config_dynamic_SUITE, Config, {spec, filename:join(DataDir, "config/spec_dynamic.spec")}, []), @@ -134,7 +134,7 @@ testspec_dynamic(Config) when is_list(Config) -> %%%----------------------------------------------------------------- %%% HELP FUNCTIONS %%%----------------------------------------------------------------- -% {suites, "ct_config_SUITE_data/config/test", config_2_SUITE}. +% {suites, "ct_config_SUITE_data/config/test", config_dynamic_SUITE}. make_spec(DataDir, Filename, Suites, Config)-> {ok, Fd} = file:open(filename:join(DataDir, Filename), [write]), ok = file:write(Fd, @@ -169,66 +169,64 @@ reformat_events(Events, EH) -> %%%----------------------------------------------------------------- %%% TEST EVENTS %%%----------------------------------------------------------------- -expected_events(Static) when - Static == require; Static == testspec_legacy; - Static == userconfig_static; Static == testspec_static-> +expected_events(config_static_SUITE)-> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, {?eh,start_info,{1,1,8}}, - {?eh,tc_start,{config_1_SUITE,init_per_suite}}, - {?eh,tc_done,{config_1_SUITE,init_per_suite,ok}}, - {?eh,tc_start,{config_1_SUITE,test_get_config_simple}}, - {?eh,tc_done,{config_1_SUITE,test_get_config_simple,ok}}, + {?eh,tc_start,{config_static_SUITE,init_per_suite}}, + {?eh,tc_done,{config_static_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{config_static_SUITE,test_get_config_simple}}, + {?eh,tc_done,{config_static_SUITE,test_get_config_simple,ok}}, {?eh,test_stats,{1,0,{0,0}}}, - {?eh,tc_start,{config_1_SUITE,test_get_config_nested}}, - {?eh,tc_done,{config_1_SUITE,test_get_config_nested,ok}}, + {?eh,tc_start,{config_static_SUITE,test_get_config_nested}}, + {?eh,tc_done,{config_static_SUITE,test_get_config_nested,ok}}, {?eh,test_stats,{2,0,{0,0}}}, - {?eh,tc_start,{config_1_SUITE,test_default_suitewide}}, - {?eh,tc_done,{config_1_SUITE,test_default_suitewide,ok}}, + {?eh,tc_start,{config_static_SUITE,test_default_suitewide}}, + {?eh,tc_done,{config_static_SUITE,test_default_suitewide,ok}}, {?eh,test_stats,{3,0,{0,0}}}, - {?eh,tc_start,{config_1_SUITE,test_config_name_already_in_use1}}, + {?eh,tc_start,{config_static_SUITE,test_config_name_already_in_use1}}, {?eh,tc_done, - {config_1_SUITE,test_config_name_already_in_use1,{skipped,{config_name_already_in_use,[x1]}}}}, + {config_static_SUITE,test_config_name_already_in_use1,{skipped,{config_name_already_in_use,[x1]}}}}, {?eh,test_stats,{3,0,{1,0}}}, - {?eh,tc_start,{config_1_SUITE,test_default_tclocal}}, - {?eh,tc_done,{config_1_SUITE,test_default_tclocal,ok}}, + {?eh,tc_start,{config_static_SUITE,test_default_tclocal}}, + {?eh,tc_done,{config_static_SUITE,test_default_tclocal,ok}}, {?eh,test_stats,{4,0,{1,0}}}, - {?eh,tc_start,{config_1_SUITE,test_config_name_already_in_use2}}, + {?eh,tc_start,{config_static_SUITE,test_config_name_already_in_use2}}, {?eh,tc_done, - {config_1_SUITE,test_config_name_already_in_use2, + {config_static_SUITE,test_config_name_already_in_use2, {skipped,{config_name_already_in_use,[x1,alias]}}}}, {?eh,test_stats,{4,0,{2,0}}}, - {?eh,tc_start,{config_1_SUITE,test_alias_tclocal}}, - {?eh,tc_done,{config_1_SUITE,test_alias_tclocal,ok}}, + {?eh,tc_start,{config_static_SUITE,test_alias_tclocal}}, + {?eh,tc_done,{config_static_SUITE,test_alias_tclocal,ok}}, {?eh,test_stats,{5,0,{2,0}}}, - {?eh,tc_start,{config_1_SUITE,test_get_config_undefined}}, - {?eh,tc_done,{config_1_SUITE,test_get_config_undefined,ok}}, + {?eh,tc_start,{config_static_SUITE,test_get_config_undefined}}, + {?eh,tc_done,{config_static_SUITE,test_get_config_undefined,ok}}, {?eh,test_stats,{6,0,{2,0}}}, - {?eh,tc_start,{config_1_SUITE,end_per_suite}}, - {?eh,tc_done,{config_1_SUITE,end_per_suite,ok}}, + {?eh,tc_start,{config_static_SUITE,end_per_suite}}, + {?eh,tc_done,{config_static_SUITE,end_per_suite,ok}}, {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} ]; -expected_events(Dynamic) when Dynamic == testspec_dynamic; Dynamic == userconfig_dynamic-> +expected_events(config_dynamic_SUITE)-> [ {ct_test_support_eh,start_logging,{'DEF','RUNDIR'}}, {ct_test_support_eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, {ct_test_support_eh,start_info,{1,1,3}}, - {ct_test_support_eh,tc_start,{config_2_SUITE,init_per_suite}}, - {ct_test_support_eh,tc_done,{config_2_SUITE,init_per_suite,ok}}, - {ct_test_support_eh,tc_start,{config_2_SUITE,test_get_known_variable}}, - {ct_test_support_eh,tc_done,{config_2_SUITE,test_get_known_variable,ok}}, + {ct_test_support_eh,tc_start,{config_dynamic_SUITE,init_per_suite}}, + {ct_test_support_eh,tc_done,{config_dynamic_SUITE,init_per_suite,ok}}, + {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_get_known_variable}}, + {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_get_known_variable,ok}}, {ct_test_support_eh,test_stats,{1,0,{0,0}}}, - {ct_test_support_eh,tc_start,{config_2_SUITE,test_localtime_update}}, - {ct_test_support_eh,tc_done,{config_2_SUITE,test_localtime_update,ok}}, + {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_localtime_update}}, + {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_localtime_update,ok}}, {ct_test_support_eh,test_stats,{2,0,{0,0}}}, - {ct_test_support_eh,tc_start,{config_2_SUITE,test_server_pid}}, - {ct_test_support_eh,tc_done,{config_2_SUITE,test_server_pid,ok}}, + {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_server_pid}}, + {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_server_pid,ok}}, {ct_test_support_eh,test_stats,{3,0,{0,0}}}, - {ct_test_support_eh,tc_start,{config_2_SUITE,end_per_suite}}, - {ct_test_support_eh,tc_done,{config_2_SUITE,end_per_suite,ok}}, + {ct_test_support_eh,tc_start,{config_dynamic_SUITE,end_per_suite}}, + {ct_test_support_eh,tc_done,{config_dynamic_SUITE,end_per_suite,ok}}, {ct_test_support_eh,test_done,{'DEF','STOP_TIME'}}, {ct_test_support_eh,stop_logging,[]} ]. \ No newline at end of file diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl deleted file mode 100644 index e102c69d3d..0000000000 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl +++ /dev/null @@ -1,151 +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: config_1_SUITE -%%% -%%% Description: -%%% Test suite for common_test which tests the get_config and require -%%% functionality -%%%------------------------------------------------------------------- --module(config_1_SUITE). - --compile(export_all). - --include_lib("common_test/include/ct.hrl"). - -% The config contains variables: -% x - atom -% gen_cfg - list with two key-values tagged with a and b -% gen_cfg2 - list of five key-values tagged with c, d, e, f and g -% gen_cfg3 - list of two complex key-values taggen with: -% h: three elements inside - i, j and k -% l: m inside, contains n and o - -suite() -> - [ - {timetrap, {seconds,10}}, - %% x1 doesn't exist in cfg-file! - {require, x1, x}, - {require, gen_cfg3}, - {require, alias, gen_cfg}, - %% x1 default value - {x1, {x,suite}} - ]. - -% to get it running on development branch (without userconfig features) -% function to print full config is in the ct_util, for me it's moved to ct_config -% two following functions are only for the design period -% after merging of userconfigs to the main branch ct_config:get_all_config/0 -% should be called instead -is_exported(Module, Function, Arity)-> - Exports = Module:module_info(exports), - case lists:keyfind(Function, 1, Exports) of - false-> - false; - {Function, Arity}-> - true; - {Function, _OtherArity}-> - false - end. - -get_all_config()-> - case is_exported(ct_util, get_all_config, 0) of - true-> - {ct_util, ct_util:get_all_config()}; - false-> - {ct_config, ct_config:get_all_config()} - end. - -init_per_suite(Config) -> - %{Module, Cfg} = get_all_config(), - %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), - Config. - -end_per_suite(_) -> - ok. - -all() -> [test_get_config_simple, test_get_config_nested, test_default_suitewide, - test_config_name_already_in_use1, test_default_tclocal, - test_config_name_already_in_use2, test_alias_tclocal, - test_get_config_undefined]. - -init_per_testcase(_, Config) -> - %{Module, Cfg} = get_all_config(), - %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), - Config. - -end_per_testcase(_, _) -> - ok. - -%% test getting a simple value -test_get_config_simple(_)-> - suite = ct:get_config(x), - ok. - -%% test getting a nested value -test_get_config_nested(_)-> - a_value = ct:get_config({gen_cfg, a}), - ok. - -%% test suite-wide default value -test_default_suitewide(_)-> - suite = ct:get_config(x1), - ok. - -%% should get skipped -test_config_name_already_in_use1() -> - [{timetrap, {seconds,2}}, - {require, x1, x}, - {x1, {x,test2}}]. -test_config_name_already_in_use1(_) -> - ct:fail("Test should've been skipped, you shouldn't see this!"), - ok. - -%% test defaults in a testcase -test_default_tclocal() -> - [{timetrap, {seconds,3}}, - {require, y1, y}, - {y1, {y,test3}}]. -test_default_tclocal(_) -> - test3 = ct:get_config(y1), - ok. - -%% should get skipped -test_config_name_already_in_use2() -> - [{require,alias,something}, - {alias,{something,else}}, - {require, x1, x}, - {x1, {x,test4}}]. -test_config_name_already_in_use2(_) -> - ct:fail("Test should've been skipped, you shouldn't see this!"), - ok. - -%% test aliases -test_alias_tclocal() -> - [{require,newalias,gen_cfg}]. -test_alias_tclocal(_) -> - A = [{a,a_value},{b,b_value}] = ct:get_config(newalias), - A = ct:get_config(gen_cfg), - ok. - -%% test for getting undefined variables -test_get_config_undefined(_) -> - undefined = ct:get_config(y1), - ok. diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl deleted file mode 100644 index 86fd300a77..0000000000 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl +++ /dev/null @@ -1,133 +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_config_SUITE -%%% -%%% Description: -%%% Test suite for common_test which tests the userconfig functionality -%%%------------------------------------------------------------------- --module(config_2_SUITE). - --compile(export_all). - --include_lib("common_test/include/ct.hrl"). - -%% This suite will be run with dynamic userconfig -%% test_driver.erl is compliant to ct_config_* callback -%% and test_server is simple server for getting runtime-changing data -%% which will return the list with the following variables: -%% localtime = the erlang:localtime() result in list [{date, Date}, {time, Time}] -%% node = erlang:node() - can be compared in the testcase -%% now = erlang:now() - easier to compare than localtime() -%% config_server_pid - pid of the config server, should NOT change! -%% config_server_vsn - .19 - -suite() -> - [ - {timetrap, {seconds,10}} - ]. - -% to get it running on development branch (without userconfig features) -% function to print full config is in the ct_util, for me it's moved to ct_config -% two following functions are only for the design period -% after merging of userconfigs to the main branch ct_config:get_all_config/0 -% should be called instead -is_exported(Module, Function, Arity)-> - Exports = Module:module_info(exports), - case lists:keyfind(Function, 1, Exports) of - false-> - false; - {Function, Arity}-> - true; - {Function, _OtherArity}-> - false - end. - -get_all_config()-> - case is_exported(ct_util, get_all_config, 0) of - true-> - {ct_util, ct_util:get_all_config()}; - false-> - {ct_config, ct_config:get_all_config()} - end. - -init_per_suite(Config) -> - %{Module, Cfg} = get_all_config(), - %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), - Config. - -end_per_suite(_) -> - ok. - -all() -> [test_get_known_variable, test_localtime_update, - test_server_pid]. - -init_per_testcase(_, Config) -> - %{Module, Cfg} = get_all_config(), - %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), - Config. - -end_per_testcase(_, _) -> - ok. - -% test that usual config works -test_get_known_variable(_)-> - Node = erlang:node(), - 0.19 = ct:get_config(config_server_vsn), - Node = ct:get_config(node), - ok. - -% localtime will be updated in 5 seconds, check that -test_localtime_update(_)-> - Seconds = 5, - LT1 = ct:get_config(localtime), - timer:sleep(Seconds*1000), - LT2 = ct:reload_config(localtime), - case is_diff_ok(LT1, LT2, Seconds) of - {false, Actual, Exp}-> - ct:fail(io_lib:format("Time difference ~p is not ok, expected ~p", [Actual, Exp])); - true-> - ok - end. - -% server pid should not change -test_server_pid()-> - [{require, cfvsn, config_server_vsn}]. -test_server_pid(_)-> - Pid = ct:get_config(config_server_pid), - Pid = ct:reload_config(config_server_pid), - Vsn = ct:get_config(config_server_vsn), - % aliases remain after config reloading - Vsn = ct:get_config(cfvsn), - ok. - -my_dt_to_datetime([{date, D},{time, T}])-> - {D, T}. - -is_diff_ok(DT1, DT2, Seconds)-> - GS1 = calendar:datetime_to_gregorian_seconds(my_dt_to_datetime(DT1)), - GS2 = calendar:datetime_to_gregorian_seconds(my_dt_to_datetime(DT2)), - if - GS2-GS1 > Seconds+Seconds/2; - GS2-GS1 < Seconds-Seconds/2-> - {false, GS2-GS1, Seconds}; - true-> - true - end. diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl new file mode 100644 index 0000000000..1013c46c7d --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl @@ -0,0 +1,172 @@ +%% +%% %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_config_SUITE +%%% +%%% Description: +%%% Test suite for common_test which tests the userconfig functionality +%%%------------------------------------------------------------------- +-module(config_2_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%% This suite will be run with dynamic userconfig +%% test_driver.erl is compliant to ct_config_* callback +%% and test_server is simple server for getting runtime-changing data +%% which will return the list with the following variables: +%% localtime = the erlang:localtime() result in list [{date, Date}, {time, Time}] +%% node = erlang:node() - can be compared in the testcase +%% now = erlang:now() - easier to compare than localtime() +%% config_server_pid - pid of the config server, should NOT change! +%% config_server_vsn - .19 +%% config_server_iteration - a number of iteration config_server's loop done +%% disappearable_variable - hereAmI - will be absent on even iterations + +suite() -> + [ + {timetrap, {seconds,10}} + ]. + +% to get it running on development branch (without userconfig features) +% function to print full config is in the ct_util, for me it's moved to ct_config +% two following functions are only for the design period +% after merging of userconfigs to the main branch ct_config:get_all_config/0 +% should be called instead +is_exported(Module, Function, Arity)-> + Exports = Module:module_info(exports), + case lists:keyfind(Function, 1, Exports) of + false-> + false; + {Function, Arity}-> + true; + {Function, _OtherArity}-> + false + end. + +get_all_config()-> + case is_exported(ct_util, get_all_config, 0) of + true-> + {ct_util, ct_util:get_all_config()}; + false-> + {ct_config, ct_config:get_all_config()} + end. + +init_per_suite(Config) -> + %{Module, Cfg} = get_all_config(), + %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + Config. + +end_per_suite(_) -> + ok. + +all() -> [test_get_known_variable, test_localtime_update, + test_server_pid, test_disappearable_variable, + test_disappearable_variable_alias]. + +init_per_testcase(_, Config) -> + %{Module, Cfg} = get_all_config(), + %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + Config. + +end_per_testcase(_, _) -> + ok. + +% test that usual config works +test_get_known_variable(_)-> + Node = erlang:node(), + 0.19 = ct:get_config(config_server_vsn), + Node = ct:get_config(node), + ok. + +% localtime will be updated in 5 seconds, check that +test_localtime_update(_)-> + Seconds = 5, + LT1 = ct:get_config(localtime), + timer:sleep(Seconds*1000), + LT2 = ct:reload_config(localtime), + case is_diff_ok(LT1, LT2, Seconds) of + {false, Actual, Exp}-> + ct:fail(io_lib:format("Time difference ~p is not ok, expected ~p", [Actual, Exp])); + true-> + ok + end. + +% server pid should not change +test_server_pid()-> + [{require, cfvsn, config_server_vsn}]. +test_server_pid(_)-> + Pid = ct:get_config(config_server_pid), + Pid = ct:reload_config(config_server_pid), + Vsn = ct:get_config(config_server_vsn), + % aliases remain after config reloading + Vsn = ct:get_config(cfvsn), + ok. + +% test that variables may disappear from the config_2_SUITE +test_disappearable_variable(_)-> + % ask CT for config_server_iteration variable + Iter = ct:reload_config(config_server_iteration), + % here we should reload this variable in case it's odd + if Iter rem 2 == 1-> + Iter2 = ct:reload_config(config_server_iteration), + Iter2 = Iter+1; + true->ok + end, + % now disappearable_variable should be in place + hereAmI = ct:get_config(disappearable_variable), + % and now it should disappear + undefined = ct:reload_config(disappearable_variable). + +% alias of disappearable_variable should disappear too +test_disappearable_variable_alias(_)-> + % the same rules apply for this testcase as for previous one + Iter = ct:reload_config(config_server_iteration), + Iter2 = if + Iter rem 2 == 1 -> + NewIter = ct:reload_config(config_server_iteration), + NewIter = Iter+1; + true-> + Iter + end, + ct:require(diav, disappearable_variable), + hereAmI = ct:get_config(disappearable_variable), + hereAmI = ct:get_config(diav), + undefined = ct:reload_config(disappearable_variable), + % after reloading, it's even again + Iter3=ct:get_config(config_server_iteration), + Iter3 = Iter2+1, + % and alias does not exist + undefined = ct:get_config(diav). + +my_dt_to_datetime([{date, D},{time, T}])-> + {D, T}. + +is_diff_ok(DT1, DT2, Seconds)-> + GS1 = calendar:datetime_to_gregorian_seconds(my_dt_to_datetime(DT1)), + GS2 = calendar:datetime_to_gregorian_seconds(my_dt_to_datetime(DT2)), + if + GS2-GS1 > Seconds+Seconds/2; + GS2-GS1 < Seconds-Seconds/2-> + {false, GS2-GS1, Seconds}; + true-> + true + end. diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl index 0ee0bcfc22..f56bdf15ad 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl @@ -24,7 +24,7 @@ %%% Config server used in the CT's tests (config_2_SUITE) %%%------------------------------------------------------------------- -module(config_server). --export([start/0, stop/0, init/1, get_config/0, loop/0]). +-export([start/0, stop/0, loop/1, init/1, get_config/0]). -define(REGISTERED_NAME, ct_test_config_server). -define(vsn, 0.19). @@ -41,7 +41,7 @@ start()-> init(Name)-> register(Name, self()), - loop(). + loop(0). get_config()-> call(self(), get_config). @@ -63,19 +63,25 @@ call(Client, Request)-> end end. -loop()-> +loop(Iteration)-> receive {Pid, stop}-> Pid ! ok; {Pid, get_config}-> {D,T} = erlang:localtime(), - Pid ! + Config = [{localtime, [{date, D}, {time, T}]}, {node, erlang:node()}, + {config_server_iteration, Iteration}, {now, erlang:now()}, {config_server_pid, self()}, {config_server_vsn, ?vsn}], - ?MODULE:loop() + Config2 = if Iteration rem 2 == 0-> + Config ++ [{disappearable_variable, hereAmI}]; + true-> Config + end, + Pid ! Config2, + ?MODULE:loop(Iteration+1) end. wait()-> diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl new file mode 100644 index 0000000000..e102c69d3d --- /dev/null +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl @@ -0,0 +1,151 @@ +%% +%% %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: config_1_SUITE +%%% +%%% Description: +%%% Test suite for common_test which tests the get_config and require +%%% functionality +%%%------------------------------------------------------------------- +-module(config_1_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +% The config contains variables: +% x - atom +% gen_cfg - list with two key-values tagged with a and b +% gen_cfg2 - list of five key-values tagged with c, d, e, f and g +% gen_cfg3 - list of two complex key-values taggen with: +% h: three elements inside - i, j and k +% l: m inside, contains n and o + +suite() -> + [ + {timetrap, {seconds,10}}, + %% x1 doesn't exist in cfg-file! + {require, x1, x}, + {require, gen_cfg3}, + {require, alias, gen_cfg}, + %% x1 default value + {x1, {x,suite}} + ]. + +% to get it running on development branch (without userconfig features) +% function to print full config is in the ct_util, for me it's moved to ct_config +% two following functions are only for the design period +% after merging of userconfigs to the main branch ct_config:get_all_config/0 +% should be called instead +is_exported(Module, Function, Arity)-> + Exports = Module:module_info(exports), + case lists:keyfind(Function, 1, Exports) of + false-> + false; + {Function, Arity}-> + true; + {Function, _OtherArity}-> + false + end. + +get_all_config()-> + case is_exported(ct_util, get_all_config, 0) of + true-> + {ct_util, ct_util:get_all_config()}; + false-> + {ct_config, ct_config:get_all_config()} + end. + +init_per_suite(Config) -> + %{Module, Cfg} = get_all_config(), + %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + Config. + +end_per_suite(_) -> + ok. + +all() -> [test_get_config_simple, test_get_config_nested, test_default_suitewide, + test_config_name_already_in_use1, test_default_tclocal, + test_config_name_already_in_use2, test_alias_tclocal, + test_get_config_undefined]. + +init_per_testcase(_, Config) -> + %{Module, Cfg} = get_all_config(), + %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), + Config. + +end_per_testcase(_, _) -> + ok. + +%% test getting a simple value +test_get_config_simple(_)-> + suite = ct:get_config(x), + ok. + +%% test getting a nested value +test_get_config_nested(_)-> + a_value = ct:get_config({gen_cfg, a}), + ok. + +%% test suite-wide default value +test_default_suitewide(_)-> + suite = ct:get_config(x1), + ok. + +%% should get skipped +test_config_name_already_in_use1() -> + [{timetrap, {seconds,2}}, + {require, x1, x}, + {x1, {x,test2}}]. +test_config_name_already_in_use1(_) -> + ct:fail("Test should've been skipped, you shouldn't see this!"), + ok. + +%% test defaults in a testcase +test_default_tclocal() -> + [{timetrap, {seconds,3}}, + {require, y1, y}, + {y1, {y,test3}}]. +test_default_tclocal(_) -> + test3 = ct:get_config(y1), + ok. + +%% should get skipped +test_config_name_already_in_use2() -> + [{require,alias,something}, + {alias,{something,else}}, + {require, x1, x}, + {x1, {x,test4}}]. +test_config_name_already_in_use2(_) -> + ct:fail("Test should've been skipped, you shouldn't see this!"), + ok. + +%% test aliases +test_alias_tclocal() -> + [{require,newalias,gen_cfg}]. +test_alias_tclocal(_) -> + A = [{a,a_value},{b,b_value}] = ct:get_config(newalias), + A = ct:get_config(gen_cfg), + ok. + +%% test for getting undefined variables +test_get_config_undefined(_) -> + undefined = ct:get_config(y1), + ok. -- cgit v1.2.3 From dd67e73980ac0c8b601079c2e3f27701c367936c Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Thu, 18 Mar 2010 18:02:37 +0100 Subject: Fix problem with disappearing variables and aliases --- lib/common_test/test/ct_config_SUITE.erl | 47 +++++++++++++--------- .../config/test/config_dynamic_SUITE.erl | 5 ++- .../config/test/config_static_SUITE.erl | 2 +- 3 files changed, 33 insertions(+), 21 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl index a7fa6fe52e..9a0177c2ec 100644 --- a/lib/common_test/test/ct_config_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE.erl @@ -211,22 +211,33 @@ expected_events(config_static_SUITE)-> expected_events(config_dynamic_SUITE)-> [ - {ct_test_support_eh,start_logging,{'DEF','RUNDIR'}}, - {ct_test_support_eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {ct_test_support_eh,start_info,{1,1,3}}, - {ct_test_support_eh,tc_start,{config_dynamic_SUITE,init_per_suite}}, - {ct_test_support_eh,tc_done,{config_dynamic_SUITE,init_per_suite,ok}}, - {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_get_known_variable}}, - {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_get_known_variable,ok}}, - {ct_test_support_eh,test_stats,{1,0,{0,0}}}, - {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_localtime_update}}, - {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_localtime_update,ok}}, - {ct_test_support_eh,test_stats,{2,0,{0,0}}}, - {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_server_pid}}, - {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_server_pid,ok}}, - {ct_test_support_eh,test_stats,{3,0,{0,0}}}, - {ct_test_support_eh,tc_start,{config_dynamic_SUITE,end_per_suite}}, - {ct_test_support_eh,tc_done,{config_dynamic_SUITE,end_per_suite,ok}}, - {ct_test_support_eh,test_done,{'DEF','STOP_TIME'}}, - {ct_test_support_eh,stop_logging,[]} + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{1,1,5}}, + {?eh,tc_start,{config_dynamic_SUITE,init_per_suite}}, + {?eh,tc_done,{config_dynamic_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{config_dynamic_SUITE,test_get_known_variable}}, + {?eh,tc_done, + {config_dynamic_SUITE,test_get_known_variable,ok}}, + {?eh,test_stats,{1,0,{0,0}}}, + {?eh,tc_start,{config_dynamic_SUITE,test_localtime_update}}, + {?eh,tc_done,{config_dynamic_SUITE,test_localtime_update,ok}}, + {?eh,test_stats,{2,0,{0,0}}}, + {?eh,tc_start,{config_dynamic_SUITE,test_server_pid}}, + {?eh,tc_done,{config_dynamic_SUITE,test_server_pid,ok}}, + {?eh,test_stats,{3,0,{0,0}}}, + {?eh,tc_start, + {config_dynamic_SUITE,test_disappearable_variable}}, + {?eh,tc_done, + {config_dynamic_SUITE,test_disappearable_variable,ok}}, + {?eh,test_stats,{4,0,{0,0}}}, + {?eh,tc_start, + {config_dynamic_SUITE,test_disappearable_variable_alias}}, + {?eh,tc_done, + {config_dynamic_SUITE,test_disappearable_variable_alias,ok}}, + {?eh,test_stats,{5,0,{0,0}}}, + {?eh,tc_start,{config_dynamic_SUITE,end_per_suite}}, + {?eh,tc_done,{config_dynamic_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} ]. \ No newline at end of file diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl index 1013c46c7d..ae66d4e9bf 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl @@ -23,7 +23,7 @@ %%% Description: %%% Test suite for common_test which tests the userconfig functionality %%%------------------------------------------------------------------- --module(config_2_SUITE). +-module(config_dynamic_SUITE). -compile(export_all). @@ -150,7 +150,8 @@ test_disappearable_variable_alias(_)-> ct:require(diav, disappearable_variable), hereAmI = ct:get_config(disappearable_variable), hereAmI = ct:get_config(diav), - undefined = ct:reload_config(disappearable_variable), + ct:reload_config(disappearable_variable), + undefined = ct:get_config(disappearable_variable), % after reloading, it's even again Iter3=ct:get_config(config_server_iteration), Iter3 = Iter2+1, diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl index e102c69d3d..d3f07980bc 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl @@ -24,7 +24,7 @@ %%% Test suite for common_test which tests the get_config and require %%% functionality %%%------------------------------------------------------------------- --module(config_1_SUITE). +-module(config_static_SUITE). -compile(export_all). -- cgit v1.2.3 From 2fa838d02446ad54588c2fe6995e3c065e99ec9c Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Mon, 22 Mar 2010 15:29:28 +0100 Subject: Add functions for adding and removing config handlers This is a draft version. --- lib/common_test/test/ct_config_SUITE.erl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl index 9a0177c2ec..168225feff 100644 --- a/lib/common_test/test/ct_config_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE.erl @@ -134,7 +134,6 @@ testspec_dynamic(Config) when is_list(Config) -> %%%----------------------------------------------------------------- %%% HELP FUNCTIONS %%%----------------------------------------------------------------- -% {suites, "ct_config_SUITE_data/config/test", config_dynamic_SUITE}. make_spec(DataDir, Filename, Suites, Config)-> {ok, Fd} = file:open(filename:join(DataDir, Filename), [write]), ok = file:write(Fd, @@ -240,4 +239,4 @@ expected_events(config_dynamic_SUITE)-> {?eh,tc_done,{config_dynamic_SUITE,end_per_suite,ok}}, {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} -]. \ No newline at end of file +]. -- cgit v1.2.3 From 497c107bcdb7095f402d4b9884b0bfc8f9bbe97f Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Wed, 24 Mar 2010 11:35:59 +0100 Subject: Add support for user_config in ct_master --- lib/common_test/test/ct_config_SUITE_data/config/config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_config_SUITE_data/config/config.txt b/lib/common_test/test/ct_config_SUITE_data/config/config.txt index 0424dbf92e..fcbffcd7f3 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/config.txt +++ b/lib/common_test/test/ct_config_SUITE_data/config/config.txt @@ -28,4 +28,4 @@ {o, 'O'} ]} ]} - ]}. \ No newline at end of file + ]}. -- cgit v1.2.3 From 2c711e660df6683eee9cdfeb204e02f093153c36 Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Thu, 25 Mar 2010 11:42:26 +0100 Subject: Add test suites for ct_master Also includes minor documentation updates. --- lib/common_test/test/Makefile | 3 +- lib/common_test/test/ct_config_SUITE.erl | 4 - .../config/test/config_dynamic_SUITE.erl | 30 +--- .../config/test/config_static_SUITE.erl | 30 +--- lib/common_test/test/ct_master_SUITE.erl | 191 +++++++++++++++++++++ .../test/ct_master_SUITE_data/master/config.txt | 2 + .../test/ct_master_SUITE_data/master/config.xml | 4 + .../ct_master_SUITE_data/master/master_SUITE.erl | 57 ++++++ lib/common_test/test/ct_test_support.erl | 11 +- 9 files changed, 267 insertions(+), 65 deletions(-) create mode 100644 lib/common_test/test/ct_master_SUITE.erl create mode 100644 lib/common_test/test/ct_master_SUITE_data/master/config.txt create mode 100644 lib/common_test/test/ct_master_SUITE_data/master/config.xml create mode 100644 lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index 2b0a06871e..eca6817682 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -34,7 +34,8 @@ MODULES= \ ct_skip_SUITE \ ct_error_SUITE \ ct_test_server_if_1_SUITE \ - ct_config_SUITE + ct_config_SUITE \ + ct_master_SUITE ERL_FILES= $(MODULES:%=%.erl) diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl index 168225feff..7c0c88e76b 100644 --- a/lib/common_test/test/ct_config_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE.erl @@ -69,13 +69,9 @@ all(suite) -> testspec_dynamic ]. - %%-------------------------------------------------------------------- %% TEST CASES %%-------------------------------------------------------------------- - -%%%----------------------------------------------------------------- -%%% require(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), run_test(config_static_SUITE, diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl index ae66d4e9bf..b7b2e8f16c 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl @@ -18,7 +18,7 @@ %% %%%------------------------------------------------------------------- -%%% File: ct_config_SUITE +%%% File: config_dynamic_SUITE %%% %%% Description: %%% Test suite for common_test which tests the userconfig functionality @@ -46,33 +46,7 @@ suite() -> {timetrap, {seconds,10}} ]. -% to get it running on development branch (without userconfig features) -% function to print full config is in the ct_util, for me it's moved to ct_config -% two following functions are only for the design period -% after merging of userconfigs to the main branch ct_config:get_all_config/0 -% should be called instead -is_exported(Module, Function, Arity)-> - Exports = Module:module_info(exports), - case lists:keyfind(Function, 1, Exports) of - false-> - false; - {Function, Arity}-> - true; - {Function, _OtherArity}-> - false - end. - -get_all_config()-> - case is_exported(ct_util, get_all_config, 0) of - true-> - {ct_util, ct_util:get_all_config()}; - false-> - {ct_config, ct_config:get_all_config()} - end. - init_per_suite(Config) -> - %{Module, Cfg} = get_all_config(), - %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), Config. end_per_suite(_) -> @@ -83,8 +57,6 @@ all() -> [test_get_known_variable, test_localtime_update, test_disappearable_variable_alias]. init_per_testcase(_, Config) -> - %{Module, Cfg} = get_all_config(), - %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), Config. end_per_testcase(_, _) -> diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl index d3f07980bc..262417fe1c 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl @@ -18,7 +18,7 @@ %% %%%------------------------------------------------------------------- -%%% File: config_1_SUITE +%%% File: config_static_SUITE %%% %%% Description: %%% Test suite for common_test which tests the get_config and require @@ -49,33 +49,7 @@ suite() -> {x1, {x,suite}} ]. -% to get it running on development branch (without userconfig features) -% function to print full config is in the ct_util, for me it's moved to ct_config -% two following functions are only for the design period -% after merging of userconfigs to the main branch ct_config:get_all_config/0 -% should be called instead -is_exported(Module, Function, Arity)-> - Exports = Module:module_info(exports), - case lists:keyfind(Function, 1, Exports) of - false-> - false; - {Function, Arity}-> - true; - {Function, _OtherArity}-> - false - end. - -get_all_config()-> - case is_exported(ct_util, get_all_config, 0) of - true-> - {ct_util, ct_util:get_all_config()}; - false-> - {ct_config, ct_config:get_all_config()} - end. - init_per_suite(Config) -> - %{Module, Cfg} = get_all_config(), - %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), Config. end_per_suite(_) -> @@ -87,8 +61,6 @@ all() -> [test_get_config_simple, test_get_config_nested, test_default_suitewide test_get_config_undefined]. init_per_testcase(_, Config) -> - %{Module, Cfg} = get_all_config(), - %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]), Config. end_per_testcase(_, _) -> diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl new file mode 100644 index 0000000000..a2eaf98e34 --- /dev/null +++ b/lib/common_test/test/ct_master_SUITE.erl @@ -0,0 +1,191 @@ +%% +%% %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_master_SUITE +%%% +%%% Description: +%%% Test ct_master. +%%% +%%% The suites used for the test are located in the data directory. +%%%------------------------------------------------------------------- +-module(ct_master_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) -> + Config1 = ct_test_support:init_per_suite(Config), + Config1. + +end_per_suite(Config) -> + ct_test_support:end_per_suite(Config). + +init_per_testcase(TestCase, Config) -> + ct_test_support:init_per_testcase(TestCase, [{master, true}|Config]). + +end_per_testcase(TestCase, Config) -> + ct_test_support:end_per_testcase(TestCase, Config). + +all(doc) -> + [""]; + +all(suite) -> + [ + ct_master_test_peer, + ct_master_test_slave + ]. + +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- +ct_master_test_peer(Config) when is_list(Config)-> + NodeCount = 5, + DataDir = ?config(data_dir, Config), + NodeNames = [list_to_atom("testnode_"++integer_to_list(N)) || + N <- lists:seq(1, NodeCount)], + FileName = filename:join(DataDir, "ct_master_spec.spec"), + Suites = [master_SUITE], + make_spec(DataDir, FileName, NodeNames, Suites, Config), + start_nodes(NodeNames, peer), + run_test(ct_master_test, FileName, Config), + stop_nodes(NodeNames, peer), + file:delete(filename:join(DataDir, FileName)). + +ct_master_test_slave(Config) when is_list(Config)-> + NodeCount = 5, + DataDir = ?config(data_dir, Config), + NodeNames = [list_to_atom("testnode_"++integer_to_list(N)) || + N <- lists:seq(1, NodeCount)], + FileName = filename:join(DataDir, "ct_master_spec.spec"), + Suites = [master_SUITE], + make_spec(DataDir, FileName, NodeNames, Suites, Config), + start_nodes(NodeNames, slave), + run_test(ct_master_test, FileName, Config), + stop_nodes(NodeNames, slave), + file:delete(filename:join(DataDir, FileName)). + +%%%----------------------------------------------------------------- +%%% HELP FUNCTIONS +%%%----------------------------------------------------------------- +make_spec(DataDir, FileName, NodeNames, Suites, Config)-> + {ok, HostName} = inet:gethostname(), + + N = lists:map(fun(NodeName)-> + {node, NodeName, enodename(HostName, NodeName)} + end, + NodeNames), + + C = lists:map(fun(NodeName)-> + Rnd = random:uniform(2), + if Rnd == 1-> + {config, NodeName, "master/config.txt"}; + true-> + {userconfig, NodeName, {ct_config_xml, "master/config.xml"}} + end + end, + NodeNames), + + S = [{suites, NodeNames, filename:join(DataDir, "master"), Suites}], + + PrivDir = ?config(priv_dir, Config), + LD = [{logdir, PrivDir}, {logdir, master, PrivDir}], + + ct_test_support:write_testspec(N++C++S++LD, DataDir, FileName). + +run_test(_Name, FileName, Config)-> + [{FileName, ok}] = ct_test_support:run(ct_master, run, [FileName], Config). + +wait_for_node_alive(_Node, 0)-> + pang; +wait_for_node_alive(Node, N)-> + timer:sleep(1000), + case net_adm:ping(Node) of + pong-> + pong; + pang-> + wait_for_node_alive(Node, N-1) + end. + +wait_for_node_dead(_Node, 0)-> + error; +wait_for_node_dead(Node, N)-> + timer:sleep(1000), + case lists:member(Node, nodes()) of + true-> + wait_for_node_dead(Node, N-1); + false-> + ok + end. + +enodename(HostName, NodeName)-> + list_to_atom(atom_to_list(NodeName)++"@"++HostName). + +start_node(HostName, NodeName, peer)-> + ENodeName = enodename(HostName, NodeName), + Cmd = "erl -detached -noinput -sname "++atom_to_list(NodeName), + open_port({spawn, Cmd}, [stream]), + pong = wait_for_node_alive(ENodeName, 3); +start_node(HostName, NodeName, slave)-> + ENodeName = enodename(HostName, NodeName), + {ok, ENodeName} = + slave:start(list_to_atom(HostName), NodeName). + +stop_node(HostName, NodeName, peer)-> + ENodeName = enodename(HostName, NodeName), + spawn(ENodeName, init, stop, []), + wait_for_node_dead(ENodeName, 3); +stop_node(HostName, NodeName, slave)-> + ENodeName = enodename(HostName, NodeName), + ok = slave:stop(ENodeName). + +start_nodes(NodeNames, Type)-> + {ok, HostName} = inet:gethostname(), + lists:foreach(fun(NodeName)-> + start_node(HostName, NodeName, Type) + end, + NodeNames). + +stop_nodes(NodeNames, Type)-> + {ok, HostName} = inet:gethostname(), + lists:foreach(fun(NodeName)-> + stop_node(HostName, NodeName, Type) + end, + NodeNames). + +reformat_events(Events, EH) -> + ct_test_support:reformat(Events, EH). + +%%%----------------------------------------------------------------- +%%% TEST EVENTS +%%%----------------------------------------------------------------- +expected_events(_)-> +[]. diff --git a/lib/common_test/test/ct_master_SUITE_data/master/config.txt b/lib/common_test/test/ct_master_SUITE_data/master/config.txt new file mode 100644 index 0000000000..3baf9e392c --- /dev/null +++ b/lib/common_test/test/ct_master_SUITE_data/master/config.txt @@ -0,0 +1,2 @@ +{a, b}. +{c, d}. diff --git a/lib/common_test/test/ct_master_SUITE_data/master/config.xml b/lib/common_test/test/ct_master_SUITE_data/master/config.xml new file mode 100644 index 0000000000..c031f45f35 --- /dev/null +++ b/lib/common_test/test/ct_master_SUITE_data/master/config.xml @@ -0,0 +1,4 @@ + + b + d + diff --git a/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl b/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl new file mode 100644 index 0000000000..1d05d1ac9a --- /dev/null +++ b/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl @@ -0,0 +1,57 @@ +%% +%% %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: master_SUITE +%%% +%%% Description: +%%% Test suite for common_test which tests the ct_master functionality +%%%------------------------------------------------------------------- +-module(master_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +suite() -> + []. + +init_per_suite(Config) -> + Config. + +end_per_suite(_) -> + ok. + +all() -> [first_testcase, second_testcase, third_testcase]. + +init_per_testcase(_, Config) -> + Config. + +end_per_testcase(_, _) -> + ok. + +first_testcase(_)-> + b = ct:get_config(a). + +second_testcase(_)-> + d = ct:get_config(c). + +third_testcase(_)-> + A = 4, + A = 2*2. diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index 4aa750c37f..0ce103e111 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -102,9 +102,16 @@ end_per_suite(Config) -> init_per_testcase(_TestCase, Config) -> {_,{_,LogDir}} = lists:keysearch(logdir, 1, get_opts(Config)), - test_server:format("See Common Test logs here:\n" + case lists:keysearch(master, 1, Config) of + false-> + test_server:format("See Common Test logs here:\n" "~s/all_runs.html", - [LogDir,LogDir]), + [LogDir,LogDir]); + {value, _}-> + test_server:format("See CT Master Test logs here:\n" + "~s/master_runs.html", + [LogDir,LogDir]) + end, Config. %%%----------------------------------------------------------------- -- cgit v1.2.3 From dbecad9f8004f0a9b53ebdeb1ce8bde35dca7663 Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Thu, 8 Apr 2010 18:56:40 +0200 Subject: Introduce ct_slave module --- lib/common_test/test/ct_master_SUITE.erl | 91 +++++++------------------------- 1 file changed, 20 insertions(+), 71 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl index a2eaf98e34..ebd399ad64 100644 --- a/lib/common_test/test/ct_master_SUITE.erl +++ b/lib/common_test/test/ct_master_SUITE.erl @@ -60,37 +60,23 @@ all(doc) -> all(suite) -> [ - ct_master_test_peer, - ct_master_test_slave + ct_master_test ]. %%-------------------------------------------------------------------- %% TEST CASES %%-------------------------------------------------------------------- -ct_master_test_peer(Config) when is_list(Config)-> +ct_master_test(Config) when is_list(Config)-> NodeCount = 5, DataDir = ?config(data_dir, Config), NodeNames = [list_to_atom("testnode_"++integer_to_list(N)) || N <- lists:seq(1, NodeCount)], FileName = filename:join(DataDir, "ct_master_spec.spec"), Suites = [master_SUITE], - make_spec(DataDir, FileName, NodeNames, Suites, Config), - start_nodes(NodeNames, peer), - run_test(ct_master_test, FileName, Config), - stop_nodes(NodeNames, peer), - file:delete(filename:join(DataDir, FileName)). - -ct_master_test_slave(Config) when is_list(Config)-> - NodeCount = 5, - DataDir = ?config(data_dir, Config), - NodeNames = [list_to_atom("testnode_"++integer_to_list(N)) || - N <- lists:seq(1, NodeCount)], - FileName = filename:join(DataDir, "ct_master_spec.spec"), - Suites = [master_SUITE], - make_spec(DataDir, FileName, NodeNames, Suites, Config), - start_nodes(NodeNames, slave), - run_test(ct_master_test, FileName, Config), - stop_nodes(NodeNames, slave), + TSFile = make_spec(DataDir, FileName, NodeNames, Suites, Config), + start_nodes(NodeNames), + [{TSFile, ok}] = run_test(ct_master_test, FileName, Config), + stop_nodes(NodeNames), file:delete(filename:join(DataDir, FileName)). %%%----------------------------------------------------------------- @@ -100,7 +86,7 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> {ok, HostName} = inet:gethostname(), N = lists:map(fun(NodeName)-> - {node, NodeName, enodename(HostName, NodeName)} + {node, NodeName, list_to_atom(atom_to_list(NodeName)++"@"++HostName)} end, NodeNames), @@ -117,67 +103,30 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> S = [{suites, NodeNames, filename:join(DataDir, "master"), Suites}], PrivDir = ?config(priv_dir, Config), - LD = [{logdir, PrivDir}, {logdir, master, PrivDir}], + LD = lists:map(fun(NodeName)-> + {logdir, NodeName, get_log_dir(PrivDir, NodeName)} + end, + NodeNames) ++ [{logdir, master, PrivDir}], ct_test_support:write_testspec(N++C++S++LD, DataDir, FileName). +get_log_dir(PrivDir, NodeName)-> + LogDir = filename:join(PrivDir, io_lib:format("slave.~p", [NodeName])), + file:make_dir(LogDir), + LogDir. + run_test(_Name, FileName, Config)-> [{FileName, ok}] = ct_test_support:run(ct_master, run, [FileName], Config). -wait_for_node_alive(_Node, 0)-> - pang; -wait_for_node_alive(Node, N)-> - timer:sleep(1000), - case net_adm:ping(Node) of - pong-> - pong; - pang-> - wait_for_node_alive(Node, N-1) - end. - -wait_for_node_dead(_Node, 0)-> - error; -wait_for_node_dead(Node, N)-> - timer:sleep(1000), - case lists:member(Node, nodes()) of - true-> - wait_for_node_dead(Node, N-1); - false-> - ok - end. - -enodename(HostName, NodeName)-> - list_to_atom(atom_to_list(NodeName)++"@"++HostName). - -start_node(HostName, NodeName, peer)-> - ENodeName = enodename(HostName, NodeName), - Cmd = "erl -detached -noinput -sname "++atom_to_list(NodeName), - open_port({spawn, Cmd}, [stream]), - pong = wait_for_node_alive(ENodeName, 3); -start_node(HostName, NodeName, slave)-> - ENodeName = enodename(HostName, NodeName), - {ok, ENodeName} = - slave:start(list_to_atom(HostName), NodeName). - -stop_node(HostName, NodeName, peer)-> - ENodeName = enodename(HostName, NodeName), - spawn(ENodeName, init, stop, []), - wait_for_node_dead(ENodeName, 3); -stop_node(HostName, NodeName, slave)-> - ENodeName = enodename(HostName, NodeName), - ok = slave:stop(ENodeName). - -start_nodes(NodeNames, Type)-> - {ok, HostName} = inet:gethostname(), +start_nodes(NodeNames)-> lists:foreach(fun(NodeName)-> - start_node(HostName, NodeName, Type) + {ok, _}=ct_slave:start(NodeName) end, NodeNames). -stop_nodes(NodeNames, Type)-> - {ok, HostName} = inet:gethostname(), +stop_nodes(NodeNames)-> lists:foreach(fun(NodeName)-> - stop_node(HostName, NodeName, Type) + {ok, _}=ct_slave:stop(NodeName) end, NodeNames). -- cgit v1.2.3 From 05f69de43fc8f95baab30e940cd80df86a433e1e Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Mon, 12 Apr 2010 15:46:16 +0200 Subject: Improve eval and node_start and add new options for ct_slave --- lib/common_test/test/ct_master_SUITE.erl | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl index ebd399ad64..3618b08a74 100644 --- a/lib/common_test/test/ct_master_SUITE.erl +++ b/lib/common_test/test/ct_master_SUITE.erl @@ -74,9 +74,7 @@ ct_master_test(Config) when is_list(Config)-> FileName = filename:join(DataDir, "ct_master_spec.spec"), Suites = [master_SUITE], TSFile = make_spec(DataDir, FileName, NodeNames, Suites, Config), - start_nodes(NodeNames), [{TSFile, ok}] = run_test(ct_master_test, FileName, Config), - stop_nodes(NodeNames), file:delete(filename:join(DataDir, FileName)). %%%----------------------------------------------------------------- @@ -100,6 +98,11 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> end, NodeNames), + NS = lists:map(fun(NodeName)-> + {node_start, NodeName, [{startup_functions, [{io, format, ["hello, world~n"]}]}]} + end, + NodeNames), + S = [{suites, NodeNames, filename:join(DataDir, "master"), Suites}], PrivDir = ?config(priv_dir, Config), @@ -108,7 +111,7 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> end, NodeNames) ++ [{logdir, master, PrivDir}], - ct_test_support:write_testspec(N++C++S++LD, DataDir, FileName). + ct_test_support:write_testspec(N++C++S++LD++NS, DataDir, FileName). get_log_dir(PrivDir, NodeName)-> LogDir = filename:join(PrivDir, io_lib:format("slave.~p", [NodeName])), @@ -118,18 +121,6 @@ get_log_dir(PrivDir, NodeName)-> run_test(_Name, FileName, Config)-> [{FileName, ok}] = ct_test_support:run(ct_master, run, [FileName], Config). -start_nodes(NodeNames)-> - lists:foreach(fun(NodeName)-> - {ok, _}=ct_slave:start(NodeName) - end, - NodeNames). - -stop_nodes(NodeNames)-> - lists:foreach(fun(NodeName)-> - {ok, _}=ct_slave:stop(NodeName) - end, - NodeNames). - reformat_events(Events, EH) -> ct_test_support:reformat(Events, EH). -- cgit v1.2.3 From 2daac36809c14007d179a118784f48ceb79a30d1 Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Tue, 13 Apr 2010 09:11:59 +0200 Subject: Change monitor_master option to false by default --- lib/common_test/test/ct_master_SUITE.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl index 3618b08a74..0f0d13f683 100644 --- a/lib/common_test/test/ct_master_SUITE.erl +++ b/lib/common_test/test/ct_master_SUITE.erl @@ -99,7 +99,8 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> NodeNames), NS = lists:map(fun(NodeName)-> - {node_start, NodeName, [{startup_functions, [{io, format, ["hello, world~n"]}]}]} + {node_start, NodeName, [{startup_functions, [{io, format, ["hello, world~n"]}]}, + {monitor_master, true}]} end, NodeNames), -- cgit v1.2.3 From 1327bd8956b2d0f6b5a9201ce9ecf361f94733aa Mon Sep 17 00:00:00 2001 From: Andrey Pampukha Date: Mon, 19 Apr 2010 17:28:07 +0200 Subject: Move 'node_start' and 'eval' terms into new 'init' term node_start+eval -> init(node_start, eval) Also include some documentation updates. --- lib/common_test/test/ct_master_SUITE.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl index 0f0d13f683..2d4a29cde1 100644 --- a/lib/common_test/test/ct_master_SUITE.erl +++ b/lib/common_test/test/ct_master_SUITE.erl @@ -99,8 +99,11 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> NodeNames), NS = lists:map(fun(NodeName)-> - {node_start, NodeName, [{startup_functions, [{io, format, ["hello, world~n"]}]}, - {monitor_master, true}]} + {init, NodeName, [ + {node_start, [{startup_functions, []}, {monitor_master, false}]}, + {eval, {erlang, nodes, []}} + ] + } end, NodeNames), -- cgit v1.2.3 From c3a1e56608ebe08f1ddc07273d85ff9c2779de9b Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Thu, 3 Jun 2010 14:14:38 +0200 Subject: Implement support for user controllable timetrap parameters (multiply and scale) Documentation still missing. --- .../test/ct_error_SUITE_data/error/test/cfg_error_3_SUITE.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_3_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_3_SUITE.erl index bf01bb52d9..08c57887ef 100644 --- a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_3_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_3_SUITE.erl @@ -37,7 +37,8 @@ suite() -> %%-------------------------------------------------------------------- init_per_suite(Config) -> timer:sleep(5000), - Config. + exit(shouldnt_happen). +% Config. %%-------------------------------------------------------------------- %% Function: end_per_suite(Config0) -> void() | {save_config,Config1} -- cgit v1.2.3 From 7c6504029f84c52de40a6b29b2fd1b17c053ccec Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Thu, 3 Jun 2010 14:34:09 +0200 Subject: Add event_handler_init start flag that can pass init arguments to event handlers Also changed: The userconfig option in ct:run_test/1 from 3-tuple to 2-tuple. --- lib/common_test/test/ct_smoke_test_SUITE.erl | 18 +++++++++--------- lib/common_test/test/ct_test_support.erl | 19 ++++++++++++++++++- lib/common_test/test/ct_test_support_eh.erl | 17 +++++++++++++++-- 3 files changed, 42 insertions(+), 12 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_smoke_test_SUITE.erl b/lib/common_test/test/ct_smoke_test_SUITE.erl index f1c695f614..76136b1d69 100644 --- a/lib/common_test/test/ct_smoke_test_SUITE.erl +++ b/lib/common_test/test/ct_smoke_test_SUITE.erl @@ -162,7 +162,7 @@ dir1(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -191,7 +191,7 @@ dir2(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -221,7 +221,7 @@ dir1_2(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -251,7 +251,7 @@ suite11(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -280,7 +280,7 @@ suite21(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -311,7 +311,7 @@ suite11_21(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -342,7 +342,7 @@ tc111(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -372,7 +372,7 @@ tc211(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -403,7 +403,7 @@ tc111_112(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + {ok,ok} = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index 0ce103e111..c3dc706d9b 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -28,7 +28,7 @@ -export([init_per_suite/1, init_per_suite/2, end_per_suite/1, init_per_testcase/2, end_per_testcase/2, write_testspec/3, - run/4, get_opts/1, wait_for_ct_stop/1]). + run/2, run/4, get_opts/1, wait_for_ct_stop/1]). -export([handle_event/2, start_event_receiver/1, get_events/2, verify_events/3, reformat/2, log_events/3]). @@ -172,6 +172,23 @@ get_opts(Config) -> %%%----------------------------------------------------------------- %%% +run(Opts, Config) -> + CTNode = ?config(ct_node, Config), + Level = ?config(trace_level, Config), + %% use ct interface + test_server:format(Level, "Calling ct:run_test(~p) on ~p~n", + [Opts, CTNode]), + Result1 = rpc:call(CTNode, ct, run_test, [Opts]), + + %% use run_test interface (simulated) + test_server:format(Level, "Saving start opts on ~p: ~p~n", [CTNode,Opts]), + rpc:call(CTNode, application, set_env, [common_test, run_test_start_opts, Opts]), + test_server:format(Level, "Calling ct_run:script_start() on ~p~n", [CTNode]), + Result2 = rpc:call(CTNode, ct_run, script_start, []), + + {Result1,Result2}. + + run(M, F, A, Config) -> CTNode = ?config(ct_node, Config), Level = ?config(trace_level, Config), diff --git a/lib/common_test/test/ct_test_support_eh.erl b/lib/common_test/test/ct_test_support_eh.erl index fd3ae18746..1454d20e47 100644 --- a/lib/common_test/test/ct_test_support_eh.erl +++ b/lib/common_test/test/ct_test_support_eh.erl @@ -44,8 +44,20 @@ %% Description: Whenever a new event handler is added to an event manager, %% this function is called to initialize the event handler. %%-------------------------------------------------------------------- +init(String = [X|_]) when is_integer(X) -> + case erl_scan:string(String++".") of + {ok,Ts,_} -> + case erl_parse:parse_term(Ts) of + {ok,Args} -> + init(Args); + _ -> + init(String) + end; + _ -> + init(String) + end; + init(Args) -> - S1 = case lists:keysearch(cbm, 1, Args) of {_,{cbm,CBM}} -> #state{cbm=CBM}; @@ -58,7 +70,8 @@ init(Args) -> _ -> S1 end, - print(S2#state.trace_level, "Event Handler ~w started!~n", [?MODULE]), + print(S2#state.trace_level, "Event Handler ~w started with ~p~n", + [?MODULE,Args]), {ok,S2}. %%-------------------------------------------------------------------- -- cgit v1.2.3 From 5d01bdc2c4c3cc18150711ebfab4c84abdfc0b45 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Thu, 3 Jun 2010 14:40:16 +0200 Subject: Improve and fix various test suites --- lib/common_test/test/ct_config_SUITE.erl | 67 ++++++++++++------- lib/common_test/test/ct_error_SUITE.erl | 21 ++++-- lib/common_test/test/ct_event_handler_SUITE.erl | 9 ++- .../test/ct_event_handler_SUITE_data/eh_A.erl | 13 ++++ lib/common_test/test/ct_groups_test_1_SUITE.erl | 68 ++++++++----------- .../groups_1/test/groups_12_SUITE.erl | 4 ++ lib/common_test/test/ct_groups_test_2_SUITE.erl | 32 ++++++++- lib/common_test/test/ct_master_SUITE.erl | 11 ++-- lib/common_test/test/ct_skip_SUITE.erl | 17 +++-- lib/common_test/test/ct_smoke_test_SUITE.erl | 52 ++++++++------- lib/common_test/test/ct_test_server_if_1_SUITE.erl | 13 +++- lib/common_test/test/ct_test_support.erl | 76 ++++++++++++++++++---- 12 files changed, 260 insertions(+), 123 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl index 7c0c88e76b..0722d137eb 100644 --- a/lib/common_test/test/ct_config_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE.erl @@ -44,8 +44,13 @@ %% there will be clashes with logging processes etc). %%-------------------------------------------------------------------- init_per_suite(Config) -> - Config1 = ct_test_support:init_per_suite(Config), - Config1. + DataDir = ?config(data_dir, Config), + PathDir = filename:join(DataDir, "config/test"), + Config1 = ct_test_support:init_per_suite([{path_dirs,[PathDir]} | Config]), + PrivDir = ?config(priv_dir, Config1), + ConfigDir = filename:join(PrivDir, "config"), + ok = file:make_dir(ConfigDir), + [{config_dir,ConfigDir} | Config1]. end_per_suite(Config) -> ct_test_support:end_per_suite(Config). @@ -94,46 +99,49 @@ userconfig_dynamic(Config) when is_list(Config) -> testspec_legacy(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), - make_spec(DataDir, - "config/spec_legacy.spec", - [config_static_SUITE], - [{config, filename:join(DataDir, "config/config.txt")}]), + ConfigDir = ?config(config_dir, Config), + make_spec(DataDir, ConfigDir, + "spec_legacy.spec", + [config_static_SUITE], + [{config, filename:join(DataDir, "config/config.txt")}]), run_test(config_static_SUITE, Config, - {spec, filename:join(DataDir, "config/spec_legacy.spec")}, + {spec, filename:join(ConfigDir, "spec_legacy.spec")}, []), - file:delete(filename:join(DataDir, "config/spec_legacy.spec")). + file:delete(filename:join(ConfigDir, "spec_legacy.spec")). testspec_static(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), - make_spec(DataDir, - "config/spec_static.spec", - [config_static_SUITE], - [{userconfig, {ct_config_xml, filename:join(DataDir, "config/config.xml")}}]), + ConfigDir = ?config(config_dir, Config), + make_spec(DataDir, ConfigDir, + "spec_static.spec", + [config_static_SUITE], + [{userconfig, {ct_config_xml, filename:join(DataDir, "config/config.xml")}}]), run_test(config_static_SUITE, Config, - {spec, filename:join(DataDir, "config/spec_static.spec")}, + {spec, filename:join(ConfigDir, "spec_static.spec")}, []), - file:delete(filename:join(DataDir, "config/spec_static.spec")). + file:delete(filename:join(ConfigDir, "spec_static.spec")). testspec_dynamic(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), - make_spec(DataDir, "config/spec_dynamic.spec", - [config_dynamic_SUITE], - [{userconfig, {config_driver, "config_server"}}]), + ConfigDir = ?config(config_dir, Config), + make_spec(DataDir, ConfigDir, "spec_dynamic.spec", + [config_dynamic_SUITE], + [{userconfig, {config_driver, "config_server"}}]), run_test(config_dynamic_SUITE, Config, - {spec, filename:join(DataDir, "config/spec_dynamic.spec")}, + {spec, filename:join(ConfigDir, "spec_dynamic.spec")}, []), - file:delete(filename:join(DataDir, "config/spec_dynamic.spec")). + file:delete(filename:join(ConfigDir, "spec_dynamic.spec")). %%%----------------------------------------------------------------- %%% HELP FUNCTIONS %%%----------------------------------------------------------------- -make_spec(DataDir, Filename, Suites, Config)-> - {ok, Fd} = file:open(filename:join(DataDir, Filename), [write]), +make_spec(DataDir, ConfigDir, Filename, Suites, Config)-> + {ok, Fd} = file:open(filename:join(ConfigDir, Filename), [write]), ok = file:write(Fd, - io_lib:format("{suites, \"~sconfig/test/\", ~p}.~n", [DataDir, Suites])), + io_lib:format("{suites, \"~sconfig/test/\", ~p}.~n", [DataDir, Suites])), lists:foreach(fun(C)-> ok=file:write(Fd, io_lib:format("~p.~n", [C])) end, Config), ok = file:close(Fd). @@ -142,12 +150,12 @@ run_test(Name, Config, CTConfig, SuiteNames)-> Joiner = fun(Suite) -> filename:join(DataDir, "config/test/"++Suite) end, Suites = lists:map(Joiner, SuiteNames), {Opts,ERPid} = setup_env({suite,Suites}, Config, CTConfig), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), TestEvents = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(Name, reformat_events(TestEvents, ?eh), - ?config(priv_dir, Config)), - ExpEvents = expected_events(Name), + ?config(config_dir, Config)), + ExpEvents = events_to_check(Name), ok = ct_test_support:verify_events(ExpEvents, TestEvents, Config). setup_env(Test, Config, CTConfig) -> @@ -164,6 +172,15 @@ reformat_events(Events, EH) -> %%%----------------------------------------------------------------- %%% 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) -> + expected_events(Test) ++ events_to_check(Test, N-1). + expected_events(config_static_SUITE)-> [ {?eh,start_logging,{'DEF','RUNDIR'}}, diff --git a/lib/common_test/test/ct_error_SUITE.erl b/lib/common_test/test/ct_error_SUITE.erl index be75d768fc..d5d91706d9 100644 --- a/lib/common_test/test/ct_error_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE.erl @@ -87,14 +87,14 @@ cfg_error(Config) when is_list(Config) -> Join(DataDir, "cfg_error_9_SUITE") ], {Opts,ERPid} = setup({suite,Suites}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(cfg_error, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(cfg_error), + TestEvents = events_to_check(cfg_error), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -105,14 +105,14 @@ lib_error(Config) when is_list(Config) -> Join = fun(D, S) -> filename:join(D, "error/test/"++S) end, Suites = [Join(DataDir, "lib_error_1_SUITE")], {Opts,ERPid} = setup({suite,Suites}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(lib_error, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(lib_error), + TestEvents = events_to_check(lib_error), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -123,14 +123,14 @@ no_compile(Config) when is_list(Config) -> Join = fun(D, S) -> filename:join(D, "error/test/"++S) end, Suites = [Join(DataDir, "no_compile_SUITE")], {Opts,ERPid} = setup({suite,Suites}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(no_compile, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(no_compile), + TestEvents = events_to_check(no_compile), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -154,6 +154,15 @@ reformat(Events, EH) -> %%%----------------------------------------------------------------- %%% 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(cfg_error) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, diff --git a/lib/common_test/test/ct_event_handler_SUITE.erl b/lib/common_test/test/ct_event_handler_SUITE.erl index bafd32f937..00a4c4ded3 100644 --- a/lib/common_test/test/ct_event_handler_SUITE.erl +++ b/lib/common_test/test/ct_event_handler_SUITE.erl @@ -88,7 +88,7 @@ start_stop(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -110,8 +110,7 @@ start_stop(Config) when is_list(Config) -> {eh_A,test_done,{'DEF','STOP_TIME'}}, {eh_A,stop_logging,[]}], - ok = ct_test_support:verify_events(TestEvents, Events, Config), - {comment,"NOTE! Known problem with test_start event!"}. + ok = ct_test_support:verify_events(TestEvents++TestEvents, Events, Config). results(doc) -> @@ -135,7 +134,7 @@ results(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -163,7 +162,7 @@ results(Config) when is_list(Config) -> {eh_A,test_done,{'DEF','STOP_TIME'}}, {eh_A,stop_logging,[]}], - ok = ct_test_support:verify_events(TestEvents, Events, Config). + ok = ct_test_support:verify_events(TestEvents++TestEvents, Events, Config). %%%----------------------------------------------------------------- diff --git a/lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl b/lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl index 6e526f15a2..cb6d4c3aaa 100644 --- a/lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl +++ b/lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl @@ -44,6 +44,19 @@ %% Description: Whenever a new event handler is added to an event manager, %% this function is called to initialize the event handler. %%-------------------------------------------------------------------- +init(String = [X|_]) when is_integer(X) -> + case erl_scan:string(String++".") of + {ok,Ts,_} -> + case erl_parse:parse_term(Ts) of + {ok,Args} -> + init(Args); + _ -> + init(String) + end; + _ -> + init(String) + end; + init(Args) -> S1 = case lists:keysearch(cbm, 1, Args) of diff --git a/lib/common_test/test/ct_groups_test_1_SUITE.erl b/lib/common_test/test/ct_groups_test_1_SUITE.erl index 1761b773f5..18a00f7f2b 100644 --- a/lib/common_test/test/ct_groups_test_1_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_1_SUITE.erl @@ -76,14 +76,14 @@ groups_suite_1(Config) when is_list(Config) -> Suite = filename:join(DataDir, "groups_1/test/groups_11_SUITE"), {Opts,ERPid} = setup({suite,Suite}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(groups_suite_1, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(groups_suite_1), + TestEvents = events_to_check(groups_suite_1), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -96,14 +96,14 @@ groups_suite_2(Config) when is_list(Config) -> Suite = filename:join(DataDir, "groups_1/test/groups_12_SUITE"), {Opts,ERPid} = setup({suite,Suite}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(groups_suite_2, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(groups_suite_2), + TestEvents = events_to_check(groups_suite_2), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -117,14 +117,14 @@ groups_suites_1(Config) when is_list(Config) -> filename:join(DataDir, "groups_1/test/groups_12_SUITE")], {Opts,ERPid} = setup({suite,Suites}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(groups_suites_1, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(groups_suites_1), + TestEvents = events_to_check(groups_suites_1), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -137,14 +137,14 @@ groups_dir_1(Config) when is_list(Config) -> Dir = filename:join(DataDir, "groups_1"), {Opts,ERPid} = setup({dir,Dir}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(groups_dir_1, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(groups_dir_1), + TestEvents = events_to_check(groups_dir_1), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -157,14 +157,14 @@ groups_dirs_1(Config) when is_list(Config) -> filename:join(DataDir, "groups_2")], {Opts,ERPid} = setup({dir,Dirs}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(groups_dirs_1, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(groups_dirs_1), + TestEvents = events_to_check(groups_dirs_1), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -188,6 +188,14 @@ reformat(Events, EH) -> %%%----------------------------------------------------------------- %%% 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(groups_suite_1) -> [{?eh,start_logging,{'DEF','RUNDIR'}}, @@ -361,12 +369,8 @@ test_events(groups_suite_2) -> {parallel,[{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}}, - - %% the done event could come in during the parallel subgroup - %% and we can't test that, yet... - %% {?eh,tc_start,{groups_12_SUITE,testcase_5a}}, - %% {?eh,tc_done,{groups_12_SUITE,testcase_5a,ok}}, - + {?eh,tc_start,{groups_12_SUITE,testcase_5a}}, + {?eh,tc_done,{groups_12_SUITE,testcase_5a,ok}}, {parallel,[{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}}, @@ -555,12 +559,8 @@ test_events(groups_suites_1) -> {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_4,[]},ok}}, {parallel,[{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}}, - - %% the done event could come in during the parallel subgroup - %% and we can't test that, yet... - %% {?eh,tc_start,{groups_12_SUITE,testcase_5a}}, - %% {?eh,tc_done,{groups_12_SUITE,testcase_5a,ok}}, - + {?eh,tc_start,{groups_12_SUITE,testcase_5a}}, + {?eh,tc_done,{groups_12_SUITE,testcase_5a,ok}}, {parallel,[{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}}, [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_7,[sequence]}}}, @@ -745,12 +745,8 @@ test_events(groups_dir_1) -> {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_4,[]},ok}}, {parallel,[{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}}, - - %% the done event could come in during the parallel subgroup - %% and we can't test that, yet... - %% {?eh,tc_start,{groups_12_SUITE,testcase_5a}}, - %% {?eh,tc_done,{groups_12_SUITE,testcase_5a,ok}}, - + {?eh,tc_start,{groups_12_SUITE,testcase_5a}}, + {?eh,tc_done,{groups_12_SUITE,testcase_5a,ok}}, {parallel,[{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}}, [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_7,[sequence]}}}, @@ -936,12 +932,8 @@ test_events(groups_dirs_1) -> {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_4,[]},ok}}, {parallel,[{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}}, - - %% the done event could come in during the parallel subgroup - %% and we can't test that, yet... - %% {?eh,tc_start,{groups_12_SUITE,testcase_5a}}, - %% {?eh,tc_done,{groups_12_SUITE,testcase_5a,ok}}, - + {?eh,tc_start,{groups_12_SUITE,testcase_5a}}, + {?eh,tc_done,{groups_12_SUITE,testcase_5a,ok}}, {parallel,[{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}}, [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_7,[sequence]}}}, @@ -1181,12 +1173,8 @@ test_events(groups_dirs_1) -> {groups_22_SUITE,{init_per_group,test_group_5,[parallel]}}}, {?eh,tc_done, {groups_22_SUITE,{init_per_group,test_group_5,[parallel]},ok}}, - - %% the done event could come in during the parallel subgroup - %% and we can't test that, yet... - %% {?eh,tc_start,{groups_22_SUITE,testcase_5a}}, - %% {?eh,tc_done,{groups_22_SUITE,testcase_5a,ok}}, - + {?eh,tc_start,{groups_22_SUITE,testcase_5a}}, + {?eh,tc_done,{groups_22_SUITE,testcase_5a,ok}}, {parallel, [{?eh,tc_start, {groups_22_SUITE,{init_per_group,test_group_6,[parallel]}}}, diff --git a/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_1/test/groups_12_SUITE.erl b/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_1/test/groups_12_SUITE.erl index b261ef581f..22eacde1f3 100644 --- a/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_1/test/groups_12_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_1/test/groups_12_SUITE.erl @@ -275,6 +275,10 @@ testcase_5a(Config) -> test_group_5 = ?config(test_group_5,Config), undefined = ?config(testcase_3,Config), testcase_5a = ?config(testcase_5a,Config), + %% increase chance the done event will come + %% during execution of subgroup (could be + %% tricky to handle) + timer:sleep(3), ok. testcase_5b() -> []. diff --git a/lib/common_test/test/ct_groups_test_2_SUITE.erl b/lib/common_test/test/ct_groups_test_2_SUITE.erl index 5a60d855b7..75348e2f4a 100644 --- a/lib/common_test/test/ct_groups_test_2_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_2_SUITE.erl @@ -75,14 +75,14 @@ missing_conf(Config) when is_list(Config) -> Suite = filename:join(DataDir, "groups_1/missing_conf_SUITE"), {Opts,ERPid} = setup({suite,Suite}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(missing_conf_SUITE, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(missing_conf), + TestEvents = events_to_check(missing_conf), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -105,6 +105,32 @@ reformat(Events, EH) -> %%%----------------------------------------------------------------- %%% 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(missing_conf) -> - exit(must_handle_this). + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{1,1,2}}, + {?eh,tc_start,{ct_framework,ct_init_per_group}}, + {?eh,tc_done,{ct_framework,ct_init_per_group,ok}}, + {?eh,test_stats,{1,0,{0,0}}}, + {?eh,tc_start,{missing_conf_SUITE,tc1}}, + {?eh,tc_done,{missing_conf_SUITE,tc1,ok}}, + {?eh,test_stats,{2,0,{0,0}}}, + {?eh,tc_start,{missing_conf_SUITE,tc2}}, + {?eh,tc_done,{missing_conf_SUITE,tc2,ok}}, + {?eh,test_stats,{3,0,{0,0}}}, + {?eh,tc_start,{ct_framework,ct_end_per_group}}, + {?eh,tc_done,{ct_framework,ct_end_per_group,ok}}, + {?eh,test_stats,{4,0,{0,0}}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]. diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl index 2d4a29cde1..8d3ed8c45c 100644 --- a/lib/common_test/test/ct_master_SUITE.erl +++ b/lib/common_test/test/ct_master_SUITE.erl @@ -69,13 +69,14 @@ all(suite) -> ct_master_test(Config) when is_list(Config)-> NodeCount = 5, DataDir = ?config(data_dir, Config), + PrivDir = ?config(priv_dir, Config), NodeNames = [list_to_atom("testnode_"++integer_to_list(N)) || N <- lists:seq(1, NodeCount)], - FileName = filename:join(DataDir, "ct_master_spec.spec"), + FileName = filename:join(PrivDir, "ct_master_spec.spec"), Suites = [master_SUITE], TSFile = make_spec(DataDir, FileName, NodeNames, Suites, Config), [{TSFile, ok}] = run_test(ct_master_test, FileName, Config), - file:delete(filename:join(DataDir, FileName)). + ok. %%%----------------------------------------------------------------- %%% HELP FUNCTIONS @@ -91,9 +92,9 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> C = lists:map(fun(NodeName)-> Rnd = random:uniform(2), if Rnd == 1-> - {config, NodeName, "master/config.txt"}; + {config, NodeName, filename:join(DataDir, "master/config.txt")}; true-> - {userconfig, NodeName, {ct_config_xml, "master/config.xml"}} + {userconfig, NodeName, {ct_config_xml, filename:join(DataDir, "master/config.xml")}} end end, NodeNames), @@ -115,7 +116,7 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> end, NodeNames) ++ [{logdir, master, PrivDir}], - ct_test_support:write_testspec(N++C++S++LD++NS, DataDir, FileName). + ct_test_support:write_testspec(N++C++S++LD++NS, FileName). get_log_dir(PrivDir, NodeName)-> LogDir = filename:join(PrivDir, io_lib:format("slave.~p", [NodeName])), diff --git a/lib/common_test/test/ct_skip_SUITE.erl b/lib/common_test/test/ct_skip_SUITE.erl index 9f428723f5..2e02061dec 100644 --- a/lib/common_test/test/ct_skip_SUITE.erl +++ b/lib/common_test/test/ct_skip_SUITE.erl @@ -89,14 +89,14 @@ auto_skip(Config) when is_list(Config) -> ], {Opts,ERPid} = setup({suite,Suites}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(auto_skip, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(auto_skip), + TestEvents = events_to_check(auto_skip), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -112,14 +112,14 @@ user_skip(Config) when is_list(Config) -> Join(DataDir, "user_skip_5_SUITE")], {Opts,ERPid} = setup({suite,Suites}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(user_skip, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(user_skip), + TestEvents = events_to_check(user_skip), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -142,6 +142,15 @@ reformat(Events, EH) -> %%%----------------------------------------------------------------- %%% 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(auto_skip) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, diff --git a/lib/common_test/test/ct_smoke_test_SUITE.erl b/lib/common_test/test/ct_smoke_test_SUITE.erl index 76136b1d69..05a2c20695 100644 --- a/lib/common_test/test/ct_smoke_test_SUITE.erl +++ b/lib/common_test/test/ct_smoke_test_SUITE.erl @@ -162,7 +162,7 @@ dir1(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -170,7 +170,7 @@ dir1(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(dir1), + TestEvents = events_to_check(dir1), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -191,7 +191,7 @@ dir2(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -199,7 +199,7 @@ dir2(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(dir2), + TestEvents = events_to_check(dir2), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -221,7 +221,7 @@ dir1_2(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -229,7 +229,7 @@ dir1_2(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(dir1_2), + TestEvents = events_to_check(dir1_2), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -251,7 +251,7 @@ suite11(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -259,7 +259,7 @@ suite11(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(suite11), + TestEvents = events_to_check(suite11), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -280,7 +280,7 @@ suite21(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -288,7 +288,7 @@ suite21(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(suite21), + TestEvents = events_to_check(suite21), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -311,7 +311,7 @@ suite11_21(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -319,7 +319,7 @@ suite11_21(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(suite11_21), + TestEvents = events_to_check(suite11_21), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -342,7 +342,7 @@ tc111(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -350,7 +350,7 @@ tc111(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(tc111), + TestEvents = events_to_check(tc111), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -372,7 +372,7 @@ tc211(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -380,7 +380,7 @@ tc211(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(tc211), + TestEvents = events_to_check(tc211), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- @@ -403,7 +403,7 @@ tc111_112(Config) when is_list(Config) -> ERPid = ct_test_support:start_event_receiver(Config), - {ok,ok} = ct_test_support:run(Opts, Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -411,7 +411,7 @@ tc111_112(Config) when is_list(Config) -> ct_test_support:reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = test_events(tc111_112), + TestEvents = events_to_check(tc111_112), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -423,8 +423,16 @@ eh_opts(Config) -> Level = ?config(trace_level, Config), [{event_handler,{?eh,[{cbm,ct_test_support},{trace_level,Level}]}}]. +events_to_check(Test) -> + %% 2 tests (ct:run_test + script_start) is default + events_to_check(Test, 2). -test_events(Test) when Test == dir1 ; Test == dir2 ; +events_to_check(_, 0) -> + []; +events_to_check(Test, N) -> + events(Test) ++ events_to_check(Test, N-1). + +events(Test) when Test == dir1 ; Test == dir2 ; Test == suite11 ; Test == suite21 -> Suite = if Test == dir1 ; Test == suite11 -> happy_11_SUITE; true -> happy_21_SUITE @@ -465,7 +473,7 @@ test_events(Test) when Test == dir1 ; Test == dir2 ; {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} ]; -test_events(Test) when Test == dir1_2 ; Test == suite11_21 -> +events(Test) when Test == dir1_2 ; Test == suite11_21 -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, @@ -532,7 +540,7 @@ test_events(Test) when Test == dir1_2 ; Test == suite11_21 -> {?eh,stop_logging,[]} ]; -test_events(Test) when Test == tc111 ; Test == tc211 -> +events(Test) when Test == tc111 ; Test == tc211 -> Suite = if Test == tc111 -> happy_11_SUITE; true -> happy_21_SUITE end, [ {?eh,start_logging,{'DEF','RUNDIR'}}, @@ -549,7 +557,7 @@ test_events(Test) when Test == tc111 ; Test == tc211 -> {?eh,stop_logging,[]} ]; -test_events(tc111_112) -> +events(tc111_112) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, diff --git a/lib/common_test/test/ct_test_server_if_1_SUITE.erl b/lib/common_test/test/ct_test_server_if_1_SUITE.erl index 069f8c75fc..8b46a30cdc 100644 --- a/lib/common_test/test/ct_test_server_if_1_SUITE.erl +++ b/lib/common_test/test/ct_test_server_if_1_SUITE.erl @@ -87,14 +87,14 @@ ts_if_1(Config) when is_list(Config) -> TestSpecName = ct_test_support:write_testspec(TestSpec, PrivDir, "ts_if_1_spec"), {Opts,ERPid} = setup({spec,TestSpecName}, Config), - ok = ct_test_support:run(ct, run_test, [Opts], Config), + ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), ct_test_support:log_events(ts_if_1, reformat(Events, ?eh), PrivDir), - TestEvents = test_events(ts_if_1), + TestEvents = events_to_check(ts_if_1), ok = ct_test_support:verify_events(TestEvents, Events, Config). @@ -119,6 +119,15 @@ reformat(Events, EH) -> %%%----------------------------------------------------------------- %%% 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(ts_if_1) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index c3dc706d9b..c7c7384847 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -27,7 +27,8 @@ -include_lib("common_test/include/ct_event.hrl"). -export([init_per_suite/1, init_per_suite/2, end_per_suite/1, - init_per_testcase/2, end_per_testcase/2, write_testspec/3, + init_per_testcase/2, end_per_testcase/2, + write_testspec/2, write_testspec/3, run/2, run/4, get_opts/1, wait_for_ct_stop/1]). -export([handle_event/2, start_event_receiver/1, get_events/2, @@ -66,12 +67,17 @@ init_per_suite(Config, Level) -> %% PrivDir as well as directory of Test Server suites %% have to be in code path on Common Test node. - true = rpc:call(CTNode, code, add_patha, [PrivDir]), [_ | Parts] = lists:reverse(filename:split(DataDir)), TSDir = filename:join(lists:reverse(Parts)), - true = rpc:call(CTNode, code, add_patha, [TSDir]), - test_server:format(Level, "Dirs added to code path (on ~w):~n" - "~s~n~s~n", [CTNode,TSDir,PrivDir]), + AddPathDirs = case ?config(path_dirs, Config) of + undefined -> []; + Ds -> Ds + end, + PathDirs = [PrivDir,TSDir | AddPathDirs], + [true = rpc:call(CTNode, code, add_patha, [D]) || D <- PathDirs], + test_server:format(Level, "Dirs added to code path (on ~w):~n", + [CTNode]), + [io:format("~s~n", [D]) || D <- PathDirs], TraceFile = filename:join(DataDir, "ct.trace"), case file:read_file_info(TraceFile) of @@ -125,9 +131,10 @@ end_per_testcase(_TestCase, Config) -> %%%----------------------------------------------------------------- %%% - write_testspec(TestSpec, Dir, Name) -> - TSFile = filename:join(Dir, Name), + write_testspec(TestSpec, filename:join(Dir, Name)). + +write_testspec(TestSpec, TSFile) -> {ok,Dev} = file:open(TSFile, [write]), [io:format(Dev, "~p.~n", [Entry]) || Entry <- TestSpec], file:close(Dev), @@ -185,9 +192,14 @@ run(Opts, Config) -> rpc:call(CTNode, application, set_env, [common_test, run_test_start_opts, Opts]), test_server:format(Level, "Calling ct_run:script_start() on ~p~n", [CTNode]), Result2 = rpc:call(CTNode, ct_run, script_start, []), - - {Result1,Result2}. - + case {Result1,Result2} of + {ok,ok} -> + ok; + {E,_} when E =/= ok -> + E; + {_,E} when E =/= ok -> + E + end. run(M, F, A, Config) -> CTNode = ?config(ct_node, Config), @@ -262,6 +274,11 @@ verify_events(TEvs, Evs, Config) -> ok end. +verify_events1([TestEv|_], [{TEH,#event{name=stop_logging,node=Node,data=_}}|_], Node, _) + when element(1,TestEv) == TEH, element(2,TestEv) =/= stop_logging -> + test_server:format("Failed to find ~p in the list of events!~n", [TestEv]), + exit({event_not_found,TestEv}); + verify_events1(TEvs = [TestEv | TestEvs], Evs = [_|Events], Node, Config) -> %% test_server:format("Next expected event: ~p~n", [TestEv]), case catch locate(TestEv, Node, Evs, Config) of @@ -363,6 +380,10 @@ locate({parallel,TEvs}, Node, Evs, Config) -> EH == TEH, EvNode == Node, Mod == M, Func == F -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_start_not_found,TEv}); (_) -> true end, Evs1), @@ -376,6 +397,10 @@ locate({parallel,TEvs}, Node, Evs, Config) -> EH == TEH, EvNode == Node, Mod == M, Func == F -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_done_not_found,TEv}); (_) -> true end, Evs2), @@ -419,6 +444,10 @@ locate({parallel,TEvs}, Node, Evs, Config) -> EH == TEH, EvNode == Node, Mod == M, EvGName == GroupName, EvProps == Props -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_start_not_found,TEv}); (_) -> true end, RemEvs), @@ -441,6 +470,10 @@ locate({parallel,TEvs}, Node, Evs, Config) -> EH == TEH, EvNode == Node, Mod == M, EvGName == GroupName, EvProps == Props, Res == R -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_done_not_found,TEv}); (_) -> true end, RemEvs), @@ -460,6 +493,10 @@ locate({parallel,TEvs}, Node, Evs, Config) -> data={Mod,end_per_group,Reason}}}) when EH == TEH, EvNode == Node, Mod == M, Reason == R -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_auto_skip_not_found,TEv}); (_) -> true end, RemEvs), @@ -564,6 +601,10 @@ locate({shuffle,TEvs}, Node, Evs, Config) -> EH == TEH, EvNode == Node, Mod == M, Func == F -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_start_not_found,TEv}); (_) -> true end, Evs1), @@ -607,6 +648,10 @@ locate({shuffle,TEvs}, Node, Evs, Config) -> EH == TEH, EvNode == Node, Mod == M, EvGName == GroupName -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_start_not_found,TEv}); (_) -> true end, RemEvs), @@ -642,6 +687,10 @@ locate({shuffle,TEvs}, Node, Evs, Config) -> EH == TEH, EvNode == Node, Mod == M, EvGName == GroupName, Res == R -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_done_not_found,TEv}); (_) -> true end, RemEvs), @@ -674,6 +723,10 @@ locate({shuffle,TEvs}, Node, Evs, Config) -> data={Mod,end_per_group,Reason}}}) when EH == TEH, EvNode == Node, Mod == M, Reason == R -> false; + ({EH,#event{name=stop_logging, + node=EvNode,data=_}}) when + EH == TEH, EvNode == Node -> + exit({tc_auto_skip_not_found,TEv}); (_) -> true end, RemEvs), @@ -816,7 +869,8 @@ log_events(TC, Events, PrivDir) -> io:format(Dev, "[~n", []), log_events1(Events, Dev, " "), file:close(Dev), - io:format("Events written to logfile: ~p~n", [LogFile]), + io:format("Events written to logfile: ~s~n", + [LogFile,LogFile]), io:format(user, "Events written to logfile: ~p~n", [LogFile]). log_events1(Evs, Dev, "") -> -- cgit v1.2.3 From 13fab1dd93fba14e55fea0a343650dbaa54e8725 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Thu, 3 Jun 2010 13:21:38 +0200 Subject: Add new tests for test case groups and test specifications --- lib/common_test/test/ct_groups_test_2_SUITE.erl | 26 +- .../cfgs/groups_2.1.cfg | 1 + .../groups_2/groups_21_SUITE.erl | 281 ++++++++++++++++++ .../groups_2/groups_22_SUITE.erl | 314 +++++++++++++++++++++ .../specs/groups_2.1.spec | 26 ++ 5 files changed, 646 insertions(+), 2 deletions(-) create mode 100644 lib/common_test/test/ct_groups_test_2_SUITE_data/cfgs/groups_2.1.cfg create mode 100644 lib/common_test/test/ct_groups_test_2_SUITE_data/groups_2/groups_21_SUITE.erl create mode 100644 lib/common_test/test/ct_groups_test_2_SUITE_data/groups_2/groups_22_SUITE.erl create mode 100644 lib/common_test/test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_groups_test_2_SUITE.erl b/lib/common_test/test/ct_groups_test_2_SUITE.erl index 75348e2f4a..1fbeff0126 100644 --- a/lib/common_test/test/ct_groups_test_2_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_2_SUITE.erl @@ -60,7 +60,7 @@ all(doc) -> ["Run smoke tests of Common Test."]; all(suite) -> - [missing_conf]. + [missing_conf, testspec_1]. %%-------------------------------------------------------------------- %% TEST CASES @@ -84,6 +84,25 @@ missing_conf(Config) when is_list(Config) -> TestEvents = events_to_check(missing_conf), ok = ct_test_support:verify_events(TestEvents, Events, Config). + +%%%----------------------------------------------------------------- +%%% + +testspec_1(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + + TestSpec = filename:join(DataDir, "specs/groups_2.1.spec"), + + {Opts,ERPid} = setup({spec,TestSpec}, Config), + ok = ct_test_support:run(Opts, Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(testspec_1, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = events_to_check(testspec_1), + ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- %%% HELP FUNCTIONS @@ -133,4 +152,7 @@ test_events(missing_conf) -> {?eh,test_stats,{4,0,{0,0}}}, {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} - ]. + ]; + +test_events(testspec_1) -> + []. diff --git a/lib/common_test/test/ct_groups_test_2_SUITE_data/cfgs/groups_2.1.cfg b/lib/common_test/test/ct_groups_test_2_SUITE_data/cfgs/groups_2.1.cfg new file mode 100644 index 0000000000..4928505157 --- /dev/null +++ b/lib/common_test/test/ct_groups_test_2_SUITE_data/cfgs/groups_2.1.cfg @@ -0,0 +1 @@ +{dummy_key, "dummy_data"}. diff --git a/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_2/groups_21_SUITE.erl b/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_2/groups_21_SUITE.erl new file mode 100644 index 0000000000..a63aa31a7f --- /dev/null +++ b/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_2/groups_21_SUITE.erl @@ -0,0 +1,281 @@ +%% +%% %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% +%% +-module(groups_21_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%==================================================================== +%% COMMON TEST CALLBACK FUNCTIONS +%%==================================================================== + +suite() -> + [{timetrap,{minutes,1}}]. + +groups() -> + [ + {test_group_1a, [testcase_1a,testcase_1b]}, + + {test_group_1b, [], [testcase_1a,testcase_1b]}, + + {test_group_2, [], [testcase_2a, + + {test_group_3, [], [testcase_3a, + testcase_3b]}, + testcase_2b]}, + + {test_group_4, [{test_group_5, [], [testcase_5a, + + {group, test_group_6}, + + testcase_5b]}]}, + + {test_group_6, [{group, test_group_7}]}, + + {test_group_7, [testcase_7a,testcase_7b]} + ]. + +all() -> + [testcase_1, + {group, test_group_1a}, + {group, test_group_1b}, + testcase_2, + {group, test_group_2}, + testcase_3, + {group, test_group_4}]. + +%% this func only for internal test purposes +grs_and_tcs() -> + {[ + test_group_1a, test_group_1b, + test_group_2, test_group_3, + test_group_4, test_group_5, + test_group_6, test_group_7 + ], + [ + testcase_1, + testcase_1a, testcase_1b, + testcase_2, + testcase_2a, testcase_2b, + testcase_3a, testcase_3b, + testcase_3, + testcase_5a, testcase_5b, + testcase_7a, testcase_7b + ]}. + +%%-------------------------------------------------------------------- +%% Suite Configuration +%%-------------------------------------------------------------------- + +init_per_suite(Config) -> + [{suite,init}|Config]. + +end_per_suite(Config) -> + init = ?config(suite,Config). + +%%-------------------------------------------------------------------- +%% Group Configuration +%%-------------------------------------------------------------------- + +init_per_group(Group, Config) -> + [{name,Group}] = ?config(tc_group_properties,Config), + {Grs,_} = grs_and_tcs(), + case lists:member(Group, Grs) of + true -> + ct:comment(io_lib:format("~w", [Group])), + init = ?config(suite,Config), + [{Group,Group} | Config]; + false -> + ct:fail({bad_group,Group}) + end. + +end_per_group(Group, Config) -> + {Grs,_} = grs_and_tcs(), + case lists:member(Group, Grs) of + true -> + init = ?config(suite,Config), + Group = ?config(Group,Config), + ok; + false -> + ct:fail({bad_group,Group}) + end. + +%%-------------------------------------------------------------------- +%% Testcase Configuration +%%-------------------------------------------------------------------- + +init_per_testcase(TestCase, Config) -> + {_,TCs} = grs_and_tcs(), + case lists:member(TestCase, TCs) of + true -> + init = ?config(suite,Config), + [{TestCase,TestCase} | Config]; + false -> + ct:fail({unknown_testcase,TestCase}) + end. + +end_per_testcase(TestCase, Config) -> + {_,TCs} = grs_and_tcs(), + case lists:member(TestCase, TCs) of + true -> + init = ?config(suite,Config), + TestCase = ?config(TestCase,Config), + ok; + false -> + ct:fail({unknown_testcase,TestCase}) + end. + + +%%-------------------------------------------------------------------- +%% Testcases +%%-------------------------------------------------------------------- + +testcase_1() -> + []. +testcase_1(Config) -> + init = ?config(suite,Config), + testcase_1 = ?config(testcase_1,Config), + ok. + +testcase_1a() -> + []. +testcase_1a(Config) -> + init = ?config(suite,Config), + case ?config(test_group_1a,Config) of + test_group_1a -> ok; + _ -> + case ?config(test_group_1b,Config) of + test_group_1b -> ok; + _ -> ct:fail(no_group_data) + end + end, + testcase_1a = ?config(testcase_1a,Config), + ok. +testcase_1b() -> + []. +testcase_1b(Config) -> + init = ?config(suite,Config), + case ?config(test_group_1a,Config) of + test_group_1a -> ok; + _ -> + case ?config(test_group_1b,Config) of + test_group_1b -> ok; + _ -> ct:fail(no_group_data) + end + end, + undefined = ?config(testcase_1a,Config), + testcase_1b = ?config(testcase_1b,Config), + ok. + +testcase_2() -> + []. +testcase_2(Config) -> + init = ?config(suite,Config), + undefined = ?config(test_group_1a,Config), + undefined = ?config(test_group_1b,Config), + testcase_2 = ?config(testcase_2,Config), + ok. + +testcase_2a() -> + []. +testcase_2a(Config) -> + init = ?config(suite,Config), + test_group_2 = ?config(test_group_2,Config), + testcase_2a = ?config(testcase_2a,Config), + ok. +testcase_2b() -> + []. +testcase_2b(Config) -> + init = ?config(suite,Config), + test_group_2 = ?config(test_group_2,Config), + undefined = ?config(testcase_2a,Config), + testcase_2b = ?config(testcase_2b,Config), + ok. + +testcase_3a() -> + []. +testcase_3a(Config) -> + init = ?config(suite,Config), + test_group_2 = ?config(test_group_2,Config), + test_group_3 = ?config(test_group_3,Config), + undefined = ?config(testcase_2b,Config), + testcase_3a = ?config(testcase_3a,Config), + ok. +testcase_3b() -> + []. +testcase_3b(Config) -> + init = ?config(suite,Config), + test_group_2 = ?config(test_group_2,Config), + test_group_3 = ?config(test_group_3,Config), + undefined = ?config(testcase_3a,Config), + testcase_3b = ?config(testcase_3b,Config), + ok. + +testcase_3() -> + []. +testcase_3(Config) -> + init = ?config(suite,Config), + undefined = ?config(test_group_2,Config), + undefined = ?config(test_group_3,Config), + testcase_3 = ?config(testcase_3,Config), + ok. + +testcase_5a() -> + []. +testcase_5a(Config) -> + init = ?config(suite,Config), + undefined = ?config(test_group_3,Config), + test_group_4 = ?config(test_group_4,Config), + test_group_5 = ?config(test_group_5,Config), + undefined = ?config(testcase_3,Config), + testcase_5a = ?config(testcase_5a,Config), + ok. +testcase_5b() -> + []. +testcase_5b(Config) -> + init = ?config(suite,Config), + test_group_4 = ?config(test_group_4,Config), + test_group_5 = ?config(test_group_5,Config), + undefined = ?config(testcase_5a,Config), + testcase_5b = ?config(testcase_5b,Config), + ok. + +testcase_7a() -> + []. +testcase_7a(Config) -> + init = ?config(suite,Config), + undefined = ?config(test_group_3,Config), + test_group_4 = ?config(test_group_4,Config), + test_group_5 = ?config(test_group_5,Config), + test_group_6 = ?config(test_group_6,Config), + test_group_7 = ?config(test_group_7,Config), + testcase_7a = ?config(testcase_7a,Config), + ok. +testcase_7b() -> + []. +testcase_7b(Config) -> + init = ?config(suite,Config), + test_group_4 = ?config(test_group_4,Config), + test_group_5 = ?config(test_group_5,Config), + test_group_6 = ?config(test_group_6,Config), + test_group_7 = ?config(test_group_7,Config), + undefined = ?config(testcase_7a,Config), + testcase_7b = ?config(testcase_7b,Config), + ok. diff --git a/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_2/groups_22_SUITE.erl b/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_2/groups_22_SUITE.erl new file mode 100644 index 0000000000..308df616d5 --- /dev/null +++ b/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_2/groups_22_SUITE.erl @@ -0,0 +1,314 @@ +%% +%% %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% +%% +-module(groups_22_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%==================================================================== +%% COMMON TEST CALLBACK FUNCTIONS +%%==================================================================== + +suite() -> + [{timetrap,{minutes,1}}]. + +groups() -> + [ + {test_group_1a, [shuffle], [testcase_1a,testcase_1b,testcase_1c]}, + + {test_group_1b, [parallel], [testcase_1a,testcase_1b]}, + + {test_group_2, [parallel], [testcase_2a, + + {test_group_3, [{repeat,1}], + [testcase_3a, testcase_3b]}, + + testcase_2b]}, + + {test_group_4, [{test_group_5, [parallel], [testcase_5a, + + {group, test_group_6}, + + testcase_5b]}]}, + + {test_group_6, [parallel], [{group, test_group_7}]}, + + {test_group_7, [sequence], [testcase_7a,testcase_7b]} + ]. + +all() -> + [{group, test_group_1a}, + {group, test_group_1b}, + testcase_1, + testcase_2, + {group, test_group_2}, + testcase_3, + {group, test_group_4}]. + +%% this func only for internal test purposes +grs_and_tcs() -> + {[ + test_group_1a, test_group_1b, + test_group_2, test_group_3, + test_group_4, test_group_5, + test_group_6, test_group_7 + ], + [ + testcase_1a, testcase_1b, testcase_1c, + testcase_1, + testcase_2, + testcase_2a, testcase_2b, + testcase_3a, testcase_3b, + testcase_3, + testcase_5a, testcase_5b, + testcase_7a, testcase_7b + ]}. + +%%-------------------------------------------------------------------- +%% Suite Configuration +%%-------------------------------------------------------------------- + +init_per_suite(Config) -> + [{suite,init}|Config]. + +end_per_suite(Config) -> + init = ?config(suite,Config). + +%%-------------------------------------------------------------------- +%% Group Configuration +%%-------------------------------------------------------------------- + +init_per_group(Group, Config) -> + Cmt = + case {Group,?config(tc_group_properties,Config)} of + {test_group_1a,[{shuffle,S},{name,test_group_1a}]} -> + io_lib:format("shuffled, ~w", [S]); + {test_group_1b,[{name,test_group_1b},parallel]} -> "parallel"; + {test_group_2,[{name,test_group_2},parallel]} -> "parallel"; + {test_group_3,[{name,test_group_3},{repeat,1}]} -> "repeat 1"; + {test_group_3,[{name,test_group_3}]} -> "repeat 0"; + {test_group_4,[{name,test_group_4}]} -> ok; + {test_group_5,[{name,test_group_5},parallel]} -> "parallel"; + {test_group_6,[{name,test_group_6},parallel]} -> "parallel"; + {test_group_7,[{name,test_group_7},sequence]} -> "sequence" + end, + {Grs,_} = grs_and_tcs(), + case lists:member(Group, Grs) of + true -> + init = ?config(suite,Config), + ct:comment(io_lib:format("~w, ~s", [Group,Cmt])), + [{Group,Group} | Config]; + false -> + ct:fail({bad_group,Group}) + end. + +end_per_group(Group, Config) -> + {Grs,_} = grs_and_tcs(), + case lists:member(Group, Grs) of + true -> + init = ?config(suite,Config), + Group = ?config(Group,Config), + ok; + false -> + ct:fail({bad_group,Group}) + end. + +%%-------------------------------------------------------------------- +%% Testcase Configuration +%%-------------------------------------------------------------------- + +init_per_testcase(TestCase, Config) -> + {_,TCs} = grs_and_tcs(), + case lists:member(TestCase, TCs) of + true -> + init = ?config(suite,Config), + [{TestCase,TestCase} | Config]; + false -> + ct:fail({unknown_testcase,TestCase}) + end. + +end_per_testcase(TestCase, Config) -> + {_,TCs} = grs_and_tcs(), + case lists:member(TestCase, TCs) of + true -> + init = ?config(suite,Config), + TestCase = ?config(TestCase,Config), + ok; + false -> + ct:fail({unknown_testcase,TestCase}) + end. + + +%%-------------------------------------------------------------------- +%% Testcases +%%-------------------------------------------------------------------- + +testcase_1a() -> + []. +testcase_1a(Config) -> + init = ?config(suite,Config), + case ?config(test_group_1a,Config) of + test_group_1a -> ok; + _ -> + case ?config(test_group_1b,Config) of + test_group_1b -> ok; + _ -> ct:fail(no_group_data) + end + end, + testcase_1a = ?config(testcase_1a,Config), + ok. +testcase_1b() -> + []. +testcase_1b(Config) -> + init = ?config(suite,Config), + case ?config(test_group_1a,Config) of + test_group_1a -> ok; + _ -> + case ?config(test_group_1b,Config) of + test_group_1b -> ok; + _ -> ct:fail(no_group_data) + end + end, + undefined = ?config(testcase_1a,Config), + testcase_1b = ?config(testcase_1b,Config), + ok. + +testcase_1c() -> + []. +testcase_1c(Config) -> + init = ?config(suite,Config), + case ?config(test_group_1a,Config) of + test_group_1a -> ok; + _ -> + case ?config(test_group_1b,Config) of + test_group_1b -> ok; + _ -> ct:fail(no_group_data) + end + end, + undefined = ?config(testcase_1b,Config), + testcase_1c = ?config(testcase_1c,Config), + ok. + +testcase_1() -> + []. +testcase_1(Config) -> + init = ?config(suite,Config), + testcase_1 = ?config(testcase_1,Config), + ok. + +testcase_2() -> + []. +testcase_2(Config) -> + init = ?config(suite,Config), + undefined = ?config(test_group_1a,Config), + undefined = ?config(test_group_1b,Config), + testcase_2 = ?config(testcase_2,Config), + ok. + +testcase_2a() -> + []. +testcase_2a(Config) -> + init = ?config(suite,Config), + test_group_2 = ?config(test_group_2,Config), + testcase_2a = ?config(testcase_2a,Config), + ok. +testcase_2b() -> + []. +testcase_2b(Config) -> + init = ?config(suite,Config), + test_group_2 = ?config(test_group_2,Config), + undefined = ?config(testcase_2a,Config), + testcase_2b = ?config(testcase_2b,Config), + ok. + +testcase_3a() -> + []. +testcase_3a(Config) -> + init = ?config(suite,Config), + test_group_2 = ?config(test_group_2,Config), + test_group_3 = ?config(test_group_3,Config), + undefined = ?config(testcase_2b,Config), + testcase_3a = ?config(testcase_3a,Config), + ok. +testcase_3b() -> + []. +testcase_3b(Config) -> + init = ?config(suite,Config), + test_group_2 = ?config(test_group_2,Config), + test_group_3 = ?config(test_group_3,Config), + undefined = ?config(testcase_3a,Config), + testcase_3b = ?config(testcase_3b,Config), + ok. + +testcase_3() -> + []. +testcase_3(Config) -> + init = ?config(suite,Config), + undefined = ?config(test_group_2,Config), + undefined = ?config(test_group_3,Config), + testcase_3 = ?config(testcase_3,Config), + ok. + +testcase_5a() -> + []. +testcase_5a(Config) -> + init = ?config(suite,Config), + undefined = ?config(test_group_3,Config), + test_group_4 = ?config(test_group_4,Config), + test_group_5 = ?config(test_group_5,Config), + undefined = ?config(testcase_3,Config), + testcase_5a = ?config(testcase_5a,Config), + %% increase chance the done event will come + %% during execution of subgroup (could be + %% tricky to handle) + timer:sleep(3), + ok. +testcase_5b() -> + []. +testcase_5b(Config) -> + init = ?config(suite,Config), + test_group_4 = ?config(test_group_4,Config), + test_group_5 = ?config(test_group_5,Config), + undefined = ?config(testcase_5a,Config), + testcase_5b = ?config(testcase_5b,Config), + ok. + +testcase_7a() -> + []. +testcase_7a(Config) -> + init = ?config(suite,Config), + undefined = ?config(test_group_3,Config), + test_group_4 = ?config(test_group_4,Config), + test_group_5 = ?config(test_group_5,Config), + test_group_6 = ?config(test_group_6,Config), + test_group_7 = ?config(test_group_7,Config), + testcase_7a = ?config(testcase_7a,Config), + ok. +testcase_7b() -> + []. +testcase_7b(Config) -> + init = ?config(suite,Config), + test_group_4 = ?config(test_group_4,Config), + test_group_5 = ?config(test_group_5,Config), + test_group_6 = ?config(test_group_6,Config), + test_group_7 = ?config(test_group_7,Config), + undefined = ?config(testcase_7a,Config), + testcase_7b = ?config(testcase_7b,Config), + ok. diff --git a/lib/common_test/test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec b/lib/common_test/test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec new file mode 100644 index 0000000000..396b8ac645 --- /dev/null +++ b/lib/common_test/test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec @@ -0,0 +1,26 @@ + +{config, "../cfgs/groups_2.1.cfg"}. +{alias, groups_2, "../groups_2"}. + +{suites, groups_2, groups_21_SUITE}. +{skip_groups, groups_2, groups_21_SUITE, + [test_group_1b, test_group_7], "Skip tg_1b & tg_7"}. +{skip_cases, groups_2, groups_21_SUITE, + [testcase_1b, testcase_3a], "Skip tc_1b & tc_3a"}. + +{groups, groups_2, groups_22_SUITE, + test_group_1a}. +{skip_cases, groups_2, groups_22_SUITE, + testcase_1a, "Skip tc_1a"}. + +{groups, groups_2, groups_22_SUITE, + test_group_1b}. +{skip_cases, groups_2, groups_22_SUITE, + testcase_1b, "Skip tc_1b"}. +{skip_groups, groups_2, groups_21_SUITE, + [test_group_3], "Skip tg_3"}. + +{groups, groups_2, groups_22_SUITE, + test_group_5}. +{skip_cases, groups_2, groups_22_SUITE, + [testcase_7a, testcase_7b], "Skip tc_7a & tc_7b"}. -- cgit v1.2.3 From 7ce6aa16313d159b1994bf1d2f18b52bd91e9075 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Fri, 4 Jun 2010 11:21:41 +0200 Subject: Add groups in test specifications Ongoing work... --- .../test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec b/lib/common_test/test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec index 396b8ac645..24d778ac44 100644 --- a/lib/common_test/test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec +++ b/lib/common_test/test/ct_groups_test_2_SUITE_data/specs/groups_2.1.spec @@ -3,8 +3,8 @@ {alias, groups_2, "../groups_2"}. {suites, groups_2, groups_21_SUITE}. -{skip_groups, groups_2, groups_21_SUITE, - [test_group_1b, test_group_7], "Skip tg_1b & tg_7"}. +%{skip_groups, groups_2, groups_21_SUITE, +% [test_group_1b, test_group_7], "Skip tg_1b & tg_7"}. {skip_cases, groups_2, groups_21_SUITE, [testcase_1b, testcase_3a], "Skip tc_1b & tc_3a"}. @@ -17,8 +17,8 @@ test_group_1b}. {skip_cases, groups_2, groups_22_SUITE, testcase_1b, "Skip tc_1b"}. -{skip_groups, groups_2, groups_21_SUITE, - [test_group_3], "Skip tg_3"}. +%{skip_groups, groups_2, groups_21_SUITE, +% [test_group_3], "Skip tg_3"}. {groups, groups_2, groups_22_SUITE, test_group_5}. -- cgit v1.2.3 From a3af252253c1fbc642cf6229ff1e23f095b75b59 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Fri, 4 Jun 2010 01:06:03 +0200 Subject: Have end_per_testcase run even after timetrap_timeout and abort_testcase --- lib/common_test/test/ct_error_SUITE.erl | 38 +++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_error_SUITE.erl b/lib/common_test/test/ct_error_SUITE.erl index d5d91706d9..edf28e0bca 100644 --- a/lib/common_test/test/ct_error_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE.erl @@ -63,7 +63,8 @@ all(suite) -> [ cfg_error, lib_error, - no_compile + no_compile, + timetrap ]. @@ -133,6 +134,23 @@ no_compile(Config) when is_list(Config) -> TestEvents = events_to_check(no_compile), ok = ct_test_support:verify_events(TestEvents, Events, Config). +%%%----------------------------------------------------------------- +%%% +timetrap(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + Join = fun(D, S) -> filename:join(D, "error/test/"++S) end, + Suites = [Join(DataDir, "timetrap_1_SUITE")], + {Opts,ERPid} = setup({suite,Suites}, Config), + ok = ct_test_support:run(Opts, Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(timetrap, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = events_to_check(timetrap), + ok = ct_test_support:verify_events(TestEvents, Events, Config). + %%%----------------------------------------------------------------- %%% HELP FUNCTIONS @@ -564,4 +582,20 @@ test_events(lib_error) -> ]; test_events(no_compile) -> - []. + []; + +test_events(timetrap) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{1,1,1}}, + {?eh,tc_start,{timetrap_1_SUITE,init_per_suite}}, + {?eh,tc_done,{timetrap_1_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{timetrap_1_SUITE,tc1}}, + {?eh,tc_done,{timetrap_1_SUITE,tc1,{failed,{timetrap_timeout,1000}}}}, + {?eh,test_stats,{0,1,{0,0}}}, + {?eh,tc_start,{timetrap_1_SUITE,end_per_suite}}, + {?eh,tc_done,{timetrap_1_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]. -- cgit v1.2.3 From 34cf18550ff792ed9da884b00a49d6accd1bd5f5 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Fri, 4 Jun 2010 15:34:42 +0200 Subject: Add support for dynamic timetrap handling --- lib/common_test/test/Makefile | 17 +-- lib/common_test/test/ct_error_SUITE.erl | 146 +++++++++++++++++---- .../error/test/timetrap_1_SUITE.erl | 135 +++++++++++++++++++ .../error/test/timetrap_2_SUITE.erl | 138 +++++++++++++++++++ lib/common_test/test/ct_test_server_if_1_SUITE.erl | 4 +- .../test_server_if/test/ts_if_1_SUITE.erl | 8 +- lib/common_test/test/ct_test_support.erl | 8 +- lib/common_test/test/ct_userconfig_callback.erl | 32 +++++ 8 files changed, 450 insertions(+), 38 deletions(-) create mode 100644 lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_1_SUITE.erl create mode 100644 lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_2_SUITE.erl create mode 100644 lib/common_test/test/ct_userconfig_callback.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index eca6817682..594993cfec 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -27,6 +27,7 @@ include $(ERL_TOP)/make/$(TARGET)/otp.mk MODULES= \ ct_test_support \ ct_test_support_eh \ + ct_userconfig_callback \ ct_smoke_test_SUITE \ ct_event_handler_SUITE \ ct_groups_test_1_SUITE \ @@ -63,17 +64,17 @@ EBIN = . # Targets # ---------------------------------------------------- -#.PHONY: make_emakefile +.PHONY: make_emakefile -#make_emakefile: -# $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) \ -# '*_SUITE_make' > $(EMAKEFILE) -# $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES)\ -# >> $(EMAKEFILE) +make_emakefile: + $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES)\ + > $(EMAKEFILE) -tests debug opt: +tests debug opt: make_emakefile + erl $(ERL_MAKE_FLAGS) -make clean: + rm -f $(EMAKEFILE) rm -f $(TARGET_FILES) rm -f core @@ -86,7 +87,7 @@ include $(ERL_TOP)/make/otp_release_targets.mk release_spec: opt -release_tests_spec: +release_tests_spec: make_emakefile $(INSTALL_DIR) $(RELSYSDIR) $(INSTALL_DATA) $(ERL_FILES) $(COVERFILE) $(RELSYSDIR) $(INSTALL_PROGRAM) common_test.spec $(RELSYSDIR) diff --git a/lib/common_test/test/ct_error_SUITE.erl b/lib/common_test/test/ct_error_SUITE.erl index edf28e0bca..11482f1508 100644 --- a/lib/common_test/test/ct_error_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE.erl @@ -64,7 +64,9 @@ all(suite) -> cfg_error, lib_error, no_compile, - timetrap + timetrap_end_conf, + timetrap_normal, + timetrap_extended ]. @@ -87,7 +89,7 @@ cfg_error(Config) when is_list(Config) -> Join(DataDir, "cfg_error_8_SUITE"), Join(DataDir, "cfg_error_9_SUITE") ], - {Opts,ERPid} = setup({suite,Suites}, Config), + {Opts,ERPid} = setup([{suite,Suites}], Config), ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -105,7 +107,7 @@ lib_error(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), Join = fun(D, S) -> filename:join(D, "error/test/"++S) end, Suites = [Join(DataDir, "lib_error_1_SUITE")], - {Opts,ERPid} = setup({suite,Suites}, Config), + {Opts,ERPid} = setup([{suite,Suites}], Config), ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -123,7 +125,7 @@ no_compile(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), Join = fun(D, S) -> filename:join(D, "error/test/"++S) end, Suites = [Join(DataDir, "no_compile_SUITE")], - {Opts,ERPid} = setup({suite,Suites}, Config), + {Opts,ERPid} = setup([{suite,Suites}], Config), ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -136,21 +138,62 @@ no_compile(Config) when is_list(Config) -> %%%----------------------------------------------------------------- %%% -timetrap(Config) when is_list(Config) -> +timetrap_end_conf(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), Join = fun(D, S) -> filename:join(D, "error/test/"++S) end, Suites = [Join(DataDir, "timetrap_1_SUITE")], - {Opts,ERPid} = setup({suite,Suites}, Config), + {Opts,ERPid} = setup([{suite,Suites}], Config), ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), - ct_test_support:log_events(timetrap, + ct_test_support:log_events(timetrap_end_conf, reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = events_to_check(timetrap), + TestEvents = events_to_check(timetrap_end_conf), ok = ct_test_support:verify_events(TestEvents, Events, Config). +%%%----------------------------------------------------------------- +%%% +timetrap_normal(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + Join = fun(D, S) -> filename:join(D, "error/test/"++S) end, + Suite = Join(DataDir, "timetrap_2_SUITE"), + {Opts,ERPid} = setup([{suite,Suite}, + {userconfig,{ct_userconfig_callback, + "multiply 1 scale false"}}], + Config), + ok = ct_test_support:run(Opts, Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(timetrap_normal, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = events_to_check(timetrap_normal), + ok = ct_test_support:verify_events(TestEvents, Events, Config). + +%%%----------------------------------------------------------------- +%%% +timetrap_extended(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + Join = fun(D, S) -> filename:join(D, "error/test/"++S) end, + Suite = Join(DataDir, "timetrap_2_SUITE"), + {Opts,ERPid} = setup([{suite,Suite}, + {multiply_timetraps,2}, + {scale_timetraps,false}, + {userconfig,{ct_userconfig_callback, + "multiply 2 scale false"}}], + Config), + ok = ct_test_support:run(Opts, Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(timetrap_extended, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = events_to_check(timetrap_extended), + ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- %%% HELP FUNCTIONS @@ -160,7 +203,7 @@ 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 ++ [Test,{event_handler,{?eh,EvHArgs}}], + Opts = Opts0 ++ [{event_handler,{?eh,EvHArgs}}|Test], ERPid = ct_test_support:start_event_receiver(Config), {Opts,ERPid}. @@ -584,18 +627,77 @@ test_events(lib_error) -> test_events(no_compile) -> []; -test_events(timetrap) -> +test_events(timetrap_end_conf) -> [ - {?eh,start_logging,{'DEF','RUNDIR'}}, - {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,start_info,{1,1,1}}, - {?eh,tc_start,{timetrap_1_SUITE,init_per_suite}}, - {?eh,tc_done,{timetrap_1_SUITE,init_per_suite,ok}}, - {?eh,tc_start,{timetrap_1_SUITE,tc1}}, - {?eh,tc_done,{timetrap_1_SUITE,tc1,{failed,{timetrap_timeout,1000}}}}, - {?eh,test_stats,{0,1,{0,0}}}, - {?eh,tc_start,{timetrap_1_SUITE,end_per_suite}}, - {?eh,tc_done,{timetrap_1_SUITE,end_per_suite,ok}}, - {?eh,test_done,{'DEF','STOP_TIME'}}, - {?eh,stop_logging,[]} + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{1,1,3}}, + {?eh,tc_start,{timetrap_1_SUITE,init_per_suite}}, + {?eh,tc_done,{timetrap_1_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{timetrap_1_SUITE,tc1}}, + {?eh,tc_done, + {timetrap_1_SUITE,tc1,{failed,{timetrap_timeout,1000}}}}, + {?eh,test_stats,{0,1,{0,0}}}, + {?eh,tc_start,{timetrap_1_SUITE,tc2}}, + {?eh,tc_done, + {timetrap_1_SUITE,tc2,{failed,{testcase_aborted,testing_end_conf}}}}, + {?eh,test_stats,{0,2,{0,0}}}, + {?eh,tc_start,{timetrap_1_SUITE,tc3}}, + {?eh,tc_done, + {timetrap_1_SUITE,tc3,{failed,{testcase_aborted,testing_end_conf}}}}, + {?eh,test_stats,{0,3,{0,0}}}, + {?eh,tc_start,{timetrap_1_SUITE,end_per_suite}}, + {?eh,tc_done,{timetrap_1_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(timetrap_normal) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{1,1,3}}, + {?eh,tc_start,{timetrap_2_SUITE,init_per_suite}}, + {?eh,tc_done,{timetrap_2_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{timetrap_2_SUITE,tc0}}, + {?eh,tc_done, + {timetrap_2_SUITE,tc0,{failed,{timetrap_timeout,3000}}}}, + {?eh,test_stats,{0,1,{0,0}}}, + {?eh,tc_start,{timetrap_2_SUITE,tc1}}, + {?eh,tc_done, + {timetrap_2_SUITE,tc1,{failed,{timetrap_timeout,1000}}}}, + {?eh,test_stats,{0,2,{0,0}}}, + {?eh,tc_start,{timetrap_2_SUITE,tc2}}, + {?eh,tc_done, + {timetrap_2_SUITE,tc2,{failed,{timetrap_timeout,500}}}}, + {?eh,test_stats,{0,3,{0,0}}}, + {?eh,tc_start,{timetrap_2_SUITE,end_per_suite}}, + {?eh,tc_done,{timetrap_2_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]; + +test_events(timetrap_extended) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{1,1,3}}, + {?eh,tc_start,{timetrap_2_SUITE,init_per_suite}}, + {?eh,tc_done,{timetrap_2_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{timetrap_2_SUITE,tc0}}, + {?eh,tc_done, + {timetrap_2_SUITE,tc0,{failed,{timetrap_timeout,6000}}}}, + {?eh,test_stats,{0,1,{0,0}}}, + {?eh,tc_start,{timetrap_2_SUITE,tc1}}, + {?eh,tc_done, + {timetrap_2_SUITE,tc1,{failed,{timetrap_timeout,2000}}}}, + {?eh,test_stats,{0,2,{0,0}}}, + {?eh,tc_start,{timetrap_2_SUITE,tc2}}, + {?eh,tc_done, + {timetrap_2_SUITE,tc2,{failed,{timetrap_timeout,1000}}}}, + {?eh,test_stats,{0,3,{0,0}}}, + {?eh,tc_start,{timetrap_2_SUITE,end_per_suite}}, + {?eh,tc_done,{timetrap_2_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} ]. diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_1_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_1_SUITE.erl new file mode 100644 index 0000000000..2e6432d05d --- /dev/null +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_1_SUITE.erl @@ -0,0 +1,135 @@ +%% +%% %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% +%% +-module(timetrap_1_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%-------------------------------------------------------------------- +%% Function: suite() -> Info +%% Info = [tuple()] +%%-------------------------------------------------------------------- +suite() -> + [{timetrap,{seconds,1}}]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config0) -> void() | {save_config,Config1} +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_group(GroupName, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% GroupName = atom() +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_group(_GroupName, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_group(GroupName, Config0) -> +%% void() | {save_config,Config1} +%% GroupName = atom() +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_group(_GroupName, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% TestCase = atom() +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_testcase(tc3, Config) -> + [{default_timeout,5000}|Config]; +init_per_testcase(_TestCase, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config0) -> +%% void() | {save_config,Config1} +%% TestCase = atom() +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_testcase(tc1, Config) -> + ct:pal("tc1: ~p", [Config]), + ok; + +end_per_testcase(tc2, Config) -> + ct:pal("tc2: ~p", [Config]), + ok; + +end_per_testcase(tc3, Config) -> + ct:pal("tc3: ~p", [Config]), + ct:sleep(10000), + ok. + +%%-------------------------------------------------------------------- +%% Function: groups() -> [Group] +%% Group = {GroupName,Properties,GroupsAndTestCases} +%% GroupName = atom() +%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}] +%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase] +%% TestCase = atom() +%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}} +%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | +%% repeat_until_any_ok | repeat_until_any_fail +%% N = integer() | forever +%%-------------------------------------------------------------------- +groups() -> + []. + +%%-------------------------------------------------------------------- +%% Function: all() -> GroupsAndTestCases | {skip,Reason} +%% GroupsAndTestCases = [{group,GroupName} | TestCase] +%% GroupName = atom() +%% TestCase = atom() +%% Reason = term() +%%-------------------------------------------------------------------- +all() -> + [tc1,tc2,tc3]. + +tc1(_) -> + ct:sleep(3000), + ok. + +tc2(_) -> + spawn(ct, abort_current_testcase, [testing_end_conf]), + timer:sleep(3000), + ok. + +tc3(_) -> + spawn(ct, abort_current_testcase, [testing_end_conf]), + timer:sleep(3000), + ok. diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_2_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_2_SUITE.erl new file mode 100644 index 0000000000..b785d330aa --- /dev/null +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_2_SUITE.erl @@ -0,0 +1,138 @@ +%% +%% %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% +%% +-module(timetrap_2_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%-------------------------------------------------------------------- +%% Function: suite() -> Info +%% Info = [tuple()] +%%-------------------------------------------------------------------- +suite() -> + [{timetrap,{seconds,3}}, + {require,multiply}, + {require,scale}]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config0) -> void() | {save_config,Config1} +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_group(GroupName, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% GroupName = atom() +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_group(_GroupName, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_group(GroupName, Config0) -> +%% void() | {save_config,Config1} +%% GroupName = atom() +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_group(_GroupName, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% TestCase = atom() +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_testcase(tc1, Config) -> + ct:timetrap({seconds,1}), + Config; + +init_per_testcase(tc3, Config) -> + ct:timetrap({seconds,1}), + Config; + +init_per_testcase(_TestCase, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config0) -> +%% void() | {save_config,Config1} +%% TestCase = atom() +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_testcase(_, Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: groups() -> [Group] +%% Group = {GroupName,Properties,GroupsAndTestCases} +%% GroupName = atom() +%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}] +%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase] +%% TestCase = atom() +%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}} +%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | +%% repeat_until_any_ok | repeat_until_any_fail +%% N = integer() | forever +%%-------------------------------------------------------------------- +groups() -> + []. + +%%-------------------------------------------------------------------- +%% Function: all() -> GroupsAndTestCases | {skip,Reason} +%% GroupsAndTestCases = [{group,GroupName} | TestCase] +%% GroupName = atom() +%% TestCase = atom() +%% Reason = term() +%%-------------------------------------------------------------------- +all() -> + [tc0,tc1,tc2]. + +tc0(_) -> + N = list_to_integer(ct:get_config(multiply)), + ct:comment(io_lib:format("TO after ~w sec", [3*N])), + ct:sleep({seconds,5}), + ok. + +tc1(_) -> + N =list_to_integer( ct:get_config(multiply)), + ct:comment(io_lib:format("TO after ~w sec", [1*N])), + ct:sleep({seconds,5}), + ok. + +tc2(_) -> + N = list_to_integer(ct:get_config(multiply)), + ct:comment(io_lib:format("TO after ~w sec", [0.5*N])), + ct:timetrap(500), + ct:sleep(2000), + ok. diff --git a/lib/common_test/test/ct_test_server_if_1_SUITE.erl b/lib/common_test/test/ct_test_server_if_1_SUITE.erl index 8b46a30cdc..eb85409073 100644 --- a/lib/common_test/test/ct_test_server_if_1_SUITE.erl +++ b/lib/common_test/test/ct_test_server_if_1_SUITE.erl @@ -202,14 +202,14 @@ test_events(ts_if_1) -> {?eh,tc_done,{ts_if_1_SUITE,{end_per_group,g2,[parallel]},ok}}]}, {?eh,tc_start,{ts_if_1_SUITE,tc12}}, - {?eh,tc_done,{undefined,undefined,{testcase_aborted,{abort_current_testcase,tc12},'_'}}}, + {?eh,tc_done,{ts_if_1_SUITE,tc12,{failed,{testcase_aborted,'stopping tc12'}}}}, {?eh,test_stats,{2,5,{3,6}}}, {?eh,tc_start,{ts_if_1_SUITE,tc13}}, {?eh,tc_done,{ts_if_1_SUITE,tc13,ok}}, {?eh,test_stats,{3,5,{3,6}}}, {?eh,tc_start,{ts_if_1_SUITE,end_per_suite}}, {?eh,tc_done,{ts_if_1_SUITE,end_per_suite,ok}}, -%%! + {?eh,tc_start,{ts_if_2_SUITE,init_per_suite}}, {?eh,tc_done,{ts_if_2_SUITE,init_per_suite, {failed,{error,{suite0_failed,{exited,suite0_goes_boom}}}}}}, diff --git a/lib/common_test/test/ct_test_server_if_1_SUITE_data/test_server_if/test/ts_if_1_SUITE.erl b/lib/common_test/test/ct_test_server_if_1_SUITE_data/test_server_if/test/ts_if_1_SUITE.erl index 8e90df21ce..47cea190dd 100644 --- a/lib/common_test/test/ct_test_server_if_1_SUITE_data/test_server_if/test/ts_if_1_SUITE.erl +++ b/lib/common_test/test/ct_test_server_if_1_SUITE_data/test_server_if/test/ts_if_1_SUITE.erl @@ -93,6 +93,10 @@ init_per_testcase(_TestCase, Config) -> %%-------------------------------------------------------------------- end_per_testcase(tc2, Config) -> timer:sleep(5000); +end_per_testcase(tc12, Config) -> + ct:comment("end_per_testcase(tc12) called!"), + ct:pal("end_per_testcase(tc12) called!", []), + ok; end_per_testcase(_TestCase, _Config) -> ok. @@ -180,9 +184,9 @@ gtc2(_) -> exit(should_have_been_skipped). tc12(_) -> - F = fun() -> ct:abort_current_testcase({abort_current_testcase,tc12}) end, + F = fun() -> ct:abort_current_testcase('stopping tc12') end, spawn(F), - timer:sleep(500), + timer:sleep(1000), exit(should_have_been_aborted). tc13(_) -> diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index c7c7384847..9ce8529bdb 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -110,11 +110,11 @@ init_per_testcase(_TestCase, Config) -> {_,{_,LogDir}} = lists:keysearch(logdir, 1, get_opts(Config)), case lists:keysearch(master, 1, Config) of false-> - test_server:format("See Common Test logs here:\n" + test_server:format("See Common Test logs here:\n\n" "~s/all_runs.html", [LogDir,LogDir]); {value, _}-> - test_server:format("See CT Master Test logs here:\n" + test_server:format("See CT Master Test logs here:\n\n" "~s/master_runs.html", [LogDir,LogDir]) end, @@ -183,14 +183,14 @@ run(Opts, Config) -> CTNode = ?config(ct_node, Config), Level = ?config(trace_level, Config), %% use ct interface - test_server:format(Level, "Calling ct:run_test(~p) on ~p~n", + test_server:format(Level, "[RUN #1] Calling ct:run_test(~p) on ~p~n", [Opts, CTNode]), Result1 = rpc:call(CTNode, ct, run_test, [Opts]), %% use run_test interface (simulated) test_server:format(Level, "Saving start opts on ~p: ~p~n", [CTNode,Opts]), rpc:call(CTNode, application, set_env, [common_test, run_test_start_opts, Opts]), - test_server:format(Level, "Calling ct_run:script_start() on ~p~n", [CTNode]), + test_server:format(Level, "[RUN #2] Calling ct_run:script_start() on ~p~n", [CTNode]), Result2 = rpc:call(CTNode, ct_run, script_start, []), case {Result1,Result2} of {ok,ok} -> diff --git a/lib/common_test/test/ct_userconfig_callback.erl b/lib/common_test/test/ct_userconfig_callback.erl new file mode 100644 index 0000000000..ca51bf240b --- /dev/null +++ b/lib/common_test/test/ct_userconfig_callback.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(ct_userconfig_callback). + +-export([check_parameter/1, read_config/1]). + +read_config(Str) -> + KeyVals = string:tokens(Str, " "), + {ok,read_config1(KeyVals)}. + +read_config1([Key,Val | KeyVals]) -> + [{list_to_atom(Key),Val} | read_config1(KeyVals)]; +read_config1([]) -> + []. + +check_parameter(Str) -> + {ok,{config,Str}}. -- cgit v1.2.3 From 1358ccecd1169d0c534137fb2c65759c7089cd0a Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Fri, 4 Jun 2010 18:21:13 +0200 Subject: Add support for config info functions (e.g. init_per_suite/0) Also fixed bug: return value {fail,Reason} from end_tc(init_per_suite) was ignored. --- lib/common_test/test/ct_error_SUITE.erl | 28 ++++- .../error/test/cfg_error_10_SUITE.erl | 123 +++++++++++++++++++ .../error/test/cfg_error_11_SUITE.erl | 134 +++++++++++++++++++++ 3 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_10_SUITE.erl create mode 100644 lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_11_SUITE.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_error_SUITE.erl b/lib/common_test/test/ct_error_SUITE.erl index 11482f1508..199a1ad97a 100644 --- a/lib/common_test/test/ct_error_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE.erl @@ -87,7 +87,9 @@ cfg_error(Config) when is_list(Config) -> Join(DataDir, "cfg_error_6_SUITE"), Join(DataDir, "cfg_error_7_SUITE"), Join(DataDir, "cfg_error_8_SUITE"), - Join(DataDir, "cfg_error_9_SUITE") + Join(DataDir, "cfg_error_9_SUITE"), + Join(DataDir, "cfg_error_10_SUITE"), + Join(DataDir, "cfg_error_11_SUITE") ], {Opts,ERPid} = setup([{suite,Suites}], Config), ok = ct_test_support:run(Opts, Config), @@ -228,7 +230,7 @@ test_events(cfg_error) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,start_info,{9,9,33}}, + {?eh,start_info,{11,11,36}}, {?eh,tc_start,{cfg_error_1_SUITE,init_per_suite}}, {?eh,tc_done, @@ -540,6 +542,28 @@ test_events(cfg_error) -> {?eh,tc_start,{cfg_error_9_SUITE,end_per_suite}}, {?eh,tc_done,{cfg_error_9_SUITE,end_per_suite,ok}}, + {?eh,tc_start,{cfg_error_10_SUITE,init_per_suite}}, + {?eh,tc_done,{cfg_error_10_SUITE,init_per_suite, + {failed,{error,fail_init_per_suite}}}}, + {?eh,tc_auto_skip,{cfg_error_10_SUITE,tc1, + {failed,{cfg_error_10_SUITE,init_per_suite, + {failed,fail_init_per_suite}}}}}, + {?eh,test_stats,{12,3,{0,19}}}, + {?eh,tc_auto_skip,{cfg_error_10_SUITE,end_per_suite, + {failed,{cfg_error_10_SUITE,init_per_suite, + {failed,fail_init_per_suite}}}}}, + {?eh,tc_start,{cfg_error_11_SUITE,init_per_suite}}, + {?eh,tc_done,{cfg_error_11_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{cfg_error_11_SUITE,tc1}}, + {?eh,tc_done,{cfg_error_11_SUITE,tc1, + {skipped,{config_name_already_in_use,[dummy0]}}}}, + {?eh,test_stats,{12,3,{1,19}}}, + {?eh,tc_start,{cfg_error_11_SUITE,tc2}}, + {?eh,tc_done,{cfg_error_11_SUITE,tc2,ok}}, + {?eh,test_stats,{13,3,{1,19}}}, + {?eh,tc_start,{cfg_error_11_SUITE,end_per_suite}}, + {?eh,tc_done,{cfg_error_11_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} ]; diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_10_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_10_SUITE.erl new file mode 100644 index 0000000000..3bb2f63d34 --- /dev/null +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_10_SUITE.erl @@ -0,0 +1,123 @@ +%% +%% %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% +%% +-module(cfg_error_10_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%-------------------------------------------------------------------- +%% Function: suite() -> Info +%% Info = [tuple()] +%%-------------------------------------------------------------------- +suite() -> + [{timetrap,{seconds,2}}, + {require, dummy0}, {default_config, dummy0, "suite/0"}, + {require, dummy1}, {default_config, dummy1, "suite/0"}, + {require, dummy2}, {default_config, dummy2, "suite/0"}]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_suite() -> + put('$test_server_framework_test', + fun(init_tc, _Default) -> {fail,fail_init_per_suite}; + (_, Default) -> Default + end), + [{require, dummy3}, {default_config, dummy3, "init_per_suite/0"}, + {timetrap,3000}]. + +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config0) -> void() | {save_config,Config1} +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_group(GroupName, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% GroupName = atom() +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_group(_GroupName, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_group(GroupName, Config0) -> +%% void() | {save_config,Config1} +%% GroupName = atom() +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_group(_GroupName, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% TestCase = atom() +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_testcase(_, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config0) -> +%% void() | {save_config,Config1} +%% TestCase = atom() +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, _Config) -> + done. + +%%-------------------------------------------------------------------- +%% Function: groups() -> [Group] +%% Group = {GroupName,Properties,GroupsAndTestCases} +%% GroupName = atom() +%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}] +%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase] +%% TestCase = atom() +%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}} +%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | +%% repeat_until_any_ok | repeat_until_any_fail +%% N = integer() | forever +%%-------------------------------------------------------------------- +groups() -> + []. + +%%-------------------------------------------------------------------- +%% Function: all() -> GroupsAndTestCases | {skip,Reason} +%% GroupsAndTestCases = [{group,GroupName} | TestCase] +%% GroupName = atom() +%% TestCase = atom() +%% Reason = term() +%%-------------------------------------------------------------------- +all() -> + [tc1]. + +tc1(_) -> + exit(should_never_run). diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_11_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_11_SUITE.erl new file mode 100644 index 0000000000..224e83620e --- /dev/null +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_11_SUITE.erl @@ -0,0 +1,134 @@ +%% +%% %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% +%% +-module(cfg_error_11_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%-------------------------------------------------------------------- +%% Function: suite() -> Info +%% Info = [tuple()] +%%-------------------------------------------------------------------- +suite() -> + [{timetrap,{seconds,2}}, + {require, dummy0}, {default_config, dummy0, "suite/0"}, + {require, dummy1}, {default_config, dummy1, "suite/0"}, + {require, dummy2}, {default_config, dummy2, "suite/0"}]. + + + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config0) -> void() | {save_config,Config1} +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_suite() -> + put('$test_server_framework_test', + fun(end_tc, _Default) -> {fail,fail_end_per_suite}; + (_, Default) -> Default + end), + [{require, dummy3}, {default_config, dummy3, "end_per_suite/0"}, + {timetrap,3000}]. + +end_per_suite(_Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_group(GroupName, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% GroupName = atom() +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_group(_GroupName, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_group(GroupName, Config0) -> +%% void() | {save_config,Config1} +%% GroupName = atom() +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_group(_GroupName, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% TestCase = atom() +%% Config0 = Config1 = [tuple()] +%% Reason = term() +%%-------------------------------------------------------------------- +init_per_testcase(_, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config0) -> +%% void() | {save_config,Config1} +%% TestCase = atom() +%% Config0 = Config1 = [tuple()] +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, _Config) -> + done. + +%%-------------------------------------------------------------------- +%% Function: groups() -> [Group] +%% Group = {GroupName,Properties,GroupsAndTestCases} +%% GroupName = atom() +%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}] +%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase] +%% TestCase = atom() +%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}} +%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | +%% repeat_until_any_ok | repeat_until_any_fail +%% N = integer() | forever +%%-------------------------------------------------------------------- +groups() -> + []. + +%%-------------------------------------------------------------------- +%% Function: all() -> GroupsAndTestCases | {skip,Reason} +%% GroupsAndTestCases = [{group,GroupName} | TestCase] +%% GroupName = atom() +%% TestCase = atom() +%% Reason = term() +%%-------------------------------------------------------------------- +all() -> + [tc1, tc2]. + +tc1() -> + [{require, dummy0}, {default_config, dummy0, "tc1"}]. + +tc1(_) -> + dummy. + +tc2() -> + [{timetrap,1}]. + +tc2(_) -> + dummy. -- cgit v1.2.3 From cc372a2ba2aaa1de19935ff178d5dce88ec16854 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Sat, 5 Jun 2010 01:40:06 +0200 Subject: Fix error with {repeat,0} property in groups causing double iterations --- lib/common_test/test/ct_groups_test_2_SUITE.erl | 118 ++++++++++++++++++++- .../groups_1/repeat_1_SUITE.erl | 105 ++++++++++++++++++ 2 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 lib/common_test/test/ct_groups_test_2_SUITE_data/groups_1/repeat_1_SUITE.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_groups_test_2_SUITE.erl b/lib/common_test/test/ct_groups_test_2_SUITE.erl index 1fbeff0126..bdf7303a59 100644 --- a/lib/common_test/test/ct_groups_test_2_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_2_SUITE.erl @@ -60,7 +60,7 @@ all(doc) -> ["Run smoke tests of Common Test."]; all(suite) -> - [missing_conf, testspec_1]. + [missing_conf, testspec_1, repeat_1]. %%-------------------------------------------------------------------- %% TEST CASES @@ -104,6 +104,25 @@ testspec_1(Config) when is_list(Config) -> TestEvents = events_to_check(testspec_1), ok = ct_test_support:verify_events(TestEvents, Events, Config). +%%%----------------------------------------------------------------- +%%% + +repeat_1(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + + Suite = filename:join(DataDir, "groups_1/repeat_1_SUITE"), + + {Opts,ERPid} = setup({suite,Suite}, Config), + ok = ct_test_support:run(Opts, Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(repeat_1, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = events_to_check(repeat_1), + ok = ct_test_support:verify_events(TestEvents, Events, Config). + %%%----------------------------------------------------------------- %%% HELP FUNCTIONS %%%----------------------------------------------------------------- @@ -155,4 +174,99 @@ test_events(missing_conf) -> ]; test_events(testspec_1) -> - []. + []; + +test_events(repeat_1) -> + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{1,1,unknown}}, + {?eh,tc_start,{repeat_1_SUITE,init_per_suite}}, + {?eh,tc_done,{repeat_1_SUITE,init_per_suite,ok}}, + [{?eh,tc_start, + {repeat_1_SUITE,{init_per_group,test_group_1,[{repeat,1}]}}}, + {?eh,tc_done, + {repeat_1_SUITE,{init_per_group,test_group_1,[{repeat,1}]},ok}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_1a}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_1a,ok}}, + {?eh,test_stats,{1,0,{0,0}}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_1b}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_1b,ok}}, + {?eh,test_stats,{2,0,{0,0}}}, + {?eh,tc_start, + {repeat_1_SUITE,{end_per_group,test_group_1,[{repeat,1}]}}}, + {?eh,tc_done, + {repeat_1_SUITE,{end_per_group,test_group_1,[{repeat,1}]},ok}}], + [{?eh,tc_start, + {repeat_1_SUITE,{init_per_group,test_group_1,[]}}}, + {?eh,tc_done, + {repeat_1_SUITE,{init_per_group,test_group_1,[]},ok}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_1a}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_1a,ok}}, + {?eh,test_stats,{3,0,{0,0}}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_1b}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_1b,ok}}, + {?eh,test_stats,{4,0,{0,0}}}, + {?eh,tc_start, + {repeat_1_SUITE,{end_per_group,test_group_1,[]}}}, + {?eh,tc_done, + {repeat_1_SUITE,{end_per_group,test_group_1,[]},ok}}], + [{?eh,tc_start, + {repeat_1_SUITE,{init_per_group,test_group_2,[{repeat,0}]}}}, + {?eh,tc_done, + {repeat_1_SUITE,{init_per_group,test_group_2,[{repeat,0}]},ok}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_2a}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_2a,ok}}, + {?eh,test_stats,{5,0,{0,0}}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_2b}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_2b,ok}}, + {?eh,test_stats,{6,0,{0,0}}}, + {?eh,tc_start, + {repeat_1_SUITE,{end_per_group,test_group_2,[{repeat,0}]}}}, + {?eh,tc_done, + {repeat_1_SUITE,{end_per_group,test_group_2,[{repeat,0}]},ok}}], + [{?eh,tc_start, + {repeat_1_SUITE, + {init_per_group,test_group_3,[{repeat_until_all_fail,0}]}}}, + {?eh,tc_done, + {repeat_1_SUITE, + {init_per_group,test_group_3,[{repeat_until_all_fail,0}]}, + ok}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_3a}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_3a,ok}}, + {?eh,test_stats,{7,0,{0,0}}}, + [{?eh,tc_start, + {repeat_1_SUITE, + {init_per_group,test_group_4,[{repeat_until_any_fail,0}]}}}, + {?eh,tc_done, + {repeat_1_SUITE, + {init_per_group,test_group_4,[{repeat_until_any_fail,0}]}, + ok}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_4a}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_4a,ok}}, + {?eh,test_stats,{8,0,{0,0}}}, + {?eh,tc_start,{repeat_1_SUITE,testcase_4b}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_4b,ok}}, + {?eh,test_stats,{9,0,{0,0}}}, + {?eh,tc_start, + {repeat_1_SUITE, + {end_per_group,test_group_4,[{repeat_until_any_fail,0}]}}}, + {?eh,tc_done, + {repeat_1_SUITE, + {end_per_group,test_group_4,[{repeat_until_any_fail,0}]}, + ok}}], + {?eh,tc_start,{repeat_1_SUITE,testcase_3b}}, + {?eh,tc_done,{repeat_1_SUITE,testcase_3b,ok}}, + {?eh,test_stats,{10,0,{0,0}}}, + {?eh,tc_start, + {repeat_1_SUITE, + {end_per_group,test_group_3,[{repeat_until_all_fail,0}]}}}, + {?eh,tc_done, + {repeat_1_SUITE, + {end_per_group,test_group_3,[{repeat_until_all_fail,0}]}, + ok}}], + {?eh,tc_start,{repeat_1_SUITE,end_per_suite}}, + {?eh,tc_done,{repeat_1_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]. diff --git a/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_1/repeat_1_SUITE.erl b/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_1/repeat_1_SUITE.erl new file mode 100644 index 0000000000..4edbc3e384 --- /dev/null +++ b/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_1/repeat_1_SUITE.erl @@ -0,0 +1,105 @@ +%% +%% %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% +%% +-module(repeat_1_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%==================================================================== +%% COMMON TEST CALLBACK FUNCTIONS +%%==================================================================== + +suite() -> + [{timetrap,{minutes,1}}]. + +groups() -> + [ + {test_group_1, [{repeat,1}], [testcase_1a,testcase_1b]}, + {test_group_2, [{repeat,0}], [testcase_2a,testcase_2b]}, + + {test_group_3, [{repeat_until_all_fail,0}], + [testcase_3a, + {test_group_4, [{repeat_until_any_fail,0}], + [testcase_4a, testcase_4b]}, + testcase_3b]} + ]. + +all() -> + [ + {group, test_group_1}, + {group, test_group_2}, + {group, test_group_3} + ]. + +%%-------------------------------------------------------------------- +%% Suite Configuration +%%-------------------------------------------------------------------- + +init_per_suite(Config) -> + Config. + +end_per_suite(Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Group Configuration +%%-------------------------------------------------------------------- + +init_per_group(Group, Config) -> + Group = proplists:get_value(name,?config(tc_group_properties,Config)), + ct:comment(Group), + Config. + +end_per_group(_Group, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Testcase Configuration +%%-------------------------------------------------------------------- + +init_per_testcase(_TestCase, Config) -> + Config. + +end_per_testcase(_TestCase, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Testcases +%%-------------------------------------------------------------------- + +testcase_1a(_) -> + ok. +testcase_1b(_) -> + ok. + +testcase_2a(_) -> + ok. +testcase_2b(_) -> + ok. + +testcase_3a(_) -> + ok. +testcase_3b(_) -> + ok. + +testcase_4a(_) -> + ok. +testcase_4b(_) -> + ok. -- cgit v1.2.3 From b9e20d9e1f3b47ab5806cd79c16c5609f12453f9 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Sat, 5 Jun 2010 03:19:35 +0200 Subject: Add test suite for remote loading of binary suites --- lib/common_test/test/Makefile | 3 +- lib/common_test/test/ct_misc_1_SUITE.erl | 138 +++++++++++++++++++++ .../test/ct_misc_1_SUITE_data/beam_1_SUITE.erl | 134 ++++++++++++++++++++ .../test/ct_misc_1_SUITE_data/beam_2_SUITE.erl | 134 ++++++++++++++++++++ lib/common_test/test/ct_test_support.erl | 4 +- 5 files changed, 410 insertions(+), 3 deletions(-) create mode 100644 lib/common_test/test/ct_misc_1_SUITE.erl create mode 100644 lib/common_test/test/ct_misc_1_SUITE_data/beam_1_SUITE.erl create mode 100644 lib/common_test/test/ct_misc_1_SUITE_data/beam_2_SUITE.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index 594993cfec..2f1ff9a835 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -36,7 +36,8 @@ MODULES= \ ct_error_SUITE \ ct_test_server_if_1_SUITE \ ct_config_SUITE \ - ct_master_SUITE + ct_master_SUITE \ + ct_misc_1_SUITE ERL_FILES= $(MODULES:%=%.erl) diff --git a/lib/common_test/test/ct_misc_1_SUITE.erl b/lib/common_test/test/ct_misc_1_SUITE.erl new file mode 100644 index 0000000000..f42081ee7e --- /dev/null +++ b/lib/common_test/test/ct_misc_1_SUITE.erl @@ -0,0 +1,138 @@ +%% +%% %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_misc_1_SUITE +%%% +%%% Description: +%%% Test misc things in Common Test suites. +%%% +%%% The suites used for the test are located in the data directory. +%%%------------------------------------------------------------------- +-module(ct_misc_1_SUITE). + +-compile(export_all). + +-include_lib("test_server/include/test_server.hrl"). +-include_lib("test_server/include/test_server_line.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) -> + Config1 = ct_test_support:init_per_suite(Config), + Config1. + +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). + +all(doc) -> + [""]; + +all(suite) -> + [ + beam_me_up + ]. + +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- + +%%%----------------------------------------------------------------- +%%% +beam_me_up(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + CTNode = ?config(ct_node, Config), + + %% Path = rpc:call(CTNode, code, get_path, []), + [_ | Parts] = lists:reverse(filename:split(DataDir)), + TSDir = filename:join(lists:reverse(Parts)), + true = rpc:call(CTNode, code, del_path, [TSDir]), + + Mods = [beam_1_SUITE, beam_2_SUITE], + Suites = [atom_to_list(M) || M <- Mods], + [{error,_} = rpc:call(CTNode, code, load_file, [M]) || M <- Mods], + + code:add_path(TSDir), + CRes = + [compile:file(filename:join(DataDir,F), + [verbose,report_errors, + report_warnings,binary]) || F <- Suites], + + [{module,_} = rpc:call(CTNode, code, load_binary, + [Mod, atom_to_list(Mod), Bin]) || + {ok,Mod,Bin} <- CRes], + + {Opts,ERPid} = setup([{suite,Suites},{auto_compile,false}], Config), + ok = ct_test_support:run(ct, run_test, [Opts], Config), + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(beam_me_up, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + + TestEvents = events_to_check(beam_me_up), + ok = ct_test_support:verify_events(TestEvents, Events, Config). + +%%%----------------------------------------------------------------- +%%% HELP FUNCTIONS +%%%----------------------------------------------------------------- + +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(beam_me_up) -> + []. diff --git a/lib/common_test/test/ct_misc_1_SUITE_data/beam_1_SUITE.erl b/lib/common_test/test/ct_misc_1_SUITE_data/beam_1_SUITE.erl new file mode 100644 index 0000000000..e371b13ccb --- /dev/null +++ b/lib/common_test/test/ct_misc_1_SUITE_data/beam_1_SUITE.erl @@ -0,0 +1,134 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2008-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(beam_1_SUITE). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%-------------------------------------------------------------------- +%% COMMON TEST CALLBACK FUNCTIONS +%%-------------------------------------------------------------------- + +%%-------------------------------------------------------------------- +%% Function: suite() -> Info +%% +%% Info = [tuple()] +%% List of key/value pairs. +%% +%% Description: Returns list of tuples to set default properties +%% for the suite. +%% +%% Note: The suite/0 function is only meant to be used to return +%% default data values, not perform any other operations. +%%-------------------------------------------------------------------- +suite() -> + [ + {timetrap,{seconds,10}} + ]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Reason = term() +%% The reason for skipping the suite. +%% +%% Description: Initialization before the suite. +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config0) -> void() | {save_config,Config1} +%% +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Cleanup after the suite. +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% +%% TestCase = atom() +%% Name of the test case that is about to run. +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Reason = term() +%% The reason for skipping the test case. +%% +%% Description: Initialization 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. +%%-------------------------------------------------------------------- +init_per_testcase(_TestCase, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config0) -> +%% void() | {save_config,Config1} +%% +%% TestCase = atom() +%% Name of the test case that is finished. +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Cleanup after each test case. +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: all() -> TestCases | {skip,Reason} +%% +%% TestCases = [TestCase | {sequence,SeqName}] +%% TestCase = atom() +%% Name of a test case. +%% SeqName = atom() +%% Name of a test case sequence. +%% Reason = term() +%% The reason for skipping all test cases. +%% +%% Description: Returns the list of test cases that are to be executed. +%%-------------------------------------------------------------------- +all() -> + [tc1, tc2]. + +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- + +tc1(_Config) -> + ct:comment("tc1 executed"), + ok. + +tc2(_Config) -> + exit('tc2 failed'). diff --git a/lib/common_test/test/ct_misc_1_SUITE_data/beam_2_SUITE.erl b/lib/common_test/test/ct_misc_1_SUITE_data/beam_2_SUITE.erl new file mode 100644 index 0000000000..d0d442bd0b --- /dev/null +++ b/lib/common_test/test/ct_misc_1_SUITE_data/beam_2_SUITE.erl @@ -0,0 +1,134 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2008-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(beam_2_SUITE). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +%%-------------------------------------------------------------------- +%% COMMON TEST CALLBACK FUNCTIONS +%%-------------------------------------------------------------------- + +%%-------------------------------------------------------------------- +%% Function: suite() -> Info +%% +%% Info = [tuple()] +%% List of key/value pairs. +%% +%% Description: Returns list of tuples to set default properties +%% for the suite. +%% +%% Note: The suite/0 function is only meant to be used to return +%% default data values, not perform any other operations. +%%-------------------------------------------------------------------- +suite() -> + [ + {timetrap,{seconds,10}} + ]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Reason = term() +%% The reason for skipping the suite. +%% +%% Description: Initialization before the suite. +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config0) -> void() | {save_config,Config1} +%% +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Cleanup after the suite. +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% +%% TestCase = atom() +%% Name of the test case that is about to run. +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Reason = term() +%% The reason for skipping the test case. +%% +%% Description: Initialization 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. +%%-------------------------------------------------------------------- +init_per_testcase(_TestCase, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config0) -> +%% void() | {save_config,Config1} +%% +%% TestCase = atom() +%% Name of the test case that is finished. +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Cleanup after each test case. +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, _Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: all() -> TestCases | {skip,Reason} +%% +%% TestCases = [TestCase | {sequence,SeqName}] +%% TestCase = atom() +%% Name of a test case. +%% SeqName = atom() +%% Name of a test case sequence. +%% Reason = term() +%% The reason for skipping all test cases. +%% +%% Description: Returns the list of test cases that are to be executed. +%%-------------------------------------------------------------------- +all() -> + [tc1, tc2]. + +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- + +tc1(_Config) -> + ct:comment("tc1 executed"), + ok. + +tc2(_Config) -> + exit('tc2 failed'). diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index 9ce8529bdb..eaf3e23859 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -183,7 +183,7 @@ run(Opts, Config) -> CTNode = ?config(ct_node, Config), Level = ?config(trace_level, Config), %% use ct interface - test_server:format(Level, "[RUN #1] Calling ct:run_test(~p) on ~p~n", + test_server:format(Level, "~n[RUN #1] Calling ct:run_test(~p) on ~p~n", [Opts, CTNode]), Result1 = rpc:call(CTNode, ct, run_test, [Opts]), @@ -204,7 +204,7 @@ run(Opts, Config) -> run(M, F, A, Config) -> CTNode = ?config(ct_node, Config), Level = ?config(trace_level, Config), - test_server:format(Level, "Calling ~w:~w(~p) on ~p~n", + test_server:format(Level, "~nCalling ~w:~w(~p) on ~p~n", [M, F, A, CTNode]), rpc:call(CTNode, M, F, A). -- cgit v1.2.3 From d3a6ecb105706b66f1c0c6b8a515370df5e29bd3 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Sat, 5 Jun 2010 18:35:37 +0200 Subject: Add support for executing pre-loaded suites (e.g. modules loaded as binaries) Also fixed bug in test_server that calls end_per_testcase after test case timeout or abortion. --- lib/common_test/test/ct_error_SUITE.erl | 20 +++- .../error/test/timetrap_1_SUITE.erl | 103 ++++++++++++++++----- lib/common_test/test/ct_misc_1_SUITE.erl | 37 +++++++- 3 files changed, 129 insertions(+), 31 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_error_SUITE.erl b/lib/common_test/test/ct_error_SUITE.erl index 199a1ad97a..b479d4133c 100644 --- a/lib/common_test/test/ct_error_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE.erl @@ -655,21 +655,33 @@ test_events(timetrap_end_conf) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,start_info,{1,1,3}}, + {?eh,start_info,{1,1,6}}, {?eh,tc_start,{timetrap_1_SUITE,init_per_suite}}, {?eh,tc_done,{timetrap_1_SUITE,init_per_suite,ok}}, {?eh,tc_start,{timetrap_1_SUITE,tc1}}, {?eh,tc_done, - {timetrap_1_SUITE,tc1,{failed,{timetrap_timeout,1000}}}}, + {timetrap_1_SUITE,tc1,{failed,{timetrap_timeout,1000}}}}, {?eh,test_stats,{0,1,{0,0}}}, {?eh,tc_start,{timetrap_1_SUITE,tc2}}, {?eh,tc_done, - {timetrap_1_SUITE,tc2,{failed,{testcase_aborted,testing_end_conf}}}}, + {timetrap_1_SUITE,tc2,{failed,{timetrap_timeout,1000}}}}, {?eh,test_stats,{0,2,{0,0}}}, {?eh,tc_start,{timetrap_1_SUITE,tc3}}, {?eh,tc_done, - {timetrap_1_SUITE,tc3,{failed,{testcase_aborted,testing_end_conf}}}}, + {timetrap_1_SUITE,tc3,{failed,{testcase_aborted,testing_end_conf}}}}, {?eh,test_stats,{0,3,{0,0}}}, + {?eh,tc_start,{timetrap_1_SUITE,tc4}}, + {?eh,tc_done, + {timetrap_1_SUITE,tc4,{failed,{testcase_aborted,testing_end_conf}}}}, + {?eh,test_stats,{0,4,{0,0}}}, + {?eh,tc_start,{timetrap_1_SUITE,tc5}}, + {?eh,tc_done, + {timetrap_1_SUITE,tc5,{failed,{timetrap_timeout,1000}}}}, + {?eh,test_stats,{0,5,{0,0}}}, + {?eh,tc_start,{timetrap_1_SUITE,tc6}}, + {?eh,tc_done, + {timetrap_1_SUITE,tc6,{failed,{testcase_aborted,testing_end_conf}}}}, + {?eh,test_stats,{0,6,{0,0}}}, {?eh,tc_start,{timetrap_1_SUITE,end_per_suite}}, {?eh,tc_done,{timetrap_1_SUITE,end_per_suite,ok}}, {?eh,test_done,{'DEF','STOP_TIME'}}, diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_1_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_1_SUITE.erl index 2e6432d05d..7a13a7c8a5 100644 --- a/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_1_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/timetrap_1_SUITE.erl @@ -36,13 +36,19 @@ suite() -> %% Reason = term() %%-------------------------------------------------------------------- init_per_suite(Config) -> - Config. + TabPid = spawn(fun() -> + ets:new(?MODULE, [named_table, set, public]), + ets:insert(?MODULE, {last_case,ok}), + receive _ -> ok end + end), + [{tab,TabPid} | Config]. %%-------------------------------------------------------------------- %% Function: end_per_suite(Config0) -> void() | {save_config,Config1} %% Config0 = Config1 = [tuple()] %%-------------------------------------------------------------------- -end_per_suite(_Config) -> +end_per_suite(Config) -> + exit(?config(tab, Config), kill), ok. %%-------------------------------------------------------------------- @@ -71,10 +77,29 @@ end_per_group(_GroupName, _Config) -> %% Config0 = Config1 = [tuple()] %% Reason = term() %%-------------------------------------------------------------------- -init_per_testcase(tc3, Config) -> - [{default_timeout,5000}|Config]; -init_per_testcase(_TestCase, Config) -> - Config. +init_per_testcase(TC, Config) -> + {_,_} = process_info(?config(tab, Config), priority), + [{_,ok}] = ets:lookup(?MODULE, last_case), + ets:insert(?MODULE, {last_case,fail}), + init_per_testcase1(TC, Config). + +init_per_testcase1(tc1, Config) -> + [{tc,tc1}|Config]; + +init_per_testcase1(tc2, Config) -> + [{tc,tc2}|Config]; + +init_per_testcase1(tc3, Config) -> + [{tc,tc3}|Config]; + +init_per_testcase1(tc4, Config) -> + [{tc,tc4},{default_timeout,5000}|Config]; + +init_per_testcase1(tc5, Config) -> + [{tc,tc5}|Config]; + +init_per_testcase1(tc6, Config) -> + [{tc,tc6}|Config]. %%-------------------------------------------------------------------- %% Function: end_per_testcase(TestCase, Config0) -> @@ -82,18 +107,45 @@ init_per_testcase(_TestCase, Config) -> %% TestCase = atom() %% Config0 = Config1 = [tuple()] %%-------------------------------------------------------------------- -end_per_testcase(tc1, Config) -> - ct:pal("tc1: ~p", [Config]), +end_per_testcase(TC, Config) -> + {_,_} = process_info(?config(tab, Config), priority), + [{_,fail}] = ets:lookup(?MODULE, last_case), + ets:insert(?MODULE, {last_case,ok}), + end_per_testcase1(TC, Config). + +end_per_testcase1(tc1, Config) -> + ct:pal("end_per_testcase(tc1): ~p", [Config]), + tc1 = ?config(tc, Config), + {failed,timetrap_timeout} = ?config(tc_status, Config), ok; -end_per_testcase(tc2, Config) -> - ct:pal("tc2: ~p", [Config]), +end_per_testcase1(tc2, Config) -> + ct:pal("end_per_testcase(tc2): ~p", [Config]), + tc2 = ?config(tc, Config), + {failed,timetrap_timeout} = ?config(tc_status, Config), + timer:sleep(2000); + +end_per_testcase1(tc3, Config) -> + ct:pal("end_per_testcase(tc3): ~p", [Config]), + tc3 = ?config(tc, Config), + {failed,{testcase_aborted,testing_end_conf}} = ?config(tc_status, Config), ok; -end_per_testcase(tc3, Config) -> - ct:pal("tc3: ~p", [Config]), - ct:sleep(10000), - ok. +end_per_testcase1(tc4, Config) -> + ct:pal("end_per_testcase(tc4): ~p", [Config]), + tc4 = ?config(tc, Config), + {failed,{testcase_aborted,testing_end_conf}} = ?config(tc_status, Config), + timer:sleep(2000); + +end_per_testcase1(tc5, Config) -> + ct:pal("end_per_testcase(tc5): ~p", [Config]), + tc5 = ?config(tc, Config), + exit(end_per_tc_fail_after_timeout); + +end_per_testcase1(tc6, Config) -> + ct:pal("end_per_testcase(tc6): ~p", [Config]), + tc6 = ?config(tc, Config), + exit(end_per_tc_fail_after_abort). %%-------------------------------------------------------------------- %% Function: groups() -> [Group] @@ -118,18 +170,25 @@ groups() -> %% Reason = term() %%-------------------------------------------------------------------- all() -> - [tc1,tc2,tc3]. + [tc1, tc2, tc3, tc4, tc5, tc6]. tc1(_) -> - ct:sleep(3000), - ok. + timer:sleep(2000). tc2(_) -> - spawn(ct, abort_current_testcase, [testing_end_conf]), - timer:sleep(3000), - ok. + timer:sleep(2000). tc3(_) -> spawn(ct, abort_current_testcase, [testing_end_conf]), - timer:sleep(3000), - ok. + timer:sleep(2000). + +tc4(_) -> + spawn(ct, abort_current_testcase, [testing_end_conf]), + timer:sleep(2000). + +tc5(_) -> + timer:sleep(2000). + +tc6(_) -> + spawn(ct, abort_current_testcase, [testing_end_conf]), + timer:sleep(2000). diff --git a/lib/common_test/test/ct_misc_1_SUITE.erl b/lib/common_test/test/ct_misc_1_SUITE.erl index f42081ee7e..e311876fb1 100644 --- a/lib/common_test/test/ct_misc_1_SUITE.erl +++ b/lib/common_test/test/ct_misc_1_SUITE.erl @@ -76,15 +76,15 @@ beam_me_up(Config) when is_list(Config) -> CTNode = ?config(ct_node, Config), %% Path = rpc:call(CTNode, code, get_path, []), - [_ | Parts] = lists:reverse(filename:split(DataDir)), - TSDir = filename:join(lists:reverse(Parts)), - true = rpc:call(CTNode, code, del_path, [TSDir]), + %% [_ | Parts] = lists:reverse(filename:split(DataDir)), + %% TSDir = filename:join(lists:reverse(Parts)), + %% true = rpc:call(CTNode, code, del_path, [TSDir]), Mods = [beam_1_SUITE, beam_2_SUITE], Suites = [atom_to_list(M) || M <- Mods], [{error,_} = rpc:call(CTNode, code, load_file, [M]) || M <- Mods], - code:add_path(TSDir), + code:add_path(DataDir), CRes = [compile:file(filename:join(DataDir,F), [verbose,report_errors, @@ -95,6 +95,7 @@ beam_me_up(Config) when is_list(Config) -> {ok,Mod,Bin} <- CRes], {Opts,ERPid} = setup([{suite,Suites},{auto_compile,false}], Config), + ok = ct_test_support:run(ct, run_test, [Opts], Config), Events = ct_test_support:get_events(ERPid, Config), @@ -135,4 +136,30 @@ events_to_check(Test, N) -> test_events(Test) ++ events_to_check(Test, N-1). test_events(beam_me_up) -> - []. + [ + {?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, + {?eh,start_info,{2,2,4}}, + {?eh,tc_start,{beam_1_SUITE,init_per_suite}}, + {?eh,tc_done,{beam_1_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{beam_1_SUITE,tc1}}, + {?eh,tc_done,{beam_1_SUITE,tc1,ok}}, + {?eh,test_stats,{1,0,{0,0}}}, + {?eh,tc_start,{beam_1_SUITE,tc2}}, + {?eh,tc_done,{beam_1_SUITE,tc2,{failed,{error,'tc2 failed'}}}}, + {?eh,test_stats,{1,1,{0,0}}}, + {?eh,tc_start,{beam_1_SUITE,end_per_suite}}, + {?eh,tc_done,{beam_1_SUITE,end_per_suite,ok}}, + {?eh,tc_start,{beam_2_SUITE,init_per_suite}}, + {?eh,tc_done,{beam_2_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{beam_2_SUITE,tc1}}, + {?eh,tc_done,{beam_2_SUITE,tc1,ok}}, + {?eh,test_stats,{2,1,{0,0}}}, + {?eh,tc_start,{beam_2_SUITE,tc2}}, + {?eh,tc_done,{beam_2_SUITE,tc2,{failed,{error,'tc2 failed'}}}}, + {?eh,test_stats,{2,2,{0,0}}}, + {?eh,tc_start,{beam_2_SUITE,end_per_suite}}, + {?eh,tc_done,{beam_2_SUITE,end_per_suite,ok}}, + {?eh,test_done,{'DEF','STOP_TIME'}}, + {?eh,stop_logging,[]} + ]. -- cgit v1.2.3 From 331bb449c72078c315eff558158478445c4cb888 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Sat, 5 Jun 2010 20:57:10 +0200 Subject: Minor fixes in code and test suites --- lib/common_test/test/ct_misc_1_SUITE.erl | 2 +- lib/common_test/test/ct_test_support.erl | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_misc_1_SUITE.erl b/lib/common_test/test/ct_misc_1_SUITE.erl index e311876fb1..94865b68f0 100644 --- a/lib/common_test/test/ct_misc_1_SUITE.erl +++ b/lib/common_test/test/ct_misc_1_SUITE.erl @@ -103,7 +103,7 @@ beam_me_up(Config) when is_list(Config) -> reformat(Events, ?eh), ?config(priv_dir, Config)), - TestEvents = events_to_check(beam_me_up), + TestEvents = events_to_check(beam_me_up, 1), ok = ct_test_support:verify_events(TestEvents, Events, Config). %%%----------------------------------------------------------------- diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index eaf3e23859..b3387e0ccf 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -280,7 +280,6 @@ verify_events1([TestEv|_], [{TEH,#event{name=stop_logging,node=Node,data=_}}|_], exit({event_not_found,TestEv}); verify_events1(TEvs = [TestEv | TestEvs], Evs = [_|Events], Node, Config) -> -%% test_server:format("Next expected event: ~p~n", [TestEv]), case catch locate(TestEv, Node, Evs, Config) of nomatch -> verify_events1(TEvs, Events, Node, Config); -- cgit v1.2.3 From 4ed31623e145531a1aa84f6c1091481820f62099 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Mon, 7 Jun 2010 12:24:26 +0200 Subject: Fix bug in handling framework:end_tc timeouts --- lib/common_test/test/ct_error_SUITE.erl | 17 +++++- .../error/test/cfg_error_12_SUITE.erl | 68 ++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_12_SUITE.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_error_SUITE.erl b/lib/common_test/test/ct_error_SUITE.erl index b479d4133c..7327fa5816 100644 --- a/lib/common_test/test/ct_error_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE.erl @@ -89,7 +89,8 @@ cfg_error(Config) when is_list(Config) -> Join(DataDir, "cfg_error_8_SUITE"), Join(DataDir, "cfg_error_9_SUITE"), Join(DataDir, "cfg_error_10_SUITE"), - Join(DataDir, "cfg_error_11_SUITE") + Join(DataDir, "cfg_error_11_SUITE"), + Join(DataDir, "cfg_error_12_SUITE") ], {Opts,ERPid} = setup([{suite,Suites}], Config), ok = ct_test_support:run(Opts, Config), @@ -230,7 +231,7 @@ test_events(cfg_error) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,start_info,{11,11,36}}, + {?eh,start_info,{12,12,39}}, {?eh,tc_start,{cfg_error_1_SUITE,init_per_suite}}, {?eh,tc_done, @@ -563,6 +564,18 @@ test_events(cfg_error) -> {?eh,test_stats,{13,3,{1,19}}}, {?eh,tc_start,{cfg_error_11_SUITE,end_per_suite}}, {?eh,tc_done,{cfg_error_11_SUITE,end_per_suite,ok}}, + {?eh,tc_start,{cfg_error_12_SUITE,tc1}}, + {?eh,tc_done,{cfg_error_12_SUITE,tc1,{failed,{timetrap_timeout,500}}}}, + {?eh,test_stats,{13,4,{1,19}}}, + {?eh,tc_start,{cfg_error_12_SUITE,tc2}}, + {?eh,tc_done,{cfg_error_12_SUITE,tc2, + {failed, + {cfg_error_12_SUITE,end_per_testcase, + {timetrap_timeout,500}}}}}, + {?eh,test_stats,{14,4,{1,19}}}, + {?eh,tc_start,{cfg_error_12_SUITE,tc3}}, + {?eh,tc_done,{cfg_error_12_SUITE,tc3,ok}}, + {?eh,test_stats,{15,4,{1,19}}}, {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_12_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_12_SUITE.erl new file mode 100644 index 0000000000..271eaa673e --- /dev/null +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_12_SUITE.erl @@ -0,0 +1,68 @@ +%% +%% %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% +%% +-module(cfg_error_12_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +end_per_testcase(tc2, _Config) -> + timer:sleep(2000), + exit(this_should_not_be_printed); +end_per_testcase(_, _) -> + ok. + +all() -> + [tc1, tc2, tc3]. + +%%%----------------------------------------------------------------- +tc1() -> + put('$test_server_framework_test', + fun(init_tc, _Default) -> + ct:pal("init_tc(~p): Night time...",[self()]), + timer:sleep(2000), + ct:pal("init_tc(~p): Day time!",[self()]), + exit(this_should_not_be_printed); + (_, Default) -> Default + end), + [{timetrap,500}]. + +tc1(_) -> + exit(this_should_not_be_printed). + +%%%----------------------------------------------------------------- +tc2() -> + [{timetrap,500}]. + +tc2(_) -> + ok. + +%%%----------------------------------------------------------------- +tc3() -> + [{timetrap,500}]. + +tc3(_) -> + put('$test_server_framework_test', + fun(end_tc, _Default) -> + ct:pal("end_tc(~p): Night time...",[self()]), + timer:sleep(1000), + ct:pal("end_tc(~p): Day time!",[self()]); + (_, Default) -> Default + end), + {comment,"should succeed since ct_fw cancels timetrap in end_tc"}. -- cgit v1.2.3 From 2dbeff631ce93744972cb04039d434aa172d28f4 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Mon, 7 Jun 2010 17:28:01 +0200 Subject: Fix so that ct_run converts relative diretories in the code path to absolute Directories added with run_test -pa or -pz in the pre erl_args part of the command line will be converted from relative to absolute, this to avoid confusion when Common Test switches working directory during the test run. Also fixed in this commit: Problem with timeouts during init_tc or end_tc (in the Test Server framework). --- lib/common_test/test/Makefile | 14 +++---- lib/common_test/test/ct_error_SUITE.erl | 35 ++++++++++++---- .../error/test/cfg_error_12_SUITE.erl | 22 +++++++++- .../error/test/cfg_error_13_SUITE.erl | 47 ++++++++++++++++++++++ .../error/test/cfg_error_14_SUITE.erl | 46 +++++++++++++++++++++ 5 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_13_SUITE.erl create mode 100644 lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_14_SUITE.erl (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index 2f1ff9a835..97ded5eb9a 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -65,18 +65,18 @@ EBIN = . # Targets # ---------------------------------------------------- -.PHONY: make_emakefile +#.PHONY: make_emakefile -make_emakefile: - $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES)\ - > $(EMAKEFILE) +#make_emakefile: +# $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES)\ +# > $(EMAKEFILE) -tests debug opt: make_emakefile +tests debug opt: erl $(ERL_MAKE_FLAGS) -make clean: - rm -f $(EMAKEFILE) rm -f $(TARGET_FILES) +# rm -f $(EMAKEFILE) rm -f core docs: @@ -88,7 +88,7 @@ include $(ERL_TOP)/make/otp_release_targets.mk release_spec: opt -release_tests_spec: make_emakefile +release_tests_spec: $(INSTALL_DIR) $(RELSYSDIR) $(INSTALL_DATA) $(ERL_FILES) $(COVERFILE) $(RELSYSDIR) $(INSTALL_PROGRAM) common_test.spec $(RELSYSDIR) diff --git a/lib/common_test/test/ct_error_SUITE.erl b/lib/common_test/test/ct_error_SUITE.erl index 7327fa5816..2fa031b884 100644 --- a/lib/common_test/test/ct_error_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE.erl @@ -90,7 +90,9 @@ cfg_error(Config) when is_list(Config) -> Join(DataDir, "cfg_error_9_SUITE"), Join(DataDir, "cfg_error_10_SUITE"), Join(DataDir, "cfg_error_11_SUITE"), - Join(DataDir, "cfg_error_12_SUITE") + Join(DataDir, "cfg_error_12_SUITE"), + Join(DataDir, "cfg_error_13_SUITE"), + Join(DataDir, "cfg_error_14_SUITE") ], {Opts,ERPid} = setup([{suite,Suites}], Config), ok = ct_test_support:run(Opts, Config), @@ -231,7 +233,7 @@ test_events(cfg_error) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,start_info,{12,12,39}}, + {?eh,start_info,{14,14,42}}, {?eh,tc_start,{cfg_error_1_SUITE,init_per_suite}}, {?eh,tc_done, @@ -568,15 +570,34 @@ test_events(cfg_error) -> {?eh,tc_done,{cfg_error_12_SUITE,tc1,{failed,{timetrap_timeout,500}}}}, {?eh,test_stats,{13,4,{1,19}}}, {?eh,tc_start,{cfg_error_12_SUITE,tc2}}, - {?eh,tc_done,{cfg_error_12_SUITE,tc2, - {failed, - {cfg_error_12_SUITE,end_per_testcase, - {timetrap_timeout,500}}}}}, + {?eh,tc_done,{cfg_error_12_SUITE,tc2,{failed, + {cfg_error_12_SUITE,end_per_testcase, + {timetrap_timeout,500}}}}}, {?eh,test_stats,{14,4,{1,19}}}, {?eh,tc_start,{cfg_error_12_SUITE,tc3}}, {?eh,tc_done,{cfg_error_12_SUITE,tc3,ok}}, {?eh,test_stats,{15,4,{1,19}}}, - + {?eh,tc_start,{cfg_error_12_SUITE,tc4}}, + {?eh,tc_done,{cfg_error_12_SUITE,tc4,{failed, + {cfg_error_12_SUITE,end_per_testcase, + {timetrap_timeout,500}}}}}, + {?eh,test_stats,{16,4,{1,19}}}, + {?eh,tc_start,{cfg_error_13_SUITE,init_per_suite}}, + {?eh,tc_done,{cfg_error_13_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{cfg_error_13_SUITE,tc1}}, + {?eh,tc_done,{cfg_error_13_SUITE,tc1,ok}}, + {?eh,test_stats,{17,4,{1,19}}}, + {?eh,tc_start,{cfg_error_13_SUITE,end_per_suite}}, + {?eh,tc_done,{cfg_error_13_SUITE,end_per_suite,ok}}, + {?eh,tc_start,{cfg_error_14_SUITE,init_per_suite}}, + {?eh,tc_done,{cfg_error_14_SUITE,init_per_suite,ok}}, + {?eh,tc_start,{cfg_error_14_SUITE,tc1}}, + {?eh,tc_done,{cfg_error_14_SUITE,tc1,ok}}, + {?eh,test_stats,{18,4,{1,19}}}, + {?eh,tc_start,{cfg_error_14_SUITE,end_per_suite}}, + {?eh,tc_done,{cfg_error_14_SUITE,end_per_suite, + {comment, + "should succeed since ct_fw cancels timetrap in end_tc"}}}, {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} ]; diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_12_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_12_SUITE.erl index 271eaa673e..75f00c1de3 100644 --- a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_12_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_12_SUITE.erl @@ -22,14 +22,20 @@ -include_lib("common_test/include/ct.hrl"). +init_per_testcase(_, Config) -> + Config. + end_per_testcase(tc2, _Config) -> timer:sleep(2000), exit(this_should_not_be_printed); +end_per_testcase(tc4, _Config) -> + timer:sleep(2000), + exit(this_should_not_be_printed); end_per_testcase(_, _) -> ok. all() -> - [tc1, tc2, tc3]. + [tc1, tc2, tc3, tc4]. %%%----------------------------------------------------------------- tc1() -> @@ -66,3 +72,17 @@ tc3(_) -> (_, Default) -> Default end), {comment,"should succeed since ct_fw cancels timetrap in end_tc"}. + +%%%----------------------------------------------------------------- +tc4() -> + put('$test_server_framework_test', + fun(end_tc, _Default) -> + ct:pal("end_tc(~p): Night time...",[self()]), + timer:sleep(1000), + ct:pal("end_tc(~p): Day time!",[self()]); + (_, Default) -> Default + end), + [{timetrap,500}]. + +tc4(_) -> + ok. diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_13_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_13_SUITE.erl new file mode 100644 index 0000000000..d1c18d0bb0 --- /dev/null +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_13_SUITE.erl @@ -0,0 +1,47 @@ +%% +%% %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% +%% +-module(cfg_error_13_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +init_per_suite() -> + put('$test_server_framework_test', + fun(end_tc, _Default) -> + ct:pal("end_tc(~p): Night time...",[self()]), + timer:sleep(1000), + ct:pal("end_tc(~p): Day time!",[self()]); + (_, Default) -> Default + end), + [{timetrap,500}]. + +init_per_suite(Config) -> + ct:comment("should succeed since ct_fw cancels timetrap in end_tc"), + Config. + +end_per_suite(_) -> + ok. + +all() -> + [tc1]. + +%%%----------------------------------------------------------------- +tc1(_) -> + dummy. diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_14_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_14_SUITE.erl new file mode 100644 index 0000000000..367f5f06d6 --- /dev/null +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/cfg_error_14_SUITE.erl @@ -0,0 +1,46 @@ +%% +%% %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% +%% +-module(cfg_error_14_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +init_per_suite(Config) -> + Config. + +end_per_suite() -> + put('$test_server_framework_test', + fun(end_tc, _Default) -> + ct:pal("end_tc(~p): Night time...",[self()]), + timer:sleep(1000), + ct:pal("end_tc(~p): Day time!",[self()]); + (_, Default) -> Default + end), + [{timetrap,500}]. + +end_per_suite(_Config) -> + {comment,"should succeed since ct_fw cancels timetrap in end_tc"}. + +all() -> + [tc1]. + +%%%----------------------------------------------------------------- +tc1(_) -> + dummy. -- cgit v1.2.3 From 10a06d2d2d1f967608877a8de2ad9c7fc5702353 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Mon, 7 Jun 2010 18:41:43 +0200 Subject: Make {repeat*,N} property in group execute the group N times exactly To be consistent with the behaviour of the run_test repeat flag/option, the repeat* group property has been changed to specify absolute number of test runs. Previously {repeat,N} meant "execute the group 1 time + N repeats". Now it means "execute the group N times". --- lib/common_test/test/ct_groups_test_1_SUITE.erl | 40 +++++++++++----------- .../groups_1/test/groups_12_SUITE.erl | 6 ++-- .../groups_2/test/groups_22_SUITE.erl | 6 ++-- lib/common_test/test/ct_groups_test_2_SUITE.erl | 32 ++++++++--------- .../groups_1/repeat_1_SUITE.erl | 8 ++--- 5 files changed, 46 insertions(+), 46 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/ct_groups_test_1_SUITE.erl b/lib/common_test/test/ct_groups_test_1_SUITE.erl index 18a00f7f2b..64d61fc104 100644 --- a/lib/common_test/test/ct_groups_test_1_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_1_SUITE.erl @@ -335,14 +335,14 @@ test_events(groups_suite_2) -> {?eh,tc_start,{groups_12_SUITE,testcase_2a}}, {?eh,tc_done,{groups_12_SUITE,testcase_2a,ok}}, - [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,1}]}}}, - {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,1}]},ok}}, + [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}}, + {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3a}}, {?eh,tc_done,{groups_12_SUITE,testcase_3a,ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3b}}, {?eh,tc_done,{groups_12_SUITE,testcase_3b,ok}}, - {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,1}]}}}, - {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,1}]},ok}}], + {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}, + {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]},ok}}], [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[]},ok}}, @@ -529,14 +529,14 @@ test_events(groups_suites_1) -> {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_2,[parallel]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_2a}}, {?eh,tc_done,{groups_12_SUITE,testcase_2a,ok}}, - [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,1}]}}}, - {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,1}]},ok}}, + [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}}, + {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3a}}, {?eh,tc_done,{groups_12_SUITE,testcase_3a,ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3b}}, {?eh,tc_done,{groups_12_SUITE,testcase_3b,ok}}, - {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,1}]}}}, - {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,1}]},ok}}], + {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}, + {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]},ok}}], [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3a}}, @@ -715,14 +715,14 @@ test_events(groups_dir_1) -> {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_2,[parallel]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_2a}}, {?eh,tc_done,{groups_12_SUITE,testcase_2a,ok}}, - [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,1}]}}}, - {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,1}]},ok}}, + [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}}, + {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3a}}, {?eh,tc_done,{groups_12_SUITE,testcase_3a,ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3b}}, {?eh,tc_done,{groups_12_SUITE,testcase_3b,ok}}, - {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,1}]}}}, - {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,1}]},ok}}], + {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}, + {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]},ok}}], [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3a}}, @@ -902,14 +902,14 @@ test_events(groups_dirs_1) -> {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_2,[parallel]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_2a}}, {?eh,tc_done,{groups_12_SUITE,testcase_2a,ok}}, - [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,1}]}}}, - {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,1}]},ok}}, + [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}}, + {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3a}}, {?eh,tc_done,{groups_12_SUITE,testcase_3a,ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3b}}, {?eh,tc_done,{groups_12_SUITE,testcase_3b,ok}}, - {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,1}]}}}, - {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,1}]},ok}}], + {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}, + {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]},ok}}], [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_3,[]}}}, {?eh,tc_done,{groups_12_SUITE,{init_per_group,test_group_3,[]},ok}}, {?eh,tc_start,{groups_12_SUITE,testcase_3a}}, @@ -1130,17 +1130,17 @@ test_events(groups_dirs_1) -> {?eh,tc_start,{groups_22_SUITE,testcase_2a}}, {?eh,tc_done,{groups_22_SUITE,testcase_2a,ok}}, [{?eh,tc_start, - {groups_22_SUITE,{init_per_group,test_group_3,[{repeat,1}]}}}, + {groups_22_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}}, {?eh,tc_done, - {groups_22_SUITE,{init_per_group,test_group_3,[{repeat,1}]},ok}}, + {groups_22_SUITE,{init_per_group,test_group_3,[{repeat,2}]},ok}}, {?eh,tc_start,{groups_22_SUITE,testcase_3a}}, {?eh,tc_done,{groups_22_SUITE,testcase_3a,ok}}, {?eh,tc_start,{groups_22_SUITE,testcase_3b}}, {?eh,tc_done,{groups_22_SUITE,testcase_3b,ok}}, {?eh,tc_start, - {groups_22_SUITE,{end_per_group,test_group_3,[{repeat,1}]}}}, + {groups_22_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}, {?eh,tc_done, - {groups_22_SUITE,{end_per_group,test_group_3,[{repeat,1}]},ok}}], + {groups_22_SUITE,{end_per_group,test_group_3,[{repeat,2}]},ok}}], [{?eh,tc_start, {groups_22_SUITE,{init_per_group,test_group_3,[]}}}, {?eh,tc_done, diff --git a/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_1/test/groups_12_SUITE.erl b/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_1/test/groups_12_SUITE.erl index 22eacde1f3..ec90ef95d1 100644 --- a/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_1/test/groups_12_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_1/test/groups_12_SUITE.erl @@ -37,7 +37,7 @@ groups() -> {test_group_2, [parallel], [testcase_2a, - {test_group_3, [{repeat,1}], + {test_group_3, [{repeat,2}], [testcase_3a, testcase_3b]}, testcase_2b]}, @@ -102,8 +102,8 @@ init_per_group(Group, Config) -> io_lib:format("shuffled, ~w", [S]); {test_group_1b,[{name,test_group_1b},parallel]} -> "parallel"; {test_group_2,[{name,test_group_2},parallel]} -> "parallel"; - {test_group_3,[{name,test_group_3},{repeat,1}]} -> "repeat 1"; - {test_group_3,[{name,test_group_3}]} -> "repeat 0"; + {test_group_3,[{name,test_group_3},{repeat,2}]} -> "repeat 2"; + {test_group_3,[{name,test_group_3}]} -> "repeat 1"; {test_group_4,[{name,test_group_4}]} -> ok; {test_group_5,[{name,test_group_5},parallel]} -> "parallel"; {test_group_6,[{name,test_group_6},parallel]} -> "parallel"; diff --git a/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_2/test/groups_22_SUITE.erl b/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_2/test/groups_22_SUITE.erl index 2e19cf6310..ec0adc5df0 100644 --- a/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_2/test/groups_22_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_1_SUITE_data/groups_2/test/groups_22_SUITE.erl @@ -37,7 +37,7 @@ groups() -> {test_group_2, [parallel], [testcase_2a, - {test_group_3, [{repeat,1}], + {test_group_3, [{repeat,2}], [testcase_3a, testcase_3b]}, testcase_2b]}, @@ -102,8 +102,8 @@ init_per_group(Group, Config) -> io_lib:format("shuffled, ~w", [S]); {test_group_1b,[{name,test_group_1b},parallel]} -> "parallel"; {test_group_2,[{name,test_group_2},parallel]} -> "parallel"; - {test_group_3,[{name,test_group_3},{repeat,1}]} -> "repeat 1"; - {test_group_3,[{name,test_group_3}]} -> "repeat 0"; + {test_group_3,[{name,test_group_3},{repeat,2}]} -> "repeat 2"; + {test_group_3,[{name,test_group_3}]} -> "repeat 1"; {test_group_4,[{name,test_group_4}]} -> ok; {test_group_5,[{name,test_group_5},parallel]} -> "parallel"; {test_group_6,[{name,test_group_6},parallel]} -> "parallel"; diff --git a/lib/common_test/test/ct_groups_test_2_SUITE.erl b/lib/common_test/test/ct_groups_test_2_SUITE.erl index bdf7303a59..56e0ac30c7 100644 --- a/lib/common_test/test/ct_groups_test_2_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_2_SUITE.erl @@ -184,9 +184,9 @@ test_events(repeat_1) -> {?eh,tc_start,{repeat_1_SUITE,init_per_suite}}, {?eh,tc_done,{repeat_1_SUITE,init_per_suite,ok}}, [{?eh,tc_start, - {repeat_1_SUITE,{init_per_group,test_group_1,[{repeat,1}]}}}, + {repeat_1_SUITE,{init_per_group,test_group_1,[{repeat,2}]}}}, {?eh,tc_done, - {repeat_1_SUITE,{init_per_group,test_group_1,[{repeat,1}]},ok}}, + {repeat_1_SUITE,{init_per_group,test_group_1,[{repeat,2}]},ok}}, {?eh,tc_start,{repeat_1_SUITE,testcase_1a}}, {?eh,tc_done,{repeat_1_SUITE,testcase_1a,ok}}, {?eh,test_stats,{1,0,{0,0}}}, @@ -194,9 +194,9 @@ test_events(repeat_1) -> {?eh,tc_done,{repeat_1_SUITE,testcase_1b,ok}}, {?eh,test_stats,{2,0,{0,0}}}, {?eh,tc_start, - {repeat_1_SUITE,{end_per_group,test_group_1,[{repeat,1}]}}}, + {repeat_1_SUITE,{end_per_group,test_group_1,[{repeat,2}]}}}, {?eh,tc_done, - {repeat_1_SUITE,{end_per_group,test_group_1,[{repeat,1}]},ok}}], + {repeat_1_SUITE,{end_per_group,test_group_1,[{repeat,2}]},ok}}], [{?eh,tc_start, {repeat_1_SUITE,{init_per_group,test_group_1,[]}}}, {?eh,tc_done, @@ -212,9 +212,9 @@ test_events(repeat_1) -> {?eh,tc_done, {repeat_1_SUITE,{end_per_group,test_group_1,[]},ok}}], [{?eh,tc_start, - {repeat_1_SUITE,{init_per_group,test_group_2,[{repeat,0}]}}}, + {repeat_1_SUITE,{init_per_group,test_group_2,[]}}}, {?eh,tc_done, - {repeat_1_SUITE,{init_per_group,test_group_2,[{repeat,0}]},ok}}, + {repeat_1_SUITE,{init_per_group,test_group_2,[]},ok}}, {?eh,tc_start,{repeat_1_SUITE,testcase_2a}}, {?eh,tc_done,{repeat_1_SUITE,testcase_2a,ok}}, {?eh,test_stats,{5,0,{0,0}}}, @@ -222,25 +222,25 @@ test_events(repeat_1) -> {?eh,tc_done,{repeat_1_SUITE,testcase_2b,ok}}, {?eh,test_stats,{6,0,{0,0}}}, {?eh,tc_start, - {repeat_1_SUITE,{end_per_group,test_group_2,[{repeat,0}]}}}, + {repeat_1_SUITE,{end_per_group,test_group_2,[]}}}, {?eh,tc_done, - {repeat_1_SUITE,{end_per_group,test_group_2,[{repeat,0}]},ok}}], + {repeat_1_SUITE,{end_per_group,test_group_2,[]},ok}}], [{?eh,tc_start, {repeat_1_SUITE, - {init_per_group,test_group_3,[{repeat_until_all_fail,0}]}}}, + {init_per_group,test_group_3,[]}}}, {?eh,tc_done, {repeat_1_SUITE, - {init_per_group,test_group_3,[{repeat_until_all_fail,0}]}, + {init_per_group,test_group_3,[]}, ok}}, {?eh,tc_start,{repeat_1_SUITE,testcase_3a}}, {?eh,tc_done,{repeat_1_SUITE,testcase_3a,ok}}, {?eh,test_stats,{7,0,{0,0}}}, [{?eh,tc_start, {repeat_1_SUITE, - {init_per_group,test_group_4,[{repeat_until_any_fail,0}]}}}, + {init_per_group,test_group_4,[]}}}, {?eh,tc_done, {repeat_1_SUITE, - {init_per_group,test_group_4,[{repeat_until_any_fail,0}]}, + {init_per_group,test_group_4,[]}, ok}}, {?eh,tc_start,{repeat_1_SUITE,testcase_4a}}, {?eh,tc_done,{repeat_1_SUITE,testcase_4a,ok}}, @@ -250,20 +250,20 @@ test_events(repeat_1) -> {?eh,test_stats,{9,0,{0,0}}}, {?eh,tc_start, {repeat_1_SUITE, - {end_per_group,test_group_4,[{repeat_until_any_fail,0}]}}}, + {end_per_group,test_group_4,[]}}}, {?eh,tc_done, {repeat_1_SUITE, - {end_per_group,test_group_4,[{repeat_until_any_fail,0}]}, + {end_per_group,test_group_4,[]}, ok}}], {?eh,tc_start,{repeat_1_SUITE,testcase_3b}}, {?eh,tc_done,{repeat_1_SUITE,testcase_3b,ok}}, {?eh,test_stats,{10,0,{0,0}}}, {?eh,tc_start, {repeat_1_SUITE, - {end_per_group,test_group_3,[{repeat_until_all_fail,0}]}}}, + {end_per_group,test_group_3,[]}}}, {?eh,tc_done, {repeat_1_SUITE, - {end_per_group,test_group_3,[{repeat_until_all_fail,0}]}, + {end_per_group,test_group_3,[]}, ok}}], {?eh,tc_start,{repeat_1_SUITE,end_per_suite}}, {?eh,tc_done,{repeat_1_SUITE,end_per_suite,ok}}, diff --git a/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_1/repeat_1_SUITE.erl b/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_1/repeat_1_SUITE.erl index 4edbc3e384..91a0a2e882 100644 --- a/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_1/repeat_1_SUITE.erl +++ b/lib/common_test/test/ct_groups_test_2_SUITE_data/groups_1/repeat_1_SUITE.erl @@ -31,12 +31,12 @@ suite() -> groups() -> [ - {test_group_1, [{repeat,1}], [testcase_1a,testcase_1b]}, - {test_group_2, [{repeat,0}], [testcase_2a,testcase_2b]}, + {test_group_1, [{repeat,2}], [testcase_1a,testcase_1b]}, + {test_group_2, [{repeat,1}], [testcase_2a,testcase_2b]}, - {test_group_3, [{repeat_until_all_fail,0}], + {test_group_3, [{repeat_until_all_fail,1}], [testcase_3a, - {test_group_4, [{repeat_until_any_fail,0}], + {test_group_4, [{repeat_until_any_fail,1}], [testcase_4a, testcase_4b]}, testcase_3b]} ]. -- cgit v1.2.3