summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Högberg <john@erlang.org>2019-09-16 12:33:37 +0200
committerJohn Högberg <john@erlang.org>2019-09-17 14:42:11 +0200
commitc2efc811a9ffab2778faf82fe72d947019173532 (patch)
tree7888b9e2fc40db27e649b855a80642b26a83236c
parentbaddc3dc78e1723ba976b39cf25b51b9a24d6250 (diff)
downloaderlang-c2efc811a9ffab2778faf82fe72d947019173532.tar.gz
erts: Fail tests when disable_lock_counting() fails
Failing in init_per_testcase hid the errors since failed inits are auto-skipped, so we'll move the checks into the tests proper instead.
-rw-r--r--erts/emulator/test/lcnt_SUITE.erl27
1 files changed, 16 insertions, 11 deletions
diff --git a/erts/emulator/test/lcnt_SUITE.erl b/erts/emulator/test/lcnt_SUITE.erl
index 2dbaec9942..7bee7cf1d4 100644
--- a/erts/emulator/test/lcnt_SUITE.erl
+++ b/erts/emulator/test/lcnt_SUITE.erl
@@ -24,8 +24,7 @@
-export(
[all/0, suite/0,
- init_per_suite/1, end_per_suite/1,
- init_per_testcase/2, end_per_testcase/2]).
+ init_per_suite/1, end_per_suite/1]).
-export(
[toggle_lock_counting/1, error_on_invalid_category/1, preserve_locks/1,
@@ -63,13 +62,6 @@ end_per_suite(Config) ->
erts_debug:lcnt_clear(),
ok.
-init_per_testcase(_Case, Config) ->
- disable_lock_counting(),
- Config.
-
-end_per_testcase(_Case, _Config) ->
- ok.
-
disable_lock_counting() ->
ok = erts_debug:lcnt_control(copy_save, false),
ok = erts_debug:lcnt_control(mask, []),
@@ -96,7 +88,10 @@ wait_for_empty_lock_list(Tries) when Tries > 0 ->
wait_for_empty_lock_list(Tries - 1)
end;
wait_for_empty_lock_list(0) ->
- ct:fail("Lock list failed to clear after disabling lock counting.").
+ [{duration, _}, {locks, Locks0}] = erts_debug:lcnt_collect(),
+ Locks = remove_untoggleable_locks(Locks0),
+ ct:fail("Lock list failed to clear after disabling lock counting.~n\t~p",
+ [Locks]).
%% Queue up a lot of thread progress cleanup ops in a vain attempt to
%% flush the lock list.
@@ -109,6 +104,8 @@ try_flush_cleanup_ops() ->
%%
toggle_lock_counting(Config) when is_list(Config) ->
+ ok = disable_lock_counting(),
+
Categories =
[allocator, db, debug, distribution, generic, io, process, scheduler],
lists:foreach(
@@ -131,6 +128,8 @@ get_lock_info_for(Category) when is_atom(Category) ->
get_lock_info_for([Category]).
preserve_locks(Config) when is_list(Config) ->
+ ok = disable_lock_counting(),
+
erts_debug:lcnt_control(mask, [process]),
erts_debug:lcnt_control(copy_save, true),
@@ -155,10 +154,14 @@ preserve_locks(Config) when is_list(Config) ->
end.
error_on_invalid_category(Config) when is_list(Config) ->
+ ok = disable_lock_counting(),
+
{error, badarg, q_invalid} = erts_debug:lcnt_control(mask, [q_invalid]),
ok.
registered_processes(Config) when is_list(Config) ->
+ ok = disable_lock_counting(),
+
%% There ought to be at least one registered process (init/code_server)
erts_debug:lcnt_control(mask, [process]),
[_, {locks, ProcLocks}] = erts_debug:lcnt_collect(),
@@ -170,6 +173,8 @@ registered_processes(Config) when is_list(Config) ->
ok.
registered_db_tables(Config) when is_list(Config) ->
+ ok = disable_lock_counting(),
+
%% There ought to be at least one registered table (code)
erts_debug:lcnt_control(mask, [db]),
[_, {locks, DbLocks}] = erts_debug:lcnt_collect(),
@@ -187,7 +192,7 @@ remove_untoggleable_locks([]) ->
[];
remove_untoggleable_locks([{resource_monitors, _, _, _} | T]) ->
remove_untoggleable_locks(T);
-remove_untoggleable_locks([{'socket[gcnt]', _, _, _} | T]) ->
+remove_untoggleable_locks([{'esock[gcnt]', _, _, _} | T]) ->
%% Global lock used by socket NIF
remove_untoggleable_locks(T);
remove_untoggleable_locks([H | T]) ->