4
%% Copyright Ericsson AB 2010. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
19
-module(timetrap_1_SUITE).
23
-include_lib("common_test/include/ct.hrl").
25
%%--------------------------------------------------------------------
26
%% Function: suite() -> Info
28
%%--------------------------------------------------------------------
30
[{timetrap,{seconds,1}}].
32
%%--------------------------------------------------------------------
33
%% Function: init_per_suite(Config0) ->
34
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
35
%% Config0 = Config1 = [tuple()]
37
%%--------------------------------------------------------------------
38
init_per_suite(Config) ->
39
TabPid = spawn(fun() ->
40
ets:new(?MODULE, [named_table, set, public]),
41
ets:insert(?MODULE, {last_case,ok}),
44
[{tab,TabPid} | Config].
46
%%--------------------------------------------------------------------
47
%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
48
%% Config0 = Config1 = [tuple()]
49
%%--------------------------------------------------------------------
50
end_per_suite(Config) ->
51
exit(?config(tab, Config), kill),
54
%%--------------------------------------------------------------------
55
%% Function: init_per_group(GroupName, Config0) ->
56
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
58
%% Config0 = Config1 = [tuple()]
60
%%--------------------------------------------------------------------
61
init_per_group(_GroupName, Config) ->
64
%%--------------------------------------------------------------------
65
%% Function: end_per_group(GroupName, Config0) ->
66
%% void() | {save_config,Config1}
68
%% Config0 = Config1 = [tuple()]
69
%%--------------------------------------------------------------------
70
end_per_group(_GroupName, _Config) ->
73
%%--------------------------------------------------------------------
74
%% Function: init_per_testcase(TestCase, Config0) ->
75
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
77
%% Config0 = Config1 = [tuple()]
79
%%--------------------------------------------------------------------
80
init_per_testcase(TC, Config) ->
81
{_,_} = process_info(?config(tab, Config), priority),
82
[{_,ok}] = ets:lookup(?MODULE, last_case),
83
ets:insert(?MODULE, {last_case,fail}),
84
init_per_testcase1(TC, Config).
86
init_per_testcase1(tc1, Config) ->
89
init_per_testcase1(tc2, Config) ->
92
init_per_testcase1(tc3, Config) ->
95
init_per_testcase1(tc4, Config) ->
96
[{tc,tc4},{default_timeout,5000}|Config];
98
init_per_testcase1(tc5, Config) ->
101
init_per_testcase1(tc6, Config) ->
104
%%--------------------------------------------------------------------
105
%% Function: end_per_testcase(TestCase, Config0) ->
106
%% void() | {save_config,Config1}
108
%% Config0 = Config1 = [tuple()]
109
%%--------------------------------------------------------------------
110
end_per_testcase(TC, Config) ->
111
{_,_} = process_info(?config(tab, Config), priority),
112
[{_,fail}] = ets:lookup(?MODULE, last_case),
113
ets:insert(?MODULE, {last_case,ok}),
114
end_per_testcase1(TC, Config).
116
end_per_testcase1(tc1, Config) ->
117
ct:pal("end_per_testcase(tc1): ~p", [Config]),
118
tc1 = ?config(tc, Config),
119
{failed,timetrap_timeout} = ?config(tc_status, Config),
122
end_per_testcase1(tc2, Config) ->
123
ct:pal("end_per_testcase(tc2): ~p", [Config]),
124
tc2 = ?config(tc, Config),
125
{failed,timetrap_timeout} = ?config(tc_status, Config),
128
end_per_testcase1(tc3, Config) ->
129
ct:pal("end_per_testcase(tc3): ~p", [Config]),
130
tc3 = ?config(tc, Config),
131
{failed,{testcase_aborted,testing_end_conf}} = ?config(tc_status, Config),
134
end_per_testcase1(tc4, Config) ->
135
ct:pal("end_per_testcase(tc4): ~p", [Config]),
136
tc4 = ?config(tc, Config),
137
{failed,{testcase_aborted,testing_end_conf}} = ?config(tc_status, Config),
140
end_per_testcase1(tc5, Config) ->
141
ct:pal("end_per_testcase(tc5): ~p", [Config]),
142
tc5 = ?config(tc, Config),
143
exit(end_per_tc_fail_after_timeout);
145
end_per_testcase1(tc6, Config) ->
146
ct:pal("end_per_testcase(tc6): ~p", [Config]),
147
tc6 = ?config(tc, Config),
148
exit(end_per_tc_fail_after_abort).
150
%%--------------------------------------------------------------------
151
%% Function: groups() -> [Group]
152
%% Group = {GroupName,Properties,GroupsAndTestCases}
153
%% GroupName = atom()
154
%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
155
%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
157
%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}
158
%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
159
%% repeat_until_any_ok | repeat_until_any_fail
160
%% N = integer() | forever
161
%%--------------------------------------------------------------------
165
%%--------------------------------------------------------------------
166
%% Function: all() -> GroupsAndTestCases | {skip,Reason}
167
%% GroupsAndTestCases = [{group,GroupName} | TestCase]
168
%% GroupName = atom()
171
%%--------------------------------------------------------------------
173
[tc1, tc2, tc3, tc4, tc5, tc6].
182
spawn(ct, abort_current_testcase, [testing_end_conf]),
186
spawn(ct, abort_current_testcase, [testing_end_conf]),
193
spawn(ct, abort_current_testcase, [testing_end_conf]),