aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2011-12-08 15:01:59 +0100
committerBjörn-Egil Dahlberg <[email protected]>2011-12-08 15:01:59 +0100
commit6578cd796f4b5c161ed641baded4a6de435325c8 (patch)
tree110f9516ab0c287b964e535f748d038bea4efa6a /erts/emulator/test
parentac3cbe8bee6b826004c02a1d21f8093899716b33 (diff)
parent4091bb7785c488f65f686f2f92de1ef420d7c81b (diff)
downloadotp-6578cd796f4b5c161ed641baded4a6de435325c8.tar.gz
otp-6578cd796f4b5c161ed641baded4a6de435325c8.tar.bz2
otp-6578cd796f4b5c161ed641baded4a6de435325c8.zip
Merge branch 'egil/file-info-opt-utc/OTP-7687'
* egil/file-info-opt-utc/OTP-7687: (39 commits) Remove time_t specific test in prim_file_SUITE Update prim_file.beam and prim_zip.beam Add types for posixtime_to_universaltime and the reverse Set BASEYEAR to 1902 Set lower limit of years handled to 1601 Emulate localtime, gmtime and mktime to enable negative time_t Document file:*_file_info/2 Fix compiler warning in unix_efile.c Change name of bif universaltime_to_seconds/1 Change options to prim_file:*_file_info/* Remove dead code Catch errors from prim_file:*_file_info Testcase for utc <-> seconds conversion Fix negative time in seconds_to_universaltime/1 Remove OS taint from datetime conversion Add utc <-> seconds conversions bifs Let prim_file validate ctime in file_info Teach #file_info spec unix epochs for file times Add file_info_opt tests in prim_file_SUITE unix_efile: Zero is a valid number in utime ... Conflicts: erts/emulator/beam/erl_time_sup.c erts/emulator/sys/win32/erl_win_sys.h erts/emulator/sys/win32/sys_time.c
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/time_SUITE.erl55
1 files changed, 54 insertions, 1 deletions
diff --git a/erts/emulator/test/time_SUITE.erl b/erts/emulator/test/time_SUITE.erl
index bd48a0a7db..4d12e3449c 100644
--- a/erts/emulator/test/time_SUITE.erl
+++ b/erts/emulator/test/time_SUITE.erl
@@ -32,6 +32,7 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2, univ_to_local/1, local_to_univ/1,
bad_univ_to_local/1, bad_local_to_univ/1,
+ univ_to_seconds/1, seconds_to_univ/1,
consistency/1,
now_unique/1, now_update/1, timestamp/1]).
@@ -59,7 +60,9 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[univ_to_local, local_to_univ, local_to_univ_utc,
- bad_univ_to_local, bad_local_to_univ, consistency,
+ bad_univ_to_local, bad_local_to_univ,
+ univ_to_seconds, seconds_to_univ,
+ consistency,
{group, now}, timestamp].
groups() ->
@@ -162,6 +165,30 @@ bad_test_local_to_univ([Local|Rest]) ->
bad_test_local_to_univ([]) ->
ok.
+
+%% Test universaltime to seconds conversions
+univ_to_seconds(Config) when is_list(Config) ->
+ test_univ_to_seconds(ok_utc_seconds()).
+
+test_univ_to_seconds([{Datetime, Seconds}|DSs]) ->
+ io:format("universaltime = ~p -> seconds = ~p", [Datetime, Seconds]),
+ Seconds = erlang:universaltime_to_posixtime(Datetime),
+ test_univ_to_seconds(DSs);
+test_univ_to_seconds([]) ->
+ ok.
+
+%% Test seconds to universaltime conversions
+seconds_to_univ(Config) when is_list(Config) ->
+ test_seconds_to_univ(ok_utc_seconds()).
+
+test_seconds_to_univ([{Datetime, Seconds}|DSs]) ->
+ io:format("universaltime = ~p <- seconds = ~p", [Datetime, Seconds]),
+ Datetime = erlang:posixtime_to_universaltime(Seconds),
+ test_seconds_to_univ(DSs);
+test_seconds_to_univ([]) ->
+ ok.
+
+
%% Test that the the different time functions return
%% consistent results. (See the test case for assumptions
%% and limitations.)
@@ -453,6 +480,32 @@ dst_dates() ->
{1998, 06, 3},
{1999, 06, 4}].
+%% exakt utc {date(), time()} which corresponds to the same seconds since 1 jan 1970
+%% negative seconds are ok
+%% generated with date --date='1979-05-28 12:30:35 UTC' +%s
+ok_utc_seconds() -> [
+ { {{1970, 1, 1},{ 0, 0, 0}}, 0 },
+ { {{1970, 1, 1},{ 0, 0, 1}}, 1 },
+ { {{1969,12,31},{23,59,59}}, -1 },
+ { {{1920,12,31},{23,59,59}}, -1546300801 },
+ { {{1600,02,19},{15,14,08}}, -11671807552 },
+ { {{1979,05,28},{12,30,35}}, 296742635 },
+ { {{1999,12,31},{23,59,59}}, 946684799 },
+ { {{2000, 1, 1},{ 0, 0, 0}}, 946684800 },
+ { {{2000, 1, 1},{ 0, 0, 1}}, 946684801 },
+
+ { {{2038, 1,19},{03,14,07}}, 2147483647 }, % Sint32 full - 1
+ { {{2038, 1,19},{03,14,08}}, 2147483648 }, % Sint32 full
+ { {{2038, 1,19},{03,14,09}}, 2147483649 }, % Sint32 full + 1
+
+ { {{2106, 2, 7},{ 6,28,14}}, 4294967294 }, % Uint32 full 0xFFFFFFFF - 1
+ { {{2106, 2, 7},{ 6,28,15}}, 4294967295 }, % Uint32 full 0xFFFFFFFF
+ { {{2106, 2, 7},{ 6,28,16}}, 4294967296 }, % Uint32 full 0xFFFFFFFF + 1
+ { {{2012,12, 6},{16,28,08}}, 1354811288 },
+ { {{2412,12, 6},{16,28,08}}, 13977592088 }
+ ].
+
+
%% The following dates should not be near the end or beginning of
%% a month, because they will be used to test when the dates are
%% different in UTC and local time.