aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2014-01-22 16:19:00 +0100
committerPeter Andersson <[email protected]>2014-01-27 19:38:10 +0100
commitda730dc3f7a6e46c0341146a69871934d07120e0 (patch)
treef2f1f1f22ff32dfbe85d95966f810fd50578825a /lib
parent584f9ec69fea19e1fed4a37699cb83e0d3c9bf94 (diff)
downloadotp-da730dc3f7a6e46c0341146a69871934d07120e0.tar.gz
otp-da730dc3f7a6e46c0341146a69871934d07120e0.tar.bz2
otp-da730dc3f7a6e46c0341146a69871934d07120e0.zip
Add and improve test cases
Also correct some issues found during test
Diffstat (limited to 'lib')
-rw-r--r--lib/common_test/src/ct_conn_log_h.erl9
-rw-r--r--lib/common_test/test/ct_telnet_SUITE.erl93
-rw-r--r--lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_basic_SUITE.erl37
-rw-r--r--lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl50
-rw-r--r--lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl2
5 files changed, 118 insertions, 73 deletions
diff --git a/lib/common_test/src/ct_conn_log_h.erl b/lib/common_test/src/ct_conn_log_h.erl
index 550f62f4c1..286844d526 100644
--- a/lib/common_test/src/ct_conn_log_h.erl
+++ b/lib/common_test/src/ct_conn_log_h.erl
@@ -200,8 +200,13 @@ pretty_head({{{Y,Mo,D},{H,Mi,S}},MicroS},ConnMod,Text0) ->
micro2milli(MicroS)]).
pretty_title(#conn_log{client=Client}=Info) ->
- io_lib:format("= Client ~w ~s Server ~ts ",
- [Client,actionstr(Info),serverstr(Info)]).
+ case actionstr(Info) of
+ {no_server,Action} ->
+ io_lib:format("= Client ~w ~s ",[Client,Action]);
+ Action ->
+ io_lib:format("= Client ~w ~s ~ts ",[Client,Action,
+ serverstr(Info)])
+ end.
actionstr(#conn_log{action=send}) -> "----->";
actionstr(#conn_log{action=cmd}) -> "----->";
diff --git a/lib/common_test/test/ct_telnet_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE.erl
index e2ee207754..1536d093a6 100644
--- a/lib/common_test/test/ct_telnet_SUITE.erl
+++ b/lib/common_test/test/ct_telnet_SUITE.erl
@@ -46,6 +46,26 @@
%% instance, the tests need to be performed on a separate node (or
%% there will be clashes with logging processes etc).
%%--------------------------------------------------------------------
+suite() -> [{ct_hooks,[ts_install_cth]}].
+
+groups() ->
+ [{legacy, [], [unix_telnet,own_server,timetrap]},
+ {raw, [], [unix_telnet,own_server]},
+ {html, [], [unix_telnet,own_server]},
+ {silent, [], [unix_telnet,own_server]}].
+
+all() ->
+ [
+ {group,legacy},
+ {group,raw},
+ {group,html},
+ {group,silent}
+ ].
+
+%%--------------------------------------------------------------------
+%% CONFIG FUNCTIONS
+%%--------------------------------------------------------------------
+
init_per_suite(Config) ->
ct_test_support:init_per_suite(Config).
@@ -67,14 +87,6 @@ end_per_testcase(TestCase, Config) ->
end,
ct_test_support:end_per_testcase(TestCase, Config).
-suite() -> [{ct_hooks,[ts_install_cth]}].
-
-all() ->
- [
- unix_telnet,
- own_server,
- timetrap
- ].
%%--------------------------------------------------------------------
%% TEST CASES
@@ -82,27 +94,43 @@ all() ->
%%%-----------------------------------------------------------------
%%%
-unix_telnet(Config) when is_list(Config) ->
- all_tests_in_suite(unix_telnet,"ct_telnet_basic_SUITE","telnet.cfg",Config).
+unix_telnet(Config) ->
+ CfgFile = "telnet.unix_telnet." ++
+ atom_to_list(groupname(Config)) ++ ".cfg",
+ all_tests_in_suite(unix_telnet,"ct_telnet_basic_SUITE",CfgFile,Config).
own_server(Config) ->
+ CfgFile = "telnet.own_server." ++
+ atom_to_list(groupname(Config)) ++ ".cfg",
all_tests_in_suite(own_server,"ct_telnet_own_server_SUITE",
- "telnet2.cfg",Config).
+ CfgFile,Config).
timetrap(Config) ->
+ CfgFile = "telnet.timetrap." ++
+ atom_to_list(groupname(Config)) ++ ".cfg",
all_tests_in_suite(timetrap,"ct_telnet_timetrap_SUITE",
- "telnet3.cfg",Config).
+ CfgFile,Config).
%%%-----------------------------------------------------------------
%%% HELP FUNCTIONS
%%%-----------------------------------------------------------------
+groupname(Config) ->
+ case proplists:get_value(tc_group_properties, Config) of
+ undefined ->
+ undefined;
+ TGP ->
+ proplists:get_value(name, TGP)
+ end.
+
all_tests_in_suite(TestCase, SuiteName, CfgFileName, Config) ->
+ PrivDir = ?config(priv_dir, Config),
DataDir = ?config(data_dir, Config),
Suite = filename:join(DataDir, SuiteName),
- CfgFile = filename:join(DataDir, CfgFileName),
- Cfg = telnet_config(TestCase),
- ok = file:write_file(CfgFile, io_lib:write(Cfg) ++ "."),
+ CfgFile = filename:join(PrivDir, CfgFileName),
+ Cfg = telnet_config(TestCase, groupname(Config)),
+ Txt = lists:flatten([lists:flatten(io_lib:write(C))++".\n" || C <- Cfg]),
+ ok = file:write_file(CfgFile, Txt),
{Opts,ERPid} = setup([{suite,Suite},
{label,TestCase},
{config,CfgFile}],
@@ -132,15 +160,32 @@ execute(Name, Opts, ERPid, Config) ->
reformat(Events, EH) ->
ct_test_support:reformat(Events, EH).
-
-telnet_config(unix_telnet) ->
- {unix, ct:get_config(unix)};
-telnet_config(_) ->
- {unix,[{telnet,"localhost"},
- {port, ?erl_telnet_server_port},
- {username,?erl_telnet_server_user},
- {password,?erl_telnet_server_pwd},
- {keep_alive,true}]}.
+telnet_config(_, undefined) ->
+ [];
+telnet_config(unix_telnet, legacy) ->
+ [{unix, ct:get_config(unix)},
+ {ct_conn_log,[]}];
+%% LogType same as GroupName
+telnet_config(unix_telnet, LogType) ->
+ [{unix, ct:get_config(unix)},
+ {ct_conn_log,
+ [{ct_telnet,[{log_type,LogType},
+ {hosts,[the_telnet_server]}]
+ }]}];
+telnet_config(_, LogType) ->
+ [{unix,[{telnet,"localhost"},
+ {port, ?erl_telnet_server_port},
+ {username,?erl_telnet_server_user},
+ {password,?erl_telnet_server_pwd},
+ {keep_alive,true}]} |
+ if LogType == legacy ->
+ [{ct_conn_log,[]}];
+ true ->
+ [{ct_conn_log,
+ [{ct_telnet,[{log_type,LogType},
+ {hosts,[the_telnet_server]}]
+ }]}]
+ end].
%%%-----------------------------------------------------------------
%%% TEST EVENTS
diff --git a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_basic_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_basic_SUITE.erl
index da0c594eda..203062eba0 100644
--- a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_basic_SUITE.erl
+++ b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_basic_SUITE.erl
@@ -9,21 +9,10 @@
%% TEST SERVER CALLBACK FUNCTIONS
%%--------------------------------------------------------------------
-init_per_suite(Config) ->
- Config.
-
-end_per_suite(_Config) ->
- ok.
-
-
suite() -> [
- {require,telnet_temp,{unix,[telnet]}}
-
-%% ,
-%% {ct_hooks, [{cth_conn_log,
-%% [{ct_telnet,[{log_type,raw},
-%% {hosts,[telnet_temp]}]
-%% }] }] }
+ {require,the_telnet_server,{unix,[telnet]}},
+ {require,ct_conn_log},
+ {ct_hooks, [{cth_conn_log,[]}]}
].
all() ->
@@ -33,6 +22,14 @@ all() ->
groups() ->
[].
+init_per_suite(Config) ->
+ ct:pal("Will use these log hook options: ~p",
+ [ct:get_config(ct_conn_log,[])]),
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
init_per_group(_GroupName, Config) ->
Config.
@@ -40,18 +37,18 @@ end_per_group(_GroupName, Config) ->
Config.
start_stop(_Config) ->
- {ok, Handle} = ct_telnet:open(telnet_temp),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:close(Handle),
ok.
send_and_get(_) ->
- {ok, Handle} = ct_telnet:open(telnet_temp),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "ayt"),
{ok, _Data} = ct_telnet:get_data(Handle),
ok = ct_telnet:close(Handle),
ok.
expect(_) ->
- {ok, Handle} = ct_telnet:open(telnet_temp),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo ayt"),
ok = case ct_telnet:expect(Handle, ["ayt"]) of
{ok, _} ->
@@ -63,20 +60,20 @@ expect(_) ->
ok.
already_closed(_) ->
- {ok, Handle} = ct_telnet:open(telnet_temp),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:close(Handle),
{error, already_closed} = ct_telnet:close(Handle),
ok.
cmd(_) ->
- {ok, Handle} = ct_telnet:open(telnet_temp),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
{ok, _} = ct_telnet:cmd(Handle, "display"),
{ok, _} = ct_telnet:cmdf(Handle, "~s ~s", ["set", "bsasdel"]),
ok = ct_telnet:close(Handle),
ok.
sendf(_) ->
- {ok, Handle} = ct_telnet:open(telnet_temp),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:sendf(Handle, "~s", ["ayt"]),
ok = ct_telnet:close(Handle),
ok.
diff --git a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
index ec2dd5db8b..c5589eddc8 100644
--- a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
+++ b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
@@ -8,21 +8,11 @@
%% TEST SERVER CALLBACK FUNCTIONS
%%--------------------------------------------------------------------
-init_per_suite(Config) ->
- Config.
-
-end_per_suite(_Config) ->
- ok.
-
-
suite() ->
[
- {require,erl_telnet_server,{unix,[telnet]}},
-
- {ct_hooks, [{cth_conn_log,
- [{ct_telnet,[{log_type,raw},
- {hosts,[erl_telnet_server]}]
- }] }] }
+ {require,the_telnet_server,{unix,[telnet]}},
+ {require,ct_conn_log},
+ {ct_hooks, [{cth_conn_log,[]}]}
].
all() ->
@@ -43,6 +33,14 @@ all() ->
groups() ->
[].
+init_per_suite(Config) ->
+ ct:pal("Will use these log hook options: ~p",
+ [ct:get_config(ct_conn_log,[])]),
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
init_per_group(_GroupName, Config) ->
Config.
@@ -51,7 +49,7 @@ end_per_group(_GroupName, Config) ->
%% Simple expect
expect(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo ayt"),
{ok,["ayt"]} = ct_telnet:expect(Handle, ["ayt"]),
ok = ct_telnet:close(Handle),
@@ -59,7 +57,7 @@ expect(_) ->
%% Expect with repeat option
expect_repeat(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo_ml xy xy"),
{ok,[["xy"],["xy"]],done} = ct_telnet:expect(Handle, ["xy"],[{repeat,2}]),
ok = ct_telnet:close(Handle),
@@ -67,7 +65,7 @@ expect_repeat(_) ->
%% Expect with sequence option
expect_sequence(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo_ml ab cd ef"),
{ok,[["ab"],["cd"],["ef"]]} = ct_telnet:expect(Handle,
[["ab"],["cd"],["ef"]],
@@ -78,7 +76,7 @@ expect_sequence(_) ->
%% Check that expect returns when a prompt is found, even if pattern
%% is not matched.
expect_error_prompt(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo xxx> yyy"),
{error,{prompt,"> "}} = ct_telnet:expect(Handle, ["yyy"]),
ok = ct_telnet:close(Handle),
@@ -88,7 +86,7 @@ expect_error_prompt(_) ->
%% expected pattern is received - as long as not newline or prompt is
%% received it will not match.
expect_error_timeout(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo_no_prompt xxx"),
{error,timeout} = ct_telnet:expect(Handle, ["xxx"], [{timeout,1000}]),
ok = ct_telnet:close(Handle),
@@ -97,7 +95,7 @@ expect_error_timeout(_) ->
%% expect with ignore_prompt option should not return even if a prompt
%% is found. The pattern after the prompt (here "> ") can be matched.
ignore_prompt(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo xxx> yyy"),
{ok,["yyy"]} = ct_telnet:expect(Handle, ["yyy"], [ignore_prompt]),
ok = ct_telnet:close(Handle),
@@ -105,7 +103,7 @@ ignore_prompt(_) ->
%% expect with ignore_prompt and repeat options.
ignore_prompt_repeat(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo_ml yyy> yyy>"),
{ok,[["yyy"],["yyy"]],done} = ct_telnet:expect(Handle, ["yyy"],
[{repeat,2},
@@ -115,7 +113,7 @@ ignore_prompt_repeat(_) ->
%% expect with ignore_prompt and sequence options.
ignore_prompt_sequence(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo_ml xxx> yyy> zzz> "),
{ok,[["xxx"],["yyy"],["zzz"]]} = ct_telnet:expect(Handle,
[["xxx"],["yyy"],["zzz"]],
@@ -129,7 +127,7 @@ ignore_prompt_sequence(_) ->
%% As for expect without the ignore_prompt option, it a newline or a
%% prompt is required in order for the pattern to match.
ignore_prompt_timeout(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo xxx"),
{error,timeout} = ct_telnet:expect(Handle, ["yyy"], [ignore_prompt,
{timeout,1000}]),
@@ -148,7 +146,7 @@ ignore_prompt_timeout(_) ->
%% no_prompt_check option shall match pattern both when prompt is sent
%% and when it is not.
no_prompt_check(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo xxx"),
{ok,["xxx"]} = ct_telnet:expect(Handle, ["xxx"], [no_prompt_check]),
ok = ct_telnet:send(Handle, "echo_no_prompt yyy"),
@@ -158,7 +156,7 @@ no_prompt_check(_) ->
%% no_prompt_check and repeat options
no_prompt_check_repeat(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo_ml xxx xxx"),
{ok,[["xxx"],["xxx"]],done} = ct_telnet:expect(Handle,["xxx"],
[{repeat,2},
@@ -172,7 +170,7 @@ no_prompt_check_repeat(_) ->
%% no_prompt_check and sequence options
no_prompt_check_sequence(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo_ml_no_prompt ab cd ef"),
{ok,[["ab"],["cd"],["ef"]]} = ct_telnet:expect(Handle,
[["ab"],["cd"],["ef"]],
@@ -184,7 +182,7 @@ no_prompt_check_sequence(_) ->
%% Check that expect returns after idle timeout when no_prompt_check
%% option is used.
no_prompt_check_timeout(_) ->
- {ok, Handle} = ct_telnet:open(erl_telnet_server),
+ {ok, Handle} = ct_telnet:open(the_telnet_server),
ok = ct_telnet:send(Handle, "echo xxx"),
{error,timeout} = ct_telnet:expect(Handle, ["yyy"], [no_prompt_check,
{timeout,1000}]),
diff --git a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl
index f274fb9112..1959ee3cb8 100644
--- a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl
+++ b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl
@@ -4,7 +4,7 @@
-include_lib("common_test/include/ct.hrl").
--define(name,erl_telnet_server).
+-define(name, the_telnet_server).
%%--------------------------------------------------------------------
%% TEST SERVER CALLBACK FUNCTIONS