Skip to content

Commit

Permalink
fix: use only the module traces
Browse files Browse the repository at this point in the history
  • Loading branch information
yagogarea committed Jun 14, 2024
1 parent 41df3f4 commit 7b8eb7c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions apps/08-anillo-de-procesos/test/prop_ring.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ nmsgs() ->

message() ->
oneof(["Hola cara de bola",
"No te aburres de estos mensajes absurdos?",
"Hasta la vista, baby!",
"No contaban con mi astucia...",
"Enough is enough"]).
"No te aburres de estos mensajes absurdos?",
"Hasta la vista, baby!",
"No contaban con mi astucia...",
"Enough is enough"]).


%% Propiedade xeral
Expand All @@ -49,7 +49,7 @@ prop_ring() ->
%% Sub-propiedades
% (1) Comprobamos que se crean tantos procesos como se indica
creacion(NProcs, Trazas) ->
ParentsAndChildren = [{Parent, Child} || {trace, Parent, spawn, Child, _Fun} <- Trazas],
ParentsAndChildren = [{Parent, Child} || {trace, Parent, spawn, Child, {ring, _, _}} <- Trazas],
length(ParentsAndChildren) == NProcs.

% (2) Comprobamos que se envía a mensaxe o número de veces axeitado
Expand All @@ -64,9 +64,10 @@ recepcion(NMsgs, Msg, Trazas) ->

% (4) Comprobamos que se destrúen os procesos
destruccion(NProcs, Trazas) ->
RingProcs = [Child || {trace, _Parent, spawn, Child, {ring, _, _}} <- Trazas],
Stoppers = [{From, To} || {trace, From, send, stop, To} <- Trazas],
Stopped = [Who || {trace, Who, 'receive', stop} <- Trazas],
Exited = [Who || {trace, Who, exit, normal} <- Trazas],
Exited = [Who || {trace, Who, exit, normal} <- Trazas, lists:member(Who, RingProcs)],
(length(Stoppers) == length(Stopped)) andalso (length(Exited) == NProcs).

% Outras posibles sub-propiedades:
Expand Down Expand Up @@ -96,3 +97,4 @@ tracer(TraceList) ->
Other ->
tracer([Other|TraceList])
end.

0 comments on commit 7b8eb7c

Please sign in to comment.