File 1251-kernel-global-test-Tweaking.patch of Package erlang

From 72f900d1f6282edb86f726c916109f8ac6bb3107 Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Mon, 2 Aug 2021 14:45:57 +0200
Subject: [PATCH] [kernel|global|test] Tweaking

Add loop-counter (in the process dictionary) to the
'loop until true' function (for debugging).
Also, when receiving a timetrap timeout (from ct) during
'wait for ready net', also include the dictionary (so that
the loop-counter is shown in the printout). And finally
kill that process (which is waiting).
---
 lib/kernel/test/global_SUITE.erl | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/lib/kernel/test/global_SUITE.erl b/lib/kernel/test/global_SUITE.erl
index bdc4d9ce16..0c3e56741b 100644
--- a/lib/kernel/test/global_SUITE.erl
+++ b/lib/kernel/test/global_SUITE.erl
@@ -116,11 +116,13 @@
 
 -define(NODES, [node()|nodes()]).
 
--define(UNTIL(Seq), loop_until_true(fun() -> Seq end, Config)).
+-define(UNTIL(Seq), loop_until_true(fun() -> Seq end, Config, 1)).
 
 %% The resource used by the global module.
 -define(GLOBAL_LOCK, global).
 
+%% -define(DBG(T), erlang:display({{self(), ?MODULE, ?LINE, ?FUNCTION_NAME}, T})).
+
 
 suite() ->
     [{ct_hooks,[ts_install_cth]}].
@@ -447,7 +449,9 @@ init_high_level_trace(Time) ->
     os:putenv("GLOBAL_HIGH_LEVEL_TRACE", "TRUE"),
     put(?nodes_tag, []).
 
-loop_until_true(Fun, Config) ->
+loop_until_true(Fun, Config, N) ->
+    %% ?DBG([{n, N}]),
+    put(n, N),
     case Fun() of
 	true ->
 	    true;
@@ -455,7 +459,7 @@ loop_until_true(Fun, Config) ->
             case get(?end_tag) of
                 undefined ->
                     timer:sleep(?UNTIL_LOOP),
-                    loop_until_true(Fun, Config);
+                    loop_until_true(Fun, Config, N+1);
                 EndAt ->
                     Left = EndAt - msec(),
                     case Left < 6000 of
@@ -465,7 +469,7 @@ loop_until_true(Fun, Config) ->
                             receive Ref -> ok end;
                         false ->
                             timer:sleep(?UNTIL_LOOP),
-                            loop_until_true(Fun, Config)
+                            loop_until_true(Fun, Config, N+1)
                     end
             end
     end.
@@ -486,7 +490,8 @@ write_high_level_trace(Nodes, Config) ->
                Node <- Nodes],
     Dir = proplists:get_value(priv_dir, Config),
     DataFile = filename:join([Dir, lists:concat(["global_", ?testcase])]),
-    io:format("High-level trace on ~p\n", [DataFile]),
+    ?P("High-level trace on:"
+       "~n      ~p", [DataFile]),
     file:write_file(DataFile, term_to_binary({high_level_trace, When, Data})).
 
 lock_global2(Id, Parent) ->
-- 
2.31.1

openSUSE Build Service is sponsored by