aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test/httpc_SUITE.erl
diff options
context:
space:
mode:
authorErland Schönbeck <[email protected]>2015-03-05 13:37:16 +0100
committerRickard Green <[email protected]>2015-03-20 15:28:54 +0100
commit1132117b38cfe33e770a0d5b1a782d48667427c4 (patch)
treec40c3da27e2f10a3c50cd5a2b4dc8d9db03aa08b /lib/inets/test/httpc_SUITE.erl
parent403fe576cd71bf32c7e42b782bf3181d809bbc88 (diff)
downloadotp-1132117b38cfe33e770a0d5b1a782d48667427c4.tar.gz
otp-1132117b38cfe33e770a0d5b1a782d48667427c4.tar.bz2
otp-1132117b38cfe33e770a0d5b1a782d48667427c4.zip
Use new time API and be back-compatible in inets
Remove unused functions and removed redundant test
Diffstat (limited to 'lib/inets/test/httpc_SUITE.erl')
-rw-r--r--lib/inets/test/httpc_SUITE.erl36
1 files changed, 28 insertions, 8 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl
index c535d59b9f..495d129661 100644
--- a/lib/inets/test/httpc_SUITE.erl
+++ b/lib/inets/test/httpc_SUITE.erl
@@ -1876,12 +1876,19 @@ run_clients(NumClients, ServerPort, SeqNumServer) ->
wait4clients([], _Timeout) ->
ok;
wait4clients(Clients, Timeout) when Timeout > 0 ->
- Time = now_ms(),
+ %% Adapt to OTP 18 erlang time API and be back-compatible
+ Time = try
+ erlang:monotonic_time()
+ catch
+ error:undef ->
+ %% Use Erlang system time as monotonic time
+ erlang:now()
+ end,
receive
{'DOWN', _MRef, process, Pid, normal} ->
{value, {Id, _, _}} = lists:keysearch(Pid, 2, Clients),
NewClients = lists:keydelete(Id, 1, Clients),
- wait4clients(NewClients, Timeout - (now_ms() - Time));
+ wait4clients(NewClients, Timeout - millisec_passed(Time));
{'DOWN', _MRef, process, Pid, Reason} ->
{value, {Id, _, _}} = lists:keysearch(Pid, 2, Clients),
ct:fail({bad_client_termination, Id, Reason})
@@ -1974,14 +1981,27 @@ parse_connection_type(Request) ->
"keep-alive" -> keep_alive
end.
-%% Time in milli seconds
-now_ms() ->
- {A,B,C} = erlang:now(),
- A*1000000000+B*1000+(C div 1000).
+%% Help function, elapsed milliseconds since T0
+millisec_passed({_,_,_} = T0 ) ->
+ %% OTP 17 and earlier
+ timer:now_diff(erlang:now(), T0) div 1000;
+
+millisec_passed(T0) ->
+ %% OTP 18
+ erlang:convert_time_resolution(erlang:monotonic_time() - T0,
+ erlang:time_resolution(),
+ 1000000) div 1000.
set_random_seed() ->
- {_, _, Micros} = now(),
- A = erlang:phash2([make_ref(), self(), Micros]),
+ %% Adapt to OTP 18 erlang time API and be back-compatible
+ Unique = try
+ erlang:unique_integer()
+ catch
+ error:undef ->
+ {MS, S, US} = erlang:now(),
+ (MS*1000000+S)*1000000+US
+ end,
+ A = erlang:phash2([make_ref(), self(), Unique]),
random:seed(A, A, A).