aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test/test')
-rw-r--r--lib/common_test/test/Makefile12
-rw-r--r--lib/common_test/test/common_test.cover7
-rw-r--r--lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl2
-rw-r--r--lib/common_test/test/ct_hooks_SUITE.erl2
-rw-r--r--lib/common_test/test/ct_master_SUITE.erl2
-rw-r--r--lib/common_test/test/ct_misc_1_SUITE.erl1
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl194
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/ns.erl23
-rw-r--r--lib/common_test/test/ct_test_support.erl8
-rw-r--r--lib/common_test/test/ct_test_support_eh.erl2
-rw-r--r--lib/common_test/test/erl2html2_SUITE.erl277
-rw-r--r--lib/common_test/test/erl2html2_SUITE_data/Makefile.src2
-rw-r--r--lib/common_test/test/erl2html2_SUITE_data/header1.hrl4
-rw-r--r--lib/common_test/test/erl2html2_SUITE_data/include/header2.hrl0
-rw-r--r--lib/common_test/test/erl2html2_SUITE_data/include/header3.hrl1
-rw-r--r--lib/common_test/test/erl2html2_SUITE_data/m1.erl52
-rw-r--r--lib/common_test/test/test_server_SUITE.erl449
-rw-r--r--lib/common_test/test/test_server_SUITE_data/Makefile.src11
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_SUITE.erl514
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_SUITE_data/dummy_file1
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_break_SUITE.erl149
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_conf01_SUITE.erl188
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_conf02_SUITE.erl295
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_cover_SUITE.erl59
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_cover_SUITE_data/cover_helper.erl4
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_parallel01_SUITE.erl519
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_shuffle01_SUITE.erl477
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_skip_SUITE.erl43
-rw-r--r--lib/common_test/test/test_server_SUITE_data/test_server_unicode_SUITE.erl82
-rw-r--r--lib/common_test/test/test_server_test_lib.erl217
-rw-r--r--lib/common_test/test/test_server_test_lib.hrl23
31 files changed, 3586 insertions, 34 deletions
diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile
index ff4495b104..aa99fe1af1 100644
--- a/lib/common_test/test/Makefile
+++ b/lib/common_test/test/Makefile
@@ -65,9 +65,13 @@ MODULES= \
ct_cover_nomerge_SUITE \
ct_groups_search_SUITE \
ct_surefire_SUITE \
- ct_telnet_SUITE
+ ct_telnet_SUITE \
+ erl2html2_SUITE \
+ test_server_SUITE \
+ test_server_test_lib
ERL_FILES= $(MODULES:%=%.erl)
+HRL_FILES= test_server_test_lib.hrl
TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR))
INSTALL_PROGS= $(TARGET_FILES)
@@ -84,8 +88,8 @@ RELSYSDIR = $(RELEASE_PATH)/common_test_test
# FLAGS
# ----------------------------------------------------
-ERL_MAKE_FLAGS += -pa $(ERL_TOP)/lib/test_server/ebin
-ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/test_server/include
+ERL_MAKE_FLAGS +=
+ERL_COMPILE_FLAGS +=
EBIN = .
@@ -118,7 +122,7 @@ release_spec: opt
release_tests_spec:
$(INSTALL_DIR) "$(RELSYSDIR)"
- $(INSTALL_DATA) $(ERL_FILES) $(COVERFILE) "$(RELSYSDIR)"
+ $(INSTALL_DATA) $(ERL_FILES) $(HRL_FILES) $(COVERFILE) "$(RELSYSDIR)"
$(INSTALL_DATA) common_test.spec common_test.cover "$(RELSYSDIR)"
chmod -R u+w "$(RELSYSDIR)"
@tar cf - *_SUITE_data | (cd "$(RELSYSDIR)"; tar xf -)
diff --git a/lib/common_test/test/common_test.cover b/lib/common_test/test/common_test.cover
index 87d00c420f..e8e01a9312 100644
--- a/lib/common_test/test/common_test.cover
+++ b/lib/common_test/test/common_test.cover
@@ -1,9 +1,2 @@
%% -*- erlang -*-
{incl_app,common_test,details}.
-{cross,common_test,[{test_server,[erl2html2,
- test_server,
- test_server_ctrl,
- test_server_gl,
- test_server_io,
- test_server_node,
- test_server_sup]}]}.
diff --git a/lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl b/lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl
index 28c85ee2db..29c25bf151 100644
--- a/lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl
+++ b/lib/common_test/test/ct_event_handler_SUITE_data/eh_A.erl
@@ -27,7 +27,7 @@
-behaviour(gen_event).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
-include_lib("common_test/include/ct_event.hrl").
%% gen_event callbacks
diff --git a/lib/common_test/test/ct_hooks_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE.erl
index f00b2bbb43..06bc0c07f4 100644
--- a/lib/common_test/test/ct_hooks_SUITE.erl
+++ b/lib/common_test/test/ct_hooks_SUITE.erl
@@ -30,7 +30,7 @@
-compile(export_all).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
-include_lib("common_test/include/ct_event.hrl").
-define(eh, ct_test_support_eh).
diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl
index 15b49c67c0..55837352e2 100644
--- a/lib/common_test/test/ct_master_SUITE.erl
+++ b/lib/common_test/test/ct_master_SUITE.erl
@@ -135,7 +135,7 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config) ->
C = lists:map(
fun(NodeName) ->
- Rnd = random:uniform(2),
+ Rnd = rand:uniform(2),
if Rnd == 1->
{config,NodeName,filename:join(DataDir,
"master/config.txt")};
diff --git a/lib/common_test/test/ct_misc_1_SUITE.erl b/lib/common_test/test/ct_misc_1_SUITE.erl
index 1db8bcc794..a562719296 100644
--- a/lib/common_test/test/ct_misc_1_SUITE.erl
+++ b/lib/common_test/test/ct_misc_1_SUITE.erl
@@ -31,7 +31,6 @@
-compile(export_all).
-include_lib("common_test/include/ct.hrl").
--include_lib("test_server/include/test_server_line.hrl").
-include_lib("common_test/include/ct_event.hrl").
-define(eh, ct_test_support_eh).
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
index ea49e36608..49b02d2bba 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
@@ -99,7 +99,10 @@ all() ->
connection_crash,
get_event_streams,
create_subscription,
- receive_event
+ receive_one_event,
+ receive_multiple_events,
+ receive_event_and_rpc,
+ receive_event_and_rpc_in_chunks
]
end.
@@ -354,7 +357,7 @@ get(Config) ->
get_a_lot(Config) ->
DataDir = ?config(data_dir,Config),
{ok,Client} = open_success(DataDir),
- Descr = lists:append(lists:duplicate(100,"Description of myserver! ")),
+ Descr = lists:append(lists:duplicate(1000,"Description of myserver! ")),
Server = {server,[{xmlns,"myns"}],[{name,[],["myserver"]},
{description,[],[Descr]}]},
Data = lists:duplicate(100,Server),
@@ -964,16 +967,16 @@ create_subscription(Config) ->
ok.
-receive_event(Config) ->
+receive_one_event(Config) ->
DataDir = ?config(data_dir,Config),
{ok,Client} = open_success(DataDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
- ?NS:hupp(send_event),
+ ?NS:hupp({send_events,1}),
receive
- %% Matching ?NS:make_msg(event)
+ %% Matching ?NS:make_msg({event,_})
{notification,?NETCONF_NOTIF_NAMESPACE_ATTR,
[{eventTime,[],[_Time]},
{event,[{xmlns,"http://my.namespaces.com/event"}],
@@ -991,6 +994,187 @@ receive_event(Config) ->
ok.
+receive_multiple_events(Config) ->
+ DataDir = ?config(data_dir,Config),
+ {ok,Client} = open_success(DataDir),
+ ?NS:expect_reply({'create-subscription',[stream]},ok),
+ ?ok = ct_netconfc:create_subscription(Client),
+
+ ?NS:hupp({send_events,3}),
+
+ receive
+ %% Matching ?NS:make_msg({event,_})
+ {notification,_,_} ->
+ ok;
+ Other1 ->
+ ct:fail({got_unexpected_while_waiting_for_event, Other1})
+ after 3000 ->
+ ct:fail(timeout_waiting_for_event)
+ end,
+ receive
+ %% Matching ?NS:make_msg({event,_})
+ {notification,_,_} ->
+ ok;
+ Other2 ->
+ ct:fail({got_unexpected_while_waiting_for_event, Other2})
+ after 3000 ->
+ ct:fail(timeout_waiting_for_event)
+ end,
+ receive
+ %% Matching ?NS:make_msg({event,_})
+ {notification,_,_} ->
+ ok;
+ Other3 ->
+ ct:fail({got_unexpected_while_waiting_for_event, Other3})
+ after 3000 ->
+ ct:fail(timeout_waiting_for_event)
+ end,
+
+ ?NS:expect_do_reply('close-session',close,ok),
+ ?ok = ct_netconfc:close_session(Client),
+
+ ok.
+
+receive_event_and_rpc(Config) ->
+ DataDir = ?config(data_dir,Config),
+ {ok,Client} = open_success(DataDir),
+
+ ?NS:expect_reply({'create-subscription',[stream]},ok),
+ ?ok = ct_netconfc:create_subscription(Client),
+
+ %% Construct the data to return from netconf server - one
+ %% rpc-reply and one notification - to be sent in the same ssh
+ %% package.
+ Data = [{servers,[{xmlns,"myns"}],[{server,[],[{name,[],["myserver"]}]}]}],
+ Rpc = {'rpc-reply',?NETCONF_NAMESPACE_ATTR ++ [{'message-id',"2"}],
+ [{data,Data}]},
+ RpcXml = list_to_binary(xmerl:export_simple_element(Rpc,xmerl_xml)),
+
+ Notification =
+ {notification,?NETCONF_NOTIF_NAMESPACE_ATTR,
+ [{eventTime,["2012-06-14T14:50:54+02:00"]},
+ {event,[{xmlns,"http://my.namespaces.com/event"}],
+ [{severity,["major"]},
+ {description,["Something terrible happened"]}]}]},
+ NotifXml =
+ list_to_binary(xmerl:export_simple_element(Notification,xmerl_xml)),
+
+ ?NS:expect_reply('get',[RpcXml,NotifXml]),
+ {ok,Data} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]}),
+
+ receive
+ {notification,_,_} ->
+ ok;
+ Other1 ->
+ ct:fail({got_unexpected_while_waiting_for_event, Other1})
+ after 3000 ->
+ ct:fail(timeout_waiting_for_event)
+ end,
+
+
+ %% Then do the same again, but now send notification first then
+ %% the rpc-reply.
+ Rpc2 = {'rpc-reply',?NETCONF_NAMESPACE_ATTR ++ [{'message-id',"3"}],
+ [{data,Data}]},
+ RpcXml2 = list_to_binary(xmerl:export_simple_element(Rpc2,xmerl_xml)),
+ ?NS:expect_reply('get',[NotifXml,RpcXml2]),
+ {ok,Data} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]}),
+
+ receive
+ {notification,_,_} ->
+ ok;
+ Other2 ->
+ ct:fail({got_unexpected_while_waiting_for_event, Other2})
+ after 3000 ->
+ ct:fail(timeout_waiting_for_event)
+ end,
+
+ ?NS:expect_do_reply('close-session',close,ok),
+ ?ok = ct_netconfc:close_session(Client),
+
+ ok.
+
+
+receive_event_and_rpc_in_chunks(Config) ->
+ DataDir = ?config(data_dir,Config),
+ {ok,Client} = open_success(DataDir),
+
+ ?NS:expect_reply({'create-subscription',[stream]},ok),
+ ?ok = ct_netconfc:create_subscription(Client),
+
+ %% Construct the data to return from netconf server
+ Data = [{servers,[{xmlns,"myns"}],
+ [{server,[],[{name,[],["server0"]}]},
+ {server,[],[{name,[],["server1"]}]},
+ {server,[],[{name,[],["server2"]}]},
+ {server,[],[{name,[],["server3"]}]},
+ {server,[],[{name,[],["server4"]}]},
+ {server,[],[{name,[],["server5"]}]},
+ {server,[],[{name,[],["server6"]}]},
+ {server,[],[{name,[],["server7"]}]},
+ {server,[],[{name,[],["server8"]}]},
+ {server,[],[{name,[],["server9"]}]}]
+ }],
+ Rpc = {'rpc-reply',?NETCONF_NAMESPACE_ATTR ++ [{'message-id',"2"}],
+ [{data,Data}]},
+ RpcXml = list_to_binary(xmerl:export_simple_element(Rpc,xmerl_xml)),
+
+ Notification =
+ {notification,?NETCONF_NOTIF_NAMESPACE_ATTR,
+ [{eventTime,["2012-06-14T14:50:54+02:00"]},
+ {event,[{xmlns,"http://my.namespaces.com/event"}],
+ [{severity,["major"]},
+ {description,["Something terrible happened"]}]}]},
+ NotifXml =
+ list_to_binary(xmerl:export_simple_element(Notification,xmerl_xml)),
+
+
+ %% First part contains a notif, but only parts of the end tag
+ Part1 =
+ <<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
+ NotifXml/binary,"\n]]">>,
+
+ %% Second part contains rest of end tag, full rpc-reply and full
+ %% notif except end tag
+ Part2 =
+ <<">]]>\n",RpcXml/binary,"\n",?END_TAG/binary,NotifXml/binary>>,
+
+ %% Third part contains last end tag
+ Part3 = <<"\n",?END_TAG/binary,"\n">>,
+
+ %% Spawn a process which will wait a bit for the client to send
+ %% the request (below), then order the server to the chunks of the
+ %% rpc-reply one by one.
+ spawn(fun() -> ct:sleep(500),?NS:hupp(send,Part1),
+ ct:sleep(100),?NS:hupp(send,Part2),
+ ct:sleep(100),?NS:hupp(send,Part3)
+ end),
+
+ %% Order server to expect a get - then the process above will make
+ %% sure the rpc-reply is sent.
+ ?NS:expect('get'),
+ {ok,Data} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]}),
+
+ receive
+ {notification,_,_} ->
+ ok;
+ Other1 ->
+ ct:fail({got_unexpected_while_waiting_for_event, Other1})
+ after 3000 ->
+ ct:fail(timeout_waiting_for_event)
+ end,
+ receive
+ {notification,_,_} ->
+ ok;
+ Other2 ->
+ ct:fail({got_unexpected_while_waiting_for_event, Other2})
+ after 3000 ->
+ ct:fail(timeout_waiting_for_event)
+ end,
+ ?NS:expect_do_reply('close-session',close,ok),
+ ?ok = ct_netconfc:close_session(Client),
+ ok.
+
%%%-----------------------------------------------------------------
break(_Config) ->
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl b/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl
index 07893faabc..67827a053f 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl
@@ -144,8 +144,8 @@ expect_do_reply(SessionId,Expect,Do,Reply) ->
%% Hupp the server - i.e. tell it to do something -
%% e.g. hupp(send_event) will cause send_event(State) to be called on
%% the session channel process.
-hupp(send_event) ->
- hupp(send,[make_msg(event)]);
+hupp({send_events,N}) ->
+ hupp(send,[make_msg({event,N})]);
hupp(kill) ->
hupp(1,fun hupp_kill/1,[]).
@@ -446,9 +446,12 @@ reply(ConnRef,Reply) ->
from_simple(Simple) ->
unicode_c2b(xmerl:export_simple_element(Simple,xmerl_xml)).
-xml(Content) ->
- <<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
- Content/binary,"\n",?END_TAG/binary>>.
+xml(Content) when is_binary(Content) ->
+ xml([Content]);
+xml(Content) when is_list(Content) ->
+ Msgs = [<<Msg/binary,"\n",?END_TAG/binary>> || Msg <- Content],
+ MsgsBin = list_to_binary(Msgs),
+ <<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", MsgsBin/binary>>.
rpc_reply(Content) when is_binary(Content) ->
MsgId = case erase(msg_id) of
@@ -571,15 +574,17 @@ make_msg({ok,Data}) ->
make_msg({data,Data}) ->
xml(rpc_reply(from_simple({data,Data})));
-make_msg(event) ->
- xml(<<"<notification xmlns=\"",?NETCONF_NOTIF_NAMESPACE,"\">"
+make_msg({event,N}) ->
+ Notification = <<"<notification xmlns=\"",?NETCONF_NOTIF_NAMESPACE,"\">"
"<eventTime>2012-06-14T14:50:54+02:00</eventTime>"
"<event xmlns=\"http://my.namespaces.com/event\">"
"<severity>major</severity>"
"<description>Something terrible happened</description>"
"</event>"
- "</notification>">>);
-make_msg(Xml) when is_binary(Xml) ->
+ "</notification>">>,
+ xml(lists:duplicate(N,Notification));
+make_msg(Xml) when is_binary(Xml) orelse
+ (is_list(Xml) andalso is_binary(hd(Xml))) ->
xml(Xml);
make_msg(Simple) when is_tuple(Simple) ->
xml(from_simple(Simple)).
diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl
index 248ec6c4df..4a47d345e9 100644
--- a/lib/common_test/test/ct_test_support.erl
+++ b/lib/common_test/test/ct_test_support.erl
@@ -414,14 +414,14 @@ ct_rpc({M,F,A}, Config) ->
%%%-----------------------------------------------------------------
%%% random_error/1
random_error(Config) when is_list(Config) ->
- random:seed(os:timestamp()),
+ rand:seed(exsplus),
Gen = fun(0,_) -> ok; (N,Fun) -> Fun(N-1, Fun) end,
- Gen(random:uniform(100), Gen),
+ Gen(rand:uniform(100), Gen),
ErrorTypes = ['BADMATCH','BADARG','CASE_CLAUSE','FUNCTION_CLAUSE',
'EXIT','THROW','UNDEF'],
- Type = lists:nth(random:uniform(length(ErrorTypes)), ErrorTypes),
- Where = case random:uniform(2) of
+ Type = lists:nth(rand:uniform(length(ErrorTypes)), ErrorTypes),
+ Where = case rand:uniform(2) of
1 ->
io:format("ct_test_support *returning* error of type ~w",
[Type]),
diff --git a/lib/common_test/test/ct_test_support_eh.erl b/lib/common_test/test/ct_test_support_eh.erl
index 7c3d137901..f3d933da04 100644
--- a/lib/common_test/test/ct_test_support_eh.erl
+++ b/lib/common_test/test/ct_test_support_eh.erl
@@ -27,7 +27,7 @@
-behaviour(gen_event).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
-include_lib("common_test/include/ct_event.hrl").
%% gen_event callbacks
diff --git a/lib/common_test/test/erl2html2_SUITE.erl b/lib/common_test/test/erl2html2_SUITE.erl
new file mode 100644
index 0000000000..9e6389109b
--- /dev/null
+++ b/lib/common_test/test/erl2html2_SUITE.erl
@@ -0,0 +1,277 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2012. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+-module(erl2html2_SUITE).
+
+-compile(export_all).
+
+-include_lib("common_test/include/ct.hrl").
+
+
+-define(HEADER,
+ ["<!DOCTYPE HTML PUBLIC",
+ "\"-//W3C//DTD HTML 3.2 Final//EN\">\n",
+ "<!-- autogenerated by 'erl2html2' -->\n",
+ "<html>\n",
+ "<head><title>Module ", Src, "</title>\n",
+ "<meta http-equiv=\"cache-control\" ",
+ "content=\"no-cache\">\n",
+ "</head>\n",
+ "<body bgcolor=\"white\" text=\"black\" ",
+ "link=\"blue\" vlink=\"purple\" alink=\"red\">\n"]).
+
+%%--------------------------------------------------------------------
+%% @spec suite() -> Info
+%% Info = [tuple()]
+%% @end
+%%--------------------------------------------------------------------
+suite() ->
+ [{timetrap,{seconds,30}},
+ {ct_hooks,[ts_install_cth,test_server_test_lib]}].
+
+%%--------------------------------------------------------------------
+%% @spec init_per_suite(Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+%% Config0 = Config1 = [tuple()]
+%% Reason = term()
+%% @end
+%%--------------------------------------------------------------------
+init_per_suite(Config) ->
+ Config.
+
+%%--------------------------------------------------------------------
+%% @spec end_per_suite(Config0) -> void() | {save_config,Config1}
+%% Config0 = Config1 = [tuple()]
+%% @end
+%%--------------------------------------------------------------------
+end_per_suite(_Config) ->
+ ok.
+
+%%--------------------------------------------------------------------
+%% @spec init_per_group(GroupName, Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+%% GroupName = atom()
+%% Config0 = Config1 = [tuple()]
+%% Reason = term()
+%% @end
+%%--------------------------------------------------------------------
+init_per_group(_GroupName, Config) ->
+ Config.
+
+%%--------------------------------------------------------------------
+%% @spec end_per_group(GroupName, Config0) ->
+%% void() | {save_config,Config1}
+%% GroupName = atom()
+%% Config0 = Config1 = [tuple()]
+%% @end
+%%--------------------------------------------------------------------
+end_per_group(_GroupName, _Config) ->
+ ok.
+
+%%--------------------------------------------------------------------
+%% @spec init_per_testcase(TestCase, Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+%% TestCase = atom()
+%% Config0 = Config1 = [tuple()]
+%% Reason = term()
+%% @end
+%%--------------------------------------------------------------------
+init_per_testcase(_TestCase, Config) ->
+ Config.
+
+%%--------------------------------------------------------------------
+%% @spec end_per_testcase(TestCase, Config0) ->
+%% void() | {save_config,Config1} | {fail,Reason}
+%% TestCase = atom()
+%% Config0 = Config1 = [tuple()]
+%% Reason = term()
+%% @end
+%%--------------------------------------------------------------------
+end_per_testcase(_TestCase, _Config) ->
+ ok.
+
+%%--------------------------------------------------------------------
+%% @spec groups() -> [Group]
+%% Group = {GroupName,Properties,GroupsAndTestCases}
+%% GroupName = atom()
+%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
+%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
+%% TestCase = atom()
+%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}
+%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
+%% repeat_until_any_ok | repeat_until_any_fail
+%% N = integer() | forever
+%% @end
+%%--------------------------------------------------------------------
+groups() ->
+ [].
+
+%%--------------------------------------------------------------------
+%% @spec all() -> GroupsAndTestCases | {skip,Reason}
+%% GroupsAndTestCases = [{group,GroupName} | TestCase]
+%% GroupName = atom()
+%% TestCase = atom()
+%% Reason = term()
+%% @end
+%%--------------------------------------------------------------------
+all() ->
+ [macros_defined, macros_undefined].
+
+%%--------------------------------------------------------------------
+%% @spec TestCase(Config0) ->
+%% ok | exit() | {skip,Reason} | {comment,Comment} |
+%% {save_config,Config1} | {skip_and_save,Reason,Config1}
+%% Config0 = Config1 = [tuple()]
+%% Reason = term()
+%% Comment = term()
+%% @end
+%%--------------------------------------------------------------------
+macros_defined(Config) ->
+ %% let erl2html2 use epp as parser
+ DataDir = ?config(data_dir,Config),
+ InclDir = filename:join(DataDir, "include"),
+ {Src,Dst} = convert_module("m1",[InclDir],Config),
+ {true,L} = check_line_numbers(Src,Dst),
+ ok = check_link_targets(Src,Dst,L,[{baz,0}],[]),
+ ok.
+
+macros_undefined(Config) ->
+ %% let erl2html2 use epp_dodger as parser
+ {Src,Dst} = convert_module("m1",[],Config),
+ {true,L} = check_line_numbers(Src,Dst),
+ ok = check_link_targets(Src,Dst,L,[{baz,0}],[{quux,0}]),
+ ok.
+
+convert_module(Mod,InclDirs,Config) ->
+ DataDir = ?config(data_dir,Config),
+ PrivDir = ?config(priv_dir,Config),
+ Src = filename:join(DataDir,Mod++".erl"),
+ Dst = filename:join(PrivDir,Mod++".erl.html"),
+ io:format("<a href=\"~s\">~s</a>\n",[Src,filename:basename(Src)]),
+ ok = erl2html2:convert(Src, Dst, InclDirs, "<html><body>"),
+ io:format("<a href=\"~s\">~s</a>\n",[Dst,filename:basename(Dst)]),
+ {Src,Dst}.
+
+%% Check that there are the same number of lines in each file, and
+%% that all line numbers are displayed in the dst file.
+check_line_numbers(Src,Dst) ->
+ {ok,SFd} = file:open(Src,[read]),
+ {ok,DFd} = file:open(Dst,[read]),
+ {ok,SN} = count_src_lines(SFd,0),
+ ok = file:close(SFd),
+ {ok,DN} = read_dst_line_numbers(DFd),
+ ok = file:close(DFd),
+ {SN == DN,SN}.
+
+count_src_lines(Fd,N) ->
+ case io:get_line(Fd,"") of
+ eof ->
+ {ok,N};
+ {error,Reason} ->
+ {error,Reason,N};
+ _Line ->
+ count_src_lines(Fd,N+1)
+ end.
+
+read_dst_line_numbers(Fd) ->
+ "<html><body><pre>\n" = io:get_line(Fd,""),
+ read_dst_line_numbers(Fd,0).
+read_dst_line_numbers(Fd,Last) when is_integer(Last) ->
+ case io:get_line(Fd,"") of
+ eof ->
+ {ok,Last};
+ {error,Reason} ->
+ {error,Reason,Last};
+ "</pre>"++_ ->
+ {ok,Last};
+ "</body>"++_ ->
+ {ok,Last};
+ Line ->
+ %% erlang:display(Line),
+ Num = check_line_number(Last,Line,Line),
+ read_dst_line_numbers(Fd,Num)
+ end.
+
+check_line_number(Last,Line,OrigLine) ->
+ case Line of
+ "<a name="++_ ->
+ [$>|Rest] = lists:dropwhile(fun($>) -> false; (_) -> true end,Line),
+ check_line_number(Last,Rest,OrigLine);
+ _ ->
+ [N |_] = string:tokens(Line,":"),
+% erlang:display(N),
+ Num =
+ try list_to_integer(string:strip(N))
+ catch _:_ -> ct:fail({no_line_number_after,Last,OrigLine})
+ end,
+ if Num == Last+1 ->
+ Num;
+ true ->
+ ct:fail({unexpected_integer,Num,Last})
+ end
+ end.
+
+
+%% Check that there is one link target for each line and one for each
+%% function.
+%% The test module has -compile(export_all), so all functions are
+%% found by listing the exported ones.
+check_link_targets(Src,Dst,L,RmFncs,ShouldRemain) ->
+ Mod = list_to_atom(filename:basename(filename:rootname(Src))),
+ Exports = Mod:module_info(exports)--[{module_info,0},{module_info,1}|RmFncs],
+ LastExprFuncs = [Func || {Func,_A} <- Exports],
+ {ok,{FAs,Fs,L},_} =
+ xmerl_sax_parser:file(Dst,
+ [{event_fun,fun sax_event/3},
+ {event_state,{Exports,LastExprFuncs,0}}]),
+ true = (length(FAs) == length(ShouldRemain)),
+ [] = [FA || FA <- FAs, not lists:member(FA,ShouldRemain)],
+ [] = [F || F <- Fs, not lists:keymember(F,1,ShouldRemain)],
+ ok.
+
+sax_event(Event,_Loc,State) ->
+ sax_event(Event,State).
+
+sax_event({startElement,_Uri,"a",_QN,Attrs},{Exports,LastExprFuncs,PrevLine}) ->
+ {_,_,"name",Name} = lists:keyfind("name",3,Attrs),
+ case catch list_to_integer(Name) of
+ Line when is_integer(Line) ->
+ case PrevLine + 1 of
+ Line ->
+ {Exports,LastExprFuncs,Line};
+ Other ->
+ ct:fail({unexpected_line_number_target,Other})
+ end;
+ {'EXIT',_} ->
+ {match,[FStr,EndStr]} =
+ re:run(Name,"^(.*)-(last_expr|[0-9]+)$",
+ [{capture,all_but_first,list}]),
+ F = list_to_atom(http_uri:decode(FStr)),
+ case EndStr of
+ "last_expr" ->
+ true = lists:member(F,LastExprFuncs),
+ {Exports,lists:delete(F,LastExprFuncs),PrevLine};
+ _ ->
+ A = list_to_integer(EndStr),
+ A = proplists:get_value(F,Exports),
+ {lists:delete({F,A},Exports),LastExprFuncs,PrevLine}
+ end
+ end;
+sax_event(_,State) ->
+ State.
diff --git a/lib/common_test/test/erl2html2_SUITE_data/Makefile.src b/lib/common_test/test/erl2html2_SUITE_data/Makefile.src
new file mode 100644
index 0000000000..942ac0584b
--- /dev/null
+++ b/lib/common_test/test/erl2html2_SUITE_data/Makefile.src
@@ -0,0 +1,2 @@
+all:
+ erlc -Iinclude m1.erl \ No newline at end of file
diff --git a/lib/common_test/test/erl2html2_SUITE_data/header1.hrl b/lib/common_test/test/erl2html2_SUITE_data/header1.hrl
new file mode 100644
index 0000000000..53d1b79ac5
--- /dev/null
+++ b/lib/common_test/test/erl2html2_SUITE_data/header1.hrl
@@ -0,0 +1,4 @@
+baz() ->
+ ok.
+
+-define(MACRO_DEFINING_A_FUNCTION,quux() -> ok).
diff --git a/lib/common_test/test/erl2html2_SUITE_data/include/header2.hrl b/lib/common_test/test/erl2html2_SUITE_data/include/header2.hrl
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/lib/common_test/test/erl2html2_SUITE_data/include/header2.hrl
diff --git a/lib/common_test/test/erl2html2_SUITE_data/include/header3.hrl b/lib/common_test/test/erl2html2_SUITE_data/include/header3.hrl
new file mode 100644
index 0000000000..2a20850a3a
--- /dev/null
+++ b/lib/common_test/test/erl2html2_SUITE_data/include/header3.hrl
@@ -0,0 +1 @@
+-define(EPP_SWITCH, on).
diff --git a/lib/common_test/test/erl2html2_SUITE_data/m1.erl b/lib/common_test/test/erl2html2_SUITE_data/m1.erl
new file mode 100644
index 0000000000..1d405963a5
--- /dev/null
+++ b/lib/common_test/test/erl2html2_SUITE_data/m1.erl
@@ -0,0 +1,52 @@
+%% Comment with <html> code &amp; </html>
+%% and also some "quotes" and 'single quotes'
+
+-module(m1).
+
+-compile(export_all).
+
+-include("header1.hrl").
+-include("header2.hrl").
+-include("header3.hrl").
+
+-define(MACRO1,value).
+
+%% This macro is used to select parser in erl2html2.
+%% If EPP_SWITCH is defined epp is used, else epp_dodger.
+epp_switch() ->
+ ?EPP_SWITCH.
+
+%%% Comment
+foo(x) ->
+ %% Comment
+ ok_x;
+foo(y) ->
+ %% Second clause
+ ok_y.
+
+'quoted_foo'() ->
+ ok.
+
+'quoted_foo_with_"_and_/'() ->
+ ok.
+
+'quoted_foo_with_(_and_)'() ->
+ ok.
+
+'quoted_foo_with_<_and_>'() ->
+ ok.
+
+bar() ->
+ do_something(),
+ok. % indentation error, OTP-9710
+
+%% Function inside macro definition
+?MACRO_DEFINING_A_FUNCTION.
+
+%% Two function one one line
+quuux() -> ok. quuuux() -> ok.
+
+%% do_something/0 does something
+do_something() ->
+ ?MACRO1.
+%% comments after last line
diff --git a/lib/common_test/test/test_server_SUITE.erl b/lib/common_test/test/test_server_SUITE.erl
new file mode 100644
index 0000000000..d1c789f34c
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE.erl
@@ -0,0 +1,449 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2010-2013. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%%-------------------------------------------------------------------
+%%% @author Lukas Larsson <[email protected]>
+%%% @copyright (C) 2011, Erlang Solutions Ltd.
+%%% @doc
+%%%
+%%% @end
+%%% Created : 15 Feb 2011 by Lukas Larsson <[email protected]>
+%%%-------------------------------------------------------------------
+-module(test_server_SUITE).
+
+%% Note: This directive should only be used in test suites.
+-compile(export_all).
+
+-include_lib("common_test/include/ct.hrl").
+-include("test_server_test_lib.hrl").
+-include_lib("kernel/include/file.hrl").
+
+%%--------------------------------------------------------------------
+%% COMMON TEST CALLBACK FUNCTIONS
+%%--------------------------------------------------------------------
+
+%% @spec suite() -> Info
+suite() ->
+ [{ct_hooks,[ts_install_cth,test_server_test_lib]}].
+
+
+%% @spec init_per_suite(Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+init_per_suite(Config) ->
+ [{path_dirs,[proplists:get_value(data_dir,Config)]} | Config].
+
+%% @spec end_per_suite(Config) -> _
+end_per_suite(_Config) ->
+ io:format("TEST_SERVER_FRAMEWORK: ~p",[os:getenv("TEST_SERVER_FRAMEWORK")]),
+ ok.
+
+%% @spec init_per_group(GroupName, Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+init_per_group(_GroupName, Config) ->
+ Config.
+
+%% @spec end_per_group(GroupName, Config0) ->
+%% void() | {save_config,Config1}
+end_per_group(_GroupName, _Config) ->
+ ok.
+
+%% @spec init_per_testcase(TestCase, Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+init_per_testcase(_TestCase, Config) ->
+ Config.
+
+%% @spec end_per_testcase(TestCase, Config0) ->
+%% void() | {save_config,Config1} | {fail,Reason}
+end_per_testcase(test_server_unicode, _Config) ->
+ [_,Host] = string:tokens(atom_to_list(node()), "@"),
+ N1 = list_to_atom("test_server_tester_latin1" ++ "@" ++ Host),
+ N2 = list_to_atom("test_server_tester_utf8" ++ "@" ++ Host),
+ test_server:stop_node(N1),
+ test_server:stop_node(N2),
+ ok;
+end_per_testcase(_TestCase, _Config) ->
+ ok.
+
+%% @spec: groups() -> [Group]
+groups() ->
+ [].
+
+%% @spec all() -> GroupsAndTestCases | {skip,Reason}
+all() ->
+ [test_server_SUITE, test_server_parallel01_SUITE,
+ test_server_conf02_SUITE, test_server_conf01_SUITE,
+ test_server_skip_SUITE, test_server_shuffle01_SUITE,
+ test_server_break_SUITE, test_server_cover_SUITE,
+ test_server_unicode].
+
+
+%%--------------------------------------------------------------------
+%% TEST CASES
+%%--------------------------------------------------------------------
+%% @spec TestCase(Config0) ->
+%% ok | exit() | {skip,Reason} | {comment,Comment} |
+%% {save_config,Config1} | {skip_and_save,Reason,Config1}
+test_server_SUITE(Config) ->
+% rpc:call(Node,dbg, tracer,[]),
+% rpc:call(Node,dbg, p,[all,c]),
+% rpc:call(Node,dbg, tpl,[test_server_ctrl,x]),
+ run_test_server_tests("test_server_SUITE",
+ [{test_server_SUITE,skip_case7,"SKIPPED!"}],
+ 40, 1, 32, 21, 9, 1, 11, 2, 27, Config).
+
+test_server_parallel01_SUITE(Config) ->
+ run_test_server_tests("test_server_parallel01_SUITE", [],
+ 37, 0, 19, 19, 0, 0, 0, 0, 37, Config).
+
+test_server_shuffle01_SUITE(Config) ->
+ run_test_server_tests("test_server_shuffle01_SUITE", [],
+ 130, 0, 0, 76, 0, 0, 0, 0, 130, Config).
+
+test_server_skip_SUITE(Config) ->
+ run_test_server_tests("test_server_skip_SUITE", [],
+ 3, 0, 1, 0, 1, 0, 3, 0, 0, Config).
+
+test_server_conf01_SUITE(Config) ->
+ run_test_server_tests("test_server_conf01_SUITE", [],
+ 24, 0, 12, 12, 0, 0, 0, 0, 24, Config).
+
+test_server_conf02_SUITE(Config) ->
+ run_test_server_tests("test_server_conf02_SUITE", [],
+ 26, 0, 12, 12, 0, 0, 0, 0, 26, Config).
+
+test_server_break_SUITE(Config) ->
+ run_test_server_tests("test_server_break_SUITE", [],
+ 8, 2, 6, 4, 0, 0, 0, 2, 6, Config).
+
+test_server_cover_SUITE(Config) ->
+ case test_server:is_cover() of
+ true ->
+ {skip, "Cover already running"};
+ false ->
+ PrivDir = ?config(priv_dir,Config),
+
+ %% Test suite has two test cases
+ %% tc1 calls cover_helper:foo/0
+ %% tc2 calls cover_helper:bar/0
+ %% Each function in cover_helper is one line.
+ %%
+ %% First test run skips tc2, so only cover_helper:foo/0 is executed.
+ %% Cover file specifies to include cover_helper in this test run.
+ CoverFile1 = filename:join(PrivDir,"t1.cover"),
+ CoverSpec1 = {include,[cover_helper]},
+ file:write_file(CoverFile1,io_lib:format("~p.~n",[CoverSpec1])),
+ run_test_server_tests("test_server_cover_SUITE",
+ [{test_server_cover_SUITE,tc2,"SKIPPED!"}],
+ 4, 0, 2, 1, 1, 0, 1, 0, 3,
+ CoverFile1, Config),
+
+ %% Next test run skips tc1, so only cover_helper:bar/0 is executed.
+ %% Cover file specifies cross compilation of cover_helper
+ CoverFile2 = filename:join(PrivDir,"t2.cover"),
+ CoverSpec2 = {cross,[{t1,[cover_helper]}]},
+ file:write_file(CoverFile2,io_lib:format("~p.~n",[CoverSpec2])),
+ run_test_server_tests("test_server_cover_SUITE",
+ [{test_server_cover_SUITE,tc1,"SKIPPED!"}],
+ 4, 0, 2, 1, 1, 0, 1, 0, 3, CoverFile2, Config),
+
+ %% Cross cover analyse
+ WorkDir = ?config(work_dir,Config),
+ WC = filename:join([WorkDir,"test_server_cover_SUITE.logs","run.*"]),
+ [D2,D1|_] = lists:reverse(lists:sort(filelib:wildcard(WC))),
+ TagDirs = [{t1,D1},{t2,D2}],
+ test_server_ctrl:cross_cover_analyse(details,TagDirs),
+
+ %% Check that cover log shows only what is really included
+ %% in the test and cross cover log show the accumulated
+ %% result.
+ {ok,Cover1} = file:read_file(filename:join(D1,"cover.log")),
+ [{cover_helper,{1,1,_}}] = binary_to_term(Cover1),
+ {ok,Cover2} = file:read_file(filename:join(D2,"cover.log")),
+ [] = binary_to_term(Cover2),
+ {ok,Cross} = file:read_file(filename:join(D1,"cross_cover.log")),
+ [{cover_helper,{2,0,_}}] = binary_to_term(Cross),
+ ok
+ end.
+
+test_server_unicode(Config) ->
+ run_test_server_tests("test_server_unicode_SUITE", [],
+ 5, 0, 3, 3, 0, 0, 0, 0, 5, Config),
+
+ %% Create and run two test suites - one with filename and content
+ %% in latin1 (if the default filename mode is latin1) and one with
+ %% filename and content in utf8. Both have name and content
+ %% including letters äöå. Check that all logs are generated with
+ %% utf8 encoded filenames.
+ case file:native_name_encoding() of
+ utf8 ->
+ ok;
+ latin1 ->
+ generate_and_run_unicode_test(Config,latin1)
+ end,
+ generate_and_run_unicode_test(Config,utf8).
+
+%%%-----------------------------------------------------------------
+run_test_server_tests(SuiteName, Skip, NCases, NFail, NExpected, NSucc,
+ NUsrSkip, NAutoSkip,
+ NActualSkip, NActualFail, NActualSucc, Config) ->
+ run_test_server_tests(SuiteName, Skip, NCases, NFail, NExpected, NSucc,
+ NUsrSkip, NAutoSkip,
+ NActualSkip, NActualFail, NActualSucc, false, Config).
+
+run_test_server_tests(SuiteName, Skip, NCases, NFail, NExpected, NSucc,
+ NUsrSkip, NAutoSkip,
+ NActualSkip, NActualFail, NActualSucc, Cover, Config) ->
+ Node = proplists:get_value(node, Config),
+ Encoding = rpc:call(Node,file,native_name_encoding,[]),
+ WorkDir = proplists:get_value(work_dir, Config),
+ LogDir = filename:join(WorkDir, SuiteName++".logs"),
+ LogDirUri = test_server_ctrl:uri_encode(LogDir, Encoding),
+ ct:log("<a href=\"file://~s\">Test case log files</a>\n", [LogDirUri]),
+
+ {ok,_Pid} = rpc:call(Node,test_server_ctrl, start, []),
+ case Cover of
+ false ->
+ ok;
+ _ ->
+ rpc:call(Node,test_server_ctrl,cover,[Cover,details])
+ end,
+ rpc:call(Node,
+ test_server_ctrl,add_dir_with_skip,
+ [SuiteName,
+ [proplists:get_value(data_dir,Config)],SuiteName,
+ Skip]),
+
+ until(fun() ->
+ rpc:call(Node,test_server_ctrl,jobs,[]) =:= []
+ end),
+
+ rpc:call(Node,test_server_ctrl, stop, []),
+
+ LogDir1 = translate_filename(LogDir,Encoding),
+ LastRunDir = get_latest_run_dir(LogDir1),
+ LastSuiteLog = filename:join(LastRunDir,"suite.log"),
+ {ok,Data} = test_server_test_lib:parse_suite(LastSuiteLog),
+ check([{"Number of cases",NCases,Data#suite.n_cases},
+ {"Number failed",NFail,Data#suite.n_cases_failed},
+ {"Number expected",NExpected,Data#suite.n_cases_expected},
+ {"Number successful",NSucc,Data#suite.n_cases_succ},
+ {"Number user skipped",NUsrSkip,Data#suite.n_cases_user_skip},
+ {"Number auto skipped",NAutoSkip,Data#suite.n_cases_auto_skip}], ok),
+ {NActualSkip,NActualFail,NActualSucc} =
+ lists:foldl(fun(#tc{ result = skip },{S,F,Su}) ->
+ {S+1,F,Su};
+ (#tc{ result = auto_skip },{S,F,Su}) ->
+ {S+1,F,Su};
+ (#tc{ result = ok },{S,F,Su}) ->
+ {S,F,Su+1};
+ (#tc{ result = failed },{S,F,Su}) ->
+ {S,F+1,Su}
+ end,{0,0,0},Data#suite.cases),
+ Data.
+
+translate_filename(Filename,EncodingOnTestNode) ->
+ case {file:native_name_encoding(),EncodingOnTestNode} of
+ {X,X} -> Filename;
+ {utf8,latin1} -> list_to_binary(Filename);
+ {latin1,utf8} -> unicode:characters_to_binary(Filename)
+ end.
+
+get_latest_run_dir(Dir) ->
+ %% For the time being, filelib:wildcard can not take a binary
+ %% argument, so we avoid using this here.
+ case file:list_dir(Dir) of
+ {ok,Files} ->
+ {ok,RE} = re:compile(<<"^run.[1-2][-_\.0-9]*$">>),
+ RunDirs = lists:filter(
+ fun(F) ->
+ L = l(F),
+ case re:run(F,RE) of
+ {match,[{0,L}]} -> true;
+ _ -> false
+ end
+ end, Files),
+ case RunDirs of
+ [] ->
+ Dir;
+ [H|T] ->
+ filename:join(Dir,get_latest_dir(T,H))
+ end;
+ _ ->
+ Dir
+ end.
+
+l(X) when is_binary(X) -> size(X);
+l(X) when is_list(X) -> length(X).
+
+get_latest_dir([H|T],Latest) when H>Latest ->
+ get_latest_dir(T,H);
+get_latest_dir([_|T],Latest) ->
+ get_latest_dir(T,Latest);
+get_latest_dir([],Latest) ->
+ Latest.
+
+check([{Str,Same,Same}|T], Status) ->
+ io:format("~s: ~p\n", [Str,Same]),
+ check(T, Status);
+check([{Str,Expected,Actual}|T], _) ->
+ io:format("~s: expected ~p, actual ~p\n", [Str,Expected,Actual]),
+ check(T, error);
+check([], ok) -> ok;
+check([], error) -> ?t:fail().
+
+until(Fun) ->
+ case Fun() of
+ true ->
+ ok;
+ false ->
+ timer:sleep(100),
+ until(Fun)
+ end.
+
+generate_and_run_unicode_test(Config0,Encoding) ->
+ DataDir = ?config(data_dir,Config0),
+ Suite = create_unicode_test_suite(DataDir,Encoding),
+
+ %% We can not run this test on default node since it must be
+ %% started with correct file name mode (+fnu/+fnl).
+ %% OBS: the node are stopped by end_per_testcase/2
+ Config1 = lists:keydelete(node,1,Config0),
+ Config2 = lists:keydelete(work_dir,1,Config1),
+ NodeName = list_to_atom("test_server_tester_" ++ atom_to_list(Encoding)),
+ Config = start_node(Config2,NodeName,erts_switch(Encoding)),
+
+ %% Compile the suite
+ Node = proplists:get_value(node,Config),
+ {ok,Mod} = rpc:call(Node,compile,file,[Suite,[report,{outdir,DataDir}]]),
+ ModStr = atom_to_list(Mod),
+
+ %% Clean logdir
+ LogDir0 = filename:join(DataDir,ModStr++".logs"),
+ LogDir = translate_filename(LogDir0,Encoding),
+ rm_dir(LogDir),
+
+ %% Run the test
+ run_test_server_tests(ModStr, [], 3, 0, 1, 1, 0, 0, 0, 0, 3, Config),
+
+ %% Check that all logs are created with utf8 encoded filenames
+ true = filelib:is_dir(LogDir),
+
+ RunDir = get_latest_run_dir(LogDir),
+ true = filelib:is_dir(RunDir),
+
+ LowerModStr = string:to_lower(ModStr),
+ SuiteHtml = translate_filename(LowerModStr++".src.html",Encoding),
+ true = filelib:is_regular(filename:join(RunDir,SuiteHtml)),
+
+ TCLog = translate_filename(LowerModStr++".tc_äöå.html",Encoding),
+ true = filelib:is_regular(filename:join(RunDir,TCLog)),
+ ok.
+
+%% Same as test_server_test_lib:start_slave, but starts a peer with
+%% additional arguments.
+%% The reason for this is that we need to start nodes with +fnu/+fnl,
+%% and that will not work well with a slave node since slave nodes run
+%% remote file system on master - i.e. they will use same file name
+%% mode as the master.
+start_node(Config,Name,Args) ->
+ [_,Host] = string:tokens(atom_to_list(node()), "@"),
+ ct:log("Trying to start ~w@~s~n",[Name,Host]),
+ case test_server:start_node(Name, peer, [{args,Args}]) of
+ {error,Reason} ->
+ test_server:fail(Reason);
+ {ok,Node} ->
+ ct:log("Node ~p started~n", [Node]),
+ test_server_test_lib:prepare_tester_node(Node,Config)
+ end.
+
+create_unicode_test_suite(Dir,Encoding) ->
+ ModStr = "test_server_"++atom_to_list(Encoding)++"_äöå_SUITE",
+ File = filename:join(Dir,ModStr++".erl"),
+ Suite =
+ ["%% -*- ",epp:encoding_to_string(Encoding)," -*-\n",
+ "-module(",ModStr,").\n"
+ "\n"
+ "-export([all/1, init_per_suite/1, end_per_suite/1]).\n"
+ "-export([init_per_testcase/2, end_per_testcase/2]).\n"
+ "-export([tc_äöå/1]).\n"
+ "\n"
+ "-include_lib(\"common_test/include/ct.hrl\").\n"
+ "\n"
+ "all(suite) ->\n"
+ " [tc_äöå].\n"
+ "\n"
+ "init_per_suite(Config) ->\n"
+ " Config.\n"
+ "\n"
+ "end_per_suite(_Config) ->\n"
+ " ok.\n"
+ "\n"
+ "init_per_testcase(_Case,Config) ->\n"
+ " init_timetrap(500,Config).\n"
+ "\n"
+ "init_timetrap(T,Config) ->\n"
+ " Dog = ?t:timetrap(T),\n"
+ " [{watchdog, Dog}|Config].\n"
+ "\n"
+ "end_per_testcase(_Case,Config) ->\n"
+ " cancel_timetrap(Config).\n"
+ "\n"
+ "cancel_timetrap(Config) ->\n"
+ " Dog=?config(watchdog, Config),\n"
+ " ?t:timetrap_cancel(Dog),\n"
+ " ok.\n"
+ "\n"
+ "tc_äöå(Config) when is_list(Config) ->\n"
+ " true = filelib:is_dir(?config(priv_dir,Config)),\n"
+ " ok.\n"],
+ {ok,Fd} = file:open(raw_filename(File,Encoding),[write,{encoding,Encoding}]),
+ io:put_chars(Fd,Suite),
+ ok = file:close(Fd),
+ File.
+
+raw_filename(Name,latin1) -> list_to_binary(Name);
+raw_filename(Name,utf8) -> unicode:characters_to_binary(Name).
+
+rm_dir(Dir) ->
+ case file:list_dir(Dir) of
+ {error,enoent} ->
+ ok;
+ {ok,Files} ->
+ rm_files([filename:join(Dir, F) || F <- Files]),
+ file:del_dir(Dir)
+ end.
+
+rm_files([F | Fs]) ->
+ case file:read_file_info(F) of
+ {ok,#file_info{type=directory}} ->
+ rm_dir(F),
+ rm_files(Fs);
+ {ok,_Regular} ->
+ case file:delete(F) of
+ ok ->
+ rm_files(Fs);
+ {error,Errno} ->
+ exit({del_failed,F,Errno})
+ end
+ end;
+rm_files([]) ->
+ ok.
+
+erts_switch(latin1) -> "+fnl";
+erts_switch(utf8) -> "+fnu".
diff --git a/lib/common_test/test/test_server_SUITE_data/Makefile.src b/lib/common_test/test/test_server_SUITE_data/Makefile.src
new file mode 100644
index 0000000000..5aeb035572
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/Makefile.src
@@ -0,0 +1,11 @@
+all:
+ erlc test_server_SUITE.erl
+ erlc test_server_parallel01_SUITE.erl
+ erlc test_server_conf01_SUITE.erl
+ erlc test_server_shuffle01_SUITE.erl
+ erlc test_server_conf02_SUITE.erl
+ erlc test_server_skip_SUITE.erl
+ erlc test_server_break_SUITE.erl
+ erlc test_server_cover_SUITE.erl
+ erlc +debug_info test_server_cover_SUITE_data/cover_helper.erl
+ erlc test_server_unicode_SUITE.erl
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_SUITE.erl
new file mode 100644
index 0000000000..c3d4315cb8
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_SUITE.erl
@@ -0,0 +1,514 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1997-2013. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%%------------------------------------------------------------------
+%%% Test Server self test.
+%%%------------------------------------------------------------------
+-module(test_server_SUITE).
+-include_lib("common_test/include/ct.hrl").
+-include_lib("kernel/include/file.hrl").
+-export([all/1]).
+
+-export([init_per_suite/1, end_per_suite/1]).
+-export([init_per_testcase/2, end_per_testcase/2, fin_per_testcase/2]).
+-export([config/1, comment/1, timetrap/1, timetrap_cancel/1, multiply_timetrap/1,
+ init_per_s/1, init_per_tc/1, end_per_tc/1,
+ timeconv/1, msgs/1, capture/1, timecall/1,
+ do_times/1, do_times_mfa/1, do_times_fun/1,
+ skip_cases/1, skip_case1/1, skip_case2/1, skip_case3/1,
+ skip_case4/1, skip_case5/1, skip_case6/1, skip_case7/1,
+ skip_case8/1, skip_case9/1,
+ conf_init/1, check_new_conf/1, conf_cleanup/1,
+ check_old_conf/1, conf_init_fail/1, start_stop_node/1,
+ cleanup_nodes_init/1, check_survive_nodes/1, cleanup_nodes_fin/1,
+ commercial/1,
+ io_invalid_data/1, print_unexpected/1]).
+
+-export([dummy_function/0,dummy_function/1,doer/1]).
+
+all(doc) -> ["Test Server self test"];
+all(suite) ->
+ [config, comment, timetrap, timetrap_cancel, multiply_timetrap,
+ init_per_s, init_per_tc, end_per_tc,
+ timeconv, msgs, capture, timecall, do_times, skip_cases,
+ commercial, io_invalid_data, print_unexpected,
+ {conf, conf_init, [check_new_conf], conf_cleanup},
+ check_old_conf,
+ {conf, conf_init_fail,[conf_member_skip],conf_cleanup_skip},
+ start_stop_node,
+ {conf, cleanup_nodes_init,[check_survive_nodes],cleanup_nodes_fin},
+ config
+ ].
+
+
+init_per_suite(Config) ->
+ [{init_per_suite_var,ok}|Config].
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) ->
+ Dog = ?t:timetrap(?t:minutes(2)),
+ Config1 = [{watchdog, Dog}|Config],
+ case Func of
+ init_per_tc ->
+ [{strange_var, 1}|Config1];
+ skip_case8 ->
+ {skipped, "This case should be noted as `Skipped'"};
+ skip_case9 ->
+ {skip, "This case should be noted as `Skipped'"};
+ _ ->
+ Config1
+ end;
+init_per_testcase(Func, Config) ->
+ io:format("Func:~p",[Func]),
+ io:format("Config:~p",[Config]),
+ ?t:fail("Arguments to init_per_testcase not correct").
+
+end_per_testcase(Func, Config) when is_atom(Func), is_list(Config) ->
+ Dog=?config(watchdog, Config),
+ ?t:timetrap_cancel(Dog),
+ case Func of
+ end_per_tc -> io:format("CLEANUP => this test case is ok\n");
+ _Other -> ok
+ end;
+end_per_testcase(Func, Config) ->
+ io:format("Func:~p",[Func]),
+ io:format("Config:~p",[Config]),
+ ?t:fail("Arguments to end_per_testcase not correct").
+
+fin_per_testcase(Func, Config) ->
+ io:format("Func:~p",[Func]),
+ io:format("Config:~p",[Config]),
+ ?t:fail("fin_per_testcase/2 called, should have called end_per_testcase/2").
+
+
+config(suite) -> [];
+config(doc) -> ["Test that the Config variable is decent, ",
+ "and that the std config variables are correct ",
+ "(check that data/priv dir exists)."
+ "Also check that ?config macro works."];
+config(Config) when is_list(Config) ->
+ is_tuplelist(Config),
+ {value,{data_dir,Dd}}=lists:keysearch(data_dir,1,Config),
+ {value,{priv_dir,Dp}}=lists:keysearch(priv_dir,1,Config),
+ true=is_dir(Dd),
+ {ok, _Bin}=file:read_file(filename:join(Dd, "dummy_file")),
+ true=is_dir(Dp),
+
+ Dd = ?config(data_dir,Config),
+ Dp = ?config(priv_dir,Config),
+ ok;
+config(_Config) ->
+ ?t:fail("Config variable is not a list.").
+
+is_tuplelist([]) ->
+ true;
+is_tuplelist([{_A,_B}|Rest]) ->
+ is_tuplelist(Rest);
+is_tuplelist(_) ->
+ false.
+
+is_dir(Dir) ->
+ case file:read_file_info(Dir) of
+ {ok, #file_info{type=directory}} ->
+ true;
+ _ ->
+ false
+ end.
+
+comment(suite) -> [];
+comment(doc) -> ["Print a comment in the HTML log"];
+comment(Config) when is_list(Config) ->
+ ?t:comment("This comment should not occur in the HTML log because a later"
+ " comment shall overwrite it"),
+ ?t:comment("This comment is printed with the comment/1 function."
+ " It should occur in the HTML log").
+
+
+
+timetrap(suite) -> [];
+timetrap(doc) -> ["Test that timetrap works."];
+timetrap(Config) when is_list(Config) ->
+ TrapAfter = 3000,
+ Dog=?t:timetrap(TrapAfter),
+ process_flag(trap_exit, true),
+ TimeOut = TrapAfter * test_server:timetrap_scale_factor() + 1000,
+ receive
+ {'EXIT', Dog, {timetrap_timeout, _, _}} ->
+ ok;
+ {'EXIT', _OtherPid, {timetrap_timeout, _, _}} ->
+ ?t:fail("EXIT signal from wrong process")
+ after
+ TimeOut ->
+ ?t:fail("Timetrap is not working.")
+ end,
+ ?t:timetrap_cancel(Dog),
+ ok.
+
+
+timetrap_cancel(suite) -> [];
+timetrap_cancel(doc) -> ["Test that timetrap_cancel works."];
+timetrap_cancel(Config) when is_list(Config) ->
+ Dog=?t:timetrap(1000),
+ receive
+ after
+ 500 ->
+ ok
+ end,
+ ?t:timetrap_cancel(Dog),
+ receive
+ after 1000 ->
+ ok
+ end,
+ ok.
+
+multiply_timetrap(suite) -> [];
+multiply_timetrap(doc) -> ["Test multiply timetrap"];
+multiply_timetrap(Config) when is_list(Config) ->
+ %% This simulates the call to test_server_ctrl:multiply_timetraps/1:
+ put(test_server_multiply_timetraps,{2,true}),
+
+ Dog = ?t:timetrap(500),
+ timer:sleep(800),
+ ?t:timetrap_cancel(Dog),
+
+ %% Reset
+ put(test_server_multiply_timetraps,1),
+ ok.
+
+
+init_per_s(suite) -> [];
+init_per_s(doc) -> ["Test that a Config that is altered in ",
+ "init_per_suite gets through to the testcases."];
+init_per_s(Config) ->
+ %% Check that the config var sent from init_per_suite
+ %% really exists.
+ {value, {init_per_suite_var, ok}} =
+ lists:keysearch(init_per_suite_var,1,Config),
+
+ %% Check that the other variables still exist.
+ {value,{data_dir,_Dd}}=lists:keysearch(data_dir,1,Config),
+ {value,{priv_dir,_Dp}}=lists:keysearch(priv_dir,1,Config),
+ ok.
+
+init_per_tc(suite) -> [];
+init_per_tc(doc) -> ["Test that a Config that is altered in ",
+ "init_per_testcase gets through to the ",
+ "actual testcase."];
+init_per_tc(Config) ->
+ %% Check that the config var sent from init_per_testcase
+ %% really exists.
+ {value, {strange_var, 1}} = lists:keysearch(strange_var,1,Config),
+
+ %% Check that the other variables still exist.
+ {value,{data_dir,_Dd}}=lists:keysearch(data_dir,1,Config),
+ {value,{priv_dir,_Dp}}=lists:keysearch(priv_dir,1,Config),
+ ok.
+
+end_per_tc(suite) -> [];
+end_per_tc(doc) -> ["Test that end_per_testcase/2 is called even if"
+ " test case fails"];
+end_per_tc(Config) when is_list(Config) ->
+ ?t:fail("This case should fail! Check that \"CLEANUP\" is"
+ " printed in the minor log file.").
+
+
+timeconv(suite) -> [];
+timeconv(doc) -> ["Test that the time unit conversion functions ",
+ "works."];
+timeconv(Config) when is_list(Config) ->
+ Val=2,
+ Secs=Val*1000,
+ Mins=Secs*60,
+ Hrs=Mins*60,
+ Secs=?t:seconds(2),
+ Mins=?t:minutes(2),
+ Hrs=?t:hours(2),
+ ok.
+
+
+msgs(suite) -> [];
+msgs(doc) -> ["Tests the messages_get function."];
+msgs(Config) when is_list(Config) ->
+ self() ! {hej, du},
+ self() ! {lite, "data"},
+ self() ! en_atom,
+ [{hej, du}, {lite, "data"}, en_atom] = ?t:messages_get(),
+ ok.
+
+capture(suite) -> [];
+capture(doc) -> ["Test that the capture functions work properly."];
+capture(Config) when is_list(Config) ->
+ String1="abcedfghjiklmnopqrstuvwxyz",
+ String2="0123456789",
+ ?t:capture_start(),
+ io:format(String1),
+ [String1]=?t:capture_get(),
+ io:format(String2),
+ [String2]=?t:capture_get(),
+ ?t:capture_stop(),
+ []=?t:capture_get(),
+ io:format(String2),
+ []=?t:capture_get(),
+ ok.
+
+timecall(suite) -> [];
+timecall(doc) -> ["Tests that timed calls work."];
+timecall(Config) when is_list(Config) ->
+ {_Time1, liten_apa_e_oxo_farlig} = ?t:timecall(?MODULE, dummy_function, []),
+ {Time2, jag_ar_en_gorilla} = ?t:timecall(?MODULE, dummy_function, [gorilla]),
+ DTime=round(Time2),
+ if
+ DTime<1 ->
+ ?t:fail("Timecall reported a too low time.");
+ DTime==1 ->
+ ok;
+ DTime>1 ->
+ ?t:fail("Timecall reported a too high time.")
+ end,
+ ok.
+
+dummy_function() ->
+ liten_apa_e_oxo_farlig.
+dummy_function(gorilla) ->
+ receive after 1000 -> ok end,
+ jag_ar_en_gorilla.
+
+
+do_times(suite) -> [do_times_mfa, do_times_fun];
+do_times(doc) -> ["Test the do_times function."].
+
+do_times_mfa(suite) -> [];
+do_times_mfa(doc) -> ["Test the do_times function with M,F,A given."];
+do_times_mfa(Config) when is_list(Config) ->
+ ?t:do_times(100, ?MODULE, doer, [self()]),
+ 100=length(?t:messages_get()),
+ ok.
+
+do_times_fun(suite) -> [];
+do_times_fun(doc) -> ["Test the do_times function with fun given."];
+do_times_fun(Config) when is_list(Config) ->
+ Self = self(),
+ ?t:do_times(100, fun() -> doer(Self) end),
+ 100=length(?t:messages_get()),
+ ok.
+
+doer(From) ->
+ From ! a,
+ ok.
+
+skip_cases(doc) -> ["Test all possible ways to skip a test case."];
+skip_cases(suite) -> [skip_case1, skip_case2, skip_case3, skip_case4,
+ skip_case5, skip_case6, skip_case7, skip_case8,
+ skip_case9].
+
+skip_case1(suite) -> [];
+skip_case1(doc) -> ["Test that you can return {skipped, Reason},"
+ " and that Reason is in the comment field in the HTML log"];
+skip_case1(Config) when is_list(Config) ->
+ %% If this comment shows, the case failed!!
+ ?t:comment("ERROR: This case should have been noted as `Skipped'"),
+ %% The Reason in {skipped, Reason} should overwrite a 'comment'
+ {skipped, "This case should be noted as `Skipped'"}.
+
+skip_case2(suite) -> [];
+skip_case2(doc) -> ["Test that you can return {skipped, Reason},"
+ " and that Reason is in the comment field in the HTML log"];
+skip_case2(Config) when is_list(Config) ->
+ %% If this comment shows, the case failed!!
+ ?t:comment("ERROR: This case should have been noted as `Skipped'"),
+ %% The Reason in {skipped, Reason} should overwrite a 'comment'
+ exit({skipped, "This case should be noted as `Skipped'"}).
+
+skip_case3(suite) -> [];
+skip_case3(doc) -> ["Test that you can return {skip, Reason},"
+ " and that Reason is in the comment field in the HTML log"];
+skip_case3(Config) when is_list(Config) ->
+ %% If this comment shows, the case failed!!
+ ?t:comment("ERROR: This case should have been noted as `Skipped'"),
+ %% The Reason in {skip, Reason} should overwrite a 'comment'
+ {skip, "This case should be noted as `Skipped'"}.
+
+skip_case4(suite) -> [];
+skip_case4(doc) -> ["Test that you can return {skip, Reason},"
+ " and that Reason is in the comment field in the HTML log"];
+skip_case4(Config) when is_list(Config) ->
+ %% If this comment shows, the case failed!!
+ ?t:comment("ERROR: This case should have been noted as `Skipped'"),
+ %% The Reason in {skip, Reason} should overwrite a 'comment'
+ exit({skip, "This case should be noted as `Skipped'"}).
+
+skip_case5(suite) -> {skipped, "This case should be noted as `Skipped'"};
+skip_case5(doc) -> ["Test that you can return {skipped, Reason}"
+ " from the specification clause"].
+
+skip_case6(suite) -> {skip, "This case should be noted as `Skipped'"};
+skip_case6(doc) -> ["Test that you can return {skip, Reason}"
+ " from the specification clause"].
+
+skip_case7(suite) -> [];
+skip_case7(doc) -> ["Test that skip works from a test specification file"];
+skip_case7(Config) when is_list(Config) ->
+ %% This case shall be skipped by adding
+ %% {skip, {test_server_SUITE, skip_case7, Reason}}.
+ %% to the test specification file.
+ ?t:fail("This case should have been Skipped by the .spec file").
+
+skip_case8(suite) -> [];
+skip_case8(doc) -> ["Test that {skipped, Reason} works from"
+ " init_per_testcase/2"];
+skip_case8(Config) when is_list(Config) ->
+ %% This case shall be skipped by adding a specific clause to
+ %% returning {skipped, Reason} from init_per_testcase/2 for this case.
+ ?t:fail("This case should have been Skipped by init_per_testcase/2").
+
+skip_case9(suite) -> [];
+skip_case9(doc) -> ["Test that {skip, Reason} works from a init_per_testcase/2"];
+skip_case9(Config) when is_list(Config) ->
+ %% This case shall be skipped by adding a specific clause to
+ %% returning {skip, Reason} from init_per_testcase/2 for this case.
+ ?t:fail("This case should have been Skipped by init_per_testcase/2").
+
+conf_init(doc) -> ["Test successful conf case: Change Config parameter"];
+conf_init(Config) when is_list(Config) ->
+ [{conf_init_var,1389}|Config].
+
+check_new_conf(suite) -> [];
+check_new_conf(doc) -> ["Check that Config parameter changed by"
+ " conf_init is used"];
+check_new_conf(Config) when is_list(Config) ->
+ 1389 = ?config(conf_init_var,Config),
+ ok.
+
+conf_cleanup(doc) -> ["Test successful conf case: Restore Config parameter"];
+conf_cleanup(Config) when is_list(Config) ->
+ lists:keydelete(conf_init_var,1,Config).
+
+check_old_conf(suite) -> [];
+check_old_conf(doc) -> ["Test that the restored Config is used after a"
+ " conf cleanup"];
+check_old_conf(Config) when is_list(Config) ->
+ undefined = ?config(conf_init_var,Config),
+ ok.
+
+conf_init_fail(doc) -> ["Test that config members are skipped if"
+ " conf init function fails."];
+conf_init_fail(Config) when is_list(Config) ->
+ ?t:fail("This case should fail! Check that conf_member_skip and"
+ " conf_cleanup_skip are skipped.").
+
+
+
+start_stop_node(suite) -> [];
+start_stop_node(doc) -> ["Test start and stop of slave and peer nodes"];
+start_stop_node(Config) when is_list(Config) ->
+ {ok,Node2} = ?t:start_node(node2,peer,[]),
+ {error, _} = ?t:start_node(node2,peer,[{fail_on_error,false}]),
+ true = lists:member(Node2,nodes()),
+
+ {ok,Node3} = ?t:start_node(node3,slave,[]),
+ {error, _} = ?t:start_node(node3,slave,[]),
+ true = lists:member(Node3,nodes()),
+
+ {ok,Node4} = ?t:start_node(node4,peer,[{wait,false}]),
+ case lists:member(Node4,nodes()) of
+ true ->
+ ?t:comment("WARNING: Node started with {wait,false}"
+ " is up faster than expected...");
+ false ->
+ test_server:wait_for_node(Node4),
+ true = lists:member(Node4,nodes())
+ end,
+
+ true = ?t:stop_node(Node2),
+ false = lists:member(Node2,nodes()),
+
+ true = ?t:stop_node(Node3),
+ false = lists:member(Node3,nodes()),
+
+ true = ?t:stop_node(Node4),
+ false = lists:member(Node4,nodes()),
+ timer:sleep(2000),
+ false = ?t:stop_node(Node4),
+
+ ok.
+
+cleanup_nodes_init(doc) -> ["Test that nodes are terminated when test case"
+ " is finished unless {cleanup,false} is given."];
+cleanup_nodes_init(Config) when is_list(Config) ->
+ {ok,DieSlave} = ?t:start_node(die_slave, slave, []),
+ {ok,SurviveSlave} = ?t:start_node(survive_slave, slave, [{cleanup,false}]),
+ {ok,DiePeer} = ?t:start_node(die_peer, peer, []),
+ {ok,SurvivePeer} = ?t:start_node(survive_peer, peer, [{cleanup,false}]),
+ [{die_slave,DieSlave},
+ {survive_slave,SurviveSlave},
+ {die_peer,DiePeer},
+ {survive_peer,SurvivePeer} | Config].
+
+
+
+check_survive_nodes(suite) -> [];
+check_survive_nodes(doc) -> ["Test that nodes with {cleanup,false} survived"];
+check_survive_nodes(Config) when is_list(Config) ->
+ timer:sleep(1000),
+ false = lists:member(?config(die_slave,Config),nodes()),
+ true = lists:member(?config(survive_slave,Config),nodes()),
+ false = lists:member(?config(die_peer,Config),nodes()),
+ true = lists:member(?config(survive_peer,Config),nodes()),
+ ok.
+
+
+cleanup_nodes_fin(doc) -> ["Test that nodes started with {cleanup,false}"
+ " can be stopped"];
+cleanup_nodes_fin(Config) when is_list(Config) ->
+ Slave = ?config(survive_slave,Config),
+ Peer = ?config(survive_peer,Config),
+
+ true = ?t:stop_node(Slave),
+ false = lists:member(Slave,nodes()),
+ true = ?t:stop_node(Peer),
+ false = lists:member(Peer,nodes()),
+
+ C1 = lists:keydelete(die_slave,1,Config),
+ C2 = lists:keydelete(survive_slave,1,C1),
+ C3 = lists:keydelete(die_peer,1,C2),
+ lists:keydelete(survive_peer,1,C3).
+
+commercial(Config) when is_list(Config) ->
+ case ?t:is_commercial() of
+ false -> {comment,"Open-source build"};
+ true -> {comment,"Commercial build"}
+ end.
+
+io_invalid_data(Config) when is_list(Config) ->
+ ok = io:put_chars("valid: " ++ [42]),
+ %% OTP-10991 caused this to hang and produce a timetrap timeout:
+ {'EXIT',{badarg,_}} = (catch io:put_chars("invalid: " ++ [42.0])),
+ ok.
+
+print_unexpected(Config) when is_list(Config) ->
+ Str = "-x-x-x- test_server_SUITE:print_unexpected -> Unexpected data -x-x-x-",
+ test_server_io:print_unexpected(Str),
+ UnexpectedLog = filename:join(filename:dirname(?config(tc_logfile,Config)),
+ "unexpected_io.log.html"),
+ {ok,Bin} = file:read_file(UnexpectedLog),
+ match = re:run(Bin, Str, [global,{capture,none}]),
+ ok.
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_SUITE_data/dummy_file b/lib/common_test/test/test_server_SUITE_data/test_server_SUITE_data/dummy_file
new file mode 100644
index 0000000000..65c88fbd75
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_SUITE_data/dummy_file
@@ -0,0 +1 @@
+Dummy file. \ No newline at end of file
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_break_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_break_SUITE.erl
new file mode 100644
index 0000000000..171f83df0f
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_break_SUITE.erl
@@ -0,0 +1,149 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2012. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+-module(test_server_break_SUITE).
+
+-export([all/1, init_per_suite/1, end_per_suite/1]).
+-export([init_per_testcase/2, end_per_testcase/2]).
+-export([break_in_init_tc/1,
+ break_in_tc/1,
+ break_in_end_tc/1,
+ break_in_end_tc_after_fail/1,
+ break_in_end_tc_after_abort/1,
+ check_all_breaks/1]).
+
+-include_lib("common_test/include/ct.hrl").
+
+all(suite) ->
+ [break_in_init_tc,
+ break_in_tc,
+ break_in_end_tc,
+ break_in_end_tc_after_fail,
+ break_in_end_tc_after_abort,
+ check_all_breaks]. %must be the last test - checks result of previous tests
+
+init_per_suite(Config) ->
+ spawn(fun break_and_continue_sup/0),
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_testcase(Case,Config) when Case==break_in_init_tc ->
+ Config1 = init_timetrap(500,Config),
+ break_and_check(Case),
+ Config1;
+init_per_testcase(Case,Config) when Case==check_all_breaks ->
+ init_timetrap({seconds,20},Config);
+init_per_testcase(_Case,Config) ->
+ init_timetrap(500,Config).
+
+init_timetrap(T,Config) ->
+ Dog = ?t:timetrap(T),
+ [{watchdog, Dog}|Config].
+
+end_per_testcase(Case,Config) when Case==break_in_end_tc;
+ Case==break_in_end_tc_after_fail;
+ Case==break_in_end_tc_after_abort ->
+ break_and_check(Case),
+ cancel_timetrap(Config);
+end_per_testcase(_Case,Config) ->
+ cancel_timetrap(Config).
+
+cancel_timetrap(Config) ->
+ Dog=?config(watchdog, Config),
+ ?t:timetrap_cancel(Dog),
+ ok.
+
+
+%%%-----------------------------------------------------------------
+%%% Test cases
+
+break_in_init_tc(Config) when is_list(Config) ->
+ ok.
+
+break_in_tc(Config) when is_list(Config) ->
+ break_and_check(break_in_tc),
+ ok.
+
+break_in_end_tc(Config) when is_list(Config) ->
+ ok.
+
+break_in_end_tc_after_fail(Config) when is_list(Config) ->
+ ?t:fail(test_case_should_fail).
+
+break_in_end_tc_after_abort(Config) when is_list(Config) ->
+ ?t:adjusted_sleep(2000). % will cause a timetrap timeout
+
+%% This test case checks that all breaks in previous test cases was
+%% also continued, and that the break lasted as long as expected.
+%% The reason for this is that some of the breaks above are in
+%% end_per_testcase, and failures there will only produce a warning,
+%% not an error - so this is to catch the error for real.
+check_all_breaks(Config) when is_list(Config) ->
+ break_and_continue_sup ! {done,self()},
+ receive {Breaks,Continued} ->
+ check_all_breaks(Breaks,Continued)
+ end.
+%%%-----------------------------------------------------------------
+%%% Internal functions
+
+
+check_all_breaks([{From,Case,T,Start}|Breaks],[{From,End}|Continued]) ->
+ Diff = timer:now_diff(End,Start),
+ DiffSec = round(Diff/1000000),
+ TSec = round(T/1000000),
+ if DiffSec==TSec ->
+ ?t:format("Break in ~p successfully continued after ~p second(s)~n",
+ [Case,DiffSec]),
+ check_all_breaks(Breaks,Continued);
+ true ->
+ ?t:format("Faulty duration of break in ~p: continued after ~p second(s)~n",
+ [Case,DiffSec]),
+ ?t:fail({faulty_diff,Case,DiffSec,TSec})
+ end;
+check_all_breaks([],[]) ->
+ ok;
+check_all_breaks(Breaks,Continued) ->
+ %% This is probably a case of a missing continue - i.e. a break
+ %% has been started, but it was never continued.
+ ?t:fail({no_match_in_breaks_and_continued,Breaks,Continued}).
+
+break_and_check(Case) ->
+ break_and_continue_sup ! {break,Case,1000,self()},
+ ?t:break(atom_to_list(Case)),
+ break_and_continue_sup ! {continued,self()},
+ ok.
+
+break_and_continue_sup() ->
+ register(break_and_continue_sup,self()),
+ break_and_continue_loop([],[]).
+
+break_and_continue_loop(Breaks,Continued) ->
+ receive
+ {break,Case,T,From} ->
+ Start = now(),
+ {RealT,_} = timer:tc(?t,adjusted_sleep,[T]),
+ ?t:continue(),
+ break_and_continue_loop([{From,Case,RealT,Start}|Breaks],Continued);
+ {continued,From} ->
+ break_and_continue_loop(Breaks,[{From,now()}|Continued]);
+ {done,From} ->
+ From ! {lists:reverse(Breaks),lists:reverse(Continued)}
+ end.
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_conf01_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_conf01_SUITE.erl
new file mode 100644
index 0000000000..e4f40f6c03
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_conf01_SUITE.erl
@@ -0,0 +1,188 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2009-2011. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%%------------------------------------------------------------------
+%%% Test Server self test.
+%%%------------------------------------------------------------------
+-module(test_server_conf01_SUITE).
+-include_lib("common_test/include/ct.hrl").
+
+-compile(export_all).
+
+all(doc) -> ["Test simple conf case structure, with and without nested cases"];
+all(suite) ->
+ [
+ {conf, conf1_init, [conf1_tc1, conf1_tc2], conf1_end},
+
+ {conf, [], conf2_init, [conf2_tc1, conf2_tc2], conf2_end},
+
+ {conf, conf3_init, [conf3_tc1,
+
+ {conf, [], conf4_init, [conf4_tc1, conf4_tc2], conf4_end},
+
+ conf3_tc2], conf3_end},
+
+ conf5
+ ].
+
+%%---------- conf cases ----------
+
+conf1_init(Config) when is_list(Config) ->
+ [{cc1,conf1}|Config].
+conf1_end(_Config) ->
+ ok.
+
+conf2_init(Config) when is_list(Config) ->
+ [{cc2,conf2}|Config].
+conf2_end(_Config) ->
+ ok.
+
+conf3_init(Config) when is_list(Config) ->
+ [{cc3,conf3}|Config].
+conf3_end(_Config) ->
+ ok.
+
+conf4_init(Config) when is_list(Config) ->
+ [{cc4,conf4}|Config].
+conf4_end(_Config) ->
+ ok.
+
+conf5_init(Config) when is_list(Config) ->
+ [{cc5,conf5}|Config].
+conf5_end(_Config) ->
+ ok.
+
+conf6_init(Config) when is_list(Config) ->
+ [{cc6,conf6}|Config].
+conf6_end(_Config) ->
+ ok.
+
+
+conf5(suite) -> % test specification
+ [{conf, conf5_init, [conf5_tc1,
+
+ {conf, [], conf6_init, [conf6_tc1, conf6_tc2], conf6_end},
+
+ conf5_tc2], conf5_end}].
+
+
+%%---------- test cases ----------
+
+conf1_tc1(Config) when is_list(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ conf1 = ?config(cc1,Config),
+ ok.
+conf1_tc2(Config) when is_list(Config) ->
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf1 = ?config(cc1,Config),
+ ok.
+
+conf2_tc1(Config) when is_list(Config) ->
+ undefined = ?config(cc1,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ conf2 = ?config(cc2,Config),
+ ok.
+conf2_tc2(Config) when is_list(Config) ->
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf2 = ?config(cc2,Config),
+ ok.
+
+conf3_tc1(Config) when is_list(Config) ->
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ conf3 = ?config(cc3,Config),
+ ok.
+conf3_tc2(Config) when is_list(Config) ->
+ conf3 = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ ok.
+
+conf4_tc1(Config) when is_list(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ conf3 = ?config(cc3,Config),
+ conf4 = ?config(cc4,Config),
+ ok.
+conf4_tc2(Config) when is_list(Config) ->
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf3 = ?config(cc3,Config),
+ conf4 = ?config(cc4,Config),
+ ok.
+
+conf5_tc1(Config) when is_list(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf5 = ?config(cc5,Config),
+ ok.
+conf5_tc2(Config) when is_list(Config) ->
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf5 = ?config(cc5,Config),
+ undefined = ?config(cc6,Config),
+ ok.
+
+conf6_tc1(Config) when is_list(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf5 = ?config(cc5,Config),
+ conf6 = ?config(cc6,Config),
+ ok.
+conf6_tc2(Config) when is_list(Config) ->
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf5 = ?config(cc5,Config),
+ conf6 = ?config(cc6,Config),
+ ok.
+
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_conf02_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_conf02_SUITE.erl
new file mode 100644
index 0000000000..1c6fe6dd0b
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_conf02_SUITE.erl
@@ -0,0 +1,295 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2009-2011. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%%------------------------------------------------------------------
+%%% Test Server self test.
+%%%------------------------------------------------------------------
+-module(test_server_conf02_SUITE).
+-include_lib("common_test/include/ct.hrl").
+
+-compile(export_all).
+
+all(doc) -> ["Test simple conf case structure, with and without nested cases"];
+all(suite) ->
+ [
+ {conf, conf1_init, [conf1_tc1, conf1_tc2], conf1_end},
+
+ {conf, [], conf2_init, [conf2_tc1, conf2_tc2], conf2_end},
+
+ {conf, conf3_init, [conf3_tc1,
+
+ {conf, [], conf4_init, [conf4_tc1, conf4_tc2], conf4_end},
+
+ conf3_tc2], conf3_end},
+
+ conf5
+ ].
+
+
+%%---------- conf cases ----------
+
+init_per_suite(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ [{suite,init}|Config].
+end_per_suite(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ ok.
+
+init_per_testcase(TC=conf1_tc1, Config) ->
+ init = ?config(suite,Config),
+ [{tc11,TC}|Config];
+init_per_testcase(TC=conf1_tc2, Config) ->
+ [{tc12,TC}|Config];
+init_per_testcase(TC=conf2_tc1, Config) ->
+ [{tc21,TC}|Config];
+init_per_testcase(TC=conf2_tc2, Config) ->
+ [{tc22,TC}|Config];
+init_per_testcase(TC=conf3_tc1, Config) ->
+ [{tc31,TC}|Config];
+init_per_testcase(TC=conf3_tc2, Config) ->
+ [{tc32,TC}|Config];
+init_per_testcase(TC=conf4_tc1, Config) ->
+ [{tc41,TC}|Config];
+init_per_testcase(TC=conf4_tc2, Config) ->
+ [{tc42,TC}|Config];
+init_per_testcase(TC=conf5_tc1, Config) ->
+ [{tc51,TC}|Config];
+init_per_testcase(TC=conf5_tc2, Config) ->
+ [{tc52,TC}|Config];
+init_per_testcase(TC=conf6_tc1, Config) ->
+ [{tc61,TC}|Config];
+init_per_testcase(TC=conf6_tc2, Config) ->
+ init = ?config(suite,Config),
+ [{tc62,TC}|Config].
+
+end_per_testcase(TC=conf1_tc1, Config) ->
+ init = ?config(suite,Config),
+ TC = ?config(tc11,Config),
+ ok;
+end_per_testcase(TC=conf1_tc2, Config) ->
+ TC = ?config(tc12,Config),
+ ok;
+end_per_testcase(TC=conf2_tc1, Config) ->
+ TC = ?config(tc21,Config),
+ ok;
+end_per_testcase(TC=conf2_tc2, Config) ->
+ TC = ?config(tc22,Config),
+ ok;
+end_per_testcase(TC=conf3_tc1, Config) ->
+ TC = ?config(tc31,Config),
+ ok;
+end_per_testcase(TC=conf3_tc2, Config) ->
+ TC = ?config(tc32,Config),
+ ok;
+end_per_testcase(TC=conf4_tc1, Config) ->
+ TC = ?config(tc41,Config),
+ ok;
+end_per_testcase(TC=conf4_tc2, Config) ->
+ TC = ?config(tc42,Config),
+ ok;
+end_per_testcase(TC=conf5_tc1, Config) ->
+ TC = ?config(tc51,Config),
+ ok;
+end_per_testcase(TC=conf5_tc2, Config) ->
+ TC = ?config(tc52,Config),
+ ok;
+end_per_testcase(TC=conf6_tc1, Config) ->
+ TC = ?config(tc61,Config),
+ ok;
+end_per_testcase(TC=conf6_tc2, Config) ->
+ init = ?config(suite,Config),
+ TC = ?config(tc62,Config),
+ ok.
+
+conf1_init(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ [{cc1,conf1}|Config].
+conf1_end(_Config) ->
+ ok.
+
+conf2_init(Config) when is_list(Config) ->
+ [{cc2,conf2}|Config].
+conf2_end(_Config) ->
+ ok.
+
+conf3_init(Config) when is_list(Config) ->
+ [{cc3,conf3}|Config].
+conf3_end(_Config) ->
+ ok.
+
+conf4_init(Config) when is_list(Config) ->
+ [{cc4,conf4}|Config].
+conf4_end(_Config) ->
+ ok.
+
+conf5_init(Config) when is_list(Config) ->
+ [{cc5,conf5}|Config].
+conf5_end(_Config) ->
+ ok.
+
+conf6_init(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ [{cc6,conf6}|Config].
+conf6_end(_Config) ->
+ ok.
+
+conf5(suite) -> % test specification
+ [{conf, conf5_init, [conf5_tc1,
+
+ {conf, [], conf6_init, [conf6_tc1, conf6_tc2], conf6_end},
+
+ conf5_tc2], conf5_end}].
+
+%%---------- test cases ----------
+
+conf1_tc1(Config) when is_list(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ conf1 = ?config(cc1,Config),
+ conf1_tc1 = ?config(tc11,Config),
+ ok.
+conf1_tc2(Config) when is_list(Config) ->
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ conf1 = ?config(cc1,Config),
+ conf1_tc2 = ?config(tc12,Config),
+ ok.
+
+conf2_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ undefined = ?config(cc1,Config),
+ undefined = ?config(tc11,Config),
+ conf2 = ?config(cc2,Config),
+ conf2_tc1 = ?config(tc21,Config),
+ ok.
+conf2_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ conf2 = ?config(cc2,Config),
+ undefined = ?config(tc21,Config),
+ conf2_tc2 = ?config(tc22,Config),
+ ok.
+
+conf3_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(tc22,Config),
+ conf3 = ?config(cc3,Config),
+ conf3_tc1 = ?config(tc31,Config),
+ ok.
+conf3_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ conf3 = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ undefined = ?config(tc31,Config),
+ undefined = ?config(tc41,Config),
+ conf3_tc2 = ?config(tc32,Config),
+ ok.
+
+conf4_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ conf3 = ?config(cc3,Config),
+ conf4 = ?config(cc4,Config),
+ undefined = ?config(tc32,Config),
+ conf4_tc1 = ?config(tc41,Config),
+ ok.
+conf4_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf3 = ?config(cc3,Config),
+ conf4 = ?config(cc4,Config),
+ undefined = ?config(tc41,Config),
+ conf4_tc2 = ?config(tc42,Config),
+ ok.
+
+conf5_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf5 = ?config(cc5,Config),
+ undefined = ?config(tc42,Config),
+ conf5_tc1 = ?config(tc51,Config),
+ ok.
+conf5_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf5 = ?config(cc5,Config),
+ undefined = ?config(cc6,Config),
+ undefined = ?config(tc51,Config),
+ undefined = ?config(tc62,Config),
+ conf5_tc2 = ?config(tc52,Config),
+ ok.
+
+conf6_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf5 = ?config(cc5,Config),
+ conf6 = ?config(cc6,Config),
+ undefined = ?config(tc52,Config),
+ conf6_tc1 = ?config(tc61,Config),
+ ok.
+conf6_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf5 = ?config(cc5,Config),
+ conf6 = ?config(cc6,Config),
+ undefined = ?config(tc61,Config),
+ conf6_tc2 = ?config(tc62,Config),
+ ok.
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_cover_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_cover_SUITE.erl
new file mode 100644
index 0000000000..3371418980
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_cover_SUITE.erl
@@ -0,0 +1,59 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2012. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+-module(test_server_cover_SUITE).
+
+-export([all/1, init_per_suite/1, end_per_suite/1]).
+-export([init_per_testcase/2, end_per_testcase/2]).
+-export([tc1/1, tc2/1]).
+
+-include_lib("common_test/include/ct.hrl").
+
+all(suite) ->
+ [tc1,tc2].
+
+init_per_suite(Config) ->
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_testcase(_Case,Config) ->
+ Dog = ?t:timetrap({minutes,10}),
+ [{watchdog, Dog}|Config].
+
+end_per_testcase(_Case,Config) ->
+ Dog=?config(watchdog, Config),
+ ?t:timetrap_cancel(Dog),
+ ok.
+
+
+%%%-----------------------------------------------------------------
+%%% Test cases
+tc1(Config) when is_list(Config) ->
+ cover_helper:foo(),
+ ok.
+
+tc2(Config) when is_list(Config) ->
+ cover_helper:bar(),
+ ok.
+
+%%%-----------------------------------------------------------------
+%%% Internal functions
+
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_cover_SUITE_data/cover_helper.erl b/lib/common_test/test/test_server_SUITE_data/test_server_cover_SUITE_data/cover_helper.erl
new file mode 100644
index 0000000000..6c74eb4e8a
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_cover_SUITE_data/cover_helper.erl
@@ -0,0 +1,4 @@
+-module(cover_helper).
+-compile(export_all).
+foo() -> ok.
+bar() -> ok.
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_parallel01_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_parallel01_SUITE.erl
new file mode 100644
index 0000000000..ad639b585d
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_parallel01_SUITE.erl
@@ -0,0 +1,519 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2009-2011. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%%------------------------------------------------------------------
+%%% Test Server self test.
+%%%------------------------------------------------------------------
+-module(test_server_parallel01_SUITE).
+-include_lib("common_test/include/ct.hrl").
+
+-compile(export_all).
+
+%% -------------------------------------------------------------------
+%% Notes on parallel execution of test cases
+%% -------------------------------------------------------------------
+%%
+%% A group nested under a parallel group will start executing in
+%% parallel with previous (parallel) test cases (no matter what
+%% properties the nested group has). Test cases are however never
+%% executed in parallel with the start or end conf case of the same
+%% group! Because of this, the test_server_ctrl loop waits at
+%% the end conf of a group for all parallel cases to finish
+%% before the end conf case actually executes. This has the effect
+%% that it's only after a nested group has finished that any
+%% remaining parallel cases in the previous group get spawned (*).
+%% Example (all parallel cases):
+%%
+%% group1_init |---->
+%% group1_case1 | --------->
+%% group1_case2 | --------------------------------->
+%% group2_init | ---->
+%% group2_case1 | ------>
+%% group2_case2 | ---------->
+%% group2_end | --->
+%% group1_case3 (*)| ---->
+%% group1_case4 (*)| -->
+%% group1_end | --->
+%%
+
+all(doc) -> ["Test simple conf case structure, with and without nested cases"];
+all(suite) ->
+ [
+ {conf, [parallel], conf1_init, [conf1_tc1, conf1_tc2], conf1_end},
+
+ {conf, [parallel], conf2_init, [conf2_tc1, conf2_tc2], conf2_end},
+
+ {conf, [parallel], conf3_init, [conf3_tc1, conf3_tc1,
+
+ {conf, [],
+ conf4_init, [conf4_tc1, conf4_tc2], conf4_end},
+
+ conf3_tc2], conf3_end},
+
+ conf5,
+
+ {conf, [parallel], conf7_init, [conf7_tc1, conf7_tc1,
+
+ {conf, [parallel],
+ conf8_init, [conf8_tc1, conf8_tc2], conf8_end},
+
+ conf7_tc2], conf7_end}
+
+ ].
+
+
+%%---------- conf cases ----------
+
+init_per_suite(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ [{suite,init}|Config].
+end_per_suite(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ ok.
+
+init_per_testcase(TC=conf1_tc1, Config) ->
+ init = ?config(suite,Config),
+ [{tc11,TC}|Config];
+init_per_testcase(TC=conf1_tc2, Config) ->
+ [{tc12,TC}|Config];
+init_per_testcase(TC=conf2_tc1, Config) ->
+ [{tc21,TC}|Config];
+init_per_testcase(TC=conf2_tc2, Config) ->
+ [{tc22,TC}|Config];
+init_per_testcase(TC=conf3_tc1, Config) ->
+ [{tc31,TC}|Config];
+init_per_testcase(TC=conf3_tc2, Config) ->
+ [{tc32,TC}|Config];
+init_per_testcase(TC=conf4_tc1, Config) ->
+ [{tc41,TC}|Config];
+init_per_testcase(TC=conf4_tc2, Config) ->
+ [{tc42,TC}|Config];
+init_per_testcase(TC=conf5_tc1, Config) ->
+ [{tc51,TC}|Config];
+init_per_testcase(TC=conf5_tc2, Config) ->
+ [{tc52,TC}|Config];
+init_per_testcase(TC=conf6_tc1, Config) ->
+ [{tc61,TC}|Config];
+init_per_testcase(TC=conf6_tc2, Config) ->
+ init = ?config(suite,Config),
+ [{tc62,TC}|Config];
+init_per_testcase(TC=conf7_tc1, Config) ->
+ [{tc71,TC}|Config];
+init_per_testcase(TC=conf7_tc2, Config) ->
+ [{tc72,TC}|Config];
+init_per_testcase(TC=conf8_tc1, Config) ->
+ [{tc81,TC}|Config];
+init_per_testcase(TC=conf8_tc2, Config) ->
+ init = ?config(suite,Config),
+ [{tc82,TC}|Config].
+
+end_per_testcase(TC=conf1_tc1, Config) ->
+ init = ?config(suite,Config),
+ TC = ?config(tc11,Config),
+ ok;
+end_per_testcase(TC=conf1_tc2, Config) ->
+ TC = ?config(tc12,Config),
+ ok;
+end_per_testcase(TC=conf2_tc1, Config) ->
+ TC = ?config(tc21,Config),
+ ok;
+end_per_testcase(TC=conf2_tc2, Config) ->
+ TC = ?config(tc22,Config),
+ ok;
+end_per_testcase(TC=conf3_tc1, Config) ->
+ TC = ?config(tc31,Config),
+ ok;
+end_per_testcase(TC=conf3_tc2, Config) ->
+ TC = ?config(tc32,Config),
+ ok;
+end_per_testcase(TC=conf4_tc1, Config) ->
+ TC = ?config(tc41,Config),
+ ok;
+end_per_testcase(TC=conf4_tc2, Config) ->
+ TC = ?config(tc42,Config),
+ ok;
+end_per_testcase(TC=conf5_tc1, Config) ->
+ TC = ?config(tc51,Config),
+ ok;
+end_per_testcase(TC=conf5_tc2, Config) ->
+ TC = ?config(tc52,Config),
+ ok;
+end_per_testcase(TC=conf6_tc1, Config) ->
+ TC = ?config(tc61,Config),
+ ok;
+end_per_testcase(TC=conf6_tc2, Config) ->
+ init = ?config(suite,Config),
+ TC = ?config(tc62,Config),
+ ok;
+end_per_testcase(TC=conf7_tc1, Config) ->
+ TC = ?config(tc71,Config),
+ ok;
+end_per_testcase(TC=conf7_tc2, Config) ->
+ TC = ?config(tc72,Config),
+ ok;
+end_per_testcase(TC=conf8_tc1, Config) ->
+ TC = ?config(tc81,Config),
+ ok;
+end_per_testcase(TC=conf8_tc2, Config) ->
+ init = ?config(suite,Config),
+ TC = ?config(tc82,Config),
+ ok.
+
+conf1_init(Config) when is_list(Config) ->
+ test_server:comment(io_lib:format("~p",[now()])),
+ [parallel] = ?config(tc_group_properties,Config),
+ init = ?config(suite,Config),
+ [{t0,now()},{cc1,conf1}|Config].
+conf1_end(Config) ->
+ %% check 2s & 3s < 4s
+ Ms = timer:now_diff(now(),?config(t0,Config)),
+ test_server:comment(io_lib:format("~p",[now()])),
+ if Ms > 4000000 -> exit({bad_parallel_exec,Ms});
+ Ms < 3000000 -> exit({bad_parallel_exec,Ms});
+ true -> ok
+ end.
+
+conf2_init(Config) when is_list(Config) ->
+ test_server:comment(io_lib:format("~p",[now()])),
+ [parallel] = ?config(tc_group_properties,Config),
+ [{t0,now()},{cc2,conf2}|Config].
+conf2_end(Config) ->
+ %% check 3s & 2s < 4s
+ Ms = timer:now_diff(now(),?config(t0,Config)),
+ test_server:comment(io_lib:format("~p",[now()])),
+ if Ms > 4000000 -> exit({bad_parallel_exec,Ms});
+ Ms < 3000000 -> exit({bad_parallel_exec,Ms});
+ true -> ok
+ end.
+
+conf3_init(Config) when is_list(Config) ->
+ test_server:comment(io_lib:format("~p",[now()])),
+ [parallel] = ?config(tc_group_properties,Config),
+ [{t0,now()},{cc3,conf3}|Config].
+conf3_end(Config) ->
+ %% check 6s & 6s & (2s & 3s) & 1s = ~6s
+ Ms = timer:now_diff(now(),?config(t0,Config)),
+ test_server:comment(io_lib:format("~p",[now()])),
+ if Ms > 7000000 -> exit({bad_parallel_exec,Ms});
+ Ms < 6000000 -> exit({bad_parallel_exec,Ms});
+ true -> ok
+ end.
+
+conf4_init(Config) when is_list(Config) ->
+ test_server:comment(io_lib:format("~p",[now()])),
+ [] = ?config(tc_group_properties,Config),
+ [{t0,now()},{cc4,conf4}|Config].
+conf4_end(Config) ->
+ %% check 2s & 3s >= 5s
+ Ms = timer:now_diff(now(),?config(t0,Config)),
+ test_server:comment(io_lib:format("~p",[now()])),
+ if Ms > 6000000 -> exit({bad_parallel_exec,Ms});
+ Ms < 5000000 -> exit({bad_parallel_exec,Ms});
+ true -> ok
+ end.
+
+conf5_init(Config) when is_list(Config) ->
+ test_server:comment(io_lib:format("~p",[now()])),
+ [] = ?config(tc_group_properties,Config),
+ [{t0,now()},{cc5,conf5}|Config].
+conf5_end(Config) ->
+ %% check 1s & 1s & (3s & 2s) & 1s = ~6s
+ Ms = timer:now_diff(now(),?config(t0,Config)),
+ test_server:comment(io_lib:format("~p",[now()])),
+ if Ms > 7500000 -> exit({bad_parallel_exec,Ms});
+ Ms < 6000000 -> exit({bad_parallel_exec,Ms});
+ true -> ok
+ end.
+
+conf6_init(Config) when is_list(Config) ->
+ test_server:comment(io_lib:format("~p",[now()])),
+ [parallel] = ?config(tc_group_properties,Config),
+ init = ?config(suite,Config),
+ [{t0,now()},{cc6,conf6}|Config].
+conf6_end(Config) ->
+ %% check 3s & 2s < 5s
+ Ms = timer:now_diff(now(),?config(t0,Config)),
+ test_server:comment(io_lib:format("~p",[now()])),
+ if Ms > 4500000 -> exit({bad_parallel_exec,Ms});
+ Ms < 3000000 -> exit({bad_parallel_exec,Ms});
+ true -> ok
+ end.
+
+conf5(suite) -> % test specification
+ [{conf, conf5_init, [conf5_tc1, conf5_tc1,
+
+ {conf, [parallel], conf6_init, [conf6_tc1, conf6_tc2], conf6_end},
+
+ conf5_tc2], conf5_end}].
+
+conf7_init(Config) when is_list(Config) ->
+ test_server:comment(io_lib:format("~p",[now()])),
+ [parallel] = ?config(tc_group_properties,Config),
+ [{t0,now()},{cc7,conf7}|Config].
+conf7_end(Config) ->
+ %% check 1s & 1s & (2s & 2s) & 1s = ~3s
+ Ms = timer:now_diff(now(),?config(t0,Config)),
+ test_server:comment(io_lib:format("~p",[now()])),
+ if Ms > 4000000 -> exit({bad_parallel_exec,Ms});
+ Ms < 3000000 -> exit({bad_parallel_exec,Ms});
+ true -> ok
+ end.
+
+conf8_init(Config) when is_list(Config) ->
+ test_server:comment(io_lib:format("~p",[now()])),
+ [parallel] = ?config(tc_group_properties,Config),
+ init = ?config(suite,Config),
+ [{t0,now()},{cc8,conf8}|Config].
+conf8_end(Config) ->
+ %% check 2s & 2s < 4s
+ Ms = timer:now_diff(now(),?config(t0,Config)),
+ test_server:comment(io_lib:format("~p",[now()])),
+ if Ms > 3000000 -> exit({bad_parallel_exec,Ms});
+ Ms < 2000000 -> exit({bad_parallel_exec,Ms});
+ true -> ok
+ end.
+
+
+%%---------- test cases ----------
+
+conf1_tc1(Config) when is_list(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ conf1 = ?config(cc1,Config),
+ conf1_tc1 = ?config(tc11,Config),
+ timer:sleep(2000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+conf1_tc2(Config) when is_list(Config) ->
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ conf1 = ?config(cc1,Config),
+ conf1_tc2 = ?config(tc12,Config),
+ timer:sleep(3000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+
+conf2_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ undefined = ?config(cc1,Config),
+ undefined = ?config(tc11,Config),
+ conf2 = ?config(cc2,Config),
+ conf2_tc1 = ?config(tc21,Config),
+ timer:sleep(3000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+conf2_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ conf2 = ?config(cc2,Config),
+ undefined = ?config(tc21,Config),
+ conf2_tc2 = ?config(tc22,Config),
+ timer:sleep(2000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+
+conf3_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(tc22,Config),
+ conf3 = ?config(cc3,Config),
+ conf3_tc1 = ?config(tc31,Config),
+ timer:sleep(6000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+conf3_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ conf3 = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ undefined = ?config(tc31,Config),
+ undefined = ?config(tc41,Config),
+ conf3_tc2 = ?config(tc32,Config),
+ timer:sleep(1000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+
+conf4_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ conf3 = ?config(cc3,Config),
+ conf4 = ?config(cc4,Config),
+ undefined = ?config(tc32,Config),
+ conf4_tc1 = ?config(tc41,Config),
+ timer:sleep(2000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+conf4_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf3 = ?config(cc3,Config),
+ conf4 = ?config(cc4,Config),
+ undefined = ?config(tc41,Config),
+ conf4_tc2 = ?config(tc42,Config),
+ timer:sleep(3000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+
+conf5_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf5 = ?config(cc5,Config),
+ undefined = ?config(tc42,Config),
+ conf5_tc1 = ?config(tc51,Config),
+ timer:sleep(1000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+conf5_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf5 = ?config(cc5,Config),
+ undefined = ?config(cc6,Config),
+ undefined = ?config(tc51,Config),
+ undefined = ?config(tc62,Config),
+ conf5_tc2 = ?config(tc52,Config),
+ timer:sleep(1000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+
+conf6_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf5 = ?config(cc5,Config),
+ conf6 = ?config(cc6,Config),
+ undefined = ?config(tc52,Config),
+ conf6_tc1 = ?config(tc61,Config),
+ timer:sleep(3000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+conf6_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf5 = ?config(cc5,Config),
+ conf6 = ?config(cc6,Config),
+ undefined = ?config(tc61,Config),
+ conf6_tc2 = ?config(tc62,Config),
+ timer:sleep(2000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+
+conf7_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ undefined = ?config(cc5,Config),
+ undefined = ?config(cc6,Config),
+ conf7 = ?config(cc7,Config),
+ undefined = ?config(tc62,Config),
+ conf7_tc1 = ?config(tc71,Config),
+ timer:sleep(1000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+conf7_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf7 = ?config(cc7,Config),
+ undefined = ?config(cc8,Config),
+ undefined = ?config(tc71,Config),
+ undefined = ?config(tc82,Config),
+ conf7_tc2 = ?config(tc72,Config),
+ timer:sleep(1000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+
+conf8_tc1(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ undefined = ?config(cc5,Config),
+ undefined = ?config(cc6,Config),
+ conf7 = ?config(cc7,Config),
+ conf8 = ?config(cc8,Config),
+ undefined = ?config(tc72,Config),
+ conf8_tc1 = ?config(tc81,Config),
+ timer:sleep(2000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
+conf8_tc2(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf7 = ?config(cc7,Config),
+ conf8 = ?config(cc8,Config),
+ undefined = ?config(tc81,Config),
+ conf8_tc2 = ?config(tc82,Config),
+ timer:sleep(2000),
+ test_server:comment(io_lib:format("~p",[now()])),
+ ok.
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_shuffle01_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_shuffle01_SUITE.erl
new file mode 100644
index 0000000000..0f7118a810
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_shuffle01_SUITE.erl
@@ -0,0 +1,477 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2009-2011. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%%------------------------------------------------------------------
+%%% Test Server self test.
+%%%------------------------------------------------------------------
+-module(test_server_shuffle01_SUITE).
+-include_lib("common_test/include/ct.hrl").
+
+-compile(export_all).
+
+all(doc) -> ["Test simple conf case structure, with and without nested cases"];
+all(suite) ->
+ [
+ {conf, [shuffle], conf1_init, [conf1_tc1, conf1_tc2, conf1_tc3], conf1_end},
+
+ {conf, [{shuffle,{1,2,3}}], conf2_init, [conf2_tc1, conf2_tc2, conf2_tc3], conf2_end},
+
+ {conf, [shuffle], conf3_init, [conf3_tc1, conf3_tc2, conf3_tc3,
+
+ {conf, [], conf4_init,
+ [conf4_tc1, conf4_tc2], conf4_end}],
+ conf3_end},
+
+ conf5,
+
+ {conf, [shuffle,{repeat,5},parallel], conf7_init, [conf7_tc1,
+
+ {conf, [{shuffle,{3,2,1}},{repeat,3}],
+ conf8_init, [conf8_tc1, conf8_tc2, conf8_tc3],
+ conf8_end},
+
+ conf7_tc2, conf7_tc3], conf7_end}
+
+ ].
+
+
+%%---------- conf cases ----------
+
+init_per_suite(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ [{suite,init}|Config].
+end_per_suite(Config) ->
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ ok.
+
+init_per_testcase(TC=conf1_tc1, Config) ->
+ init = ?config(suite,Config),
+ [{tc11,TC}|Config];
+init_per_testcase(TC=conf1_tc2, Config) ->
+ [{tc12,TC}|Config];
+init_per_testcase(TC=conf1_tc3, Config) ->
+ [{tc13,TC}|Config];
+init_per_testcase(TC=conf2_tc1, Config) ->
+ [{tc21,TC}|Config];
+init_per_testcase(TC=conf2_tc2, Config) ->
+ [{tc22,TC}|Config];
+init_per_testcase(TC=conf2_tc3, Config) ->
+ [{tc23,TC}|Config];
+init_per_testcase(TC=conf3_tc1, Config) ->
+ [{tc31,TC}|Config];
+init_per_testcase(TC=conf3_tc2, Config) ->
+ [{tc32,TC}|Config];
+init_per_testcase(TC=conf3_tc3, Config) ->
+ [{tc33,TC}|Config];
+init_per_testcase(TC=conf4_tc1, Config) ->
+ [{tc41,TC}|Config];
+init_per_testcase(TC=conf4_tc2, Config) ->
+ [{tc42,TC}|Config];
+init_per_testcase(TC=conf5_tc1, Config) ->
+ [{tc51,TC}|Config];
+init_per_testcase(TC=conf5_tc2, Config) ->
+ [{tc52,TC}|Config];
+init_per_testcase(TC=conf6_tc1, Config) ->
+ [{tc61,TC}|Config];
+init_per_testcase(TC=conf6_tc2, Config) ->
+ init = ?config(suite,Config),
+ [{tc62,TC}|Config];
+init_per_testcase(TC=conf6_tc3, Config) ->
+ [{tc63,TC}|Config];
+init_per_testcase(TC=conf7_tc1, Config) ->
+ [{tc71,TC}|Config];
+init_per_testcase(TC=conf7_tc2, Config) ->
+ [{tc72,TC}|Config];
+init_per_testcase(TC=conf7_tc3, Config) ->
+ [{tc73,TC}|Config];
+init_per_testcase(TC=conf8_tc1, Config) ->
+ [{tc81,TC}|Config];
+init_per_testcase(TC=conf8_tc2, Config) ->
+ init = ?config(suite,Config),
+ [{tc82,TC}|Config];
+init_per_testcase(TC=conf8_tc3, Config) ->
+ [{tc83,TC}|Config].
+
+end_per_testcase(TC=conf1_tc1, Config) ->
+ init = ?config(suite,Config),
+ TC = ?config(tc11,Config),
+ ok;
+end_per_testcase(TC=conf1_tc2, Config) ->
+ TC = ?config(tc12,Config),
+ ok;
+end_per_testcase(TC=conf1_tc3, Config) ->
+ TC = ?config(tc13,Config),
+ ok;
+end_per_testcase(TC=conf2_tc1, Config) ->
+ TC = ?config(tc21,Config),
+ ok;
+end_per_testcase(TC=conf2_tc2, Config) ->
+ TC = ?config(tc22,Config),
+ ok;
+end_per_testcase(TC=conf2_tc3, Config) ->
+ TC = ?config(tc23,Config),
+ ok;
+end_per_testcase(TC=conf3_tc1, Config) ->
+ TC = ?config(tc31,Config),
+ ok;
+end_per_testcase(TC=conf3_tc2, Config) ->
+ TC = ?config(tc32,Config),
+ ok;
+end_per_testcase(TC=conf3_tc3, Config) ->
+ TC = ?config(tc33,Config),
+ ok;
+end_per_testcase(TC=conf4_tc1, Config) ->
+ TC = ?config(tc41,Config),
+ ok;
+end_per_testcase(TC=conf4_tc2, Config) ->
+ TC = ?config(tc42,Config),
+ ok;
+end_per_testcase(TC=conf5_tc1, Config) ->
+ TC = ?config(tc51,Config),
+ ok;
+end_per_testcase(TC=conf5_tc2, Config) ->
+ TC = ?config(tc52,Config),
+ ok;
+end_per_testcase(TC=conf6_tc1, Config) ->
+ TC = ?config(tc61,Config),
+ ok;
+end_per_testcase(TC=conf6_tc2, Config) ->
+ init = ?config(suite,Config),
+ TC = ?config(tc62,Config),
+ ok;
+end_per_testcase(TC=conf6_tc3, Config) ->
+ TC = ?config(tc63,Config),
+ ok;
+end_per_testcase(TC=conf7_tc1, Config) ->
+ TC = ?config(tc71,Config),
+ ok;
+end_per_testcase(TC=conf7_tc2, Config) ->
+ TC = ?config(tc72,Config),
+ ok;
+end_per_testcase(TC=conf7_tc3, Config) ->
+ TC = ?config(tc73,Config),
+ ok;
+end_per_testcase(TC=conf8_tc1, Config) ->
+ TC = ?config(tc81,Config),
+ ok;
+end_per_testcase(TC=conf8_tc2, Config) ->
+ init = ?config(suite,Config),
+ TC = ?config(tc82,Config),
+ ok;
+end_per_testcase(TC=conf8_tc3, Config) ->
+ TC = ?config(tc83,Config),
+ ok.
+
+
+conf1_init(Config) when is_list(Config) ->
+ init = ?config(suite,Config),
+ [{shuffle,{_,_,_}}] = ?config(tc_group_properties,Config),
+ test_server:comment("Shuffle (random seed)"),
+ [{cc1,conf1}|Config].
+conf1_end(_Config) ->
+ ok.
+
+conf2_init(Config) when is_list(Config) ->
+ [{shuffle,{1,2,3}}] = ?config(tc_group_properties,Config),
+ test_server:comment("Shuffle (user seed)"),
+ [{cc2,conf2}|Config].
+conf2_end(_Config) ->
+ ok.
+
+conf3_init(Config) when is_list(Config) ->
+ [{shuffle,{_,_,_}}] = ?config(tc_group_properties,Config),
+ test_server:comment("Shuffle (random)"),
+ [{cc3,conf3}|Config].
+conf3_end(_Config) ->
+ ok.
+
+conf4_init(Config) when is_list(Config) ->
+ [] = ?config(tc_group_properties,Config),
+ test_server:comment("No shuffle"),
+ [{cc4,conf4}|Config].
+conf4_end(_Config) ->
+ ok.
+
+conf5_init(Config) when is_list(Config) ->
+ [] = ?config(tc_group_properties,Config),
+ test_server:comment("No shuffle"),
+ [{cc5,conf5}|Config].
+conf5_end(_Config) ->
+ ok.
+
+conf6_init(Config) when is_list(Config) ->
+ validate_shuffle(Config),
+ test_server:comment("Shuffle (random)"),
+ init = ?config(suite,Config),
+ [{cc6,conf6}|Config].
+conf6_end(_Config) ->
+ ok.
+
+conf5(suite) -> % test specification
+ [{conf, conf5_init, [conf5_tc1,
+
+ {conf, [shuffle], conf6_init,
+ [conf6_tc1, conf6_tc2, conf6_tc3],
+ conf6_end},
+
+ conf5_tc2], conf5_end}].
+
+conf7_init(Config) when is_list(Config) ->
+ test_server:comment("Group 7, Shuffle (random seed)"),
+ validate_shuffle(Config),
+ [{cc7,conf7}|Config].
+conf7_end(_Config) ->
+ ok.
+
+conf8_init(Config) when is_list(Config) ->
+ test_server:comment("Group 8, Shuffle (user start seed)"),
+ validate_shuffle(Config),
+ init = ?config(suite,Config),
+ [{cc8,conf8}|Config].
+conf8_end(_Config) ->
+ ok.
+
+validate_shuffle(Config) ->
+ case proplists:get_value(shuffle, ?config(tc_group_properties,Config)) of
+ {_,_,_} ->
+ ok;
+ Seed ->
+ %% Must be a valid seed.
+ _ = rand:seed_s(rand:export_seed_s(Seed))
+ end.
+
+
+%%---------- test cases ----------
+
+conf1_tc1(Config) when is_list(Config) ->
+ test_server:comment("Case 1"),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ conf1 = ?config(cc1,Config),
+ conf1_tc1 = ?config(tc11,Config),
+ ok.
+conf1_tc2(Config) when is_list(Config) ->
+ test_server:comment("Case 2"),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ init = ?config(suite,Config),
+ conf1 = ?config(cc1,Config),
+ conf1_tc2 = ?config(tc12,Config),
+ ok.
+conf1_tc3(suite) -> [];
+conf1_tc3(_Config) ->
+ test_server:comment("Case 3"),
+ ok.
+
+conf2_tc1(Config) when is_list(Config) ->
+ test_server:comment("Case 1"),
+ init = ?config(suite,Config),
+ undefined = ?config(cc1,Config),
+ conf2 = ?config(cc2,Config),
+ conf2_tc1 = ?config(tc21,Config),
+ ok.
+conf2_tc2(Config) when is_list(Config) ->
+ test_server:comment("Case 2"),
+ init = ?config(suite,Config),
+ conf2 = ?config(cc2,Config),
+ conf2_tc2 = ?config(tc22,Config),
+ ok.
+conf2_tc3(suite) -> [];
+conf2_tc3(_Config) ->
+ test_server:comment("Case 3"),
+ ok.
+
+conf3_tc1(Config) when is_list(Config) ->
+ test_server:comment("Case 1"),
+ init = ?config(suite,Config),
+ undefined = ?config(cc2,Config),
+ conf3 = ?config(cc3,Config),
+ conf3_tc1 = ?config(tc31,Config),
+ ok.
+conf3_tc2(Config) when is_list(Config) ->
+ test_server:comment("Case 2"),
+ init = ?config(suite,Config),
+ conf3 = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf3_tc2 = ?config(tc32,Config),
+ ok.
+conf3_tc3(suite) -> [];
+conf3_tc3(_Config) ->
+ test_server:comment("Case 3"),
+ ok.
+
+conf4_tc1(Config) when is_list(Config) ->
+ test_server:comment("Case 1"),
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ conf3 = ?config(cc3,Config),
+ conf4 = ?config(cc4,Config),
+ conf4_tc1 = ?config(tc41,Config),
+ ok.
+conf4_tc2(Config) when is_list(Config) ->
+ test_server:comment("Case 2"),
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf3 = ?config(cc3,Config),
+ conf4 = ?config(cc4,Config),
+ conf4_tc2 = ?config(tc42,Config),
+ ok.
+
+conf5_tc1(Config) when is_list(Config) ->
+ test_server:comment("Case 1"),
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf5 = ?config(cc5,Config),
+ conf5_tc1 = ?config(tc51,Config),
+ ok.
+conf5_tc2(Config) when is_list(Config) ->
+ test_server:comment("Case 2"),
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf5 = ?config(cc5,Config),
+ undefined = ?config(cc6,Config),
+ conf5_tc2 = ?config(tc52,Config),
+ ok.
+
+conf6_tc1(Config) when is_list(Config) ->
+ test_server:comment("Case 1"),
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ conf5 = ?config(cc5,Config),
+ conf6 = ?config(cc6,Config),
+ conf6_tc1 = ?config(tc61,Config),
+ ok.
+conf6_tc2(Config) when is_list(Config) ->
+ test_server:comment("Case 2"),
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf5 = ?config(cc5,Config),
+ conf6 = ?config(cc6,Config),
+ conf6_tc2 = ?config(tc62,Config),
+ ok.
+conf6_tc3(suite) -> [];
+conf6_tc3(_Config) ->
+ test_server:comment("Case 3"),
+ ok.
+
+conf7_tc1(Config) when is_list(Config) ->
+ test_server:comment("Case 1"),
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ undefined = ?config(cc5,Config),
+ undefined = ?config(cc6,Config),
+ conf7 = ?config(cc7,Config),
+ conf7_tc1 = ?config(tc71,Config),
+ ok.
+conf7_tc2(Config) when is_list(Config) ->
+ test_server:comment("Case 2"),
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf7 = ?config(cc7,Config),
+ undefined = ?config(cc8,Config),
+ conf7_tc2 = ?config(tc72,Config),
+ ok.
+conf7_tc3(suite) -> [];
+conf7_tc3(_Config) ->
+ test_server:comment("Case 3"),
+ ok.
+
+conf8_tc1(Config) when is_list(Config) ->
+ test_server:comment("Case 1"),
+ init = ?config(suite,Config),
+ case ?config(data_dir,Config) of
+ undefined -> exit(no_data_dir);
+ _ -> ok
+ end,
+ undefined = ?config(cc1,Config),
+ undefined = ?config(cc2,Config),
+ undefined = ?config(cc3,Config),
+ undefined = ?config(cc4,Config),
+ undefined = ?config(cc5,Config),
+ undefined = ?config(cc6,Config),
+ conf7 = ?config(cc7,Config),
+ conf8 = ?config(cc8,Config),
+ conf8_tc1 = ?config(tc81,Config),
+ ok.
+conf8_tc2(Config) when is_list(Config) ->
+ test_server:comment("Case 2"),
+ init = ?config(suite,Config),
+ case ?config(priv_dir,Config) of
+ undefined -> exit(no_priv_dir);
+ _ -> ok
+ end,
+ conf7 = ?config(cc7,Config),
+ conf8 = ?config(cc8,Config),
+ conf8_tc2 = ?config(tc82,Config),
+ ok.
+conf8_tc3(suite) -> [];
+conf8_tc3(_Config) ->
+ test_server:comment("Case 3"),
+ ok.
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_skip_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_skip_SUITE.erl
new file mode 100644
index 0000000000..ae2321c6ad
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_skip_SUITE.erl
@@ -0,0 +1,43 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2004-2011. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+-module(test_server_skip_SUITE).
+
+-export([all/1, init_per_suite/1, end_per_suite/1]).
+-export([dummy/1]).
+
+-include_lib("common_test/include/ct.hrl").
+
+all(suite) ->
+ [dummy].
+
+init_per_suite(Config) when is_list(Config) ->
+ {skip,"Skipping init_per_suite - check that \'dummy\' and"
+ " \'end_per_suite\' are also skipped"}.
+
+dummy(suite) -> [];
+dummy(doc) -> ["This testcase should never be executed"];
+dummy(Config) when is_list(Config) ->
+ ?t:fail("This testcase should be executed since"
+ " init_per_suite/1 is skipped").
+
+end_per_suite(doc) -> ["This testcase should never be executed"];
+end_per_suite(Config) when is_list(Config) ->
+ ?t:fail("end_per_suite/1 should not be executed when"
+ " init_per_suite/1 is skipped").
diff --git a/lib/common_test/test/test_server_SUITE_data/test_server_unicode_SUITE.erl b/lib/common_test/test/test_server_SUITE_data/test_server_unicode_SUITE.erl
new file mode 100644
index 0000000000..0cabce995f
--- /dev/null
+++ b/lib/common_test/test/test_server_SUITE_data/test_server_unicode_SUITE.erl
@@ -0,0 +1,82 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2013. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+-module(test_server_unicode_SUITE).
+
+-export([all/1, init_per_suite/1, end_per_suite/1]).
+-export([init_per_testcase/2, end_per_testcase/2]).
+-export(['#=@: difficult_case_name_äöå'/1,
+ print_and_log_unicode/1,
+ print_and_log_latin1/1]).
+
+-include_lib("common_test/include/ct.hrl").
+
+all(suite) ->
+ ['#=@: difficult_case_name_äöå',
+ print_and_log_unicode,
+ print_and_log_latin1].
+
+init_per_suite(Config) ->
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_testcase(_Case,Config) ->
+ init_timetrap(500,Config).
+
+init_timetrap(T,Config) ->
+ Dog = ?t:timetrap(T),
+ [{watchdog, Dog}|Config].
+
+end_per_testcase(_Case,Config) ->
+ cancel_timetrap(Config).
+
+cancel_timetrap(Config) ->
+ Dog=?config(watchdog, Config),
+ ?t:timetrap_cancel(Dog),
+ ok.
+
+
+%%%-----------------------------------------------------------------
+%%% Test cases
+
+'#=@: difficult_case_name_äöå'(Config) when is_list(Config) ->
+ ok.
+
+print_and_log_unicode(Config) when is_list(Config) ->
+ String = "שלום-שלום+של 日本語",
+ test_server:comment(String),
+ test_server:capture_start(),
+ io:format("String with ts: ~ts",[String]),
+ test_server:capture_stop(),
+ "String with ts: "++String = lists:flatten(test_server:capture_get()),
+ ok.
+
+print_and_log_latin1(Config) when is_list(Config) ->
+ String = "æøå",
+ test_server:comment(String),
+ test_server:capture_start(),
+ io:format("String with s: ~s",[String]),
+ io:format("String with ts: ~ts",[String]),
+ test_server:capture_stop(),
+ ["String with s: "++String,
+ "String with ts: "++String] =
+ [lists:flatten(L) || L<- test_server:capture_get()],
+ ok.
diff --git a/lib/common_test/test/test_server_test_lib.erl b/lib/common_test/test/test_server_test_lib.erl
new file mode 100644
index 0000000000..e2680938e0
--- /dev/null
+++ b/lib/common_test/test/test_server_test_lib.erl
@@ -0,0 +1,217 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2009-2013. 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.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+-module(test_server_test_lib).
+
+-export([parse_suite/1]).
+-export([init/2, pre_init_per_testcase/3, post_end_per_testcase/4]).
+
+%% for test_server_SUITE when node can not be started as slave
+-export([prepare_tester_node/2]).
+
+-include("test_server_test_lib.hrl").
+
+%% The CTH hooks all tests
+init(_Id, _Opts) ->
+ [].
+
+pre_init_per_testcase(_TC,Config,State) ->
+ case os:type() of
+ {win32, _} ->
+ %% Extend timeout for windows as starting node
+ %% can take a long time there
+ test_server:timetrap( 120000 * test_server:timetrap_scale_factor());
+ _ ->
+ ok
+ end,
+ {start_slave(Config, 50),State}.
+
+start_slave(Config,_Level) ->
+ [_,Host] = string:tokens(atom_to_list(node()), "@"),
+
+ ct:log("Trying to start ~s~n",
+ ["test_server_tester@"++Host]),
+ case slave:start(Host, test_server_tester, []) of
+ {error,Reason} ->
+ test_server:fail(Reason);
+ {ok,Node} ->
+ ct:log("Node ~p started~n", [Node]),
+ IsCover = test_server:is_cover(),
+ if IsCover ->
+ cover:start(Node);
+ true->
+ ok
+ end,
+ prepare_tester_node(Node,Config)
+ end.
+
+prepare_tester_node(Node,Config) ->
+ DataDir = proplists:get_value(data_dir, Config),
+ %% We would normally use priv_dir for temporary data,
+ %% but the pathnames gets too long on Windows.
+ %% Until the run-time system can support long pathnames,
+ %% use the data dir.
+ WorkDir = DataDir,
+
+ %% WorkDir as well as directory of Test Server suites
+ %% have to be in code path on Test Server node.
+ [_ | Parts] = lists:reverse(filename:split(DataDir)),
+ TSDir = filename:join(lists:reverse(Parts)),
+ AddPathDirs = case proplists:get_value(path_dirs, Config) of
+ undefined -> [];
+ Ds -> Ds
+ end,
+ PathDirs = [WorkDir,TSDir | AddPathDirs],
+ [true = rpc:call(Node, code, add_patha, [D]) || D <- PathDirs],
+ io:format("Dirs added to code path (on ~w):~n",
+ [Node]),
+ [io:format("~s~n", [D]) || D <- PathDirs],
+
+ true = rpc:call(Node, os, putenv,
+ ["TEST_SERVER_FRAMEWORK", "undefined"]),
+
+ ok = rpc:call(Node, file, set_cwd, [WorkDir]),
+ [{node,Node}, {work_dir,WorkDir} | Config].
+
+post_end_per_testcase(_TC, Config, Return, State) ->
+ Node = proplists:get_value(node, Config),
+ Cover = test_server:is_cover(),
+ if Cover-> cover:flush(Node);
+ true -> ok
+ end,
+ erlang:monitor_node(Node, true),
+ slave:stop(Node),
+ receive
+ {nodedown, Node} ->
+ if Cover -> cover:stop(Node);
+ true -> ok
+ end
+ after 5000 ->
+ erlang:monitor_node(Node, false),
+ receive {nodedown, Node} -> ok after 0 -> ok end %flush
+ end,
+ {Return, State}.
+
+%% Parse an .suite log file
+parse_suite(FileName) ->
+
+ case file:open(FileName, [read, raw, read_ahead]) of
+ {ok, Fd} ->
+ Data = parse_suite(Fd, #suite{ }),
+ file:close(Fd),
+ {ok, Data};
+ _ ->
+ error
+ end.
+
+fline(Fd) ->
+ case prim_file:read_line(Fd) of
+ eof -> eof;
+ {ok, Line} -> Line
+ end.
+
+parse_suite(Fd, S) ->
+ _Started = fline(Fd),
+ _Starting = fline(Fd),
+ "=cases" ++ NCases = fline(Fd),
+ "=user" ++ _User = fline(Fd),
+ "=host" ++ Host = fline(Fd),
+ "=hosts" ++ _Hosts = fline(Fd),
+ "=emulator_vsn" ++ Evsn = fline(Fd),
+ "=emulator" ++ Emu = fline(Fd),
+ "=otp_release" ++ OtpRel = fline(Fd),
+ "=started" ++ Start = fline(Fd),
+ NewS = parse_cases(Fd, S#suite{
+ n_cases_expected = list_to_int(clean(NCases)),
+ host = list_to_binary(clean(Host)),
+ emulator_vsn = list_to_binary(clean(Evsn)),
+ emulator = list_to_binary(clean(Emu)),
+ otp_release = list_to_binary(clean(OtpRel)),
+ started = list_to_binary(clean(Start))
+ }),
+ "=failed" ++ Failed = fline(Fd),
+ "=successful" ++ Succ = fline(Fd),
+ "=user_skipped" ++ UsrSkip = fline(Fd),
+ "=auto_skipped" ++ AutSkip = fline(Fd),
+ NewS#suite{ n_cases_failed = list_to_int(clean(Failed)),
+ n_cases_succ = list_to_int(clean(Succ)),
+ n_cases_user_skip = list_to_int(clean(UsrSkip)),
+ n_cases_auto_skip = list_to_int(clean(AutSkip)) }.
+
+
+parse_cases(Fd, #suite{ n_cases = N,
+ cases = Cases } = S) ->
+ case parse_case(Fd) of
+ finished -> S#suite{ log_ok = true };
+ {eof, Tc} ->
+ S#suite{ n_cases = N + 1,
+ cases = [Tc#tc{ result = crashed }|Cases]};
+ {ok, Case} ->
+ parse_cases(Fd, S#suite{ n_cases = N + 1,
+ cases = [Case|Cases]})
+ end.
+
+parse_case(Fd) -> parse_case(Fd, #tc{}).
+parse_case(Fd, Tc) -> parse_case(fline(Fd), Fd, Tc).
+
+parse_case(eof, _, Tc) -> {eof, Tc};
+parse_case("=case" ++ Case, Fd, Tc) ->
+ Name = list_to_binary(clean(Case)),
+ parse_case(fline(Fd), Fd, Tc#tc{ name = Name });
+parse_case("=logfile" ++ File, Fd, Tc) ->
+ Log = list_to_binary(clean(File)),
+ parse_case(fline(Fd), Fd, Tc#tc{ logfile = Log });
+parse_case("=elapsed" ++ Elapsed, Fd, Tc) ->
+ {ok, [Time], _} = io_lib:fread("~f", clean(Elapsed)),
+ parse_case(fline(Fd), Fd, Tc#tc{ elapsed = Time });
+parse_case("=result" ++ Result, _, Tc) ->
+ case clean(Result) of
+ "ok" ++ _ ->
+ {ok, Tc#tc{ result = ok } };
+ "failed" ++ _ ->
+ {ok, Tc#tc{ result = failed } };
+ "skipped" ++ _ ->
+ {ok, Tc#tc{ result = skip } };
+ "auto_skipped" ++ _ ->
+ {ok, Tc#tc{ result = auto_skip } }
+ end;
+parse_case("=finished" ++ _ , _Fd, #tc{ name = undefined }) ->
+ finished;
+parse_case(_, Fd, Tc) ->
+ parse_case(fline(Fd), Fd, Tc).
+
+skip([]) -> [];
+skip([$ |Ts]) -> skip(Ts);
+skip(Ts) -> Ts.
+
+%rmnl(L) -> L.
+rmnl([]) -> [];
+rmnl([$\n | Ts]) -> rmnl(Ts);
+rmnl([T|Ts]) -> [T | rmnl(Ts)].
+
+clean(L) ->
+ rmnl(skip(L)).
+
+list_to_int(L) ->
+ try
+ list_to_integer(L)
+ catch
+ _:_ ->
+ 0
+ end.
diff --git a/lib/common_test/test/test_server_test_lib.hrl b/lib/common_test/test/test_server_test_lib.hrl
new file mode 100644
index 0000000000..27b7be9618
--- /dev/null
+++ b/lib/common_test/test/test_server_test_lib.hrl
@@ -0,0 +1,23 @@
+-record(tc, {
+ name,
+ result,
+ elapsed,
+ logfile
+ }).
+
+-record(suite, {
+ application,
+ n_cases = 0,
+ n_cases_failed = 0,
+ n_cases_expected = 0,
+ n_cases_succ,
+ n_cases_user_skip,
+ n_cases_auto_skip,
+ cases = [],
+ host,
+ emulator_vsn,
+ emulator,
+ otp_release,
+ started,
+ log_ok = false
+ }).