Debugged status inspection, add spawn/1, spawn_opt/2

This commit is contained in:
Ulf Wiger
2026-06-04 08:12:09 +02:00
parent b05895f14f
commit 03ec666998
4 changed files with 81 additions and 25 deletions
+22 -5
View File
@@ -6,10 +6,13 @@
, erase/1
]).
-export([note_flow/1,
ct_log/2, %% ct_log(Fmt, Args)
ct_log/3, %% ct_log(Flow, Fmt, Args)
timestamp/0]).
-export([ note_flow/1
, ct_log/2 %% ct_log(Fmt, Args)
, ct_log/3 %% ct_log(Flow, Fmt, Args)
, timestamp/0 ]).
-export([ spawn/1
, spawn_opt/2 ]).
-export([ status/0
, summarize_flow/1
@@ -106,6 +109,7 @@ summary_({fun_state, S}) -> fw("= Fun State: ~s~n", [maybe_state_str(S)]).
maybe_state_str({ok, S}) -> fw("~p", [S]);
maybe_state_str({error, E}) -> fw("ERROR: ~p", [E]);
maybe_state_str(undefined) -> "- none -";
maybe_state_str(error) -> "- none -".
fw(Fmt, Args) -> io_lib:fwrite(Fmt, Args).
@@ -114,7 +118,8 @@ try_call(F, Flow) ->
try F(Flow)
catch
exit:E:ST ->
ct:log("Call to ~p(~p) failed: exit:~p:~p", [F, Flow, E, ST]);
ct:log("Call to ~p(~p) failed: exit:~p:~p", [F, Flow, E, ST]),
undefined;
error:E:ST ->
ct:log("Call to ~p(~p) failed: error:~p:~p", [F, Flow, E, ST]),
undefined
@@ -129,3 +134,15 @@ timestamp() ->
lists:flatten(io_lib:format("~4.10.0B-~2.10.0B-~2.10.0B "
"~2.10.0B:~2.10.0B:~2.10.0B.~3.10.0B",
[Year,Month,Day,Hour,Min,Sec,MilliSec])).
spawn(F) ->
proc_lib:spawn(fun() ->
ct_util:mark_process(),
F()
end).
spawn_opt(F, Opts) ->
proc_lib:spawn_opt(fun() ->
ct_util:mark_process(),
F()
end, Opts).