From 332591f03f7bc4585c8c108c192ab3bba6fec12c Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Wed, 17 Feb 2010 15:59:05 +0000 Subject: OTP-8311: Various updates and fixes in Common Test and Test Server --- .../happy_1/cfg/config1.cfg | 5 + .../happy_1/test/happy_11_SUITE.erl | 196 +++++++++++++++++++++ .../happy_2_cfg/config1.cfg | 5 + .../happy_2_test/happy_21_SUITE.erl | 196 +++++++++++++++++++++ 4 files changed, 402 insertions(+) create mode 100644 lib/common_test/test/ct_smoke_test_SUITE_data/happy_1/cfg/config1.cfg create mode 100644 lib/common_test/test/ct_smoke_test_SUITE_data/happy_1/test/happy_11_SUITE.erl create mode 100644 lib/common_test/test/ct_smoke_test_SUITE_data/happy_2_cfg/config1.cfg create mode 100644 lib/common_test/test/ct_smoke_test_SUITE_data/happy_2_test/happy_21_SUITE.erl (limited to 'lib/common_test/test/ct_smoke_test_SUITE_data') diff --git a/lib/common_test/test/ct_smoke_test_SUITE_data/happy_1/cfg/config1.cfg b/lib/common_test/test/ct_smoke_test_SUITE_data/happy_1/cfg/config1.cfg new file mode 100644 index 0000000000..3d6e5622f5 --- /dev/null +++ b/lib/common_test/test/ct_smoke_test_SUITE_data/happy_1/cfg/config1.cfg @@ -0,0 +1,5 @@ +{v1, apple}. +{v2, plum}. +{v3, [{v31, cherry}, + {v32, banana}, + {v33, coconut}]}. diff --git a/lib/common_test/test/ct_smoke_test_SUITE_data/happy_1/test/happy_11_SUITE.erl b/lib/common_test/test/ct_smoke_test_SUITE_data/happy_1/test/happy_11_SUITE.erl new file mode 100644 index 0000000000..f33f0934cb --- /dev/null +++ b/lib/common_test/test/ct_smoke_test_SUITE_data/happy_1/test/happy_11_SUITE.erl @@ -0,0 +1,196 @@ +%% +%% %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% +%% + +%%%------------------------------------------------------------------- +%%% File : happy_11_SUITE.erl +%%% Description : Happy test of all common_test callback functions. +%%%------------------------------------------------------------------- +-module(happy_11_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}}, + {require, v1}, + {userdata, {info,"Happy test of CT callback functions."}} + ]. + +%%-------------------------------------------------------------------- +%% 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) -> + [{ips,ips_data} | 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) -> + ips_data = ?config(ips, Config). + +%%-------------------------------------------------------------------- +%% 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) -> + [{TestCase,{TestCase,data}} | 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) -> + {TestCase,data} = ?config(TestCase, Config). + +%%-------------------------------------------------------------------- +%% Function: sequences() -> Sequences +%% +%% Sequences = [{SeqName,TestCases}] +%% SeqName = atom() +%% Name of a sequence. +%% TestCases = [atom()] +%% List of test cases that are part of the sequence +%% +%% Description: Specifies test case sequences. +%%-------------------------------------------------------------------- +sequences() -> + [{seq1,[seq1_tc1, seq1_tc2]}, + {seq2,[seq2_tc1, seq2_tc2]}]. + +%%-------------------------------------------------------------------- +%% 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, + seq1, + tc3, + seq2, + tc4]. + + +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- + +tc1() -> + [{userdata,{info, "This is a testcase"}}]. + +tc1(Config) -> + ips_data = ?config(ips, Config), + {tc1,data} = ?config(tc1, Config), + apple = ct:get_config(v1), + ok. + +tc2() -> + [{timetrap,5000}, + {require,v2}]. + +tc2(Config) -> + ips_data = ?config(ips, Config), + undefined = ?config(tc1, Config), + {tc2,data} = ?config(tc2, Config), + plum = ct:get_config(v2), + ok. + +tc3() -> + [{timetrap,{minutes,1}}]. + +tc3(_Config) -> + ok = ct:require(v3), + [{v31, cherry},{v32, banana},{v33, coconut}] = ct:get_config(v3), + banana = ct:get_config({v3,v32}), + ok. + +tc4(Config) -> + {skip,"Skipping this one"}. + +seq1_tc1(_) -> + ok. +seq1_tc2(_) -> + ok. + +seq2_tc1(_) -> + ok. +seq2_tc2(_) -> + ok. diff --git a/lib/common_test/test/ct_smoke_test_SUITE_data/happy_2_cfg/config1.cfg b/lib/common_test/test/ct_smoke_test_SUITE_data/happy_2_cfg/config1.cfg new file mode 100644 index 0000000000..3d6e5622f5 --- /dev/null +++ b/lib/common_test/test/ct_smoke_test_SUITE_data/happy_2_cfg/config1.cfg @@ -0,0 +1,5 @@ +{v1, apple}. +{v2, plum}. +{v3, [{v31, cherry}, + {v32, banana}, + {v33, coconut}]}. diff --git a/lib/common_test/test/ct_smoke_test_SUITE_data/happy_2_test/happy_21_SUITE.erl b/lib/common_test/test/ct_smoke_test_SUITE_data/happy_2_test/happy_21_SUITE.erl new file mode 100644 index 0000000000..33d18006f9 --- /dev/null +++ b/lib/common_test/test/ct_smoke_test_SUITE_data/happy_2_test/happy_21_SUITE.erl @@ -0,0 +1,196 @@ +%% +%% %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% +%% + +%%%------------------------------------------------------------------- +%%% File : happy_21_SUITE.erl +%%% Description : Happy test of all common_test callback functions. +%%%------------------------------------------------------------------- +-module(happy_21_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}}, + {require, v1}, + {userdata, {info,"Happy test of CT callback functions."}} + ]. + +%%-------------------------------------------------------------------- +%% 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) -> + [{ips,ips_data} | 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) -> + ips_data = ?config(ips, Config). + +%%-------------------------------------------------------------------- +%% 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) -> + [{TestCase,{TestCase,data}} | 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) -> + {TestCase,data} = ?config(TestCase, Config). + +%%-------------------------------------------------------------------- +%% Function: sequences() -> Sequences +%% +%% Sequences = [{SeqName,TestCases}] +%% SeqName = atom() +%% Name of a sequence. +%% TestCases = [atom()] +%% List of test cases that are part of the sequence +%% +%% Description: Specifies test case sequences. +%%-------------------------------------------------------------------- +sequences() -> + [{seq1,[seq1_tc1, seq1_tc2]}, + {seq2,[seq2_tc1, seq2_tc2]}]. + +%%-------------------------------------------------------------------- +%% 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, + seq1, + tc3, + seq2, + tc4]. + + +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- + +tc1() -> + [{userdata,{info, "This is a testcase"}}]. + +tc1(Config) -> + ips_data = ?config(ips, Config), + {tc1,data} = ?config(tc1, Config), + apple = ct:get_config(v1), + ok. + +tc2() -> + [{timetrap,5000}, + {require,v2}]. + +tc2(Config) -> + ips_data = ?config(ips, Config), + undefined = ?config(tc1, Config), + {tc2,data} = ?config(tc2, Config), + plum = ct:get_config(v2), + ok. + +tc3() -> + [{timetrap,{minutes,1}}]. + +tc3(_Config) -> + ok = ct:require(v3), + [{v31, cherry},{v32, banana},{v33, coconut}] = ct:get_config(v3), + banana = ct:get_config({v3,v32}), + ok. + +tc4(Config) -> + {skip,"Skipping this one"}. + +seq1_tc1(_) -> + ok. +seq1_tc2(_) -> + ok. + +seq2_tc1(_) -> + ok. +seq2_tc2(_) -> + ok. -- cgit v1.2.3