diff options
author | Tomas Pihl <[email protected]> | 2012-07-22 13:01:43 +0200 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2012-10-05 11:25:06 +0200 |
commit | c2b6342cb57df5925acbacff0aea74358c9a5ffb (patch) | |
tree | 26210740332aebc41f66ce304b06033b9b65c50a /lib/stdlib/test/supervisor_SUITE.erl | |
parent | a24c49aec663f19092cf0d2062af19523666d291 (diff) | |
download | otp-c2b6342cb57df5925acbacff0aea74358c9a5ffb.tar.gz otp-c2b6342cb57df5925acbacff0aea74358c9a5ffb.tar.bz2 otp-c2b6342cb57df5925acbacff0aea74358c9a5ffb.zip |
Have supervisor send errors up the chain
If a child fails to start, supervisor relies upon error_logger which does not
work when IO is inhibited. Instead pass the error up the chain and let someone
else use a proper Reason for any possible printouts.
Diffstat (limited to 'lib/stdlib/test/supervisor_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/supervisor_SUITE.erl | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/stdlib/test/supervisor_SUITE.erl b/lib/stdlib/test/supervisor_SUITE.erl index 767ae3d62c..d9f2e82b31 100644 --- a/lib/stdlib/test/supervisor_SUITE.erl +++ b/lib/stdlib/test/supervisor_SUITE.erl @@ -46,6 +46,7 @@ temporary_normal/1, permanent_shutdown/1, transient_shutdown/1, temporary_shutdown/1, + faulty_application_shutdown/1, permanent_abnormal/1, transient_abnormal/1, temporary_abnormal/1, temporary_bystander/1]). @@ -98,7 +99,8 @@ groups() -> {normal_termination, [], [permanent_normal, transient_normal, temporary_normal]}, {shutdown_termination, [], - [permanent_shutdown, transient_shutdown, temporary_shutdown]}, + [permanent_shutdown, transient_shutdown, temporary_shutdown, + faulty_application_shutdown]}, {abnormal_termination, [], [permanent_abnormal, transient_abnormal, temporary_abnormal]}, @@ -659,6 +661,32 @@ temporary_shutdown(Config) when is_list(Config) -> [0,0,0,0] = get_child_counts(sup_test). %%------------------------------------------------------------------------- +%% Faulty application should shutdown and pass on errors +faulty_application_shutdown(Config) when is_list(Config) -> + + %% Set some paths + AppDir = filename:join(?config(data_dir, Config), "app_faulty"), + EbinDir = filename:join(AppDir, "ebin"), + + %% Start faulty app + code:add_patha(EbinDir), + + % {error, + % {{shutdown, + % {undef,[ + % {an_undefined_module_with,an_undefined_function,[argument1,argument2],[]}, + % {app_faulty_server,init,1,[{file,"app_faulty/src/app_faulty_server.erl"},{line,16}]}, + % {gen_server,init_it,6,[{file,"gen_server.erl"},{line,304}]}, + % {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]} + % ]}},{app_faulty,start,[normal,[]]}}} + + {error, Error} = application:start(app_faulty), + {{shutdown, {undef, CallStack}},{app_faulty,start,_}} = Error, + [{an_undefined_module_with,an_undefined_function,_,_}|_] = CallStack, + ok = application:unload(app_faulty), + ok. + +%%------------------------------------------------------------------------- %% A permanent child should always be restarted. permanent_abnormal(Config) when is_list(Config) -> {ok, SupPid} = start_link({ok, {{one_for_one, 2, 3600}, []}}), |