aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/test/ct_telnet_SUITE.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-05-21 17:50:09 +0200
committerSiri Hansen <[email protected]>2013-05-21 17:50:09 +0200
commit2886d9937990c3465671b59d744f6bacd43545c8 (patch)
treebf4a5b8e4cf45de31809eb63b60a7b559c1ed164 /lib/common_test/test/ct_telnet_SUITE.erl
parente0e9885cd3561c46114ee22ac84c01d9347187ea (diff)
parentcae4bc87c2b3009a505f91a1c2d38a484cc9a1e4 (diff)
downloadotp-2886d9937990c3465671b59d744f6bacd43545c8.tar.gz
otp-2886d9937990c3465671b59d744f6bacd43545c8.tar.bz2
otp-2886d9937990c3465671b59d744f6bacd43545c8.zip
Merge branch 'siri/ct/no_prompt_check/OTP-11095' into maint
* siri/ct/no_prompt_check/OTP-11095: [common_test] Refactor ct_telnet_SUITE.erl [common_test] Add new option 'no_prompt_check' to ct_telnet:expect/3. [common_test] Add debug printouts in ct_telnet_client [common_test] Backed out wait_for_linebreak option from ct_telnet [common_test] Add test for ct_telnet using own telnet server [common_test] Add telnet server to use for testing
Diffstat (limited to 'lib/common_test/test/ct_telnet_SUITE.erl')
-rw-r--r--lib/common_test/test/ct_telnet_SUITE.erl69
1 files changed, 54 insertions, 15 deletions
diff --git a/lib/common_test/test/ct_telnet_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE.erl
index b4f24baa0c..17617f59eb 100644
--- a/lib/common_test/test/ct_telnet_SUITE.erl
+++ b/lib/common_test/test/ct_telnet_SUITE.erl
@@ -33,6 +33,10 @@
-define(eh, ct_test_support_eh).
+-define(erl_telnet_server_port,1234).
+-define(erl_telnet_server_user,"telnuser").
+-define(erl_telnet_server_pwd,"telnpwd").
+
%%--------------------------------------------------------------------
%% TEST SERVER CALLBACK FUNCTIONS
%%--------------------------------------------------------------------
@@ -48,17 +52,27 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
ct_test_support:end_per_suite(Config).
+init_per_testcase(TestCase, Config) when TestCase=/=unix_telnet->
+ TS = telnet_server:start([{port,?erl_telnet_server_port},
+ {users,[{?erl_telnet_server_user,
+ ?erl_telnet_server_pwd}]}]),
+ ct_test_support:init_per_testcase(TestCase, [{telnet_server,TS}|Config]);
init_per_testcase(TestCase, Config) ->
ct_test_support:init_per_testcase(TestCase, Config).
end_per_testcase(TestCase, Config) ->
+ case ?config(telnet_server,Config) of
+ undefined -> ok;
+ TS -> telnet_server:stop(TS)
+ end,
ct_test_support:end_per_testcase(TestCase, Config).
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[
- default
+ unix_telnet,
+ own_server
].
%%--------------------------------------------------------------------
@@ -67,19 +81,29 @@ all() ->
%%%-----------------------------------------------------------------
%%%
-default(Config) when is_list(Config) ->
- DataDir = ?config(data_dir, Config),
- Suite = filename:join(DataDir, "ct_telnet_basic_SUITE"),
- Cfg = {unix, ct:get_config(unix)},
- ok = file:write_file(filename:join(DataDir, "telnet.cfg"), io_lib:write(Cfg) ++ "."),
- CfgFile = filename:join(DataDir, "telnet.cfg"),
- {Opts,ERPid} = setup([{suite,Suite},{label,default}, {config, CfgFile}], Config),
- ok = execute(default, Opts, ERPid, Config).
+unix_telnet(Config) when is_list(Config) ->
+ all_tests_in_suite(unix_telnet,"ct_telnet_basic_SUITE","telnet.cfg",Config).
+
+own_server(Config) ->
+ all_tests_in_suite(own_server,"ct_telnet_own_server_SUITE",
+ "telnet2.cfg",Config).
%%%-----------------------------------------------------------------
%%% HELP FUNCTIONS
%%%-----------------------------------------------------------------
+all_tests_in_suite(TestCase, SuiteName, CfgFileName, 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) ++ "."),
+ {Opts,ERPid} = setup([{suite,Suite},
+ {label,TestCase},
+ {config,CfgFile}],
+ Config),
+ ok = execute(TestCase, Opts, ERPid, Config).
+
setup(Test, Config) ->
Opts0 = ct_test_support:get_opts(Config),
Level = ?config(trace_level, Config),
@@ -103,19 +127,34 @@ 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}]}.
+
%%%-----------------------------------------------------------------
%%% TEST EVENTS
%%%-----------------------------------------------------------------
-events_to_check(default,Config) ->
+events_to_check(unix_telnet,Config) ->
+ all_cases(ct_telnet_basic_SUITE,Config);
+events_to_check(own_server,Config) ->
+ all_cases(ct_telnet_own_server_SUITE,Config).
+
+all_cases(Suite,Config) ->
{module,_} = code:load_abs(filename:join(?config(data_dir,Config),
- ct_telnet_basic_SUITE)),
- TCs = ct_telnet_basic_SUITE:all(),
- code:purge(ct_telnet_basic_SUITE),
- code:delete(ct_telnet_basic_SUITE),
+ Suite)),
+ TCs = Suite:all(),
+ code:purge(Suite),
+ code:delete(Suite),
OneTest =
[{?eh,start_logging,{'DEF','RUNDIR'}}] ++
- [{?eh,tc_done,{ct_telnet_basic_SUITE,TC,ok}} || TC <- TCs] ++
+ [{?eh,tc_done,{Suite,TC,ok}} || TC <- TCs] ++
[{?eh,stop_logging,[]}],
%% 2 tests (ct:run_test + script_start) is default