Permalink
Browse files

tests: Limits - add consecutive set limits test

  • Loading branch information...
1 parent 9cb6fc6 commit 3dae4f1e1263832a88856fe472998acfa798b181 @psyeugenic committed Feb 2, 2012
Showing with 37 additions and 2 deletions.
  1. +37 −2 erts/emulator/test/limits_SUITE.erl
@@ -38,7 +38,8 @@
-export([
process_heap/1,
process_heap_check_size/1,
- do_not_trap_exit/1
+ do_not_trap_exit/1,
+ consecutive_limit_sets/1
]).
-include_lib("test_server/include/test_server.hrl").
@@ -49,7 +50,8 @@ all() ->
[
process_heap,
process_heap_check_size,
- do_not_trap_exit
+ do_not_trap_exit,
+ consecutive_limit_sets
].
groups() ->
@@ -198,6 +200,39 @@ do_not_trap_exit(_Conf) ->
ok.
+%% case consecutive_limit_sets
+
+consecutive_limit_sets(_Conf) ->
+ process_flag(trap_exit,true),
+ Me = self(),
+ Pids = [spawn_opt(fun() ->
+ [{heap_size, undefined}] = erlang:process_flag(limits, [{heap_size, 50000}]),
+ [{heap_size, 50000}] = erlang:process_flag(limits, [{heap_size, undefined}]),
+ [{heap_size, undefined}] = erlang:process_flag(limits, [{heap_size, 40000}]),
+ [{heap_size, 40000}] = erlang:process_flag(limits, [{heap_size, 500}]),
+ Above500 = lists:seq(1, 500),
+ erlang:garbage_collect(),
+ Me ! {self(), point_of_no_execute, length(Above500)}
+ end, [
+ link,
+ {limits, [{heap_size, undefined}]}
+ ]) || _ <- lists:seq(1,100)],
+ receive_consecutive_limits(Pids).
+
+receive_consecutive_limits([]) -> ok;
+receive_consecutive_limits(Pids) ->
+ receive
+ {'EXIT',Pid, {system_limit, {heap_size, _Size}}} ->
+ % yep, ok
+ receive_consecutive_limits(Pids -- [Pid]);
+ Msg ->
+ % "oh my gosh", to quote skrillex cup stacking
+ % we have an unexptected message, i.e. a failure
+ [exit(Id, kill) || Id <- Pids],
+ ct:fail("No system_limit exit, instead we got: ~p~n", [Msg])
+ end.
+
+
%% aux

0 comments on commit 3dae4f1

Please sign in to comment.