aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2018-03-05 11:28:09 +0100
committerJohn Högberg <[email protected]>2018-03-05 11:28:09 +0100
commitf6968db2c08dc96197a0d4af46a020f3a6c9bc6c (patch)
tree2cbe5a43b8d733aaa1bc8e207e75aa159ef5c6ca /erts/emulator
parentc25ef3f11a46046c20e5d8c5e99b36bffb2179d4 (diff)
parentae3e6b6d18019a8f8d1c5804e48cddffc9cc3c2d (diff)
downloadotp-f6968db2c08dc96197a0d4af46a020f3a6c9bc6c.tar.gz
otp-f6968db2c08dc96197a0d4af46a020f3a6c9bc6c.tar.bz2
otp-f6968db2c08dc96197a0d4af46a020f3a6c9bc6c.zip
Merge branch 'john/erts/efile_SUITE-iter-max-files-stability'
* john/erts/efile_SUITE-iter-max-files-stability: Make efile_SUITE:iter_max_files more stable
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/test/efile_SUITE.erl21
1 files changed, 12 insertions, 9 deletions
diff --git a/erts/emulator/test/efile_SUITE.erl b/erts/emulator/test/efile_SUITE.erl
index 16d581a567..821381bf0d 100644
--- a/erts/emulator/test/efile_SUITE.erl
+++ b/erts/emulator/test/efile_SUITE.erl
@@ -46,14 +46,14 @@ iter_max_files_1(Config) ->
DataDir = proplists:get_value(data_dir,Config),
TestFile = filename:join(DataDir, "existing_file"),
N = 10,
- %% Run on a different node in order to set the max ports
+ %% Run on a different node in order to make the test more stable.
Dir = filename:dirname(code:which(?MODULE)),
{ok,Node} = test_server:start_node(test_iter_max_files,slave,
- [{args,"+Q 1524 -pa " ++ Dir}]),
+ [{args,"-pa " ++ Dir}]),
L = rpc:call(Node,?MODULE,do_iter_max_files,[N, TestFile]),
test_server:stop_node(Node),
io:format("Number of files opened in each test:~n~w\n", [L]),
- all_equal(L),
+ verify_max_files(L),
Head = hd(L),
if Head >= 2 -> ok;
true -> ct:fail(too_few_files)
@@ -65,12 +65,15 @@ do_iter_max_files(N, Name) when N > 0 ->
do_iter_max_files(_, _) ->
[].
-all_equal([E, E| T]) ->
- all_equal([E| T]);
-all_equal([_]) ->
- ok;
-all_equal([]) ->
- ok.
+%% The attempts shouldn't vary too much; we used to require that they were all
+%% exactly equal, but after we reimplemented the file driver as a NIF we
+%% noticed that the only reason it was stable on Darwin was because the port
+%% limit was hit before ulimit.
+verify_max_files(Attempts) ->
+ N = length(Attempts),
+ Mean = lists:sum(Attempts) / N,
+ Variance = lists:sum([(X - Mean) * (X - Mean) || X <- Attempts]) / N,
+ true = math:sqrt(Variance) =< 1 + (Mean / 1000).
max_files(Name) ->
Fds = open_files(Name),