aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/proc_lib_SUITE.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-09-09 12:37:52 +0200
committerBjörn Gustavsson <[email protected]>2015-09-09 12:37:52 +0200
commitd307079cc7b88f89e8cf68fe189d1d329a47ad51 (patch)
treeabfb7a4a861717f3b3704adb707293d0024bad26 /lib/stdlib/test/proc_lib_SUITE.erl
parent439de942a4db2a422dbfe7813f66b150f947313f (diff)
parentd73f47345776d3567b50115af69d551077909514 (diff)
downloadotp-d307079cc7b88f89e8cf68fe189d1d329a47ad51.tar.gz
otp-d307079cc7b88f89e8cf68fe189d1d329a47ad51.tar.bz2
otp-d307079cc7b88f89e8cf68fe189d1d329a47ad51.zip
Merge branch 'bjorn/error-loggers/OTP-12864' into maint
* bjorn/error-loggers/OTP-12864: Add documentation Introduce sasl_report_SUITE Teach sasl_report to limit crash reports proc_lib: Add format/3 Teach error_logger_tty_h to truncate big messages error_logger_tty_h: Refactor and modernize code Teach error_logger_file_h to truncate big messages error_logger_file_h: Refactor and modernize code Remove unused code in error logger handlers Add error_logger_h_SUITE sasl_SUITE: Add a rudimentary test of the utc_log configuration sasl_SUITE: Correct the log_file/1 test case proc_lib_SUITE: Remove added report handlers zip_SUITE: Don't trust priv_dir to be empty
Diffstat (limited to 'lib/stdlib/test/proc_lib_SUITE.erl')
-rw-r--r--lib/stdlib/test/proc_lib_SUITE.erl56
1 files changed, 53 insertions, 3 deletions
diff --git a/lib/stdlib/test/proc_lib_SUITE.erl b/lib/stdlib/test/proc_lib_SUITE.erl
index 36f009eec6..3a8fa74d36 100644
--- a/lib/stdlib/test/proc_lib_SUITE.erl
+++ b/lib/stdlib/test/proc_lib_SUITE.erl
@@ -28,7 +28,7 @@
init_per_group/2,end_per_group/2,
crash/1, sync_start_nolink/1, sync_start_link/1,
spawn_opt/1, sp1/0, sp2/0, sp3/1, sp4/2, sp5/1,
- hibernate/1, stop/1]).
+ hibernate/1, stop/1, t_format/1]).
-export([ otp_6345/1, init_dont_hang/1]).
-export([hib_loop/1, awaken/1]).
@@ -51,7 +51,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[crash, {group, sync_start}, spawn_opt, hibernate,
- {group, tickets}, stop].
+ {group, tickets}, stop, t_format].
groups() ->
[{tickets, [], [otp_6345, init_dont_hang]},
@@ -149,7 +149,11 @@ crash(Config) when is_list(Config) ->
?line ?t:fail({unexpected_message,Any})
after 2000 ->
ok
- end.
+ end,
+
+ error_logger:delete_report_handler(?MODULE),
+ ok.
+
sync_start_nolink(Config) when is_list(Config) ->
@@ -301,6 +305,7 @@ hibernate(Config) when is_list(Config) ->
?line {value,{initial_call,{?MODULE,hib_loop,[_]}}} =
lists:keysearch(initial_call, 1, Report),
+ error_logger:delete_report_handler(?MODULE),
ok.
hib_loop(LoopData) ->
@@ -452,6 +457,51 @@ system_terminate(crash,_Parent,_Deb,_State) ->
system_terminate(Reason,_Parent,_Deb,_State) ->
exit(Reason).
+
+t_format(_Config) ->
+ error_logger:tty(false),
+ try
+ t_format()
+ after
+ error_logger:tty(true)
+ end,
+ ok.
+
+t_format() ->
+ error_logger:add_report_handler(?MODULE, self()),
+ Pid = proc_lib:spawn(fun t_format_looper/0),
+ HugeData = gb_sets:from_list(lists:seq(1, 100)),
+ Pid ! {die,HugeData},
+ Report = receive
+ {crash_report, Pid, Report0} -> Report0
+ end,
+ Usz = do_test_format(Report, unlimited),
+ Tsz = do_test_format(Report, 20),
+
+ if
+ Tsz >= Usz ->
+ ?t:fail();
+ true ->
+ ok
+ end,
+
+ ok.
+
+do_test_format(Report, Depth) ->
+ io:format("*** Depth = ~p", [Depth]),
+ S0 = proc_lib:format(Report, latin1, Depth),
+ S = lists:flatten(S0),
+ io:put_chars(S),
+ length(S).
+
+t_format_looper() ->
+ receive
+ {die,Data} ->
+ exit(Data);
+ _ ->
+ t_format_looper()
+ end.
+
%%-----------------------------------------------------------------
%% The error_logger handler used.
%%-----------------------------------------------------------------