Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

36 wiersze
1.2 KiB

  1. %% @doc This test is named zzzz_gh280_crash because it has to be run first and tests are run in
  2. %% reverse alphabetical order.
  3. %%
  4. %% The problem we are attempting to detect here is when log_mf_h is installed as a handler for error_logger
  5. %% and lager starts up to replace the current handlers with its own. This causes a start up crash because
  6. %% OTP error logging modules do not have any notion of a lager-style log level.
  7. -module(zzzz_gh280_crash).
  8. -compile(export_all).
  9. -include_lib("eunit/include/eunit.hrl").
  10. gh280_crash_test() ->
  11. {timeout, 30, fun() -> gh280_impl() end}.
  12. gh280_impl() ->
  13. application:stop(lager),
  14. application:stop(goldrush),
  15. error_logger:tty(false),
  16. %% see https://github.com/erlang/otp/blob/maint/lib/stdlib/src/log_mf_h.erl#L81
  17. %% for an explanation of the init arguments to log_mf_h
  18. ok = gen_event:add_sup_handler(error_logger, log_mf_h, log_mf_h:init("/tmp", 10000, 5)),
  19. lager:start(),
  20. Result = receive
  21. {gen_event_EXIT,log_mf_h,normal} ->
  22. true;
  23. {gen_event_EXIT,Handler,Reason} ->
  24. {Handler,Reason};
  25. X ->
  26. X
  27. after 10000 ->
  28. timeout
  29. end,
  30. ?assert(Result),
  31. application:stop(lager),
  32. application:stop(goldrush).