aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test/diameter_util.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2015-02-10 08:44:35 +0100
committerAnders Svensson <[email protected]>2015-02-20 02:26:53 +0100
commiteae8ecd1fd2ba33b1c81d0c19605047e2f317eda (patch)
treec6dacca281e305e441a23b2fda3859cd5a623877 /lib/diameter/test/diameter_util.erl
parente6d19a18b7c1057c2b4493f8db822c82bb0dbe0d (diff)
downloadotp-eae8ecd1fd2ba33b1c81d0c19605047e2f317eda.tar.gz
otp-eae8ecd1fd2ba33b1c81d0c19605047e2f317eda.tar.bz2
otp-eae8ecd1fd2ba33b1c81d0c19605047e2f317eda.zip
Use new time api in test suites
Where it's less important to do so, but it has to be done at some point since erlang:now/0 is deprecated. As in the parent commit, continue to use the old api if the new one is unavailable.
Diffstat (limited to 'lib/diameter/test/diameter_util.erl')
-rw-r--r--lib/diameter/test/diameter_util.erl30
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl
index e95cbfceb5..c496876ee1 100644
--- a/lib/diameter/test/diameter_util.erl
+++ b/lib/diameter/test/diameter_util.erl
@@ -30,6 +30,9 @@
fold/3,
foldl/3,
scramble/1,
+ timestamp/0,
+ seed/0,
+ unique_string/0,
have_sctp/0]).
%% diameter-specific
@@ -175,7 +178,7 @@ scramble(L) ->
[[fun s/1, L]]).
s(L) ->
- random:seed(now()),
+ random:seed(seed()),
s([], L).
s(Acc, []) ->
@@ -185,6 +188,31 @@ s(Acc, L) ->
s([T|Acc], H ++ Rest).
%% ---------------------------------------------------------------------------
+%% timestamp/0
+
+timestamp() ->
+ diameter_lib:timestamp(diameter_lib:now()).
+
+%% ---------------------------------------------------------------------------
+%% seed/0
+
+seed() ->
+ {_,T} = diameter_lib:seed(),
+ T.
+
+%% ---------------------------------------------------------------------------
+%% unique_string/0
+
+unique_string() ->
+ us(diameter_lib:now()).
+
+us({M,S,U}) ->
+ tl(lists:append(["-" ++ integer_to_list(N) || N <- [M,S,U]]));
+
+us(MonoT) ->
+ integer_to_list(MonoT).
+
+%% ---------------------------------------------------------------------------
%% have_sctp/0
have_sctp() ->