diff options
author | Lukas Larsson <[email protected]> | 2012-04-10 14:05:02 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2012-04-10 14:09:12 +0200 |
commit | 3e5015a959c9533582b0e4a027158ea8252f7c31 (patch) | |
tree | e00b0614d142142ba66df9235c10779a74fd9d07 /lib/kernel | |
parent | 944a57a11a79c5a9bb2f554c921e2e00e7d56c91 (diff) | |
download | otp-3e5015a959c9533582b0e4a027158ea8252f7c31.tar.gz otp-3e5015a959c9533582b0e4a027158ea8252f7c31.tar.bz2 otp-3e5015a959c9533582b0e4a027158ea8252f7c31.zip |
Add testcase for controlling_process(P,self())
Diffstat (limited to 'lib/kernel')
-rw-r--r-- | lib/kernel/test/gen_tcp_misc_SUITE.erl | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/kernel/test/gen_tcp_misc_SUITE.erl b/lib/kernel/test/gen_tcp_misc_SUITE.erl index 3da4b07c05..826d9ff088 100644 --- a/lib/kernel/test/gen_tcp_misc_SUITE.erl +++ b/lib/kernel/test/gen_tcp_misc_SUITE.erl @@ -24,7 +24,8 @@ -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, - controlling_process/1, no_accept/1, close_with_pending_output/1, + controlling_process/1, controlling_process_self/1, + no_accept/1, close_with_pending_output/1, data_before_close/1, iter_max_socks/1, get_status/1, passive_sockets/1, accept_closed_by_other_process/1, init_per_testcase/2, end_per_testcase/2, @@ -57,7 +58,7 @@ end_per_testcase(_Func, Config) -> suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [controlling_process, no_accept, + [controlling_process, controlling_process_self, no_accept, close_with_pending_output, data_before_close, iter_max_socks, passive_sockets, accept_closed_by_other_process, otp_3924, closed_socket, @@ -306,6 +307,32 @@ not_owner(S) -> ok end. +controlling_process_self(doc) -> + ["Open a listen port and assign the controlling process to " + "it self, then exit and make sure the port is closed properly."]; +controlling_process_self(Config) when is_list(Config) -> + S = self(), + process_flag(trap_exit,true), + spawn_link(fun() -> + {ok,Sock} = gen_tcp:listen(0,[]), + S ! {socket, Sock}, + ok = gen_tcp:controlling_process(Sock,self()), + S ! done + end), + receive + done -> + receive + {socket,Sock} -> + process_flag(trap_exit,false), + %% Make sure the port is invalid after process crash + {error,einval} = inet:port(Sock) + end; + Msg when element(1,Msg) /= socket -> + process_flag(trap_exit,false), + exit({unknown_msg,Msg}) + end. + + no_accept(doc) -> ["Open a listen port and connect to it, then close the listen port ", "without doing any accept. The connected socket should receive ", |