4
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
21
21
-module(timer_simple_SUITE).
24
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
25
init_per_group/2,end_per_group/2,
25
26
init_per_testcase/2,
52
-include("test_server.hrl").
53
-include_lib("test_server/include/test_server.hrl").
54
55
-define(MAXREF, (1 bsl 18)).
55
56
-define(REFMARG, 30).
57
all(doc) -> "Test of the timer module.";
58
suite() -> [{ct_hooks,[ts_install_cth]}].
61
[apply_after, send_after1, send_after2, send_after3,
62
exit_after1, exit_after2, kill_after1, kill_after2,
63
apply_interval, send_interval1, send_interval2,
64
send_interval3, send_interval4, cancel1, cancel2, tc,
65
unique_refs, timer_perf].
70
init_per_suite(Config) ->
73
end_per_suite(_Config) ->
76
init_per_group(_GroupName, Config) ->
79
end_per_group(_GroupName, Config) ->
78
83
init_per_testcase(_, Config) when is_list(Config) ->
224
229
tc(doc) -> "Test sleep/1 and tc/3.";
226
231
tc(Config) when is_list(Config) ->
227
% This should both sleep and tc
228
?line {Res, ok} = timer:tc(timer, sleep, [500]),
230
Res < 500*1000 -> {too_early, Res}; % Too early
231
Res > 800*1000 -> {too_late, Res}; % Too much time
232
% This should both sleep and tc/3
233
?line {Res1, ok} = timer:tc(timer, sleep, [500]),
235
Res1 < 500*1000 -> {too_early, Res1}; % Too early
236
Res1 > 800*1000 -> {too_late, Res1}; % Too much time
240
% This should both sleep and tc/2
241
?line {Res2, ok} = timer:tc(fun(T) -> timer:sleep(T) end, [500]),
243
Res2 < 500*1000 -> {too_early, Res2}; % Too early
244
Res2 > 800*1000 -> {too_late, Res2}; % Too much time