[erlang-patches] Fixed test suite for supervisor_child_count_only
Björn Gustavsson
bgustavsson@REDACTED
Wed Feb 10 15:55:34 CET 2010
On Wed, Feb 10, 2010 at 8:45 AM, Jay Nelson <jay@REDACTED> wrote:
> supervisor_SUITE will skip the count_children_memory test if +Meamin is
> used.
>
> git fetch git://github.com/jaynel/otp.git supervisor_child_count_only
Thanks! Will be included in pu.
We found a few stylistic problems that we want fixed before we can
graduate the branch. I have done the fixes, but want your approval
before I include them. (I intend to combine them with your commit.)
If you approve to the changes below, just reply to this email and
tell me that you approve, and we should be able to graduate this
branch before the feature freeze.
Date: Wed, 10 Feb 2010 15:42:38 +0100
Subject: [PATCH 1/2] fixup! Add count_children/1 to supervisor.erl to
determine the number of children being managed without the memory
impact of which_children/1
Use tuples, not lists, for collection of terms of
a fixed size.
---
lib/stdlib/src/supervisor.erl | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl
index d5c95b4..342b71f 100644
--- a/lib/stdlib/src/supervisor.erl
+++ b/lib/stdlib/src/supervisor.erl
@@ -320,10 +320,10 @@ handle_call(count_children, _From, State) when
?is_simple(State) ->
handle_call(count_children, _From, State) ->
%% Specs and children are together on the children list...
- [Specs, Active, Supers, Workers] =
+ {Specs, Active, Supers, Workers} =
lists:foldl(fun(Child, Counts) ->
count_child(Child, Counts)
- end, [0,0,0,0], State#state.children),
+ end, {0,0,0,0}, State#state.children),
%% Reformat counts to a property list.
Reply = [{specs, Specs}, {active, Active},
@@ -332,16 +332,16 @@ handle_call(count_children, _From, State) ->
count_child(#child{pid = Pid, child_type = worker},
- [Specs, Active, Supers, Workers]) ->
+ {Specs, Active, Supers, Workers}) ->
case is_pid(Pid) andalso is_process_alive(Pid) of
- true -> [Specs+1, Active+1, Supers, Workers+1];
- false -> [Specs+1, Active, Supers, Workers+1]
+ true -> {Specs+1, Active+1, Supers, Workers+1};
+ false -> {Specs+1, Active, Supers, Workers+1}
end;
count_child(#child{pid = Pid, child_type = supervisor},
- [Specs, Active, Supers, Workers]) ->
+ {Specs, Active, Supers, Workers}) ->
case is_pid(Pid) andalso is_process_alive(Pid) of
- true -> [Specs+1, Active+1, Supers+1, Workers];
- false -> [Specs+1, Active, Supers+1, Workers]
+ true -> {Specs+1, Active+1, Supers+1, Workers};
+ false -> {Specs+1, Active, Supers+1, Workers}
end.
Date: Wed, 10 Feb 2010 15:48:18 +0100
Subject: [PATCH 2/2] fixup! Add count_children/1 to supervisor.erl to
determine the number of children being managed without the memory
impact of which_children/1
Remove redundant parenthesis.
---
lib/stdlib/test/supervisor_SUITE.erl | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/stdlib/test/supervisor_SUITE.erl
b/lib/stdlib/test/supervisor_SUITE.erl
index aa4abdb..039ea29 100644
--- a/lib/stdlib/test/supervisor_SUITE.erl
+++ b/lib/stdlib/test/supervisor_SUITE.erl
@@ -1330,18 +1330,18 @@ count_children_memory(Config) when is_list(Config) ->
false ->
?line test_server:fail({count_children, used_more_memory})
end,
- case (Size7 =< Size6) of
+ case Size7 =< Size6 of
true -> ok;
false ->
?line test_server:fail({count_children, used_more_memory})
end,
- case (Size4 > Size3) of
+ case Size4 > Size3 of
true -> ok;
false ->
?line test_server:fail({which_children, used_no_memory})
end,
- case (Size6 > Size5) of
+ case Size6 > Size5 of
true -> ok;
false ->
?line test_server:fail({which_children, used_no_memory})
--
Björn Gustavsson, Erlang/OTP, Ericsson AB
More information about the erlang-patches
mailing list