From 70b6b32a9c7e3e3fca45fc3a0e11e2a5087a4660 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Tue, 3 Oct 2017 14:53:42 +0200 Subject: Add app name tag in process dictionary --- lib/common_test/src/ct_util.erl | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/common_test/src/ct_util.erl') diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index abf131f4df..0e0d6f84e1 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -124,6 +124,7 @@ start(Mode, LogDir, Verbosity) -> end. do_start(Parent, Mode, LogDir, Verbosity) -> + put(app, common_test), process_flag(trap_exit,true), register(ct_util_server,self()), create_table(?conn_table,#conn.handle), -- cgit v1.2.3 From 2df013b5bfd714247570d9b4958b40f7559d35dd Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Fri, 6 Oct 2017 14:22:25 +0200 Subject: Tag Common Test system processes using process dictionary --- lib/common_test/src/ct_util.erl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/common_test/src/ct_util.erl') diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index 0e0d6f84e1..fd0db4a78d 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -65,6 +65,8 @@ -export([warn_duplicates/1]). +-export([mark_process/0, is_marked/1]). + -export([get_profile_data/0, get_profile_data/1, get_profile_data/2, open_url/3]). @@ -124,9 +126,9 @@ start(Mode, LogDir, Verbosity) -> end. do_start(Parent, Mode, LogDir, Verbosity) -> - put(app, common_test), process_flag(trap_exit,true), register(ct_util_server,self()), + mark_process(), create_table(?conn_table,#conn.handle), create_table(?board_table,2), create_table(?suite_table,#suite_data.key), @@ -931,6 +933,18 @@ warn_duplicates(Suites) -> lists:foreach(Warn, Suites), ok. +%%%----------------------------------------------------------------- +%%% @spec +%%% +%%% @doc +mark_process() -> + put(app, common_test). + +is_marked(Pid) -> + {dictionary,List} = process_info(self(), dictionary), + common_test == proplists:get_value(app, List). + + %%%----------------------------------------------------------------- %%% @spec %%% -- cgit v1.2.3 From ca7eb97b48c523cf2eb26d610894f8e3057b7740 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Sat, 7 Oct 2017 00:27:07 +0200 Subject: Implement function that finds disposable test processes --- lib/common_test/src/ct_util.erl | 61 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'lib/common_test/src/ct_util.erl') diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index fd0db4a78d..796a459bfe 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -65,7 +65,8 @@ -export([warn_duplicates/1]). --export([mark_process/0, is_marked/1]). +-export([mark_process/0, mark_process/1, is_marked/1, is_marked/2, + get_test_processes/0]). -export([get_profile_data/0, get_profile_data/1, get_profile_data/2, open_url/3]). @@ -938,12 +939,64 @@ warn_duplicates(Suites) -> %%% %%% @doc mark_process() -> - put(app, common_test). + mark_process(system). + +mark_process(Type) -> + put(ct_process_type, Type). is_marked(Pid) -> - {dictionary,List} = process_info(self(), dictionary), - common_test == proplists:get_value(app, List). + is_marked(Pid, system). + +is_marked(Pid, Type) -> + case process_info(Pid, dictionary) of + {dictionary,List} -> + Type == proplists:get_value(ct_process_type, List); + undefined -> + false + end. +get_test_processes() -> + Procs = processes(), + {SharedGL,OtherGLs,Procs2} = + lists:foldl( + fun(Pid, ProcTypes = {Shared,Other,Procs1}) -> + case is_marked(Pid, group_leader) of + true -> + if not is_pid(Shared) -> + case test_server_io:get_gl(true) of + Pid -> + {Pid,Other, + lists:delete(Pid,Procs1)}; + _ -> + {Shared,[Pid|Other],Procs1} + end; + true -> % SharedGL already found + {Shared,[Pid|Other],Procs1} + end; + false -> + case is_marked(Pid) of + true -> + {Shared,Other,lists:delete(Pid,Procs1)}; + false -> + ProcTypes + end + end + end, {undefined,[],Procs}, Procs), + + AllGLs = [SharedGL | OtherGLs], + TestProcs = + lists:flatmap(fun(Pid) -> + case process_info(Pid, group_leader) of + {group_leader,GL} -> + case lists:member(GL, AllGLs) of + true -> [{Pid,GL}]; + false -> [] + end; + undefined -> + [] + end + end, Procs2), + {TestProcs, SharedGL, OtherGLs}. %%%----------------------------------------------------------------- %%% @spec -- cgit v1.2.3 From 378da5aef27e1679aa30b8f4a2a6569accb70ff2 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Tue, 24 Oct 2017 16:24:18 +0200 Subject: Add tests and doc for the new remaining_test_procs function --- lib/common_test/src/ct_util.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/common_test/src/ct_util.erl') diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index 796a459bfe..468edc4bee 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -66,7 +66,7 @@ -export([warn_duplicates/1]). -export([mark_process/0, mark_process/1, is_marked/1, is_marked/2, - get_test_processes/0]). + remaining_test_procs/0]). -export([get_profile_data/0, get_profile_data/1, get_profile_data/2, open_url/3]). @@ -955,7 +955,7 @@ is_marked(Pid, Type) -> false end. -get_test_processes() -> +remaining_test_procs() -> Procs = processes(), {SharedGL,OtherGLs,Procs2} = lists:foldl( -- cgit v1.2.3