diff options
author | Erland Schönbeck <[email protected]> | 2015-03-23 12:12:38 +0100 |
---|---|---|
committer | Erland Schönbeck <[email protected]> | 2015-03-23 12:12:38 +0100 |
commit | 7a4967882b44e9048949bd8dc6cb6e953ea0c1c9 (patch) | |
tree | 54d3da0fb406b7f29538d76df0d17ff47f5a7ccc /lib | |
parent | 90f97f3e17acb63bfae2e07646cfaf098ed3dbdd (diff) | |
parent | 68f600f7466abca20ab5b2f81ab3c433a2b87064 (diff) | |
download | otp-7a4967882b44e9048949bd8dc6cb6e953ea0c1c9.tar.gz otp-7a4967882b44e9048949bd8dc6cb6e953ea0c1c9.tar.bz2 otp-7a4967882b44e9048949bd8dc6cb6e953ea0c1c9.zip |
Merge branch 'erland/revert_time/OTP-12444' into maint
* erland/revert_time/OTP-12444:
Revert "Use new time API and be back-compatible in ssh"
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ssh/src/ssh_info.erl | 9 | ||||
-rw-r--r-- | lib/ssh/test/ssh_basic_SUITE.erl | 29 |
2 files changed, 10 insertions, 28 deletions
diff --git a/lib/ssh/src/ssh_info.erl b/lib/ssh/src/ssh_info.erl index e5a8666af0..9a91875894 100644 --- a/lib/ssh/src/ssh_info.erl +++ b/lib/ssh/src/ssh_info.erl @@ -179,14 +179,7 @@ line(Len, Char) -> datetime() -> - %% Adapt to new OTP 18 erlang time API and be back-compatible - TimeStamp = try - erlang:timestamp() - catch - error:undef -> - erlang:now() - end, - {{YYYY,MM,DD}, {H,M,S}} = calendar:now_to_universal_time(TimeStamp), + {{YYYY,MM,DD}, {H,M,S}} = calendar:now_to_universal_time(now()), lists:flatten(io_lib:format('~4w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w UTC',[YYYY,MM,DD, H,M,S])). diff --git a/lib/ssh/test/ssh_basic_SUITE.erl b/lib/ssh/test/ssh_basic_SUITE.erl index b449012ffc..45c03035cb 100644 --- a/lib/ssh/test/ssh_basic_SUITE.erl +++ b/lib/ssh/test/ssh_basic_SUITE.erl @@ -715,14 +715,7 @@ ssh_connect_arg4_timeout(_Config) -> %% try to connect with a timeout, but "supervise" it Client = spawn(fun() -> - %% Adapt to OTP 18 erlang time API and be back-compatible - T0 = try - erlang:monotonic_time() - catch - error:undef -> - %% Use Erlang system time as monotonic time - erlang:now() - end, + T0 = now(), Rc = ssh:connect("localhost",Port,[],Timeout), ct:log("Client ssh:connect got ~p",[Rc]), Parent ! {done,self(),Rc,T0} @@ -731,12 +724,13 @@ ssh_connect_arg4_timeout(_Config) -> %% Wait for client reaction on the connection try: receive {done, Client, {error,timeout}, T0} -> - Msp = ms_passed(T0), + Msp = ms_passed(T0, now()), exit(Server,hasta_la_vista___baby), Low = 0.9*Timeout, High = 1.1*Timeout, ct:log("Timeout limits: ~.4f - ~.4f ms, timeout " "was ~.4f ms, expected ~p ms",[Low,High,Msp,Timeout]), + %%ct:log("Timeout limits: ~p--~p, my timeout was ~p, expected ~p",[Low,High,Msp0,Timeout]), if Low<Msp, Msp<High -> ok; true -> {fail, "timeout not within limits"} @@ -755,17 +749,12 @@ ssh_connect_arg4_timeout(_Config) -> {fail, "Didn't timeout"} end. - -%% Help function, elapsed milliseconds since T0 -ms_passed({_,_,_} = T0 ) -> - %% OTP 17 and earlier - timer:now_diff(erlang:now(), T0)/1000; - -ms_passed(T0) -> - %% OTP 18 - erlang:convert_time_resolution(erlang:monotonic_time() - T0, - erlang:time_resolution(), - 1000000)/1000. +%% Help function +%% N2-N1 +ms_passed(N1={_,_,M1}, N2={_,_,M2}) -> + {0,{0,Min,Sec}} = calendar:time_difference(calendar:now_to_local_time(N1), + calendar:now_to_local_time(N2)), + 1000 * (Min*60 + Sec + (M2-M1)/1000000). %%-------------------------------------------------------------------- ssh_connect_negtimeout_parallel(Config) -> ssh_connect_negtimeout(Config,true). |