Skip to content
Browse files

Added test and implementation for named starting another process

1 parent c567948 commit ffa6bec4d88fb81a03ac2f487dce2ab8e6efb8c1 Gianfranco committed Jul 8, 2011
Showing with 31 additions and 2 deletions.
  1. +15 −1 src/audit_collector.erl
  2. +16 −1 test/audit_collector_tests.erl
View
16 src/audit_collector.erl
@@ -74,6 +74,8 @@ options_to_trace_flag([named_send|R]) ->
[procs,send|options_to_trace_flag(R)];
options_to_trace_flag([named_receive|R]) ->
[procs,'receive'|options_to_trace_flag(R)];
+options_to_trace_flag([named_start|R]) ->
+ [procs|options_to_trace_flag(R)];
options_to_trace_flag([X|R]) ->
[X|options_to_trace_flag(R)];
options_to_trace_flag([]) -> [].
@@ -135,7 +137,19 @@ make_log([named_receive|R],History) ->
Acc;
Name -> Acc++[{'receive',Name,Msg}]
end
- end,[],Received)++make_log(R,History).
+ end,[],Received)++make_log(R,History);
+make_log([named_start|R],History) ->
+ Registered = registered(History),
+ Started = make_log([start],History),
+ lists:foldl(
+ fun({started,P,P2},Acc) ->
+ case proplists:get_value(P,Registered) of
+ undefined ->
+ Acc;
+ Name ->
+ Acc++[{started,Name,P2}]
+ end
+ end,[],Started)++make_log(R,History).
registered(History) ->
lists:foldl(
View
17 test/audit_collector_tests.erl
@@ -12,7 +12,8 @@ audit_collector_test_() ->
fun audit_collector_process_exited/0,
fun audit_collector_process_exited_deep/0,
fun audit_collector_process_named_send/0,
- fun audit_collector_process_named_receive/0
+ fun audit_collector_process_named_receive/0,
+ fun audit_collector_process_named_started/0
]}.
audit_collector_process_send() ->
@@ -104,3 +105,17 @@ audit_collector_process_named_receive() ->
?assertMatch(
[{'receive',iName,die}],
audit_collector:review(process,[named_receive])).
+
+audit_collector_process_named_started() ->
+ audit_collector:audit(process,[named_start]),
+ Self = self(),
+ Started = spawn(fun() ->
+ register(iName,self()),
+ Startee = spawn(lists,reverse,[[1,2,3]]),
+ Self ! {started,Startee} end),
+ {started,Startee} = receive X -> X end,
+ timer:sleep(10),
+ ?assertMatch(
+ [{started,iName,Startee}],
+ audit_collector:review(process,[named_start])).
+

0 comments on commit ffa6bec

Please sign in to comment.
Something went wrong with that request. Please try again.