diff options
author | Micael Karlberg <[email protected]> | 2019-06-10 20:55:48 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-07-01 18:01:56 +0200 |
commit | eb12db36e0e66055fddb31f52c03b423997528b0 (patch) | |
tree | ea0debfd0477f31ec1e6fa6ba6dd255f9682c509 /lib/megaco/test/megaco_test_lib.erl | |
parent | d96df449f8232c33dff837b13a5f706390301b71 (diff) | |
download | otp-eb12db36e0e66055fddb31f52c03b423997528b0.tar.gz otp-eb12db36e0e66055fddb31f52c03b423997528b0.tar.bz2 otp-eb12db36e0e66055fddb31f52c03b423997528b0.zip |
[megaco|test] Fixing the examples test suite
The simple test case was faulty in that the simple example
(which it is testing) require that the MGC and MG run on different
erlang nodes. But the test case did not do this. Instead, it ran
both the MGC and the MG on the test server node, which caused
the test case to fail 1 time of 10.
Diffstat (limited to 'lib/megaco/test/megaco_test_lib.erl')
-rw-r--r-- | lib/megaco/test/megaco_test_lib.erl | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/lib/megaco/test/megaco_test_lib.erl b/lib/megaco/test/megaco_test_lib.erl index 5fe03b28e3..0617b96456 100644 --- a/lib/megaco/test/megaco_test_lib.erl +++ b/lib/megaco/test/megaco_test_lib.erl @@ -62,6 +62,7 @@ proxy_start/1, proxy_start/2, + mk_nodes/1, start_nodes/3 ]). @@ -765,6 +766,7 @@ still_alive(Pid) -> end end. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% The proxy process @@ -776,32 +778,51 @@ proxy_start(Node, ProxyId) -> proxy_init(ProxyId, Controller) -> process_flag(trap_exit, true), - ?LOG("[~p] proxy started by ~p~n",[ProxyId, Controller]), + IdStr = proxyid2string(ProxyId), + put(id, IdStr), + ?LOG("[~s] proxy started by ~p~n", [IdStr, Controller]), proxy_loop(ProxyId, Controller). proxy_loop(OwnId, Controller) -> receive {'EXIT', Controller, Reason} -> - p("proxy_loop -> received exit from controller" + pprint("proxy_loop -> received exit from controller" + "~n Reason: ~p", [Reason]), + exit(Reason); + {stop, Controller, Reason} -> + p("proxy_loop -> received stop from controller" "~n Reason: ~p" "~n", [Reason]), exit(Reason); + {apply, Fun} -> - p("proxy_loop -> received apply request~n", []), + pprint("proxy_loop -> received apply request"), Res = Fun(), - p("proxy_loop -> apply result: " - "~n ~p" - "~n", [Res]), + pprint("proxy_loop -> apply result: " + "~n ~p", [Res]), Controller ! {res, OwnId, Res}, proxy_loop(OwnId, Controller); OtherMsg -> - p("proxy_loop -> received unknown message: " - "~n OtherMsg: ~p" - "~n", [OtherMsg]), + pprint("proxy_loop -> received unknown message: " + "~n ~p", [OtherMsg]), Controller ! {msg, OwnId, OtherMsg}, proxy_loop(OwnId, Controller) end. +proxyid2string(Id) when is_list(Id) -> + Id; +proxyid2string(Id) when is_atom(Id) -> + atom_to_list(Id); +proxyid2string(Id) -> + f("~p", [Id]). + +pprint(F) -> + pprint(F, []). + +pprint(F, A) -> + io:format("[~s] ~p ~s " ++ F ++ "~n", + [get(id), self(), formated_timestamp() | A]). + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Test server callbacks @@ -943,7 +964,10 @@ default_config() -> [{nodes, default_nodes()}, {ts, megaco}]. default_nodes() -> - mk_nodes(2, []). + mk_nodes(3, []). + +mk_nodes(N) when (N > 0) -> + mk_nodes(N, []). mk_nodes(0, Nodes) -> Nodes; @@ -983,5 +1007,11 @@ start_nodes([Node | Nodes], File, Line) -> start_nodes([], _File, _Line) -> ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +f(F, A) -> + lists:flatten(io_lib:format(F, A)). + p(F, A) -> io:format("~p~w:" ++ F ++ "~n", [self(), ?MODULE |A]). |