diff options
author | Siri Hansen <[email protected]> | 2012-11-15 08:54:25 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2012-11-15 08:54:25 +0100 |
commit | 042c2986445465f843e5dc4be4df34b28381d0d2 (patch) | |
tree | ff7934a3b0115cf80f415ade66fc2c8ccca6aad7 /lib/common_test | |
parent | c8d19718ca8e3c2ccc947f67e4068e752b34f6d3 (diff) | |
parent | ad398a0dbcdb36323d359bff61fe7f2e39f0e455 (diff) | |
download | otp-042c2986445465f843e5dc4be4df34b28381d0d2.tar.gz otp-042c2986445465f843e5dc4be4df34b28381d0d2.tar.bz2 otp-042c2986445465f843e5dc4be4df34b28381d0d2.zip |
Merge branch 'siri/common_test/ct_netconfc-close-problems' into maint
* siri/common_test/ct_netconfc-close-problems:
[common_test] Allow server to terminate netconf session before rpc-reply
[common_test] Ensure process down after ct_netconf:close_session
Diffstat (limited to 'lib/common_test')
-rw-r--r-- | lib/common_test/src/ct_netconfc.erl | 33 | ||||
-rw-r--r-- | lib/common_test/test/ct_netconfc_SUITE.erl | 2 |
2 files changed, 28 insertions, 7 deletions
diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl index 52fe9599ce..294b82bff6 100644 --- a/lib/common_test/src/ct_netconfc.erl +++ b/lib/common_test/src/ct_netconfc.erl @@ -968,7 +968,7 @@ close_session(Client) -> %% @end %%---------------------------------------------------------------------- close_session(Client, Timeout) -> - call(Client,{send_rpc_op, close_session, [], Timeout}). + call(Client,{send_rpc_op, close_session, [], Timeout}, true). %%---------------------------------------------------------------------- @@ -1121,17 +1121,38 @@ close(Client) -> %% Internal functions %%---------------------------------------------------------------------- call(Client, Msg) -> - call(Client, Msg, infinity). -call(Client, Msg, Timeout) -> + call(Client, Msg, infinity, false). +call(Client, Msg, Timeout) when is_integer(Timeout); Timeout==infinity -> + call(Client, Msg, Timeout, false); +call(Client, Msg, WaitStop) when is_boolean(WaitStop) -> + call(Client, Msg, infinity, WaitStop). +call(Client, Msg, Timeout, WaitStop) -> case get_handle(Client) of {ok,Pid} -> case ct_gen_conn:call(Pid,Msg,Timeout) of - {error,{process_down,Client,noproc}} -> + {error,{process_down,Pid,noproc}} -> {error,no_such_client}; - {error,{process_down,Client,normal}} -> + {error,{process_down,Pid,normal}} when WaitStop -> + %% This will happen when server closes connection + %% before clien received rpc-reply on + %% close-session. + ok; + {error,{process_down,Pid,normal}} -> {error,closed}; - {error,{process_down,Client,Reason}} -> + {error,{process_down,Pid,Reason}} -> {error,{closed,Reason}}; + Other when WaitStop -> + MRef = erlang:monitor(process,Pid), + receive + {'DOWN',MRef,process,Pid,Normal} when Normal==normal; + Normal==noproc -> + Other; + {'DOWN',MRef,process,Pid,Reason} -> + {error,{{closed,Reason},Other}} + after Timeout -> + erlang:demonitor(MRef, [flush]), + {error,{timeout,Other}} + end; Other -> Other end; diff --git a/lib/common_test/test/ct_netconfc_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE.erl index 30084a6228..3042a924fe 100644 --- a/lib/common_test/test/ct_netconfc_SUITE.erl +++ b/lib/common_test/test/ct_netconfc_SUITE.erl @@ -113,7 +113,7 @@ reformat(Events, EH) -> %%%----------------------------------------------------------------- %%% TEST EVENTS %%%----------------------------------------------------------------- -events_to_check(Test,Config) -> +events_to_check(default,Config) -> {module,_} = code:load_abs(filename:join(?config(data_dir,Config), netconfc1_SUITE)), TCs = netconfc1_SUITE:all(), |