aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common_test/doc/src/run_test.xml14
-rw-r--r--lib/common_test/doc/src/run_test_chapter.xml3
-rw-r--r--lib/common_test/src/ct.erl3
-rw-r--r--lib/common_test/test/Makefile3
-rw-r--r--lib/common_test/test/ct_config_SUITE.erl4
-rw-r--r--lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl30
-rw-r--r--lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl30
-rw-r--r--lib/common_test/test/ct_master_SUITE.erl191
-rw-r--r--lib/common_test/test/ct_master_SUITE_data/master/config.txt2
-rw-r--r--lib/common_test/test/ct_master_SUITE_data/master/config.xml4
-rw-r--r--lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl57
-rw-r--r--lib/common_test/test/ct_test_support.erl11
12 files changed, 284 insertions, 68 deletions
diff --git a/lib/common_test/doc/src/run_test.xml b/lib/common_test/doc/src/run_test.xml
index d9dd22d411..451d3c5737 100644
--- a/lib/common_test/doc/src/run_test.xml
+++ b/lib/common_test/doc/src/run_test.xml
@@ -4,7 +4,7 @@
<comref>
<header>
<copyright>
- <year>2007</year><year>2009</year>
+ <year>2007</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -27,8 +27,8 @@
<docno></docno>
<approved></approved>
<checked></checked>
- <date>2007-07-04</date>
- <rev>PA1</rev>
+ <date>2010-04-01</date>
+ <rev>PA2</rev>
<file>run_test.xml</file>
</header>
<com>run_test</com>
@@ -61,6 +61,8 @@
[[-group Group1 Group2 .. GroupN] [-case Case1 Case2 .. CaseN]]]
[-step [config | keep_inactive]]
[-config ConfigFile1 ConfigFile2 .. ConfigFileN]
+ [-userconfig CallbackModule1 ConfigString1 and CallbackModule2
+ ConfigString2 and .. and CallbackModuleN ConfigStringN]
[-decrypt_key Key] | [-decrypt_file KeyFile]
[-logdir LogDir]
[-silent_connections [ConnType1 ConnType2 .. ConnTypeN]]
@@ -79,6 +81,8 @@
<pre>
run_test -spec TestSpec1 TestSpec2 .. TestSpecN
[-config ConfigFile1 ConfigFile2 .. ConfigFileN]
+ [-userconfig CallbackModule1 ConfigString1 and CallbackModule2
+ ConfigString2 and .. and CallbackModuleN ConfigStringN]
[-decrypt_key Key] | [-decrypt_file KeyFile]
[-logdir LogDir]
[-allow_user_terms]
@@ -98,6 +102,8 @@
<pre>
run_test -vts [-browser Browser]
[-config ConfigFile1 ConfigFile2 .. ConfigFileN]
+ [-userconfig CallbackModule1 ConfigString1 and CallbackModule2
+ ConfigString2 and .. and CallbackModuleN ConfigStringN]
[-decrypt_key Key] | [-decrypt_file KeyFile]
[-dir TestDir1 TestDir2 .. TestDirN] |
[-suite Suite [[-group Group] [-case Case]]]
@@ -115,6 +121,8 @@
<pre>
run_test -shell
[-config ConfigFile1 ConfigFile2 ... ConfigFileN]
+ [-userconfig CallbackModule1 ConfigString1 and CallbackModule2
+ ConfigString2 and .. and CallbackModuleN ConfigStringN]
[-decrypt_key Key] | [-decrypt_file KeyFile]</pre>
</section>
<section>
diff --git a/lib/common_test/doc/src/run_test_chapter.xml b/lib/common_test/doc/src/run_test_chapter.xml
index b7e9ab88e3..00cf4adf52 100644
--- a/lib/common_test/doc/src/run_test_chapter.xml
+++ b/lib/common_test/doc/src/run_test_chapter.xml
@@ -370,6 +370,9 @@
{config, ConfigFiles}.
{config, NodeRefs, ConfigFiles}.
+
+ {userconfig, {CallbackModule, ConfigStrings}}.
+ {userconfig, NodeRefs, {CallbackModule, ConfigStrings}}.
{alias, DirAlias, Dir}.
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl
index 6cc876b42e..c32075332b 100644
--- a/lib/common_test/src/ct.erl
+++ b/lib/common_test/src/ct.erl
@@ -393,6 +393,9 @@ get_config(Required,Default,Opts) ->
%%% <p>This function performs updating of the configuration data from which the
%%% given configuration variable was read, and returns the (possibly) new
%%% value of this variable.</p>
+%%% <p>Note that if some variables were present in the configuration but are not loaded
+%%% using this function, they will be removed from the configuration table together
+%%% with their aliases.</p>
%%%
reload_config(Required)->
ct_config:reload_config(Required).
diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile
index 2b0a06871e..eca6817682 100644
--- a/lib/common_test/test/Makefile
+++ b/lib/common_test/test/Makefile
@@ -34,7 +34,8 @@ MODULES= \
ct_skip_SUITE \
ct_error_SUITE \
ct_test_server_if_1_SUITE \
- ct_config_SUITE
+ ct_config_SUITE \
+ ct_master_SUITE
ERL_FILES= $(MODULES:%=%.erl)
diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl
index 168225feff..7c0c88e76b 100644
--- a/lib/common_test/test/ct_config_SUITE.erl
+++ b/lib/common_test/test/ct_config_SUITE.erl
@@ -69,13 +69,9 @@ all(suite) ->
testspec_dynamic
].
-
%%--------------------------------------------------------------------
%% TEST CASES
%%--------------------------------------------------------------------
-
-%%%-----------------------------------------------------------------
-%%%
require(Config) when is_list(Config) ->
DataDir = ?config(data_dir, Config),
run_test(config_static_SUITE,
diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
index ae66d4e9bf..b7b2e8f16c 100644
--- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
+++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
@@ -18,7 +18,7 @@
%%
%%%-------------------------------------------------------------------
-%%% File: ct_config_SUITE
+%%% File: config_dynamic_SUITE
%%%
%%% Description:
%%% Test suite for common_test which tests the userconfig functionality
@@ -46,33 +46,7 @@ suite() ->
{timetrap, {seconds,10}}
].
-% to get it running on development branch (without userconfig features)
-% function to print full config is in the ct_util, for me it's moved to ct_config
-% two following functions are only for the design period
-% after merging of userconfigs to the main branch ct_config:get_all_config/0
-% should be called instead
-is_exported(Module, Function, Arity)->
- Exports = Module:module_info(exports),
- case lists:keyfind(Function, 1, Exports) of
- false->
- false;
- {Function, Arity}->
- true;
- {Function, _OtherArity}->
- false
- end.
-
-get_all_config()->
- case is_exported(ct_util, get_all_config, 0) of
- true->
- {ct_util, ct_util:get_all_config()};
- false->
- {ct_config, ct_config:get_all_config()}
- end.
-
init_per_suite(Config) ->
- %{Module, Cfg} = get_all_config(),
- %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]),
Config.
end_per_suite(_) ->
@@ -83,8 +57,6 @@ all() -> [test_get_known_variable, test_localtime_update,
test_disappearable_variable_alias].
init_per_testcase(_, Config) ->
- %{Module, Cfg} = get_all_config(),
- %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]),
Config.
end_per_testcase(_, _) ->
diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl
index d3f07980bc..262417fe1c 100644
--- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl
+++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl
@@ -18,7 +18,7 @@
%%
%%%-------------------------------------------------------------------
-%%% File: config_1_SUITE
+%%% File: config_static_SUITE
%%%
%%% Description:
%%% Test suite for common_test which tests the get_config and require
@@ -49,33 +49,7 @@ suite() ->
{x1, {x,suite}}
].
-% to get it running on development branch (without userconfig features)
-% function to print full config is in the ct_util, for me it's moved to ct_config
-% two following functions are only for the design period
-% after merging of userconfigs to the main branch ct_config:get_all_config/0
-% should be called instead
-is_exported(Module, Function, Arity)->
- Exports = Module:module_info(exports),
- case lists:keyfind(Function, 1, Exports) of
- false->
- false;
- {Function, Arity}->
- true;
- {Function, _OtherArity}->
- false
- end.
-
-get_all_config()->
- case is_exported(ct_util, get_all_config, 0) of
- true->
- {ct_util, ct_util:get_all_config()};
- false->
- {ct_config, ct_config:get_all_config()}
- end.
-
init_per_suite(Config) ->
- %{Module, Cfg} = get_all_config(),
- %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]),
Config.
end_per_suite(_) ->
@@ -87,8 +61,6 @@ all() -> [test_get_config_simple, test_get_config_nested, test_default_suitewide
test_get_config_undefined].
init_per_testcase(_, Config) ->
- %{Module, Cfg} = get_all_config(),
- %ct:pal("CONFIG (handled by ~p):~n~p", [Module, Cfg]),
Config.
end_per_testcase(_, _) ->
diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl
new file mode 100644
index 0000000000..a2eaf98e34
--- /dev/null
+++ b/lib/common_test/test/ct_master_SUITE.erl
@@ -0,0 +1,191 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2009-2010. 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
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%%-------------------------------------------------------------------
+%%% File: ct_master_SUITE
+%%%
+%%% Description:
+%%% Test ct_master.
+%%%
+%%% The suites used for the test are located in the data directory.
+%%%-------------------------------------------------------------------
+-module(ct_master_SUITE).
+-compile(export_all).
+
+-include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct_event.hrl").
+
+-define(eh, ct_test_support_eh).
+
+%%--------------------------------------------------------------------
+%% TEST SERVER CALLBACK FUNCTIONS
+%%--------------------------------------------------------------------
+
+%%--------------------------------------------------------------------
+%% Description: Since Common Test starts another Test Server
+%% instance, the tests need to be performed on a separate node (or
+%% there will be clashes with logging processes etc).
+%%--------------------------------------------------------------------
+init_per_suite(Config) ->
+ Config1 = ct_test_support:init_per_suite(Config),
+ Config1.
+
+end_per_suite(Config) ->
+ ct_test_support:end_per_suite(Config).
+
+init_per_testcase(TestCase, Config) ->
+ ct_test_support:init_per_testcase(TestCase, [{master, true}|Config]).
+
+end_per_testcase(TestCase, Config) ->
+ ct_test_support:end_per_testcase(TestCase, Config).
+
+all(doc) ->
+ [""];
+
+all(suite) ->
+ [
+ ct_master_test_peer,
+ ct_master_test_slave
+ ].
+
+%%--------------------------------------------------------------------
+%% TEST CASES
+%%--------------------------------------------------------------------
+ct_master_test_peer(Config) when is_list(Config)->
+ NodeCount = 5,
+ DataDir = ?config(data_dir, Config),
+ NodeNames = [list_to_atom("testnode_"++integer_to_list(N)) ||
+ N <- lists:seq(1, NodeCount)],
+ FileName = filename:join(DataDir, "ct_master_spec.spec"),
+ Suites = [master_SUITE],
+ make_spec(DataDir, FileName, NodeNames, Suites, Config),
+ start_nodes(NodeNames, peer),
+ run_test(ct_master_test, FileName, Config),
+ stop_nodes(NodeNames, peer),
+ file:delete(filename:join(DataDir, FileName)).
+
+ct_master_test_slave(Config) when is_list(Config)->
+ NodeCount = 5,
+ DataDir = ?config(data_dir, Config),
+ NodeNames = [list_to_atom("testnode_"++integer_to_list(N)) ||
+ N <- lists:seq(1, NodeCount)],
+ FileName = filename:join(DataDir, "ct_master_spec.spec"),
+ Suites = [master_SUITE],
+ make_spec(DataDir, FileName, NodeNames, Suites, Config),
+ start_nodes(NodeNames, slave),
+ run_test(ct_master_test, FileName, Config),
+ stop_nodes(NodeNames, slave),
+ file:delete(filename:join(DataDir, FileName)).
+
+%%%-----------------------------------------------------------------
+%%% HELP FUNCTIONS
+%%%-----------------------------------------------------------------
+make_spec(DataDir, FileName, NodeNames, Suites, Config)->
+ {ok, HostName} = inet:gethostname(),
+
+ N = lists:map(fun(NodeName)->
+ {node, NodeName, enodename(HostName, NodeName)}
+ end,
+ NodeNames),
+
+ C = lists:map(fun(NodeName)->
+ Rnd = random:uniform(2),
+ if Rnd == 1->
+ {config, NodeName, "master/config.txt"};
+ true->
+ {userconfig, NodeName, {ct_config_xml, "master/config.xml"}}
+ end
+ end,
+ NodeNames),
+
+ S = [{suites, NodeNames, filename:join(DataDir, "master"), Suites}],
+
+ PrivDir = ?config(priv_dir, Config),
+ LD = [{logdir, PrivDir}, {logdir, master, PrivDir}],
+
+ ct_test_support:write_testspec(N++C++S++LD, DataDir, FileName).
+
+run_test(_Name, FileName, Config)->
+ [{FileName, ok}] = ct_test_support:run(ct_master, run, [FileName], Config).
+
+wait_for_node_alive(_Node, 0)->
+ pang;
+wait_for_node_alive(Node, N)->
+ timer:sleep(1000),
+ case net_adm:ping(Node) of
+ pong->
+ pong;
+ pang->
+ wait_for_node_alive(Node, N-1)
+ end.
+
+wait_for_node_dead(_Node, 0)->
+ error;
+wait_for_node_dead(Node, N)->
+ timer:sleep(1000),
+ case lists:member(Node, nodes()) of
+ true->
+ wait_for_node_dead(Node, N-1);
+ false->
+ ok
+ end.
+
+enodename(HostName, NodeName)->
+ list_to_atom(atom_to_list(NodeName)++"@"++HostName).
+
+start_node(HostName, NodeName, peer)->
+ ENodeName = enodename(HostName, NodeName),
+ Cmd = "erl -detached -noinput -sname "++atom_to_list(NodeName),
+ open_port({spawn, Cmd}, [stream]),
+ pong = wait_for_node_alive(ENodeName, 3);
+start_node(HostName, NodeName, slave)->
+ ENodeName = enodename(HostName, NodeName),
+ {ok, ENodeName} =
+ slave:start(list_to_atom(HostName), NodeName).
+
+stop_node(HostName, NodeName, peer)->
+ ENodeName = enodename(HostName, NodeName),
+ spawn(ENodeName, init, stop, []),
+ wait_for_node_dead(ENodeName, 3);
+stop_node(HostName, NodeName, slave)->
+ ENodeName = enodename(HostName, NodeName),
+ ok = slave:stop(ENodeName).
+
+start_nodes(NodeNames, Type)->
+ {ok, HostName} = inet:gethostname(),
+ lists:foreach(fun(NodeName)->
+ start_node(HostName, NodeName, Type)
+ end,
+ NodeNames).
+
+stop_nodes(NodeNames, Type)->
+ {ok, HostName} = inet:gethostname(),
+ lists:foreach(fun(NodeName)->
+ stop_node(HostName, NodeName, Type)
+ end,
+ NodeNames).
+
+reformat_events(Events, EH) ->
+ ct_test_support:reformat(Events, EH).
+
+%%%-----------------------------------------------------------------
+%%% TEST EVENTS
+%%%-----------------------------------------------------------------
+expected_events(_)->
+[].
diff --git a/lib/common_test/test/ct_master_SUITE_data/master/config.txt b/lib/common_test/test/ct_master_SUITE_data/master/config.txt
new file mode 100644
index 0000000000..3baf9e392c
--- /dev/null
+++ b/lib/common_test/test/ct_master_SUITE_data/master/config.txt
@@ -0,0 +1,2 @@
+{a, b}.
+{c, d}.
diff --git a/lib/common_test/test/ct_master_SUITE_data/master/config.xml b/lib/common_test/test/ct_master_SUITE_data/master/config.xml
new file mode 100644
index 0000000000..c031f45f35
--- /dev/null
+++ b/lib/common_test/test/ct_master_SUITE_data/master/config.xml
@@ -0,0 +1,4 @@
+<config>
+ <a>b</a>
+ <c>d</c>
+</config>
diff --git a/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl b/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl
new file mode 100644
index 0000000000..1d05d1ac9a
--- /dev/null
+++ b/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl
@@ -0,0 +1,57 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2009-2010. 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
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%%-------------------------------------------------------------------
+%%% File: master_SUITE
+%%%
+%%% Description:
+%%% Test suite for common_test which tests the ct_master functionality
+%%%-------------------------------------------------------------------
+-module(master_SUITE).
+
+-compile(export_all).
+
+-include_lib("common_test/include/ct.hrl").
+
+suite() ->
+ [].
+
+init_per_suite(Config) ->
+ Config.
+
+end_per_suite(_) ->
+ ok.
+
+all() -> [first_testcase, second_testcase, third_testcase].
+
+init_per_testcase(_, Config) ->
+ Config.
+
+end_per_testcase(_, _) ->
+ ok.
+
+first_testcase(_)->
+ b = ct:get_config(a).
+
+second_testcase(_)->
+ d = ct:get_config(c).
+
+third_testcase(_)->
+ A = 4,
+ A = 2*2.
diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl
index 4aa750c37f..0ce103e111 100644
--- a/lib/common_test/test/ct_test_support.erl
+++ b/lib/common_test/test/ct_test_support.erl
@@ -102,9 +102,16 @@ end_per_suite(Config) ->
init_per_testcase(_TestCase, Config) ->
{_,{_,LogDir}} = lists:keysearch(logdir, 1, get_opts(Config)),
- test_server:format("See Common Test logs here:\n"
+ case lists:keysearch(master, 1, Config) of
+ false->
+ test_server:format("See Common Test logs here:\n"
"<a href=\"file://~s/all_runs.html\">~s/all_runs.html</a>",
- [LogDir,LogDir]),
+ [LogDir,LogDir]);
+ {value, _}->
+ test_server:format("See CT Master Test logs here:\n"
+ "<a href=\"file://~s/master_runs.html\">~s/master_runs.html</a>",
+ [LogDir,LogDir])
+ end,
Config.
%%%-----------------------------------------------------------------