aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test')
-rw-r--r--lib/common_test/doc/src/ct_slave.xml22
-rw-r--r--lib/common_test/src/ct_logs.erl6
-rw-r--r--lib/common_test/src/ct_run.erl22
-rw-r--r--lib/common_test/src/ct_slave.erl58
-rw-r--r--lib/common_test/test/ct_master_SUITE.erl2
5 files changed, 52 insertions, 58 deletions
diff --git a/lib/common_test/doc/src/ct_slave.xml b/lib/common_test/doc/src/ct_slave.xml
index 4533de92f7..ceebf51f1a 100644
--- a/lib/common_test/doc/src/ct_slave.xml
+++ b/lib/common_test/doc/src/ct_slave.xml
@@ -12,12 +12,12 @@
<rev>A</rev>
<file>ct_slave.xml</file></header>
<module>ct_slave</module>
-<modulesummary>Common Test Framework functions for starting and stopping nodes for
+<modulesummary>Common Test Framework functions for starting and stopping nodes for
Large Scale Testing.</modulesummary>
<description>
-<p>Common Test Framework functions for starting and stopping nodes for
+<p>Common Test Framework functions for starting and stopping nodes for
Large Scale Testing.</p>
-
+
<p>This module exports functions which are used by the Common Test Master
to start and stop "slave" nodes. It is the default callback module for the
<c>{init, node_start}</c> term of the Test Specification.</p></description>
@@ -56,16 +56,16 @@ Large Scale Testing.</p>
<p>Starts an Erlang node with name <c>Node</c> on host
<c>Host</c> as specified by the combination of options in
<c>Opts</c>.</p>
-
+
<p>Options <c>Username</c> and <c>Password</c> will be used
to log in onto the remote host <c>Host</c>.
Username, if omitted, defaults to the current user name,
and password is empty by default.</p>
-
+
<p>A list of functions specified in the <c>Startup</c> option will be
executed after startup of the node. Note that all used modules should be
present in the code path on the <c>Host</c>.</p>
-
+
<p>The timeouts are applied as follows:
<list>
<item>
@@ -87,18 +87,18 @@ Large Scale Testing.</p>
<c>{error, startup_timeout, NodeName}</c> is returned.
</item>
</list></p>
-
+
<p>Option <c>monitor_master</c> specifies, if the slave node should be
stopped in case of master node stop. Defaults to false.</p>
-
+
<p>Option <c>kill_if_fail</c> specifies, if the slave node should be
killed in case of a timeout during initialization or startup.
Defaults to true. Note that node also may be still alive it the boot
timeout occurred, but it will not be killed in this case.</p>
-
+
<p>Option <c>erlang_flags</c> specifies, which flags will be added
to the parameters of the <c>erl</c> executable.</p>
-
+
<p>Special return values are:
<list>
<item><c>{error, already_started, NodeName}</c> - if the node with
@@ -109,7 +109,7 @@ Large Scale Testing.</p>
<c>ct_slave:start/3</c> is called, is not alive. Note that
<c>NodeName</c> is the name of current node in this case.</item>
</list></p>
-
+
</desc></func>
<func>
<name>stop(Node) -&gt; Result</name>
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl
index f8ae7202e6..c716111f4d 100644
--- a/lib/common_test/src/ct_logs.erl
+++ b/lib/common_test/src/ct_logs.erl
@@ -461,9 +461,11 @@ logger_loop(State) ->
{'EXIT',_Reason} ->
Fd = State#logger_state.ct_log_fd,
io:format(Fd,
- "Logging fails! Str: ~p, Args: ~p~n",
+ "Logging fails! "
+ "Str: ~p, Args: ~p~n",
[Str,Args]),
- %% stop the testcase, we need to see the fault
+ %% stop the testcase, we need
+ %% to see the fault
exit(Pid,logging_failed),
ok;
IoStr when IoList == [] ->
diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl
index 5447b9c8fc..62d73ecbbf 100644
--- a/lib/common_test/src/ct_run.erl
+++ b/lib/common_test/src/ct_run.erl
@@ -739,11 +739,12 @@ run_test1(StartOpts) ->
%% test specification
case proplists:get_value(spec, StartOpts) of
undefined ->
- case proplists:get_value(prepared_tests, StartOpts) of
- undefined -> % use dir|suite|case
- run_dir(Opts, StartOpts);
- {{Run,Skip},Specs} -> % use prepared tests
- run_prepared(Run, Skip, Opts#opts{testspecs = Specs}, StartOpts)
+ case lists:keysearch(prepared_tests, 1, StartOpts) of
+ {value,{_,{Run,Skip},Specs}} -> % use prepared tests
+ run_prepared(Run, Skip, Opts#opts{testspecs = Specs},
+ StartOpts);
+ false ->
+ run_dir(Opts, StartOpts)
end;
Specs ->
Relaxed = get_start_opt(allow_user_terms, value, false, StartOpts),
@@ -1100,7 +1101,7 @@ groups_and_cases([G], Cs) ->
[{ensure_atom(G),[ensure_atom(C) || C <- listify(Cs)]}];
groups_and_cases([_,_|_] , Cs) when Cs =/= [] ->
{error,multiple_groups_and_cases};
-groups_and_cases(Gs, Cs) ->
+groups_and_cases(_Gs, _Cs) ->
{error,incorrect_group_or_case_option}.
tests(TestDir, Suites, []) when is_list(TestDir), is_integer(hd(TestDir)) ->
@@ -1383,17 +1384,8 @@ suite_tuples([]) ->
[].
final_tests(Tests, Skip, Bad) ->
-
- %%! --- Thu Jun 24 15:47:27 2010 --- peppe was here!
- %%! io:format(user, "FINAL0 = ~p~nSKIP0 = ~p~n", [Tests, Skip]),
-
{Tests1,Skip1} = final_tests1(Tests, [], Skip, Bad),
Skip2 = final_skip(Skip1, []),
-
-
- %%! --- Thu Jun 24 15:47:27 2010 --- peppe was here!
- %%! io:format(user, "FINAL1 = ~p~nSKIP1 = ~p~n", [Tests1, Skip2]),
-
{Tests1,Skip2}.
final_tests1([{TestDir,Suites,_}|Tests], Final, Skip, Bad) when
diff --git a/lib/common_test/src/ct_slave.erl b/lib/common_test/src/ct_slave.erl
index d2a491e079..aa3413fa89 100644
--- a/lib/common_test/src/ct_slave.erl
+++ b/lib/common_test/src/ct_slave.erl
@@ -52,7 +52,7 @@
%%% NodeName = atom()
%%% @doc Starts an Erlang node with name <code>Node</code> on the local host.
%%% @see start/3
-start(Node)->
+start(Node) ->
start(gethostname(), Node).
%%%-----------------------------------------------------------------
@@ -70,7 +70,7 @@ start(Node)->
%%% @doc Starts an Erlang node with name <code>Node</code> on host
%%% <code>Host</code> with the default options.
%%% @see start/3
-start(Host, Node)->
+start(Host, Node) ->
start(Host, Node, []).
%%%-----------------------------------------------------------------
@@ -163,7 +163,7 @@ start(Host, Node)->
%%% <code>NodeName</code> is the name of current node in this case.</item>
%%% </list></p>
%%%
-start(Host, Node, Options)->
+start(Host, Node, Options) ->
ENode = enodename(Host, Node),
case erlang:is_alive() of
false->
@@ -189,7 +189,7 @@ start(Host, Node, Options)->
%%% NodeName = atom()
%%% @doc Stops the running Erlang node with name <code>Node</code> on
%%% the localhost.
-stop(Node)->
+stop(Node) ->
stop(gethostname(), Node).
%%% @spec stop(Host, Node) -> Result
@@ -202,7 +202,7 @@ stop(Node)->
%%% NodeName = atom()
%%% @doc Stops the running Erlang node with name <code>Node</code> on
%%% host <code>Host</code>.
-stop(Host, Node)->
+stop(Host, Node) ->
ENode = enodename(Host, Node),
case is_started(ENode) of
{true, connected}->
@@ -214,7 +214,7 @@ stop(Host, Node)->
end.
%%% fetch an option value from the tagged tuple list with default
-get_option_value(Key, OptionList, Default)->
+get_option_value(Key, OptionList, Default) ->
case lists:keyfind(Key, 1, OptionList) of
false->
Default;
@@ -223,7 +223,7 @@ get_option_value(Key, OptionList, Default)->
end.
%%% convert option list to the option record, fill all defaults
-fetch_options(Options)->
+fetch_options(Options) ->
UserName = get_option_value(username, Options, []),
Password = get_option_value(password, Options, []),
BootTimeout = get_option_value(boot_timeout, Options, 3),
@@ -240,23 +240,23 @@ fetch_options(Options)->
% send a message when slave node is started
% @hidden
-slave_started(ENode, MasterPid)->
+slave_started(ENode, MasterPid) ->
MasterPid ! {node_started, ENode},
ok.
% send a message when slave node has finished startup
% @hidden
-slave_ready(ENode, MasterPid)->
+slave_ready(ENode, MasterPid) ->
MasterPid ! {node_ready, ENode},
ok.
% start monitoring of the master node
% @hidden
-monitor_master(MasterNode)->
- spawn(fun()->monitor_master_int(MasterNode) end).
+monitor_master(MasterNode) ->
+ spawn(fun() -> monitor_master_int(MasterNode) end).
% code of the masterdeath-waiter process
-monitor_master_int(MasterNode)->
+monitor_master_int(MasterNode) ->
erlang:monitor_node(MasterNode, true),
receive
{nodedown, MasterNode}->
@@ -264,11 +264,11 @@ monitor_master_int(MasterNode)->
end.
% check if node is listed in the nodes()
-is_connected(ENode)->
+is_connected(ENode) ->
[N||N<-nodes(), N==ENode] == [ENode].
% check if node is alive (ping and disconnect if pingable)
-is_started(ENode)->
+is_started(ENode) ->
case is_connected(ENode) of
true->
{true, connected};
@@ -283,11 +283,11 @@ is_started(ENode)->
end.
% make a Erlang node name from name and hostname
-enodename(Host, Node)->
+enodename(Host, Node) ->
list_to_atom(atom_to_list(Node)++"@"++atom_to_list(Host)).
% performs actual start of the "slave" node
-do_start(Host, Node, Options)->
+do_start(Host, Node, Options) ->
ENode = enodename(Host, Node),
Functions =
lists:concat([[{ct_slave, slave_started, [ENode, self()]}],
@@ -338,7 +338,7 @@ do_start(Host, Node, Options)->
Result.
% are we using fully qualified hostnames
-long_or_short()->
+long_or_short() ->
case net_kernel:longnames() of
true->
" -name ";
@@ -347,7 +347,7 @@ long_or_short()->
end.
% get the localhost's name, depending on the using name policy
-gethostname()->
+gethostname() ->
Hostname = case net_kernel:longnames() of
true->
net_adm:localhost();
@@ -358,19 +358,19 @@ gethostname()->
list_to_atom(Hostname).
% get cmd for starting Erlang
-get_cmd(Node, Flags)->
+get_cmd(Node, Flags) ->
Cookie = erlang:get_cookie(),
"erl -detached -noinput -setcookie "++ atom_to_list(Cookie) ++
long_or_short() ++ atom_to_list(Node) ++ " " ++ Flags.
% spawn node locally
-spawn_local_node(Node, Options)->
+spawn_local_node(Node, Options) ->
ErlFlags = Options#options.erl_flags,
Cmd = get_cmd(Node, ErlFlags),
open_port({spawn, Cmd}, [stream]).
% start crypto and ssh if not yet started
-check_for_ssh_running()->
+check_for_ssh_running() ->
case application:get_application(crypto) of
undefined->
application:start(crypto),
@@ -385,7 +385,7 @@ check_for_ssh_running()->
end.
% spawn node remotely
-spawn_remote_node(Host, Node, Options)->
+spawn_remote_node(Host, Node, Options) ->
Username = Options#options.username,
Password = Options#options.password,
ErlFlags = Options#options.erl_flags,
@@ -403,16 +403,16 @@ spawn_remote_node(Host, Node, Options)->
ssh_connection:exec(SSHConnRef, SSHChannelId, get_cmd(Node, ErlFlags), infinity).
% call functions on a remote Erlang node
-call_functions(_Node, [])->
+call_functions(_Node, []) ->
ok;
-call_functions(Node, [{M, F, A}|Functions])->
+call_functions(Node, [{M, F, A}|Functions]) ->
rpc:call(Node, M, F, A),
call_functions(Node, Functions).
% wait N seconds until node is pingable
-wait_for_node_alive(_Node, 0)->
+wait_for_node_alive(_Node, 0) ->
pang;
-wait_for_node_alive(Node, N)->
+wait_for_node_alive(Node, N) ->
timer:sleep(1000),
case net_adm:ping(Node) of
pong->
@@ -422,14 +422,14 @@ wait_for_node_alive(Node, N)->
end.
% call init:stop on a remote node
-do_stop(ENode)->
+do_stop(ENode) ->
spawn(ENode, init, stop, []),
wait_for_node_dead(ENode, 5).
% wait N seconds until node is disconnected
-wait_for_node_dead(Node, 0)->
+wait_for_node_dead(Node, 0) ->
{error, stop_timeout, Node};
-wait_for_node_dead(Node, N)->
+wait_for_node_dead(Node, N) ->
timer:sleep(1000),
case lists:member(Node, nodes()) of
true->
diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl
index 87e2c3049a..e0e1f93db2 100644
--- a/lib/common_test/test/ct_master_SUITE.erl
+++ b/lib/common_test/test/ct_master_SUITE.erl
@@ -101,7 +101,7 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)->
NS = lists:map(fun(NodeName)->
{init, NodeName, [
- {node_start, [{startup_functions, []}, {monitor_master, false}]},
+ {node_start, [{startup_functions, []}, {monitor_master, true}]},
{eval, {erlang, nodes, []}}
]
}