From f5f480c5750b76b662430b62ef85ebceea5aadc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 17 Aug 2015 16:52:46 +0200 Subject: Beginnings of modernizing the test suite Merging because I have to do other work but this is still a nice enough improvement. --- test/shutdown_SUITE.erl | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'test/shutdown_SUITE.erl') diff --git a/test/shutdown_SUITE.erl b/test/shutdown_SUITE.erl index 109c381..97963d5 100644 --- a/test/shutdown_SUITE.erl +++ b/test/shutdown_SUITE.erl @@ -13,34 +13,14 @@ %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -module(shutdown_SUITE). +-compile(export_all). --include_lib("common_test/include/ct.hrl"). - -%% ct. --export([all/0]). --export([init_per_suite/1]). --export([end_per_suite/1]). - -%% Tests. - --export([brutal_kill/1]). --export([infinity/1]). --export([infinity_trap_exit/1]). --export([timeout/1]). --export([timeout_trap_exit/1]). +-import(ct_helper, [doc/1]). %% ct. all() -> - [brutal_kill, infinity, infinity_trap_exit, timeout, timeout_trap_exit]. - -init_per_suite(Config) -> - ok = application:start(ranch), - Config. - -end_per_suite(_) -> - application:stop(ranch), - ok. + ct_helper:all(?MODULE). %% Tests. @@ -57,7 +37,7 @@ brutal_kill(_) -> = lists:keyfind(ranch_conns_sup, 1, ListenerSupChildren), [{_, Pid, _, _}] = supervisor:which_children(ConnsSup), true = is_process_alive(Pid), - ranch:stop_listener(Name), + ok = ranch:stop_listener(Name), receive after 100 -> ok end, false = is_process_alive(Pid), false = is_process_alive(ListenerSup), @@ -77,7 +57,7 @@ infinity(_) -> = lists:keyfind(ranch_conns_sup, 1, ListenerSupChildren), [{_, Pid, _, _}] = supervisor:which_children(ConnsSup), true = is_process_alive(Pid), - ranch:stop_listener(Name), + ok = ranch:stop_listener(Name), receive after 100 -> ok end, false = is_process_alive(Pid), false = is_process_alive(ListenerSup), @@ -98,7 +78,7 @@ infinity_trap_exit(_) -> [{_, Pid, _, _}] = supervisor:which_children(ConnsSup), true = is_process_alive(Pid), %% This call will block infinitely. - SpawnPid = spawn(fun() -> ranch:stop_listener(Name) end), + SpawnPid = spawn(fun() -> ok = ranch:stop_listener(Name) end), receive after 100 -> ok end, %% The protocol traps exit signals, and ignore them, so it won't die. true = is_process_alive(Pid), @@ -127,7 +107,7 @@ timeout(_) -> = lists:keyfind(ranch_conns_sup, 1, ListenerSupChildren), [{_, Pid, _, _}] = supervisor:which_children(ConnsSup), true = is_process_alive(Pid), - ranch:stop_listener(Name), + ok = ranch:stop_listener(Name), receive after 100 -> ok end, false = is_process_alive(Pid), false = is_process_alive(ListenerSup), @@ -148,7 +128,7 @@ timeout_trap_exit(_) -> [{_, Pid, _, _}] = supervisor:which_children(ConnsSup), true = is_process_alive(Pid), %% This call will block for the duration of the shutdown. - SpawnPid = spawn(fun() -> ranch:stop_listener(Name) end), + SpawnPid = spawn(fun() -> ok = ranch:stop_listener(Name) end), receive after 100 -> ok end, %% The protocol traps exit signals, and ignore them, so it won't die. true = is_process_alive(Pid), -- cgit v1.2.3