From a60680bb3a066df123b96cee12660057a989fab3 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 7 Mar 2013 09:23:19 +0100 Subject: Add ct_slave:start(Node, Opts) to start a node on the local host This is convenient when starting nodes locally since there's otherwise no trivial way to specify the local hostname. --- lib/common_test/src/ct_slave.erl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_slave.erl b/lib/common_test/src/ct_slave.erl index 1fd8c04f8b..bcb27f66b5 100644 --- a/lib/common_test/src/ct_slave.erl +++ b/lib/common_test/src/ct_slave.erl @@ -1,7 +1,7 @@ %%-------------------------------------------------------------------- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2012. All Rights Reserved. +%% Copyright Ericsson AB 2010-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -56,9 +56,9 @@ start(Node) -> start(gethostname(), Node). %%%----------------------------------------------------------------- -%%% @spec start(Host, Node) -> Result -%%% Node = atom() -%%% Host = atom() +%%% @spec start(HostOrNode, NodeOrOpts) -> Result +%%% HostOrNode = atom() +%%% NodeOrOpts = atom() | list() %%% Result = {ok, NodeName} | %%% {error, already_started, NodeName} | %%% {error, started_not_connected, NodeName} | @@ -67,9 +67,16 @@ start(Node) -> %%% {error, startup_timeout, NodeName} | %%% {error, not_alive, NodeName} %%% NodeName = atom() -%%% @doc Starts an Erlang node with name Node on host -%%% Host with the default options. +%%% @doc Starts an Erlang node with default options on a specified +%%% host, or on the local host with specified options. That is, +%%% the call is interpreted as start(Host, Node) when the +%%% second argument is atom-valued and start(Node, Opts) +%%% when it's list-valued. %%% @see start/3 +start(_HostOrNode = Node, _NodeOrOpts = Opts) %% match to satiate edoc + when is_list(Opts) -> + start(gethostname(), Node, Opts); + start(Host, Node) -> start(Host, Node, []). -- cgit v1.2.3 From 0dde6af789f55458604da0337f265edf1eea764d Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 7 Mar 2013 09:34:25 +0100 Subject: Minor edoc fix edoc inserted a type spec into the signature ("Options :: Opts") when @spec and code used different variable names. --- lib/common_test/src/ct_slave.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_slave.erl b/lib/common_test/src/ct_slave.erl index bcb27f66b5..6a14ba31ad 100644 --- a/lib/common_test/src/ct_slave.erl +++ b/lib/common_test/src/ct_slave.erl @@ -176,7 +176,7 @@ start(Host, Node) -> %%% NodeName is the name of current node in this case. %%%

%%% -start(Host, Node, Options) -> +start(Host, Node, Opts) -> ENode = enodename(Host, Node), case erlang:is_alive() of false-> @@ -184,7 +184,7 @@ start(Host, Node, Options) -> true-> case is_started(ENode) of false-> - OptionsRec = fetch_options(Options), + OptionsRec = fetch_options(Opts), do_start(Host, Node, OptionsRec); {true, not_connected}-> {error, started_not_connected, ENode}; -- cgit v1.2.3 From 19b2a8501d2da5d246880fa2d73cf74593cfe1d5 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Mon, 11 Mar 2013 09:36:35 +0100 Subject: Simplify doc of error return As {error, Reason, NodeName} together with a Reason production. --- lib/common_test/src/ct_slave.erl | 55 ++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_slave.erl b/lib/common_test/src/ct_slave.erl index 6a14ba31ad..872c39de04 100644 --- a/lib/common_test/src/ct_slave.erl +++ b/lib/common_test/src/ct_slave.erl @@ -43,12 +43,13 @@ %%% @spec start(Node) -> Result %%% Node = atom() %%% Result = {ok, NodeName} | -%%% {error, already_started, NodeName} | -%%% {error, started_not_connected, NodeName} | -%%% {error, boot_timeout, NodeName} | -%%% {error, init_timeout, NodeName} | -%%% {error, startup_timeout, NodeName} | -%%% {error, not_alive, NodeName} +%%% {error, Reason, NodeName} +%%% Reason = already_started | +%%% started_not_connected | +%%% boot_timeout | +%%% init_timeout | +%%% startup_timeout | +%%% not_alive %%% NodeName = atom() %%% @doc Starts an Erlang node with name Node on the local host. %%% @see start/3 @@ -60,12 +61,13 @@ start(Node) -> %%% HostOrNode = atom() %%% NodeOrOpts = atom() | list() %%% Result = {ok, NodeName} | -%%% {error, already_started, NodeName} | -%%% {error, started_not_connected, NodeName} | -%%% {error, boot_timeout, NodeName} | -%%% {error, init_timeout, NodeName} | -%%% {error, startup_timeout, NodeName} | -%%% {error, not_alive, NodeName} +%%% {error, Reason, NodeName} +%%% Reason = already_started | +%%% started_not_connected | +%%% boot_timeout | +%%% init_timeout | +%%% startup_timeout | +%%% not_alive %%% NodeName = atom() %%% @doc Starts an Erlang node with default options on a specified %%% host, or on the local host with specified options. That is, @@ -109,12 +111,14 @@ start(Host, Node) -> %%% ErlangFlags = string() %%% EnvVar = string() %%% Value = string() -%%% Result = {ok, NodeName} | {error, already_started, NodeName} | -%%% {error, started_not_connected, NodeName} | -%%% {error, boot_timeout, NodeName} | -%%% {error, init_timeout, NodeName} | -%%% {error, startup_timeout, NodeName} | -%%% {error, not_alive, NodeName} +%%% Result = {ok, NodeName} | +%%% {error, Reason, NodeName} +%%% Reason = already_started | +%%% started_not_connected | +%%% boot_timeout | +%%% init_timeout | +%%% startup_timeout | +%%% not_alive %%% NodeName = atom() %%% @doc Starts an Erlang node with name Node on host %%% Host as specified by the combination of options in @@ -196,9 +200,11 @@ start(Host, Node, Opts) -> %%% @spec stop(Node) -> Result %%% Node = atom() %%% Result = {ok, NodeName} | -%%% {error, not_started, NodeName} | -%%% {error, not_connected, NodeName} | -%%% {error, stop_timeout, NodeName} +%%% {error, Reason, NodeName} +%%% Reason = not_started | +%%% not_connected | +%%% stop_timeout + %%% NodeName = atom() %%% @doc Stops the running Erlang node with name Node on %%% the localhost. @@ -209,9 +215,10 @@ stop(Node) -> %%% Host = atom() %%% Node = atom() %%% Result = {ok, NodeName} | -%%% {error, not_started, NodeName} | -%%% {error, not_connected, NodeName} | -%%% {error, stop_timeout, NodeName} +%%% {error, Reason, NodeName} +%%% Reason = not_started | +%%% not_connected | +%%% stop_timeout %%% NodeName = atom() %%% @doc Stops the running Erlang node with name Node on %%% host Host. -- cgit v1.2.3