aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/gen_event_SUITE.erl
diff options
context:
space:
mode:
authorGeoff Cant <[email protected]>2010-06-12 16:49:54 -0700
committerRaimo Niskanen <[email protected]>2010-07-07 16:34:09 +0200
commit95ed86fc9893460751c5141ff872bdc13814a273 (patch)
tree1722de5f58c95432ca4de75e590c9c90aa4a8334 /lib/stdlib/test/gen_event_SUITE.erl
parentc752a4ea65c744ac283cc277717f8defa15ae610 (diff)
downloadotp-95ed86fc9893460751c5141ff872bdc13814a273.tar.gz
otp-95ed86fc9893460751c5141ff872bdc13814a273.tar.bz2
otp-95ed86fc9893460751c5141ff872bdc13814a273.zip
Fix format_status bug for unregistered gen_event processes
Port the gen_fsm code for format_status to gen_event in order to prevent a lists:concat([...,pid()]) crash when calling sys:get_status/1 on an unregistered gen_event process. Refactor format_status header code from gen_* behaviours to module gen. Extend the format_status tests in gen_event_SUITE to cover format_status bugs with anonymous gen_event processes.
Diffstat (limited to 'lib/stdlib/test/gen_event_SUITE.erl')
-rw-r--r--lib/stdlib/test/gen_event_SUITE.erl22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/stdlib/test/gen_event_SUITE.erl b/lib/stdlib/test/gen_event_SUITE.erl
index 4f7de451e3..4c6466d860 100644
--- a/lib/stdlib/test/gen_event_SUITE.erl
+++ b/lib/stdlib/test/gen_event_SUITE.erl
@@ -24,10 +24,12 @@
-export([start/1, test_all/1, add_handler/1, add_sup_handler/1,
delete_handler/1, swap_handler/1, swap_sup_handler/1,
notify/1, sync_notify/1, call/1, info/1, hibernate/1,
- call_format_status/1, error_format_status/1]).
+ call_format_status/1, call_format_status_anon/1,
+ error_format_status/1]).
all(suite) -> {req, [stdlib], [start, test_all, hibernate,
- call_format_status, error_format_status]}.
+ call_format_status, call_format_status_anon,
+ error_format_status]}.
%% --------------------------------------
%% Start an event manager.
@@ -868,6 +870,22 @@ call_format_status(Config) when is_list(Config) ->
?line {"Installed handlers", [{_,dummy1_h,_,FmtState,_}]} = HandlerInfo2,
ok.
+call_format_status_anon(suite) ->
+ [];
+call_format_status_anon(doc) ->
+ ["Test that sys:get_status/1,2 calls format_status/2 for anonymous gen_event processes"];
+call_format_status_anon(Config) when is_list(Config) ->
+ ?line {ok, Pid} = gen_event:start(),
+ %% The 'Name' of the gen_event process will be a pid() here, so
+ %% the next line will crash if format_status can't string-ify pids.
+ ?line Status1 = sys:get_status(Pid),
+ ?line ok = gen_event:stop(Pid),
+ Header = "Status for event handler " ++ pid_to_list(Pid),
+ ?line {status, Pid, _, [_, _, Pid, [], Data1]} = Status1,
+ ?line Header = proplists:get_value(header, Data1),
+ ok.
+
+
error_format_status(suite) ->
[];
error_format_status(doc) ->