aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server/src/test_server_node.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/test_server/src/test_server_node.erl')
-rw-r--r--lib/test_server/src/test_server_node.erl52
1 files changed, 30 insertions, 22 deletions
diff --git a/lib/test_server/src/test_server_node.erl b/lib/test_server/src/test_server_node.erl
index 4e6839fc6b..37f8941d24 100644
--- a/lib/test_server/src/test_server_node.erl
+++ b/lib/test_server/src/test_server_node.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2014. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2016. 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.
@@ -121,7 +121,7 @@ start_tracer_node(TraceFile,TI) ->
%%%
trace_nodes(Sock,Nodes) ->
Bin = term_to_binary({add_nodes,Nodes}),
- ok = gen_tcp:send(Sock, [1|Bin]),
+ ok = gen_tcp:send(Sock, tag_trace_message(Bin)),
receive_ack(Sock).
@@ -142,7 +142,7 @@ receive_ack(Sock) ->
%%%
stop_tracer_node(Sock) ->
Bin = term_to_binary(id(stop)),
- ok = gen_tcp:send(Sock, [1|Bin]),
+ ok = gen_tcp:send(Sock, tag_trace_message(Bin)),
receive {tcp_closed,Sock} -> gen_tcp:close(Sock) end,
ok.
@@ -171,7 +171,7 @@ trc([TraceFile, PortAtom, Type]) ->
{packet,2}]) of
{ok,Sock} ->
BinResult = term_to_binary(Result),
- ok = gen_tcp:send(Sock,[1|BinResult]),
+ ok = gen_tcp:send(Sock,tag_trace_message(BinResult)),
trc_loop(Sock,Patterns,Type);
_else ->
ok
@@ -187,7 +187,7 @@ trc_loop(Sock,Patterns,Type) ->
{ok,{add_nodes,Nodes}} ->
add_nodes(Nodes,Patterns,Type),
Bin = term_to_binary(id(ok)),
- ok = gen_tcp:send(Sock, [1|Bin]),
+ ok = gen_tcp:send(Sock, tag_trace_message(Bin)),
trc_loop(Sock,Patterns,Type);
{ok,stop} ->
ttb:stop(),
@@ -307,11 +307,11 @@ start_node_peer(SlaveName, OptList, From, TI) ->
HostStr, " ", WaitPort]),
% Support for erl_crash_dump files..
- CrashFile = filename:join([TI#target_info.test_server_dir,
+ CrashDir = test_server_sup:crash_dump_dir(),
+ CrashFile = filename:join([CrashDir,
"erl_crash_dump."++cast_to_list(SlaveName)]),
CrashArgs = lists:concat([" -env ERL_CRASH_DUMP \"",CrashFile,"\" "]),
FailOnError = start_node_get_option_value(fail_on_error, OptList, true),
- Pa = TI#target_info.test_server_dir,
Prog0 = start_node_get_option_value(erl, OptList, default),
Prog = quote_progname(pick_erl_program(Prog0)),
Args =
@@ -322,7 +322,6 @@ start_node_peer(SlaveName, OptList, From, TI) ->
Cmd = lists:concat([Prog,
" -detached ",
TI#target_info.naming, " ", SlaveName,
- " -pa \"", Pa,"\"",
NodeStarted,
CrashArgs,
" ", Args]),
@@ -354,28 +353,31 @@ start_node_peer(SlaveName, OptList, From, TI) ->
I = "=== Not waiting for node",
gen_server:reply(From,{{ok, Nodename}, HostStr, Cmd, I, []}),
Self = self(),
- spawn_link(
- fun() ->
- wait_for_node_started(LSock,Tmo,undefined,
- Cleanup,TI,Self),
- receive after infinity -> ok end
- end),
+ spawn_link(wait_for_node_started_fun(LSock,Tmo,Cleanup,TI,Self)),
ok
end.
+-spec wait_for_node_started_fun(_, _, _, _, _) -> fun(() -> no_return()).
+wait_for_node_started_fun(LSock, Tmo, Cleanup, TI, Self) ->
+ fun() ->
+ wait_for_node_started(LSock,Tmo,undefined,
+ Cleanup,TI,Self),
+ receive after infinity -> ok end
+ end.
+
%%
%% Slave nodes are started on a remote host if
%% - the option remote is given when calling test_server:start_node/3
%%
-start_node_slave(SlaveName, OptList, From, TI) ->
+start_node_slave(SlaveName, OptList, From, _TI) ->
SuppliedArgs = start_node_get_option_value(args, OptList, []),
Cleanup = start_node_get_option_value(cleanup, OptList, true),
- CrashFile = filename:join([TI#target_info.test_server_dir,
+ CrashDir = test_server_sup:crash_dump_dir(),
+ CrashFile = filename:join([CrashDir,
"erl_crash_dump."++cast_to_list(SlaveName)]),
CrashArgs = lists:concat([" -env ERL_CRASH_DUMP \"",CrashFile,"\" "]),
- Pa = TI#target_info.test_server_dir,
- Args = lists:concat([" -pa \"", Pa, "\" ", SuppliedArgs, CrashArgs]),
+ Args = lists:concat([" ", SuppliedArgs, CrashArgs]),
Prog0 = start_node_get_option_value(erl, OptList, default),
Prog = pick_erl_program(Prog0),
@@ -468,7 +470,11 @@ handle_start_node_return(Version,VsnStr,{started, Node, OVersion, OVsnStr}) ->
node_started([Host,PortAtom]) ->
%% Must spawn a new process because the boot process should not
%% hang forever!!
- spawn(fun() -> node_started(Host,PortAtom) end).
+ spawn(node_started_fun(Host,PortAtom)).
+
+-spec node_started_fun(_, _) -> fun(() -> no_return()).
+node_started_fun(Host,PortAtom) ->
+ fun() -> node_started(Host,PortAtom) end.
%% This process hangs forever, just waiting for the socket to be
%% closed and terminating the node
@@ -482,7 +488,7 @@ node_started(Host,PortAtom) ->
{ok,Sock} ->
Started = term_to_binary({started, node(), Version, VsnStr}),
- ok = gen_tcp:send(Sock, [1|Started]),
+ ok = gen_tcp:send(Sock, tag_trace_message(Started)),
receive _Anyting ->
gen_tcp:close(Sock),
erlang:halt()
@@ -492,8 +498,10 @@ node_started(Host,PortAtom) ->
end.
-
-
+-compile({inline, [tag_trace_message/1]}).
+-dialyzer({no_improper_lists, tag_trace_message/1}).
+tag_trace_message(M) ->
+ [1|M].
% start_which_node(Optlist) -> hostname
start_which_node(Optlist) ->