diff options
author | Steve Vinoski <[email protected]> | 2010-05-09 12:19:16 -0400 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-05-27 16:53:24 +0200 |
commit | dab11bf07c66e1f119cc5d6198c8e90c5a02219e (patch) | |
tree | c4d69fedca3ab23224239ee2fc058867f08afe2b /lib/stdlib/test/gen_server_SUITE.erl | |
parent | 02e434b8befb2696adc98f23bcc195e1ae0539c3 (diff) | |
download | otp-dab11bf07c66e1f119cc5d6198c8e90c5a02219e.tar.gz otp-dab11bf07c66e1f119cc5d6198c8e90c5a02219e.tar.bz2 otp-dab11bf07c66e1f119cc5d6198c8e90c5a02219e.zip |
handle {global, term()} names in format_status/2
The gen_fsm, gen_server, and wx_object format_status implementations
fail to handle global names of the form {global, term()} where term()
is something other than an atom, pid, or list. Change these
format_status implementations to treat names that are atoms, pids, or
lists as before, but for all other terms, set the header property of
the function return value to a tuple whose first element is a string
describing the return value and whose second element is the name term.
Add unit tests for gen_server and gen_fsm to verify sys:get_status
calls work successfully for globally registered instances.
Diffstat (limited to 'lib/stdlib/test/gen_server_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/gen_server_SUITE.erl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/stdlib/test/gen_server_SUITE.erl b/lib/stdlib/test/gen_server_SUITE.erl index 0966734c89..99388ba2e3 100644 --- a/lib/stdlib/test/gen_server_SUITE.erl +++ b/lib/stdlib/test/gen_server_SUITE.erl @@ -905,6 +905,28 @@ call_format_status(Config) when is_list(Config) -> ?line Status2 = sys:get_status(call_format_status, 5000), ?line {status, Pid, _Mod, [_PDict, running, _Parent, _, Data2]} = Status2, ?line [format_status_called | _] = lists:reverse(Data2), + + %% check that format_status can handle a name being a pid (atom is + %% already checked by the previous test) + ?line {ok, Pid3} = gen_server:start_link(gen_server_SUITE, [], []), + ?line Status3 = sys:get_status(Pid3), + ?line {status, Pid3, _Mod, [_PDict3, running, _Parent, _, Data3]} = Status3, + ?line [format_status_called | _] = lists:reverse(Data3), + + %% check that format_status can handle a name being a term other than a + %% pid or atom + GlobalName1 = {global, "CallFormatStatus"}, + ?line {ok, Pid4} = gen_server:start_link(GlobalName1, + gen_server_SUITE, [], []), + ?line Status4 = sys:get_status(Pid4), + ?line {status, Pid4, _Mod, [_PDict4, running, _Parent, _, Data4]} = Status4, + ?line [format_status_called | _] = lists:reverse(Data4), + GlobalName2 = {global, {name, "term"}}, + ?line {ok, Pid5} = gen_server:start_link(GlobalName2, + gen_server_SUITE, [], []), + ?line Status5 = sys:get_status(GlobalName2), + ?line {status, Pid5, _Mod, [_PDict5, running, _Parent, _, Data5]} = Status5, + ?line [format_status_called | _] = lists:reverse(Data5), ok. %% Verify that error termination correctly calls our format_status/2 fun |