diff options
author | Rickard Green <[email protected]> | 2016-01-13 18:33:42 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2016-01-20 11:10:37 +0100 |
commit | dc8e62f33ad0ca7a772ec74d67b6d3e157f639b4 (patch) | |
tree | dfb9c44328ba358c34678d557941a13b79e3d281 /lib/stdlib/test/dets_SUITE.erl | |
parent | 858c6f7fa44f7b2dc363b359198d6522dd60e914 (diff) | |
download | otp-dc8e62f33ad0ca7a772ec74d67b6d3e157f639b4.tar.gz otp-dc8e62f33ad0ca7a772ec74d67b6d3e157f639b4.tar.bz2 otp-dc8e62f33ad0ca7a772ec74d67b6d3e157f639b4.zip |
Introduce time warp safe replacement for safe_fixed option
The new time warp safe option is safe_fixed_monotonic_time which
gives erlang:monotonic_time().
The safe_fixed option was also slightly changed. It now gives
erlang:timestamp() instead of erlang:now(). This has however
not been documented, so it is considered a compatible change.
The above effects both ets, and dets.
This commit also include the bugfix OTP-13239 for
dets:info(Tab, safe_fixed). The timestamp in the result returned
by dets:info(Tab, safe_fixed) was unintentionally broken as a
result of the time API rewrites in OTP 18.0.
Diffstat (limited to 'lib/stdlib/test/dets_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/dets_SUITE.erl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/stdlib/test/dets_SUITE.erl b/lib/stdlib/test/dets_SUITE.erl index 7f5e06524a..35e587afcc 100644 --- a/lib/stdlib/test/dets_SUITE.erl +++ b/lib/stdlib/test/dets_SUITE.erl @@ -1876,9 +1876,33 @@ fixtable(Config, Version) when is_list(Config) -> {ok, _} = dets:open_file(T, [{type, duplicate_bag} | Args]), %% In a fixed table, delete and re-insert an object. ok = dets:insert(T, {1, a, b}), + SysBefore = erlang:timestamp(), + MonBefore = erlang:monotonic_time(), dets:safe_fixtable(T, true), + MonAfter = erlang:monotonic_time(), + SysAfter = erlang:timestamp(), + Self = self(), + {FixMonTime,[{Self,1}]} = dets:info(T,safe_fixed_monotonic_time), + {FixSysTime,[{Self,1}]} = dets:info(T,safe_fixed), + true = is_integer(FixMonTime), + true = MonBefore =< FixMonTime, + true = FixMonTime =< MonAfter, + {FstMs,FstS,FstUs} = FixSysTime, + true = is_integer(FstMs), + true = is_integer(FstS), + true = is_integer(FstUs), + case erlang:system_info(time_warp_mode) of + no_time_warp -> + true = timer:now_diff(FixSysTime, SysBefore) >= 0, + true = timer:now_diff(SysAfter, FixSysTime) >= 0; + _ -> + %% ets:info(Tab,safe_fixed) not timewarp safe... + ignore + end, ok = dets:match_delete(T, {1, a, b}), ok = dets:insert(T, {1, a, b}), + {FixMonTime,[{Self,1}]} = dets:info(T,safe_fixed_monotonic_time), + {FixSysTime,[{Self,1}]} = dets:info(T,safe_fixed), dets:safe_fixtable(T, false), 1 = length(dets:match_object(T, '_')), |