Debugging, improved logging, etc.

This commit is contained in:
Ulf Wiger
2026-05-30 13:15:17 +02:00
parent 2ea1966973
commit d7b052a076
14 changed files with 521 additions and 65 deletions
+29
View File
@@ -24,6 +24,9 @@
, checkl1/1
, checkl2/1
, checkl3/1
, reset/1
, reset_flow/1
, status/1
]).
-include_lib("stdlib/include/assert.hrl").
@@ -33,6 +36,7 @@ all() ->
{group, state}
, {group, statefuns}
, {group, workers}
, {group, reset}
].
groups() ->
@@ -47,6 +51,7 @@ groups() ->
, check2 %% state = 2
, incr
, check3 %% state = 3
, status
]}
, {workers, [sequence], [ init_counter
, init_worker
@@ -56,7 +61,19 @@ groups() ->
, checkl2 %% [A0, A1]
, append
, checkl3 %% [A0, A1, A2]
, status
]}
, {reset, [sequence], [ init_counter
, init_worker
, append %% also increments
, check1 %% so, state = 1
, checkl1
, reset_flow
, checkl1 %% flow 'my_list' unaffected
, init_counter
, incr
, check1
, status ]}
].
init_per_suite(Config) ->
@@ -74,9 +91,11 @@ end_per_group(_Grp, _Config) ->
ok.
init_per_testcase(_Case, Config) ->
gm_ctflow:status(),
Config.
end_per_testcase(_Case, _Config) ->
gm_ctflow:status(),
ok.
%% ======================================================================
@@ -101,6 +120,7 @@ erase_a(_Cfg) ->
%% easily threaded through the sequence of cases otherwise.
%%
init_counter(_Cfg) ->
gm_ctflow:status(),
gm_ctflow_fun:new(my_counter, fun ctr/2, 0),
ok.
@@ -122,6 +142,12 @@ ctr(incr, N) ->
NewN = N+1,
{ok, NewN, NewN}.
reset_flow(_Cfg) ->
gm_ctflow:reset_flow(my_counter).
status(_Cfg) ->
gm_ctflow:status().
%% ======================================================================
%% Here, we make use of the `gm_ctflow_worker` it's a complete process
%% (a gen_server, whose logic we instrument with the fun we provice).
@@ -155,3 +181,6 @@ checkl_(L) ->
lfun({call,_From}, {append, Item}, L) ->
NewL = L ++ [Item],
{reply, NewL, NewL}.
reset(_Cfg) ->
gm_ctflow:reset().