diff options
author | Tim Watson <tim@rabbitmq.com> | 2013-04-19 13:46:38 +0100 |
---|---|---|
committer | Tim Watson <tim@rabbitmq.com> | 2013-04-19 13:46:38 +0100 |
commit | 1b52a408c67351ceb4ae7b6bb3890885520681d9 (patch) | |
tree | 96da3f978ee75d72f6cb6267e8dbf0ec55539aa1 | |
parent | 6dff79458ef7b54fe9c253414676a44cd323802e (diff) | |
download | rabbitmq-server-1b52a408c67351ceb4ae7b6bb3890885520681d9.tar.gz |
back out of f608b9df9a14 changes supervisor2_tests
-rw-r--r-- | src/supervisor2_tests.erl | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/src/supervisor2_tests.erl b/src/supervisor2_tests.erl index c53b613c..518f11b7 100644 --- a/src/supervisor2_tests.erl +++ b/src/supervisor2_tests.erl @@ -17,22 +17,12 @@ -module(supervisor2_tests). -behaviour(supervisor2). --include_lib("eunit/include/eunit.hrl"). - --define(ASSERT, true). --define(EUNIT_NOAUTO, true). - -export([test_all/0, start_link/0]). --export([start_link_bad/0]). -export([init/1]). test_all() -> - catch ets:new(?MODULE, [named_table, public]), - %% ok = check_shutdown(stop, 200, 200, 2000), - %% ok = check_shutdown(ignored, 1, 2, 2000), - %% ok = check_logging(transient), - ets:delete(?MODULE, bang), - ok = check_logging({permanent, 1}). + ok = check_shutdown(stop, 200, 200, 2000), + ok = check_shutdown(ignored, 1, 2, 2000). check_shutdown(SigStop, Iterations, ChildCount, SupTimeout) -> {ok, Sup} = supervisor2:start_link(?MODULE, [SupTimeout]), @@ -62,20 +52,6 @@ check_shutdown(SigStop, Iterations, ChildCount, SupTimeout) -> exit(Sup, shutdown), Res. -check_logging(How) -> - process_flag(trap_exit, true), - {ok, Sup} = supervisor2:start_link(?MODULE, [bang, How]), - io:format("super pid = ~p~n", [Sup]), - MRef = erlang:monitor(process, Sup), - [Pid] = supervisor2:find_child(Sup, test_try_again_sup), - io:format("Pid == ~p~nChildren == ~p~n", [Pid, supervisor2:which_children(Sup)]), - Pid ! {shutdown, bang}, - io:format("restart issued - awaiting sup death~n"), - receive - {'DOWN', MRef, process, Sup, Reason} -> - io:format("stopped Sup == ~p~n", [Reason]) - end. - start_link() -> Pid = spawn_link(fun () -> process_flag(trap_exit, true), @@ -83,35 +59,6 @@ start_link() -> end), {ok, Pid}. -start_link_bad() -> - Boom = ets:lookup(?MODULE, bang), - case Boom of - [{bang, true}] -> io:format("BOOM!~n"), exit(bang); - _ -> ok - end, - io:format("no Boom - starting server~n"), - Pid = spawn_link(fun () -> - process_flag(trap_exit, true), - receive - {shutdown, Bang} -> - ets:insert(?MODULE, [{bang, true}]), - io:format("exiting...~n"), - exit(Bang); - shutdown -> - io:format("exiting (shutdown)...~n"), - exit(shutdown); - Other -> - io:format("odd signal: ~p~n", [Other]), - exit(Other) - end - end), - {ok, Pid}. - -init([bang, How]) -> - {ok, {{one_for_one, 3, 10}, - [{test_try_again_sup, {?MODULE, start_link_bad, []}, - How, 5000, worker, [?MODULE]}]}}; - init([Timeout]) -> {ok, {{one_for_one, 0, 1}, [{test_sup, {supervisor2, start_link, @@ -121,4 +68,3 @@ init([]) -> {ok, {{simple_one_for_one, 0, 1}, [{test_worker, {?MODULE, start_link, []}, temporary, 1000, worker, [?MODULE]}]}}. - |