瀏覽代碼

Add test case for gh280 fix

pull/282/head
Mark Allen 9 年之前
父節點
當前提交
9c0e141d30
共有 2 個文件被更改,包括 33 次插入18 次删除
  1. +0
    -18
      test/gh280_crash.erl
  2. +33
    -0
      test/zzzz_gh280_crash.erl

+ 0
- 18
test/gh280_crash.erl 查看文件

@ -1,18 +0,0 @@
-module(gh280_crash).
-include_lib("eunit/include/eunit.hrl").
gh280_crash_test() ->
error_logger:tty(false),
%% see https://github.com/erlang/otp/blob/maint/lib/stdlib/src/log_mf_h.erl#L81
%% for an explanation of the init arguments to log_mf_h
ok = gen_event:add_sup_handler(error_logger, log_mf_h, log_mf_h:init("/tmp", 10000, 5)),
lager:start(),
receive
{gen_event_EXIT,Handler,Reason} ->
throw({Handler,Reason});
X ->
throw(X)
after 2000 ->
throw(timeout)
end.

+ 33
- 0
test/zzzz_gh280_crash.erl 查看文件

@ -0,0 +1,33 @@
%% @doc This test is named zzzz_gh280_crash because it has to be run first and tests are run in
%% reverse alphabetical order.
%%
%% The problem we are attempting to detect here is when log_mf_h is installed as a handler for error_logger
%% and lager starts up to replace the current handlers with its own. This causes a start up crash because
%% OTP error logging modules do not have any notion of a lager-style log level.
-module(zzzz_gh280_crash).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
gh280_crash_test() ->
application:stop(lager),
application:stop(goldrush),
error_logger:tty(false),
%% see https://github.com/erlang/otp/blob/maint/lib/stdlib/src/log_mf_h.erl#L81
%% for an explanation of the init arguments to log_mf_h
ok = gen_event:add_sup_handler(error_logger, log_mf_h, log_mf_h:init("/tmp", 10000, 5)),
lager:start(),
Result = receive
{gen_event_EXIT,log_mf_h,normal} ->
true;
{gen_event_EXIT,Handler,Reason} ->
{Handler,Reason};
X ->
X
after 1000 ->
timeout
end,
?assert(Result),
application:stop(lager),
application:stop(goldrush).

Loading…
取消
儲存