diff options
-rw-r--r-- | lib/megaco/test/megaco_actions_test.erl | 11 | ||||
-rw-r--r-- | lib/megaco/test/megaco_config_test.erl | 24 | ||||
-rw-r--r-- | lib/megaco/test/megaco_flex_test.erl | 17 | ||||
-rw-r--r-- | lib/megaco/test/megaco_load_test.erl | 34 | ||||
-rw-r--r-- | lib/megaco/test/megaco_mreq_test.erl | 11 | ||||
-rw-r--r-- | lib/megaco/test/megaco_pending_limit_test.erl | 46 | ||||
-rw-r--r-- | lib/megaco/test/megaco_segment_test.erl | 51 | ||||
-rw-r--r-- | lib/megaco/test/megaco_tcp_test.erl | 19 | ||||
-rw-r--r-- | lib/megaco/test/megaco_test_generator.erl | 18 | ||||
-rw-r--r-- | lib/megaco/test/megaco_test_generic_transport.erl | 20 | ||||
-rw-r--r-- | lib/megaco/test/megaco_test_lib.hrl | 1 | ||||
-rw-r--r-- | lib/megaco/test/megaco_test_megaco_generator.erl | 7 | ||||
-rw-r--r-- | lib/megaco/test/megaco_test_mg.erl | 19 | ||||
-rw-r--r-- | lib/megaco/test/megaco_test_mgc.erl | 21 | ||||
-rw-r--r-- | lib/megaco/test/megaco_udp_test.erl | 17 |
15 files changed, 84 insertions, 232 deletions
diff --git a/lib/megaco/test/megaco_actions_test.erl b/lib/megaco/test/megaco_actions_test.erl index fcbe4f12fa..4e52bc6e16 100644 --- a/lib/megaco/test/megaco_actions_test.erl +++ b/lib/megaco/test/megaco_actions_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2016. All Rights Reserved. +%% Copyright Ericsson AB 2004-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -391,7 +391,9 @@ print(Severity, Verbosity, P, F, A) -> print(printable(Severity,Verbosity), P, F, A). print(true, P, F, A) -> - io:format("~s~p:~s: " ++ F ++ "~n", [P, self(), get(sname) | A]); + io:format("*** [~s] ~s ~p ~s ***" + "~n " ++ F ++ "~n", + [?FTS(), P, self(), get(sname) | A]); print(_, _, _, _) -> ok. @@ -399,11 +401,10 @@ print(_, _, _, _) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% random_init() -> - {A,B,C} = now(), - random:seed(A,B,C). + ok. random() -> - 10 * random:uniform(50). + 10 * rand:uniform(50). apply_load_timer() -> erlang:send_after(random(), self(), apply_load_timeout). diff --git a/lib/megaco/test/megaco_config_test.erl b/lib/megaco/test/megaco_config_test.erl index 02e06a722a..62a9c0980a 100644 --- a/lib/megaco/test/megaco_config_test.erl +++ b/lib/megaco/test/megaco_config_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -1122,28 +1122,18 @@ i(F) -> i(F, []). i(F, A) -> - print(info, get(verbosity), now(), get(tc), "INF", F, A). + print(info, get(verbosity), get(tc), "INF", F, A). printable(_, debug) -> true; printable(info, info) -> true; printable(_,_) -> false. -print(Severity, Verbosity, Ts, Tc, P, F, A) -> - print(printable(Severity,Verbosity), Ts, Tc, P, F, A). +print(Severity, Verbosity, Tc, P, F, A) -> + print(printable(Severity,Verbosity), Tc, P, F, A). -print(true, Ts, Tc, P, F, A) -> +print(true, Tc, P, F, A) -> io:format("*** [~s] ~s ~p ~s:~w ***" "~n " ++ F ++ "~n", - [format_timestamp(Ts), P, self(), get(sname), Tc | A]); -print(_, _, _, _, _, _) -> + [?FTS(), P, self(), get(sname), Tc | A]); +print(_, _, _, _, _) -> ok. - -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY,MM,DD} = Date, - {Hour,Min,Sec} = Time, - FormatDate = - io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), - lists:flatten(FormatDate). - diff --git a/lib/megaco/test/megaco_flex_test.erl b/lib/megaco/test/megaco_flex_test.erl index 999d1abc6c..27c46a3b47 100644 --- a/lib/megaco/test/megaco_flex_test.erl +++ b/lib/megaco/test/megaco_flex_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2016. All Rights Reserved. +%% Copyright Ericsson AB 2008-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -219,18 +219,5 @@ p(F, A) -> TC = get(tc), io:format("*** [~s] ~p ~w ***" "~n " ++ F ++ "~n", - [formated_timestamp(), self(), TC | A]). - -formated_timestamp() -> - format_timestamp(erlang:now()). - -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY, MM, DD} = Date, - {Hour, Min, Sec} = Time, - FormatDate = - io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), - lists:flatten(FormatDate). - + [?FTS(), self(), TC | A]). diff --git a/lib/megaco/test/megaco_load_test.erl b/lib/megaco/test/megaco_load_test.erl index 511e5a2e8e..b2c799b929 100644 --- a/lib/megaco/test/megaco_load_test.erl +++ b/lib/megaco/test/megaco_load_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2016. All Rights Reserved. +%% Copyright Ericsson AB 2003-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -630,8 +630,9 @@ make_mids([MgNode|MgNodes], Mids) -> end. tim() -> - {A,B,C} = erlang:now(), - A*1000000000+B*1000+(C div 1000). + %% {A,B,C} = erlang:now(), + %% A*1000000000+B*1000+(C div 1000). + erlang:monotonic_time(milli_seconds). sleep(X) -> receive after X -> ok end. @@ -651,46 +652,37 @@ i(F) -> i(F, []). i(F, A) -> - print(info, get(verbosity), now(), get(tc), "INF", F, A). + print(info, get(verbosity), get(tc), "INF", F, A). d(F) -> d(F, []). d(F, A) -> - print(debug, get(verbosity), now(), get(tc), "DBG", F, A). + print(debug, get(verbosity), get(tc), "DBG", F, A). printable(_, debug) -> true; printable(info, info) -> true; printable(_,_) -> false. -print(Severity, Verbosity, Ts, Tc, P, F, A) -> - print(printable(Severity,Verbosity), Ts, Tc, P, F, A). +print(Severity, Verbosity, Tc, P, F, A) -> + print(printable(Severity,Verbosity), Tc, P, F, A). -print(true, Ts, Tc, P, F, A) -> +print(true, Tc, P, F, A) -> io:format("*** [~s] ~s ~p ~s:~w ***" "~n " ++ F ++ "~n", - [format_timestamp(Ts), P, self(), get(sname), Tc | A]); -print(_, _, _, _, _, _) -> + [?FTS(), P, self(), get(sname), Tc | A]); +print(_, _, _, _, _) -> ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% random_init() -> - {A,B,C} = now(), - random:seed(A,B,C). + ok. random() -> - 10 * random:uniform(50). + 10 * rand:uniform(50). apply_load_timer() -> erlang:send_after(random(), self(), apply_load_timeout). -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY,MM,DD} = Date, - {Hour,Min,Sec} = Time, - FormatDate = - io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), - lists:flatten(FormatDate). diff --git a/lib/megaco/test/megaco_mreq_test.erl b/lib/megaco/test/megaco_mreq_test.erl index e6a5ed3181..229141df4f 100644 --- a/lib/megaco/test/megaco_mreq_test.erl +++ b/lib/megaco/test/megaco_mreq_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2016. All Rights Reserved. +%% Copyright Ericsson AB 2003-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -456,7 +456,9 @@ print(Severity, Verbosity, P, F, A) -> print(printable(Severity,Verbosity), P, F, A). print(true, P, F, A) -> - io:format("~s~p:~s: " ++ F ++ "~n", [P, self(), get(sname) | A]); + io:format("*** [~s] ~s ~p ~s ***" + "~n " ++ F ++ "~n", + [?FTS(), P, self(), get(sname) | A]); print(_, _, _, _) -> ok. @@ -464,11 +466,10 @@ print(_, _, _, _) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% random_init() -> - {A,B,C} = now(), - random:seed(A,B,C). + ok. random() -> - 10 * random:uniform(50). + 10 * rand:uniform(50). apply_load_timer() -> erlang:send_after(random(), self(), apply_load_timeout). diff --git a/lib/megaco/test/megaco_pending_limit_test.erl b/lib/megaco/test/megaco_pending_limit_test.erl index ef3b7e51cf..e0c0468d99 100644 --- a/lib/megaco/test/megaco_pending_limit_test.erl +++ b/lib/megaco/test/megaco_pending_limit_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2016. All Rights Reserved. +%% Copyright Ericsson AB 2003-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -2065,23 +2065,12 @@ await_completion(Ids) -> ?ERROR({failed, Reply}) end. -%% await_completion(Ids, Timeout) -> -%% case megaco_test_generator_lib:await_completion(Ids, Timeout) of -%% {ok, Reply} -> -%% d("OK => Reply: ~n~p", [Reply]), -%% ok; -%% {error, Reply} -> -%% d("ERROR => Reply: ~n~p", [Reply]), -%% ?ERROR({failed, Reply}) -%% end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sleep(X) -> receive after X -> ok end. -%% error_msg(F,A) -> error_logger:error_msg(F ++ "~n",A). - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -2089,49 +2078,30 @@ i(F) -> i(F, []). i(F, A) -> - print(info, get(verbosity), now(), get(tc), "INF", F, A). + print(info, get(verbosity), get(tc), "INF", F, A). d(F) -> d(F, []). d(F, A) -> - print(debug, get(verbosity), now(), get(tc), "DBG", F, A). + print(debug, get(verbosity), get(tc), "DBG", F, A). printable(_, debug) -> true; printable(info, info) -> true; printable(_,_) -> false. -print(Severity, Verbosity, Ts, Tc, P, F, A) -> - print(printable(Severity,Verbosity), Ts, Tc, P, F, A). +print(Severity, Verbosity, Tc, P, F, A) -> + print(printable(Severity,Verbosity), Tc, P, F, A). -print(true, Ts, Tc, P, F, A) -> +print(true, Tc, P, F, A) -> io:format("*** [~s] ~s ~p ~s:~w ***" "~n " ++ F ++ "~n", - [format_timestamp(Ts), P, self(), get(sname), Tc | A]); -print(_, _, _, _, _, _) -> + [?FTS(), P, self(), get(sname), Tc | A]); +print(_, _, _, _, _) -> ok. -%% print(F, A) -> -%% io:format("*** [~s] ***" -%% "~n " ++ F ++ "~n", -%% [format_timestamp(now()) | A]). - -format_timestamp(Now) -> megaco:format_timestamp(Now). - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% random_init() -> -%% {A,B,C} = now(), -%% random:seed(A,B,C). - -%% random() -> -%% 10 * random:uniform(50). - -%% apply_load_timer() -> -%% erlang:send_after(random(), self(), apply_load_timeout). - - - diff --git a/lib/megaco/test/megaco_segment_test.erl b/lib/megaco/test/megaco_segment_test.erl index ddb8b9f06b..47f708a14b 100644 --- a/lib/megaco/test/megaco_segment_test.erl +++ b/lib/megaco/test/megaco_segment_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2016. All Rights Reserved. +%% Copyright Ericsson AB 2006-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -7718,29 +7718,9 @@ await_completion(Ids) -> ?ERROR({failed, Reply}) end. -%% await_completion(Ids, Timeout) -> -%% case megaco_test_generator_lib:await_completion(Ids, Timeout) of -%% {ok, Reply} -> -%% d("OK => Reply: ~n~p", [Reply]), -%% ok; -%% {error, {OK, ERROR}} -> -%% d("ERROR => " -%% "~n OK: ~p" -%% "~n ERROR: ~p", [OK, ERROR]), -%% ?ERROR({failed, ERROR}); -%% {error, Reply} -> -%% d("ERROR => Reply: ~n~p", [Reply]), -%% ?ERROR({failed, Reply}) -%% end. - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% tim() -> -%% {A,B,C} = erlang:now(), -%% A*1000000000+B*1000+(C div 1000). - - make_node_name(Name) -> case string:tokens(atom_to_list(node()), [$@]) of [_,Host] -> @@ -7754,8 +7734,6 @@ make_node_name(Name) -> sleep(X) -> receive after X -> ok end. -%% error_msg(F,A) -> error_logger:error_msg(F ++ "~n",A). - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -7763,44 +7741,31 @@ i(F) -> i(F, []). i(F, A) -> - print(info, get(verbosity), now(), get(tc), "INF", F, A). + print(info, get(verbosity), get(tc), "INF", F, A). d(F) -> d(F, []). d(F, A) -> - print(debug, get(verbosity), now(), get(tc), "DBG", F, A). + print(debug, get(verbosity), get(tc), "DBG", F, A). printable(_, debug) -> true; printable(info, info) -> true; printable(_,_) -> false. -print(Severity, Verbosity, Ts, Tc, P, F, A) -> - print(printable(Severity,Verbosity), Ts, Tc, P, F, A). +print(Severity, Verbosity, Tc, P, F, A) -> + print(printable(Severity, Verbosity), Tc, P, F, A). -print(true, Ts, Tc, P, F, A) -> +print(true, Tc, P, F, A) -> io:format("*** [~s] ~s ~p ~s:~w ***" "~n " ++ F ++ "~n", - [format_timestamp(Ts), P, self(), get(sname), Tc | A]); -print(_, _, _, _, _, _) -> + [?FTS(), P, self(), get(sname), Tc | A]); +print(_, _, _, _, _) -> ok. -format_timestamp(Now) -> megaco:format_timestamp(Now). - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% random_init() -> -%% {A,B,C} = now(), -%% random:seed(A,B,C). - -%% random() -> -%% 10 * random:uniform(50). - -%% apply_load_timer() -> -%% erlang:send_after(random(), self(), apply_load_timeout). - - diff --git a/lib/megaco/test/megaco_tcp_test.erl b/lib/megaco/test/megaco_tcp_test.erl index a1865ad690..1f09db265d 100644 --- a/lib/megaco/test/megaco_tcp_test.erl +++ b/lib/megaco/test/megaco_tcp_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -1214,23 +1214,14 @@ p(F, A) -> p(S, F, A) when is_list(S) -> io:format("*** [~s] ~p ~s ***" "~n " ++ F ++ "~n", - [format_timestamp(now()), self(), S | A]); + [?FTS(), self(), S | A]); p(_S, F, A) -> io:format("*** [~s] ~p ~s *** " "~n " ++ F ++ "~n", - [format_timestamp(now()), self(), "undefined" | A]). + [?FTS(), self(), "undefined" | A]). ms() -> - {A,B,C} = erlang:now(), - A*1000000000+B*1000+(C div 1000). - + erlang:monotonic_time(milli_seconds). + -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY,MM,DD} = Date, - {Hour,Min,Sec} = Time, - FormatDate = - io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), - lists:flatten(FormatDate). diff --git a/lib/megaco/test/megaco_test_generator.erl b/lib/megaco/test/megaco_test_generator.erl index 63f66bda07..f922afa37d 100644 --- a/lib/megaco/test/megaco_test_generator.erl +++ b/lib/megaco/test/megaco_test_generator.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2016. All Rights Reserved. +%% Copyright Ericsson AB 2007-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -65,6 +65,7 @@ -include_lib("megaco/include/megaco.hrl"). +-include("megaco_test_lib.hrl"). %%---------------------------------------------------------------------- @@ -533,22 +534,13 @@ print(P, F, A) -> print([], undefined, F, A) -> io:format("*** [~s] ~p *** " ++ "~n " ++ F ++ "~n", - [format_timestamp(now()),self()|A]); + [?FTS(), self() | A]); print(P, undefined, F, A) -> io:format("*** [~s] ~p ~s *** " ++ "~n " ++ F ++ "~n", - [format_timestamp(now()),self(),P|A]); + [?FTS(), self(), P | A]); print(P, N, F, A) -> io:format("*** [~s] ~p ~s~s *** " ++ "~n " ++ F ++ "~n", - [format_timestamp(now()),self(),N,P|A]). + [?FTS(), self(), N, P | A]). - -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY, MM, DD} = Date, - {Hour, Min, Sec} = Time, - FormatDate = - io_lib:format("~.4w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY, MM, DD, Hour, Min, Sec, round(N3/1000)]), - lists:flatten(FormatDate). diff --git a/lib/megaco/test/megaco_test_generic_transport.erl b/lib/megaco/test/megaco_test_generic_transport.erl index 3185e4c6b6..cd387f748a 100644 --- a/lib/megaco/test/megaco_test_generic_transport.erl +++ b/lib/megaco/test/megaco_test_generic_transport.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2016. All Rights Reserved. +%% Copyright Ericsson AB 2007-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ receive_handle}). -include_lib("megaco/include/megaco.hrl"). -%% -include("megaco_test_lib.hrl"). +-include("megaco_test_lib.hrl"). -define(SERVER, ?MODULE). @@ -335,21 +335,11 @@ d(F) -> d(F, []). d(F, A) -> - print(now(), F, A). + print(F, A). -print(Ts, F, A) -> +print(F, A) -> io:format("*** [~s] GENERIC TRANSPORT [~p] ***" "~n " ++ F ++ "~n", - [format_timestamp(Ts), self() | A]). - -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY,MM,DD} = Date, - {Hour,Min,Sec} = Time, - FormatDate = - io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), - lists:flatten(FormatDate). - + [?FTS(), self() | A]). diff --git a/lib/megaco/test/megaco_test_lib.hrl b/lib/megaco/test/megaco_test_lib.hrl index 409f8d52e5..b759c9bc75 100644 --- a/lib/megaco/test/megaco_test_lib.hrl +++ b/lib/megaco/test/megaco_test_lib.hrl @@ -86,4 +86,5 @@ -define(MINUTES(T), megaco_test_lib:minutes(T)). -define(SECONDS(T), megaco_test_lib:seconds(T)). -define(FTS(), megaco:format_timestamp(erlang:timestamp())). +-define(FTS(TS), megaco:format_timestamp(TS)). diff --git a/lib/megaco/test/megaco_test_megaco_generator.erl b/lib/megaco/test/megaco_test_megaco_generator.erl index 8a37fa33fe..5ec4a75b73 100644 --- a/lib/megaco/test/megaco_test_megaco_generator.erl +++ b/lib/megaco/test/megaco_test_megaco_generator.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2016. All Rights Reserved. +%% Copyright Ericsson AB 2007-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -1096,11 +1096,10 @@ handle_megaco_callback_reply(_, _, _, _) -> %%---------------------------------------------------------------------- random_init() -> - {A,B,C} = now(), - random:seed(A,B,C). + ok. random(N) -> - random:uniform(N). + rand:uniform(N). get_config(Key, Opts) -> diff --git a/lib/megaco/test/megaco_test_mg.erl b/lib/megaco/test/megaco_test_mg.erl index d6a9a8c314..b7b220dfa9 100644 --- a/lib/megaco/test/megaco_test_mg.erl +++ b/lib/megaco/test/megaco_test_mg.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2016. All Rights Reserved. +%% Copyright Ericsson AB 2003-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -1536,37 +1536,28 @@ print(Severity, Verbosity, P, F, A) -> print(true, P, F, A) -> io:format("*** [~s] ~s ~p ~s ***" "~n " ++ F ++ "~n~n", - [format_timestamp(now()), P, self(), get(sname) | A]); + [?FTS(), P, self(), get(sname) | A]); print(_, _, _, _) -> ok. -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY,MM,DD} = Date, - {Hour,Min,Sec} = Time, - FormatDate = - io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), - lists:flatten(FormatDate). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% random_init() -> - {A,B,C} = now(), - random:seed(A,B,C). + ok. random() -> random(50). random(N) -> - random:uniform(N). + rand:uniform(N). display_system_info(Mid) -> display_system_info(Mid, ""). display_system_info(Mid, Pre) -> - TimeStr = format_timestamp(now()), + TimeStr = ?FTS(), MibStr = lists:flatten(io_lib:format("~p ", [Mid])), megaco_test_lib:display_system_info(MibStr ++ Pre ++ TimeStr). diff --git a/lib/megaco/test/megaco_test_mgc.erl b/lib/megaco/test/megaco_test_mgc.erl index 045bc7c9fd..9021efa656 100644 --- a/lib/megaco/test/megaco_test_mgc.erl +++ b/lib/megaco/test/megaco_test_mgc.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2016. All Rights Reserved. +%% Copyright Ericsson AB 2003-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -1153,18 +1153,17 @@ get_conf(Key, Config, Default) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% random_init() -> - {A,B,C} = now(), - random:seed(A,B,C). + ok. random(N) -> - random:uniform(N). + rand:uniform(N). display_system_info(Mid) -> display_system_info(Mid, ""). display_system_info(Mid, Pre) -> - TimeStr = format_timestamp(now()), + TimeStr = ?FTS(), MibStr = lists:flatten(io_lib:format("~p ", [Mid])), megaco_test_lib:display_system_info(MibStr ++ Pre ++ TimeStr). @@ -1209,14 +1208,6 @@ print(_, _, _, _) -> print(P, F, A) -> io:format("*** [~s] ~s ~p ~s ***" "~n " ++ F ++ "~n~n", - [format_timestamp(now()), P, self(), get(sname) | A]). - -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY,MM,DD} = Date, - {Hour,Min,Sec} = Time, - FormatDate = - io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), - lists:flatten(FormatDate). + [?FTS(), P, self(), get(sname) | A]). + diff --git a/lib/megaco/test/megaco_udp_test.erl b/lib/megaco/test/megaco_udp_test.erl index cc03ec733a..39ff44709e 100644 --- a/lib/megaco/test/megaco_udp_test.erl +++ b/lib/megaco/test/megaco_udp_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -1211,23 +1211,14 @@ p(F, A) -> p(S, F, A) when is_list(S) -> io:format("*** [~s] ~p ~s ***" "~n " ++ F ++ "~n", - [format_timestamp(now()), self(), S | A]); + [?FTS(), self(), S | A]); p(_S, F, A) -> io:format("*** [~s] ~p ~s *** " "~n " ++ F ++ "~n", - [format_timestamp(now()), self(), "undefined" | A]). + [?FTS(), self(), "undefined" | A]). ms() -> - {A,B,C} = erlang:now(), - A*1000000000+B*1000+(C div 1000). + erlang:monotonic_time(milli_seconds). -format_timestamp({_N1, _N2, N3} = Now) -> - {Date, Time} = calendar:now_to_datetime(Now), - {YYYY,MM,DD} = Date, - {Hour,Min,Sec} = Time, - FormatDate = - io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", - [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), - lists:flatten(FormatDate). |