diff options
author | Siri Hansen <[email protected]> | 2013-05-27 09:33:02 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2013-05-27 09:33:02 +0200 |
commit | 429e9d8ce78f7498e06e252e487c75cea6c585d4 (patch) | |
tree | 8ba4cb73888a1d55226085542f897824fd85d4fd /lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl | |
parent | 3f7107a53d59a2dc35163e8c6119164dfb9e6822 (diff) | |
parent | 28f3a4a5713487cb6ade48f2d142d8c2d5b7ac6e (diff) | |
download | otp-429e9d8ce78f7498e06e252e487c75cea6c585d4.tar.gz otp-429e9d8ce78f7498e06e252e487c75cea6c585d4.tar.bz2 otp-429e9d8ce78f7498e06e252e487c75cea6c585d4.zip |
Merge branch 'siri/ct_telnet/no-more-after-timetrap/OTP-10648' into maint
* siri/ct_telnet/no-more-after-timetrap/OTP-10648:
[common_test] Unregister connection if killed
Diffstat (limited to 'lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl')
-rw-r--r-- | lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl | 76 |
1 files changed, 76 insertions, 0 deletions
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 new file mode 100644 index 0000000000..f274fb9112 --- /dev/null +++ b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_timetrap_SUITE.erl @@ -0,0 +1,76 @@ +-module(ct_telnet_timetrap_SUITE). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). + +-define(name,erl_telnet_server). + +%%-------------------------------------------------------------------- +%% TEST SERVER CALLBACK FUNCTIONS +%%-------------------------------------------------------------------- + +init_per_suite(Config) -> + Config. + +end_per_suite(_Config) -> + ok. + +suite() -> [{require,?name,{unix,[telnet]}}, + {timetrap,{seconds,7}}]. + +all() -> + [expect_timetrap, + expect_success]. + +groups() -> + []. + +init_per_group(_GroupName, Config) -> + Config. + +end_per_group(_GroupName, Config) -> + Config. + +init_per_testcase(_,Config) -> + ct:log("init_per_testcase: opening telnet connection...",[]), + {ok,_} = ct_telnet:open(?name), + ct:log("...done",[]), + Config. + +end_per_testcase(_,_Config) -> + ct:log("end_per_testcase: closing telnet connection...",[]), + _ = ct_telnet:close(?name), + ct:log("...done",[]), + ok. + + +%% OTP-10648 +%% This test case should fail with timetrap timeout. +%% +%% The long timetrap timeout and timeout option in the expect call +%% also causes the telnet client to hang so long that the attempt at +%% closing it (in end_per_testcase) will time out (close timeout is 5 +%% sec) without a timetrap timeout occuring in end_per_testcase. +%% +%% The point is to see that the connection is thoroughly removed and +%% unregistered anyway so that the next test case can successfully +%% open a connection with the same name. +%% +%% Note!!! that if end_per_testcase reaches a timetrap timeout before +%% the connection is closed, then the connection will survive until +%% the hanging expect times out, after which it will be closed in a +%% seemingly normal way due to the close message which was sent by the +%% close attempt. This could happen any time during the subsequent +%% test cases and cause confusion... There is however not much to do +%% about this, except writing test cases with timetrap timeout longer +%% than the close timeout (as this test case does) +expect_timetrap(_) -> + {error,timeout} = ct_telnet:expect(?name, ["ayt"], [{timeout,20000}]), + ok. + +%% This should succeed +expect_success(_) -> + ok = ct_telnet:send(?name, "echo ayt"), + {ok,["ayt"]} = ct_telnet:expect(?name, ["ayt"]), + ok. |