-module(syn_register_processes_SUITE). %% callbacks -export([all/0]). -export([init_per_suite/1, end_per_suite/1]). -export([groups/0, init_per_group/2, end_per_group/2]). %% tests -export([ single_node_when_mnesia_is_ram_simple_registration/1 ]). %% include -include_lib("common_test/include/ct.hrl"). %% =================================================================== %% Callbacks %% =================================================================== %% ------------------------------------------------------------------- %% Function: all() -> GroupsAndTestCases | {skip,Reason} %% GroupsAndTestCases = [{group,GroupName} | TestCase] %% GroupName = atom() %% TestCase = atom() %% Reason = term() %% ------------------------------------------------------------------- all() -> [ {group, single_node_process_registration} ]. %% ------------------------------------------------------------------- %% Function: groups() -> [Group] %% Group = {GroupName,Properties,GroupsAndTestCases} %% GroupName = atom() %% Properties = [parallel | sequence | Shuffle | {RepeatType,N}] %% GroupsAndTestCases = [Group | {group,GroupName} | TestCase] %% TestCase = atom() %% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}} %% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | %% repeat_until_any_ok | repeat_until_any_fail %% N = integer() | forever %% ------------------------------------------------------------------- groups() -> [ {single_node_process_registration, [shuffle], [ single_node_when_mnesia_is_ram_simple_registration ]} ]. %% ------------------------------------------------------------------- %% Function: init_per_suite(Config0) -> %% Config1 | {skip,Reason} | %% {skip_and_save,Reason,Config1} %% Config0 = Config1 = [tuple()] %% Reason = term() %% ------------------------------------------------------------------- init_per_suite(Config) -> %% config [ {slave_node_short_name, syn_slave} | Config ]. %% ------------------------------------------------------------------- %% Function: end_per_suite(Config0) -> void() | {save_config,Config1} %% Config0 = Config1 = [tuple()] %% ------------------------------------------------------------------- end_per_suite(_Config) -> ok. %% ------------------------------------------------------------------- %% Function: init_per_group(GroupName, Config0) -> %% Config1 | {skip,Reason} | %% {skip_and_save,Reason,Config1} %% GroupName = atom() %% Config0 = Config1 = [tuple()] %% Reason = term() %% ------------------------------------------------------------------- init_per_group(_GroupName, Config) -> Config. %% ------------------------------------------------------------------- %% Function: end_per_group(GroupName, Config0) -> %% void() | {save_config,Config1} %% GroupName = atom() %% Config0 = Config1 = [tuple()] %% ------------------------------------------------------------------- end_per_group(_GroupName, _Config) -> clean_after_test(). %% =================================================================== %% Tests %% =================================================================== single_node_when_mnesia_is_ram_simple_registration(_Config) -> %% set schema location application:set_env(mnesia, schema_location, ram), %% start ok = syn:start(), %% start process Pid = start_process(), %% retrieve undefined = syn:find_by_key(<<"my proc">>), %% register syn:register(<<"my proc">>, Pid), %% retrieve Pid = syn:find_by_key(<<"my proc">>), %% kill process kill_process(Pid), timer:sleep(100), %% retrieve undefined = syn:find_by_key(<<"my proc">>). %% =================================================================== %% Internal %% =================================================================== clean_after_test() -> %% stop mnesia mnesia:stop(), %% delete schema mnesia:delete_schema([node()]), %% stop syn syn:stop(). start_process() -> Pid = spawn(?MODULE, process_main, []), Pid. kill_process(Pid) -> exit(Pid, kill). process_main() -> receive shutdown -> ok end.