1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2010-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20-module(timetrap_3_SUITE). 21 22-compile(export_all). 23 24-include_lib("common_test/include/ct.hrl"). 25 26-define(TO, 3). 27 28%%-------------------------------------------------------------------- 29%% Function: suite() -> Info 30%% Info = [tuple()] 31%%-------------------------------------------------------------------- 32suite() -> 33 [{timetrap,{seconds,?TO}}]. 34 35%%-------------------------------------------------------------------- 36%% Function: init_per_suite(Config0) -> 37%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} 38%% Config0 = Config1 = [tuple()] 39%% Reason = term() 40%%-------------------------------------------------------------------- 41init_per_suite(Config) -> 42 Config. 43 44%%-------------------------------------------------------------------- 45%% Function: end_per_suite(Config0) -> void() | {save_config,Config1} 46%% Config0 = Config1 = [tuple()] 47%%-------------------------------------------------------------------- 48end_per_suite(_Config) -> 49 ok. 50 51%%-------------------------------------------------------------------- 52%% Function: init_per_group(GroupName, Config0) -> 53%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} 54%% GroupName = atom() 55%% Config0 = Config1 = [tuple()] 56%% Reason = term() 57%%-------------------------------------------------------------------- 58init_per_group(_GroupName, Config) -> 59 Config. 60 61%%-------------------------------------------------------------------- 62%% Function: end_per_group(GroupName, Config0) -> 63%% void() | {save_config,Config1} 64%% GroupName = atom() 65%% Config0 = Config1 = [tuple()] 66%%-------------------------------------------------------------------- 67end_per_group(_GroupName, _Config) -> 68 ok. 69 70%%-------------------------------------------------------------------- 71%% Function: groups() -> [Group] 72%% Group = {GroupName,Properties,GroupsAndTestCases} 73%% GroupName = atom() 74%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}] 75%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase] 76%% TestCase = atom() 77%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}} 78%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | 79%% repeat_until_any_ok | repeat_until_any_fail 80%% N = integer() | forever 81%%-------------------------------------------------------------------- 82groups() -> 83 [{g1,[parallel],[tc0,tc1,tc2,tc3,tc4,tc5,tc6,tc7]}]. 84 85%%-------------------------------------------------------------------- 86%% Function: all() -> GroupsAndTestCases | {skip,Reason} 87%% GroupsAndTestCases = [{group,GroupName} | TestCase] 88%% GroupName = atom() 89%% TestCase = atom() 90%% Reason = term() 91%%-------------------------------------------------------------------- 92all() -> 93 [{group,g1}]. 94 95tc0() -> 96 [{timetrap,2000}]. 97tc0(_) -> 98 ct:comment("TO after 2 sec"), 99 ct:sleep({seconds,5}), 100 ok. 101 102tc1() -> 103 [{timetrap,500}]. 104tc1(_) -> 105 ct:comment("TO after 1/2 sec"), 106 ct:sleep({seconds,5}), 107 ok. 108 109tc2() -> 110 [{timetrap,1000}]. 111tc2(_) -> 112 ct:comment("TO after 1 sec"), 113 ct:sleep({seconds,5}), 114 ok. 115 116tc3(_) -> 117 ct:comment(io_lib:format("TO after ~w sec", [?TO])), 118 ct:sleep({seconds,5}), 119 ok. 120 121tc4() -> 122 [{timetrap,2000}]. 123tc4(_) -> 124 ct:comment(io_lib:format("TO after 2 sec", [])), 125 ct:sleep({seconds,5}), 126 ok. 127 128tc5() -> 129 [{timetrap,2000}]. 130tc5(_) -> 131 ct:comment("No timeout"), 132 ct:sleep({seconds,1}), 133 ok. 134 135tc6() -> 136 [{timetrap,1000}]. 137tc6(_) -> 138 ct:comment("TO after 1 sec"), 139 ct:sleep({seconds,5}), 140 ok. 141 142tc7() -> 143 [{timetrap,1500}]. 144tc7(_) -> 145 ct:comment("TO after 1 1/2 sec"), 146 ct:sleep({seconds,5}), 147 ok. 148