~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to erts/emulator/test/time_SUITE.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
3
%% 
4
 
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
 
4
%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
5
5
%% 
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
29
29
%%      now/0
30
30
%%
31
31
 
32
 
-export([all/1, univ_to_local/1, local_to_univ/1,
 
32
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 
 
33
         init_per_group/2,end_per_group/2, univ_to_local/1, local_to_univ/1,
33
34
         bad_univ_to_local/1, bad_local_to_univ/1,
 
35
         univ_to_seconds/1, seconds_to_univ/1,
34
36
         consistency/1,
35
 
         now/1, now_unique/1, now_update/1, timestamp/1]).
 
37
         now_unique/1, now_update/1, timestamp/1]).
36
38
 
37
39
-export([local_to_univ_utc/1]).
38
40
 
39
 
-include("test_server.hrl").
 
41
-include_lib("test_server/include/test_server.hrl").
40
42
 
41
43
-export([linear_time/1]).
42
44
 
54
56
 
55
57
-define(dst_timezone, 2).
56
58
 
57
 
all(suite) -> [univ_to_local, local_to_univ,
58
 
               local_to_univ_utc,
59
 
               bad_univ_to_local, bad_local_to_univ,
60
 
               consistency, now, timestamp].
 
59
suite() -> [{ct_hooks,[ts_install_cth]}].
 
60
 
 
61
all() -> 
 
62
    [univ_to_local, local_to_univ, local_to_univ_utc,
 
63
     bad_univ_to_local, bad_local_to_univ, 
 
64
     univ_to_seconds, seconds_to_univ,
 
65
     consistency,
 
66
     {group, now}, timestamp].
 
67
 
 
68
groups() -> 
 
69
    [{now, [], [now_unique, now_update]}].
 
70
 
 
71
init_per_suite(Config) ->
 
72
    Config.
 
73
 
 
74
end_per_suite(_Config) ->
 
75
    ok.
 
76
 
 
77
init_per_group(_GroupName, Config) ->
 
78
    Config.
 
79
 
 
80
end_per_group(_GroupName, Config) ->
 
81
    Config.
 
82
 
61
83
 
62
84
local_to_univ_utc(suite) ->
63
85
    [];
143
165
bad_test_local_to_univ([]) ->
144
166
    ok.
145
167
 
 
168
 
 
169
%% Test universaltime to seconds conversions
 
170
univ_to_seconds(Config) when is_list(Config) ->
 
171
    test_univ_to_seconds(ok_utc_seconds()).
 
172
 
 
173
test_univ_to_seconds([{Datetime, Seconds}|DSs]) ->
 
174
    io:format("universaltime = ~p -> seconds = ~p", [Datetime, Seconds]),
 
175
    Seconds = erlang:universaltime_to_posixtime(Datetime),
 
176
    test_univ_to_seconds(DSs);
 
177
test_univ_to_seconds([]) -> 
 
178
    ok.
 
179
 
 
180
%% Test seconds to universaltime conversions
 
181
seconds_to_univ(Config) when is_list(Config) ->
 
182
    test_seconds_to_univ(ok_utc_seconds()).
 
183
 
 
184
test_seconds_to_univ([{Datetime, Seconds}|DSs]) ->
 
185
    io:format("universaltime = ~p <- seconds = ~p", [Datetime, Seconds]),
 
186
    Datetime = erlang:posixtime_to_universaltime(Seconds),
 
187
    test_seconds_to_univ(DSs);
 
188
test_seconds_to_univ([]) -> 
 
189
    ok.
 
190
 
 
191
 
146
192
%% Test that the the different time functions return
147
193
%% consistent results. (See the test case for assumptions
148
194
%% and limitations.)
283
329
 
284
330
%% Test now/0.
285
331
 
286
 
now(suite) -> [now_unique, now_update].
287
332
 
288
333
%% Tests that successive calls to now/0 returns different values.
289
334
%% Also returns a comment string with the median difference between
435
480
     {1998, 06, 3},
436
481
     {1999, 06, 4}].
437
482
 
 
483
%% exakt utc {date(), time()} which corresponds to the same seconds since 1 jan 1970 
 
484
%% negative seconds are ok
 
485
%% generated with date --date='1979-05-28 12:30:35 UTC' +%s
 
486
ok_utc_seconds() -> [
 
487
        { {{1970, 1, 1},{ 0, 0, 0}},            0 },
 
488
        { {{1970, 1, 1},{ 0, 0, 1}},            1 },
 
489
        { {{1969,12,31},{23,59,59}},           -1 },
 
490
        { {{1920,12,31},{23,59,59}},  -1546300801 },
 
491
        { {{1600,02,19},{15,14,08}}, -11671807552 },
 
492
        { {{1979,05,28},{12,30,35}},    296742635 },
 
493
        { {{1999,12,31},{23,59,59}},    946684799 },
 
494
        { {{2000, 1, 1},{ 0, 0, 0}},    946684800 },
 
495
        { {{2000, 1, 1},{ 0, 0, 1}},    946684801 },
 
496
 
 
497
        { {{2038, 1,19},{03,14,07}},   2147483647 }, % Sint32 full - 1
 
498
        { {{2038, 1,19},{03,14,08}},   2147483648 }, % Sint32 full
 
499
        { {{2038, 1,19},{03,14,09}},   2147483649 }, % Sint32 full + 1
 
500
 
 
501
        { {{2106, 2, 7},{ 6,28,14}},   4294967294 }, % Uint32 full  0xFFFFFFFF - 1
 
502
        { {{2106, 2, 7},{ 6,28,15}},   4294967295 }, % Uint32 full  0xFFFFFFFF
 
503
        { {{2106, 2, 7},{ 6,28,16}},   4294967296 }, % Uint32 full  0xFFFFFFFF + 1
 
504
        { {{2012,12, 6},{16,28,08}},   1354811288 },
 
505
        { {{2412,12, 6},{16,28,08}},  13977592088 }
 
506
    ].
 
507
 
 
508
 
438
509
%% The following dates should not be near the end or beginning of
439
510
%% a month, because they will be used to test when the dates are
440
511
%% different in UTC and local time.