From 06ea28e87e2edf8c26cd27de9c913a7dbf615d29 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 11 Jul 2012 11:14:23 +0200 Subject: [common_test] Don't abort test if opening of connection fails When opening a connection, the connection process would link itself to ct_util_server before calling the init callback, e.g. in ct_netconfc, ct_telnet etc. If the init callback failed, then ct_util_server would get the 'EXIT'. ct_util looks up the pid in the connection table, but since the connection is not yet registered it is not found. ct_util does not know which process it is and will thus die - aborting the complete test run. This commit moves the link(CtUtilServer) after the init callback, so a crash in the init callback will not be detected by ct_util_server - the caller process, however, will get a 'DOWN' message due to monitoring and ct_gen_conn:start will give an error return. --- lib/common_test/src/ct_gen_conn.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/common_test/src') diff --git a/lib/common_test/src/ct_gen_conn.erl b/lib/common_test/src/ct_gen_conn.erl index 72937e747c..5df9127725 100644 --- a/lib/common_test/src/ct_gen_conn.erl +++ b/lib/common_test/src/ct_gen_conn.erl @@ -278,8 +278,6 @@ return({To,Ref},Result) -> init_gen(Parent,Opts) -> process_flag(trap_exit,true), - CtUtilServer = whereis(ct_util_server), - link(CtUtilServer), put(silent,false), try (Opts#gen_opts.callback):init(Opts#gen_opts.name, Opts#gen_opts.address, @@ -287,6 +285,8 @@ init_gen(Parent,Opts) -> {ok,ConnPid,State} when is_pid(ConnPid) -> link(ConnPid), put(conn_pid,ConnPid), + CtUtilServer = whereis(ct_util_server), + link(CtUtilServer), Parent ! {connected,self()}, loop(Opts#gen_opts{conn_pid=ConnPid, cb_state=State, -- cgit v1.2.3