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/ct_telnet_SUITE.erl2
-rw-r--r--lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl19
-rw-r--r--lib/common_test/test/telnet_server.erl16
3 files changed, 32 insertions, 5 deletions
diff --git a/lib/common_test/test/ct_telnet_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE.erl
index acce4eca14..8163009409 100644
--- a/lib/common_test/test/ct_telnet_SUITE.erl
+++ b/lib/common_test/test/ct_telnet_SUITE.erl
@@ -73,11 +73,13 @@ end_per_suite(Config) ->
ct_test_support:end_per_suite(Config).
init_per_testcase(TestCase, Config) when TestCase=/=unix_telnet->
+ ct:pal("Testcase ~p starting!", [TestCase]),
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:pal("Testcase ~p starting!", [TestCase]),
ct_test_support:init_per_testcase(TestCase, Config).
end_per_testcase(TestCase, Config) ->
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 8d142e85a8..0277dc2a44 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
@@ -28,7 +28,8 @@ all() ->
ignore_prompt,
ignore_prompt_repeat,
ignore_prompt_sequence,
- ignore_prompt_timeout].
+ ignore_prompt_timeout,
+ server_speaks].
groups() ->
[].
@@ -188,3 +189,19 @@ no_prompt_check_timeout(_) ->
{timeout,1000}]),
ok = ct_telnet:close(Handle),
ok.
+
+%% Let the server say things, to make sure it gets printed correctly
+%% in the general IO log
+server_speaks(_) ->
+ {ok, Handle} = ct_telnet:open(telnet_server_conn1),
+ ok = ct_telnet:send(Handle, "echo This is the first message"),
+ ok = ct_telnet:send(Handle, "echo This is the second message"),
+ %% let ct_telnet_client get an idle timeout
+ timer:sleep(15000),
+ ok = ct_telnet:send(Handle, "echo This is the third message"),
+ {ok,_} = ct_telnet:expect(Handle, ["the"], [no_prompt_check]),
+ {error,timeout} = ct_telnet:expect(Handle, ["the"], [no_prompt_check,
+ {timeout,1000}]),
+ ok = ct_telnet:send(Handle, "echo This is the fourth message"),
+ ok = ct_telnet:close(Handle),
+ ok.
diff --git a/lib/common_test/test/telnet_server.erl b/lib/common_test/test/telnet_server.erl
index 1760100d8e..eb90f18320 100644
--- a/lib/common_test/test/telnet_server.erl
+++ b/lib/common_test/test/telnet_server.erl
@@ -67,7 +67,7 @@ accept(#state{listen=LSock}=State) ->
io:format("[telnet_server] telnet_server stopped\n"),
ok;
R ->
- io:format("[telnet_server] connection to client"
+ io:format("[telnet_server] connection to client "
"closed with reason ~p~n",[R]),
accept(State)
end;
@@ -97,19 +97,19 @@ init_client(#state{client=Sock}=State) ->
dbg("Server sending: ~p~n",["login: "]),
R = case gen_tcp:send(Sock,"login: ") of
ok ->
- loop(State);
+ loop(State, 1);
Error ->
Error
end,
_ = gen_tcp:close(Sock),
R.
-loop(State) ->
+loop(State, N) ->
receive
{tcp,_,Data} ->
try handle_data(Data,State) of
{ok,State1} ->
- loop(State1)
+ loop(State1, N)
catch
throw:Error ->
Error
@@ -120,6 +120,14 @@ loop(State) ->
{error,tcp,Error};
stop ->
stopped
+ after
+ 500 ->
+ Report = lists:flatten(
+ io_lib:format("The CT Telnet Server says: "
+ "Iteration no ~w\r\n", [N])),
+ dbg("Server sending: ~s~n", [Report]),
+ gen_tcp:send(State#state.client, Report),
+ loop(State, N+1)
end.
handle_data([?IAC|Cmd],State) ->