diff options
author | Micael Karlberg <bmk@erlang.org> | 2020-02-24 14:54:48 +0100 |
---|---|---|
committer | Micael Karlberg <bmk@erlang.org> | 2020-02-24 17:51:27 +0100 |
commit | 3190b17a7205de6c188214d824c5d06058f3e0e9 (patch) | |
tree | 5ec8153a3f4a5ee37eacc19491b929a060b4f3b5 /lib | |
parent | c005c42aef78884328d80c36c157496a48f05a3c (diff) | |
download | erlang-3190b17a7205de6c188214d824c5d06058f3e0e9.tar.gz |
[snmp|test] Agent suite print cleanup
Diffstat (limited to 'lib')
-rw-r--r-- | lib/snmp/test/snmp_agent_SUITE.erl | 833 | ||||
-rw-r--r-- | lib/snmp/test/snmp_agent_test_lib.erl | 210 | ||||
-rw-r--r-- | lib/snmp/test/snmp_test_mgr.erl | 323 | ||||
-rw-r--r-- | lib/snmp/test/snmp_test_mgr_misc.erl | 64 |
4 files changed, 687 insertions, 743 deletions
diff --git a/lib/snmp/test/snmp_agent_SUITE.erl b/lib/snmp/test/snmp_agent_SUITE.erl index ca9df90192..2a6cfbedbe 100644 --- a/lib/snmp/test/snmp_agent_SUITE.erl +++ b/lib/snmp/test/snmp_agent_SUITE.erl @@ -578,9 +578,9 @@ all_cases() -> init_per_suite(Config0) when is_list(Config0) -> - p("init_per_suite -> entry with" - "~n Config: ~p" - "~n Nodes: ~p", [Config0, erlang:nodes()]), + ?IPRINT("init_per_suite -> entry with" + "~n Config: ~p" + "~n Nodes: ~p", [Config0, erlang:nodes()]), case ?LIB:init_per_suite(Config0) of {skip, _} = SKIP -> @@ -601,33 +601,34 @@ init_per_suite(Config0) when is_list(Config0) -> snmp_test_mgr_counter_server:start(), - p("init_per_suite -> end when" - "~n Config: ~p" - "~n Nodes: ~p", [Config4, erlang:nodes()]), + ?IPRINT("init_per_suite -> end when" + "~n Config: ~p" + "~n Nodes: ~p", [Config4, erlang:nodes()]), Config4 end. end_per_suite(Config0) when is_list(Config0) -> - p("end_per_suite -> entry with" - "~n Config0: ~p" - "~n Nodes: ~p", [Config0, erlang:nodes()]), + ?IPRINT("end_per_suite -> entry with" + "~n Config0: ~p" + "~n Nodes: ~p", [Config0, erlang:nodes()]), case snmp_test_mgr_counter_server:stop() of {ok, Counters} -> - p("end_per_suite -> sucessfully stopped counter server" - "~n Counters: ~p", [Counters]); + ?IPRINT("end_per_suite -> sucessfully stopped counter server" + "~n Counters: ~p", [Counters]); {error, Reason} -> - p("end_per_suite -> failed stopping counter server" - "~n Reason: ~p", [Reason]) + ?IPRINT("end_per_suite -> failed stopping counter server" + "~n Reason: ~p", [Reason]) end, snmp_test_sys_monitor:stop(), Config1 = ?LIB:end_per_suite(Config0), - p("end_per_suite -> end when" - "~n Nodes: ~p", [erlang:nodes()]), + ?IPRINT("end_per_suite -> end when" + "~n Nodes: ~p", [erlang:nodes()]), + Config1. @@ -831,17 +832,17 @@ wd_stop(Config) -> lists:keydelete(Dog, 2, Config). init_per_testcase(Case, Config) when is_list(Config) -> - p("init_per_testcase -> entry with" - "~n Config: ~p" - "~n Nodes: ~p", [Config, erlang:nodes()]), + ?IPRINT("init_per_testcase -> entry with" + "~n Config: ~p" + "~n Nodes: ~p", [Config, erlang:nodes()]), Result = init_per_testcase1(Case, Config), snmp_test_global_sys_monitor:reset_events(), - p("init_per_testcase -> done when" - "~n Result: ~p" - "~n Nodes: ~p", [Result, erlang:nodes()]), + ?IPRINT("init_per_testcase -> done when" + "~n Result: ~p" + "~n Nodes: ~p", [Result, erlang:nodes()]), Result. init_per_testcase1(otp8395 = Case, Config) when is_list(Config) -> @@ -923,13 +924,14 @@ init_per_testcase2(Case, Config) -> %% ---- End Per TestCase ---- end_per_testcase(Case, Config) when is_list(Config) -> - p("end_per_testcase -> entry with" - "~n Config: ~p" - "~n Nodes: ~p", - [Config, erlang:nodes()]), - p("system events during test: " - "~n ~p", [snmp_test_global_sys_monitor:events()]), + ?IPRINT("end_per_testcase -> entry with" + "~n Config: ~p" + "~n Nodes: ~p", + [Config, erlang:nodes()]), + + ?IPRINT("system events during test: " + "~n ~p", [snmp_test_global_sys_monitor:events()]), %% On some hosts, this operation can take a long time. %% So long, that the timetrap expires and the test case @@ -953,17 +955,17 @@ end_per_testcase(Case, Config) when is_list(Config) -> process_flag(trap_exit, Flag), ok after DisplayLogTimeout -> - p("Display Log process fail to complete in time (~w msec): kill it", - [DisplayLogTimeout]), + ?WPRINT("Display Log process fail to complete in time (~w msec): " + "kill it", [DisplayLogTimeout]), process_flag(trap_exit, Flag), exit(Pid, kill) end, Result = end_per_testcase1(Case, Config), - p("end_per_testcase -> done with" - "~n Result: ~p" - "~n Nodes: ~p", [Result, erlang:nodes()]), + ?IPRINT("end_per_testcase -> done with" + "~n Result: ~p" + "~n Nodes: ~p", [Result, erlang:nodes()]), Result. end_per_testcase1(otp8395, Config) when is_list(Config) -> @@ -1185,28 +1187,28 @@ varm_mib_storage_mnesia_cases() -> [msm_varm_mib_start]. init_mib_storage_ets(Config) when is_list(Config) -> - ?LOG("init_mib_storage_ets -> entry", []), + ?IPRINT("init_mib_storage_ets -> entry"), MibStorage = {mib_storage, [{module, snmpa_mib_storage_ets}]}, init_ms(Config, [MibStorage]). init_mib_storage_dets(Config) when is_list(Config) -> - ?LOG("init_mib_storage_dets -> entry", []), + ?IPRINT("init_mib_storage_dets -> entry"), ?line AgentDbDir = ?GCONF(agent_db_dir, Config), MibStorage = {mib_storage, [{module, snmpa_mib_storage_dets}, {options, [{dir, AgentDbDir}]}]}, init_ms(Config, [MibStorage]). init_mib_storage_mnesia(Config) when is_list(Config) -> - ?LOG("init_mib_storage_mnesia -> entry", []), + ?IPRINT("init_mib_storage_mnesia -> entry"), ?line AgentNode = ?GCONF(snmp_master, Config), MibStorage = {mib_storage, [{module, snmpa_mib_storage_mnesia}, {options, [{nodes, [AgentNode]}]}]}, init_ms(Config, [MibStorage]). init_ms(Config, Opts) when is_list(Config) -> - ?LOG("init_ms -> entry with" - "~n Config: ~p" - "~n Opts: ~p", [Config, Opts]), + ?IPRINT("init_ms -> entry with" + "~n Config: ~p" + "~n Opts: ~p", [Config, Opts]), ?line SaNode = ?GCONF(snmp_sa, Config), ?line create_tables(SaNode), ?line AgentConfDir = ?GCONF(agent_conf_dir, Config), @@ -1243,16 +1245,16 @@ init_size_check_ms(Config, Opts) when is_list(Config) -> ok -> case ?CRYPTO_SUPPORT() of {no, Reason} -> - ?INF("crypto support not sufficient:" - "~n ~p", [Reason]), + ?WPRINT("crypto support not sufficient:" + "~n ~p", [Reason]), ?SKIP({unsupported_encryption, Reason}); yes -> - ?INF("crypto started"), + ?IPRINT("crypto started"), ok end; {error, Reason} -> - ?INF("crypto not started:" - "~n ~p", [Reason]), + ?IPRINT("crypto not started:" + "~n ~p", [Reason]), ?SKIP({failed_starting_crypto, Reason}) end, create_tables(SaNode), @@ -1264,7 +1266,7 @@ init_size_check_ms(Config, Opts) when is_list(Config) -> [{vsn, v3} | start_v3_agent(Config, Opts)]. init_varm_mib_storage_dets(Config) when is_list(Config) -> - ?LOG("init_varm_mib_storage_dets -> entry", []), + ?IPRINT("init_varm_mib_storage_dets -> entry"), ?line SaNode = ?GCONF(snmp_sa, Config), ?line create_tables(SaNode), ?line AgentDbDir = ?GCONF(agent_db_dir, Config), @@ -1285,7 +1287,7 @@ init_varm_mib_storage_dets(Config) when is_list(Config) -> [{vsn, v1}, {agent_opts, Opts} | Config]. init_varm_mib_storage_mnesia(Config) when is_list(Config) -> - ?LOG("init_varm_mib_storage_mnesia -> entry", []), + ?IPRINT("init_varm_mib_storage_mnesia -> entry"), ?line SaNode = ?GCONF(snmp_sa, Config), ?line create_tables(SaNode), ?line AgentConfDir = ?GCONF(agent_conf_dir, Config), @@ -1306,7 +1308,7 @@ init_varm_mib_storage_mnesia(Config) when is_list(Config) -> [{vsn, v1}, {agent_opts, Opts} | Config]. finish_mib_storage_ets(Config) when is_list(Config) -> - ?LOG("finish_mib_storage_ets -> entry", []), + ?IPRINT("finish_mib_storage_ets -> entry"), delete_tables(), C1 = stop_agent(Config), delete_files(C1), @@ -1314,7 +1316,7 @@ finish_mib_storage_ets(Config) when is_list(Config) -> lists:keydelete(agent_opts, 1, C2). finish_mib_storage_dets(Config) when is_list(Config) -> - ?LOG("finish_mib_storage_dets -> entry", []), + ?IPRINT("finish_mib_storage_dets -> entry"), delete_tables(), C1 = stop_agent(Config), delete_files(C1), @@ -1322,7 +1324,7 @@ finish_mib_storage_dets(Config) when is_list(Config) -> lists:keydelete(agent_opts, 1, C2). finish_mib_storage_mnesia(Config) when is_list(Config) -> - ?LOG("finish_mib_storage_mnesia -> entry", []), + ?IPRINT("finish_mib_storage_mnesia -> entry"), delete_tables(), delete_mib_storage_mnesia_tables(), C1 = stop_agent(Config), @@ -1331,7 +1333,7 @@ finish_mib_storage_mnesia(Config) when is_list(Config) -> lists:keydelete(agent_opts, 1, C2). finish_varm_mib_storage_dets(Config) when is_list(Config) -> - ?LOG("finish_varm_mib_storage_dets -> entry", []), + ?IPRINT("finish_varm_mib_storage_dets -> entry"), delete_tables(), %% C1 = stop_agent(Config), % In case something went wrong... delete_files(Config), @@ -1339,7 +1341,7 @@ finish_varm_mib_storage_dets(Config) when is_list(Config) -> lists:keydelete(agent_opts, 1, C2). finish_varm_mib_storage_mnesia(Config) when is_list(Config) -> - ?LOG("finish_varm_mib_storage_mnesia -> entry", []), + ?IPRINT("finish_varm_mib_storage_mnesia -> entry"), delete_tables(), delete_mib_storage_mnesia_tables(), %% C1 = stop_agent(Config), % In case something went wrong... @@ -1450,7 +1452,7 @@ ms_size_check(suite) -> []; ms_size_check(Config) when is_list(Config) -> ?P(ms_size_check), init_case(Config), - ?LOG("mib server size check...", []), + ?IPRINT("mib server size check..."), ?line load_master("Test2"), ?line load_master("TestTrap"), @@ -1491,7 +1493,7 @@ ms_size_check(Config) when is_list(Config) -> varm_mib_start(suite) -> []; varm_mib_start(Config) when is_list(Config) -> ?P(varm_mib_start), - ?LOG("varm_mib_start -> entry", []), + ?IPRINT("varm_mib_start -> entry"), init_case(Config), %% Start the agent @@ -1745,41 +1747,41 @@ create_local_db_dir(Config) when is_list(Config) -> DbDir = filename:join([DataDir, As, Bs, Cs]), Name = list_to_atom(atom_to_list(create_local_db_dir) ++"_"++As++"_"++Bs++"_"++Cs), - p("try ensuring db-dir does not exist"), + ?IPRINT("try ensuring db-dir does not exist"), try del_dir(DbDir, 3) of ok -> ok catch C:E:S -> - e("Failed pre db-dir delete: " - "~n Class: ~p" - "~n Error: ~p" - "~n Stack: ~p", [C, E, S]), + ?WPRINT("Failed pre db-dir delete: " + "~n Class: ~p" + "~n Error: ~p" + "~n Stack: ~p", [C, E, S]), throw({skip, "Failed pre db-dir cleanup"}) end, - p("try start node ~p", [Name]), + ?IPRINT("try start node ~p", [Name]), case ?ALIB:start_node(Name) of {ok, Node} -> {DbDir, Node}; {error, Reason} -> - e("Failed starting node ~p:" + ?WPRINT("Failed starting node ~p:" "~n ~p", [Reason]), throw({skip, ?F("Failed starting node ~p", [Name])}) end end, Case = fun do_create_local_db_dir/1, Post = fun({DbDir, Node}) -> - p("try stop node ~p", [Node]), + ?IPRINT("try stop node ~p", [Node]), ?ALIB:stop_node(Node), - p("try delete db-dir"), + ?IPRINT("try delete db-dir"), try del_dir(DbDir, 3) catch C:E:S -> - e("Failed post db-dir delete: " - "~n DbDir ~s" - "~n Class: ~p" - "~n Error: ~p" - "~n Stack: ~p", [DbDir, C, E, S]), + ?WPRINT("Failed post db-dir delete: " + "~n DbDir ~s" + "~n Class: ~p" + "~n Error: ~p" + "~n Stack: ~p", [DbDir, C, E, S]), ok end end, @@ -1792,7 +1794,8 @@ do_create_local_db_dir({DbDir, Node}) -> false = filelib:is_dir(DbDir), process_flag(trap_exit,true), {error, {error, {failed_open_dets, {file_error, _, _}}}} = - snmpa_local_db:start_link(normal, DbDir, [{verbosity,trace}]), + snmpa_local_db:start_link(normal, DbDir, + [{verbosity, trace}]), false = filelib:is_dir(DbDir), {ok, not_found} end, @@ -2073,16 +2076,16 @@ init_v3(Config) when is_list(Config) -> ok -> case ?CRYPTO_SUPPORT() of {no, Reason} -> - ?INF("crypto support not sufficient:" - "~n ~p", [Reason]), + ?WPRINT("crypto support not sufficient:" + "~n ~p", [Reason]), ?SKIP({unsupported_encryption, Reason}); yes -> - ?INF("crypto started"), + ?IPRINT("crypto started"), ok end; {error, Reason} -> - ?INF("crypto not started:" - "~n ~p", [Reason]), + ?IPRINT("crypto not started:" + "~n ~p", [Reason]), ?SKIP({failed_starting_crypto, Reason}) end, SaNode = ?config(snmp_sa, Config), @@ -2202,7 +2205,7 @@ simple(Config) when is_list(Config) -> try_test(simple_standard_test), - p("done"), + ?IPRINT("done"), ok. simple_2(X) -> ?P(simple_2), simple(X). @@ -2229,7 +2232,7 @@ big(Config) when is_list(Config) -> {SaNode, _MgrNode, _MibDir} = init_case(Config), - ?P1("Starting subagent..."), + ?NPRINT("Starting subagent..."), ?line pong = net_adm:ping(SaNode), ?line {ok, SA} = start_subagent(SaNode, ?klas1, "Klas1"), @@ -2258,7 +2261,7 @@ big2(Config) when is_list(Config) -> %% v2 equivalent of the mibs. {SaNode, _MgrNode, _MibDir} = init_case(Config), - ?P1("Starting subagent..."), + ?NPRINT("Starting subagent..."), ?line pong = net_adm:ping(SaNode), ?line {ok, SA} = start_subagent(SaNode, ?klas1, "Klas1-v2"), @@ -2364,7 +2367,7 @@ opaque_3(X) -> ?P(opaque_2), opaque(X). change_target_addr_config(suite) -> []; change_target_addr_config(Config) when is_list(Config) -> ?P(change_target_addr_config), - ?LOG("change_target_addr_config -> entry",[]), + ?IPRINT("change_target_addr_config -> entry"), init_case(Config), put(sname,snmp_suite), @@ -2372,43 +2375,43 @@ change_target_addr_config(Config) when is_list(Config) -> MA = whereis(snmp_master_agent), - ?LOG("change_target_addr_config -> load TestTrap",[]), + ?IPRINT("change_target_addr_config -> load TestTrap"), ?line load_master("TestTrap"), - ?LOG("change_target_addr_config -> set trace verbosity for local_db",[]), + ?IPRINT("change_target_addr_config -> set trace verbosity for local_db"), ?line snmpa:verbosity(local_db,trace), %% First send some traps that will arive att the original manager - ?LOG("change_target_addr_config -> send trap",[]), + ?IPRINT("change_target_addr_config -> send trap"), try_test(ma_trap1, [MA]), - ?LOG("change_target_addr_config -> set silence verbosity for local_db",[]), + ?IPRINT("change_target_addr_config -> set silence verbosity for local_db"), ?line snmpa:verbosity(local_db, silence), %% Start new dummy listener - ?LOG("change_target_addr_config -> start dummy manager",[]), + ?IPRINT("change_target_addr_config -> start dummy manager"), ?line {ok,Pid,NewPort} = dummy_manager_start(MA), %% Reconfigure - ?LOG("change_target_addr_config -> reconfigure",[]), + ?IPRINT("change_target_addr_config -> reconfigure"), AgentConfDir = ?config(agent_conf_dir, Config), ?line rewrite_target_addr_conf(AgentConfDir, NewPort), ?line snmp_target_mib:reconfigure(AgentConfDir), %% Send the trap again - ?LOG("change_target_addr_config -> send trap again",[]), + ?IPRINT("change_target_addr_config -> send trap again"), catch dummy_manager_send_trap2(Pid), - ?LOG("change_target_addr_config -> await trap ack",[]), + ?IPRINT("change_target_addr_config -> await trap ack"), catch dummy_manager_await_trap2_ack(), - ?LOG("change_target_addr_config -> stop dummy manager",[]), + ?IPRINT("change_target_addr_config -> stop dummy manager"), ?line ok = dummy_manager_stop(Pid), - ?LOG("change_target_addr_config -> reset target address config",[]), + ?IPRINT("change_target_addr_config -> reset target address config"), ?line reset_target_addr_conf(AgentConfDir), - ?LOG("change_target_addr_config -> unload TestTrap",[]), + ?IPRINT("change_target_addr_config -> unload TestTrap"), ?line unload_master("TestTrap"). @@ -2424,11 +2427,15 @@ await_dummy_manager_started(Pid) -> ?DBG("dummy_manager_start -> acknowledge received with" "~n Port: ~p",[Port]), {ok,Pid,Port}; + {'EXIT', Pid, Reason} -> + ?EPRINT("dummy manager terminated: " + "~n ~p", [Reason]), {error, Pid, Reason}; + _O -> - ?LOG("dummy_manager_start -> received unknown message:" - "~n ~p",[_O]), + ?NPRINT("dummy_manager_start -> received unknown message:" + "~n ~p", [_O]), await_dummy_manager_started(Pid) end. @@ -2440,7 +2447,7 @@ dummy_manager_stop(Pid) -> ?DBG("dummy_manager_stop -> acknowledge received",[]), ok after 10000 -> - ?ERR("dummy_manager_stop -> timeout",[]), + ?EPRINT("dummy_manager_stop -> timeout"), timeout end. @@ -2452,7 +2459,7 @@ dummy_manager_await_trap2_ack() -> ?DBG("dummy_manager_await_trap2 -> entry",[]), receive {received_trap, _Trap} -> - ?LOG("dummy_manager_await_trap2 -> received trap: ~p", [_Trap]), + ?IPRINT("dummy_manager_await_trap2 -> received trap: ~p", [_Trap]), %% Note: %% Without this sleep the v2_inform_i testcase failes! There %% is no relation between these two test cases as far as I @@ -2460,10 +2467,10 @@ dummy_manager_await_trap2_ack() -> ?SLEEP(60000), ok; _O -> - ?ERR("dummy_manager_await_trap2 -> unexpected message: ~p",[_O]), + ?WPRINT("dummy_manager_await_trap2 -> unexpected message: ~p",[_O]), ok after 10000 -> - ?ERR("dummy_manager_await_trap2 -> timeout",[]), + ?EPRINT("dummy_manager_await_trap2 -> timeout",[]), timeout end. @@ -2479,18 +2486,18 @@ dummy_manager_init(Parent,MA) -> dummy_manager_loop(Parent,S,MA). dummy_manager_loop(P,S,MA) -> - ?LOG("dummy_manager_loop -> ready for receive",[]), + ?IPRINT("dummy_manager_loop -> ready for receive"), receive {send_trap,Trap} -> - ?LOG("dummy_manager_loop -> received trap send request" - "~n Trap: ~p",[Trap]), + ?IPRINT("dummy_manager_loop -> received trap send request" + "~n Trap: ~p", [Trap]), snmpa:send_trap(MA, Trap, "standard trap"), dummy_manager_loop(P,S,MA); {udp, _UdpId, _Ip, _UdpPort, Bytes} -> - ?LOG("dummy_manager_loop -> received upd message" - "~n from: ~p:~p" - "~n size: ~p", - [_Ip, _UdpPort, dummy_manager_message_sz(Bytes)]), + ?IPRINT("dummy_manager_loop -> received upd message" + "~n from: ~p:~p" + "~n size: ~p", + [_Ip, _UdpPort, dummy_manager_message_sz(Bytes)]), R = dummy_manager_handle_message(Bytes), ?DBG("dummy_manager_loop -> R: ~p", [R]), P ! R, @@ -2501,30 +2508,31 @@ dummy_manager_loop(P,S,MA) -> gen_udp:close(S), exit(normal); _O -> - ?LOG("dummy_manager_loop -> received unknown message:" - "~n ~p", [_O]), + ?WPRINT("dummy_manager_loop -> received unknown message:" + "~n ~p", [_O]), dummy_manager_loop(P, S, MA) end. --ifdef(snmp_log). +%% -ifdef(snmp_log). dummy_manager_message_sz(B) when is_binary(B) -> size(B); dummy_manager_message_sz(L) when is_list(L) -> length(L); dummy_manager_message_sz(_) -> undefined. --endif. +%% -endif. dummy_manager_handle_message(Bytes) -> case (catch snmp_pdus:dec_message(Bytes)) of {'EXIT',Reason} -> - ?ERR("dummy_manager_handle_message -> " - "failed decoding message only:~n ~p",[Reason]), - {error,Reason}; + ?EPRINT("dummy_manager_handle_message -> " + "failed decoding message only:" + "~n ~p", [Reason]), + {error, Reason}; M -> ?DBG("dummy_manager_handle_message -> decoded message:" - "~n ~p",[M]), - {received_trap,M} + "~n ~p", [M]), + {received_trap, M} end. @@ -2551,19 +2559,20 @@ subagent(Config) when is_list(Config) -> ?line {ok, SA} = start_subagent(SaNode, ?klas1, "Klas1"), try_test(load_test_sa), - ?P1("Testing unregister subagent..."), + ?NPRINT("Testing unregister subagent..."), MA = whereis(snmp_master_agent), rpc:call(SaNode, snmp, unregister_subagent, [MA, SA]), try_test(unreg_test), - ?P1("Loading previous subagent mib in master and testing..."), + ?NPRINT("Loading previous subagent mib in master and testing..."), ?line ok = snmpa:load_mib(MA, join(MibDir, "Klas1")), try_test(load_test), - ?P1("Unloading previous subagent mib in master and testing..."), + ?NPRINT("Unloading previous subagent mib in master and testing..."), ?line ok = snmpa:unload_mib(MA, join(MibDir, "Klas1")), try_test(unreg_test), - ?P1("Testing register subagent..."), + + ?NPRINT("Testing register subagent..."), rpc:call(SaNode, snmp, register_subagent, [MA, ?klas1, SA]), try_test(load_test_sa), @@ -2589,14 +2598,14 @@ mnesia(Config) when is_list(Config) -> ?P(mnesia), {SaNode, _MgrNode, _MibDir} = init_case(Config), - ?P1("Starting subagent with mnesia impl..."), + ?NPRINT("Starting subagent with mnesia impl..."), {ok, SA} = start_subagent(SaNode, ?klas2, "Klas2"), ?line load_master("OLD-SNMPEA-MIB"), ?line init_old(), try_test(big_test_2), - ?P1("Testing unregister subagent..."), + ?NPRINT("Testing unregister subagent..."), MA = whereis(snmp_master_agent), rpc:call(SaNode, snmp, unregister_subagent, [MA, SA]), try_test(unreg_test), @@ -2663,7 +2672,7 @@ mul_get(Config) when is_list(Config) -> ?P(mul_get), init_case(Config), - ?P1("Testing multiple get..."), + ?NPRINT("Testing multiple get..."), try_test(do_mul_get). mul_get_2(X) -> ?P(mul_get_2), mul_get(X). @@ -2676,7 +2685,7 @@ mul_get_err(Config) when is_list(Config) -> ?P(mul_get_err), init_case(Config), - ?P1("Testing multiple get with error..."), + ?NPRINT("Testing multiple get with error..."), try_test(do_mul_get_err). mul_get_err_2(X) -> ?P(mul_get_err_2), mul_get_err(X). @@ -2689,7 +2698,7 @@ mul_next(Config) when is_list(Config) -> ?P(mul_next), init_case(Config), - ?P1("Testing multiple next..."), + ?NPRINT("Testing multiple next..."), try_test(do_mul_next). mul_next_2(X) -> ?P(mul_next_2), mul_next(X). @@ -2702,7 +2711,7 @@ mul_next_err(Config) when is_list(Config) -> ?P(mul_next_err), init_case(Config), - ?P1("Testing multiple next..."), + ?NPRINT("Testing multiple next..."), try_test(do_mul_next_err). mul_next_err_2(X) -> ?P(mul_next_err_2), mul_next_err(X). @@ -2715,7 +2724,7 @@ mul_set(Config) when is_list(Config) -> ?P(mul_set), init_case(Config), - ?P1("Testing multiple set..."), + ?NPRINT("Testing multiple set..."), try_test(do_mul_set). mul_set_2(X) -> ?P(mul_set_2), mul_set(X). @@ -2728,7 +2737,7 @@ mul_set_err(Config) when is_list(Config) -> ?P(mul_set_err), init_case(Config), - ?P1("Testing multiple set with error..."), + ?NPRINT("Testing multiple set with error..."), try_test(do_mul_set_err). mul_set_err_2(X) -> ?P(mul_set_err_2), mul_set_err(X). @@ -2742,30 +2751,30 @@ sa_register(Config) when is_list(Config) -> {SaNode, _MgrNode, MibDir} = init_case(Config), ?DBG("sa_register -> start subagent", []), - ?P1("start subagent..."), + ?NPRINT("start subagent..."), ?line {ok, SA} = start_subagent(SaNode, ?klas1, "Klas1"), ?DBG("sa_register -> unregister subagent", []), - ?P1("Testing unregister subagent (2)..."), + ?NPRINT("Testing unregister subagent (2)..."), MA = whereis(snmp_master_agent), rpc:call(SaNode, snmp, unregister_subagent, [MA, ?klas1]), try_test(unreg_test), - ?P1("Unloading Klas1..."), + ?NPRINT("Unloading Klas1..."), ?DBG("sa_register -> unload mibs", []), snmpa:unload_mib(SA, join(MibDir, "Klas1")), - ?P1("Loading SA-MIB..."), + ?NPRINT("Loading SA-MIB..."), ?DBG("sa_register -> unload mibs", []), snmpa:load_mib(SA, join(MibDir, "SA-MIB")), - ?P1("register subagent..."), + ?NPRINT("register subagent..."), ?DBG("sa_register -> register subagent", []), rpc:call(SaNode, snmp, register_subagent, [MA, ?sa, SA]), try_test(sa_mib), - ?P1("stop subagent..."), + ?NPRINT("stop subagent..."), ?DBG("sa_register -> stop subagent", []), ?line stop_subagent(SA). @@ -2782,32 +2791,32 @@ v1_trap(Config) when is_list(Config) -> trap1(Config) -> {SaNode, _MgrNode, _MibDir} = init_case(Config), - ?P1("start subagent..."), + ?NPRINT("start subagent..."), ?line {ok, SA} = start_subagent(SaNode, ?sa, "SA-MIB"), - ?P1("Testing trap sending from master agent..."), + ?NPRINT("Testing trap sending from master agent..."), MA = whereis(snmp_master_agent), - ?P1("load TestTrap & TestTrapv2..."), + ?NPRINT("load TestTrap & TestTrapv2..."), ?line load_master("TestTrap"), ?line load_master("TestTrapv2"), - ?P1("Testing trap sending from master-agent..."), + ?NPRINT("Testing trap sending from master-agent..."), try_test(ma_trap1, [MA]), try_test(ma_trap2, [MA]), try_test(ma_v2_2_v1_trap, [MA]), try_test(ma_v2_2_v1_trap2, [MA]), - ?P1("Testing trap sending from subagent..."), + ?NPRINT("Testing trap sending from subagent..."), try_test(sa_trap1, [SA]), try_test(sa_trap2, [SA]), try_test(sa_trap3, [SA]), - ?P1("unload TestTrap & TestTrapv2..."), + ?NPRINT("unload TestTrap & TestTrapv2..."), ?line unload_master("TestTrap"), ?line unload_master("TestTrapv2"), - ?P1("stop subagent..."), + ?NPRINT("stop subagent..."), ?line stop_subagent(SA). v2_trap(suite) -> []; @@ -2818,17 +2827,17 @@ v2_trap(Config) when is_list(Config) -> trap2(Config) -> {SaNode, _MgrNode, _MibDir} = init_case(Config), - ?P1("start subagent..."), + ?NPRINT("start subagent..."), ?line {ok, SA} = start_subagent(SaNode, ?sa, "SA-MIB"), - ?P1("Testing trap sending from master agent..."), + ?NPRINT("Testing trap sending from master agent..."), MA = whereis(snmp_master_agent), - ?P1("load TestTrap & TestTrapv2..."), + ?NPRINT("load TestTrap & TestTrapv2..."), ?line load_master("TestTrap"), ?line load_master("TestTrapv2"), - ?P1("Testing trap sending from master-agent..."), + ?NPRINT("Testing trap sending from master-agent..."), try_test(ma_v2_trap1, [MA]), try_test(ma_v2_trap2, [MA]), try_test(ma_v1_2_v2_trap, [MA]), @@ -2836,16 +2845,16 @@ trap2(Config) -> try_test(sa_mib), - ?P1("Testing trap sending from subagent..."), + ?NPRINT("Testing trap sending from subagent..."), try_test(sa_v1_2_v2_trap1, [SA]), try_test(sa_v1_2_v2_trap2, [SA]), try_test(sa_v1_2_v2_trap3, [SA]), - ?P1("unload TestTrap & TestTrapv2..."), + ?NPRINT("unload TestTrap & TestTrapv2..."), ?line unload_master("TestTrap"), ?line unload_master("TestTrapv2"), - ?P1("stop subagent..."), + ?NPRINT("stop subagent..."), ?line stop_subagent(SA). v3_trap(suite) -> []; @@ -2897,18 +2906,18 @@ inform_i(Config) -> MA = whereis(snmp_master_agent), - ?P1("load TestTrap & TestTrapv2..."), + ?NPRINT("load TestTrap & TestTrapv2..."), ?line load_master("TestTrap"), ?line load_master("TestTrapv2"), - ?P1("Testing inform sending from master agent... " + ?NPRINT("Testing inform sending from master agent... " "~nNOTE! This test takes a few minutes (10) to complete."), try_test(ma_v2_inform1, [MA]), try_test(ma_v2_inform2, [MA]), try_test(ma_v2_inform3, [MA]), - ?P1("unload TestTrap & TestTrapv2..."), + ?NPRINT("unload TestTrap & TestTrapv2..."), ?line unload_master("TestTrap"), ?line unload_master("TestTrapv2"), ok. @@ -2929,26 +2938,26 @@ sa_error(Config) when is_list(Config) -> ?P(sa_error), {SaNode, _MgrNode, _MibDir} = init_case(Config), - ?P1("load OLD-SNMPEA-MIB..."), + ?NPRINT("load OLD-SNMPEA-MIB..."), ?line load_master("OLD-SNMPEA-MIB"), ?line init_old(), - ?P1("start subagent..."), + ?NPRINT("start subagent..."), ?line {ok, SA} = start_subagent(SaNode, ?sa, "SA-MIB"), - ?P1("Testing sa bad value (is_set_ok)..."), + ?NPRINT("Testing sa bad value (is_set_ok)..."), try_test(sa_errs_bad_value), - ?P1("Testing sa gen err (set)..."), + ?NPRINT("Testing sa gen err (set)..."), try_test(sa_errs_gen_err), - ?P1("Testing too big..."), + ?NPRINT("Testing too big..."), try_test(sa_too_big), - ?P1("unload OLD-SNMPEA-MIB..."), + ?NPRINT("unload OLD-SNMPEA-MIB..."), ?line unload_master("OLD-SNMPEA-MIB"), - ?P1("stop subagent..."), + ?NPRINT("stop subagent..."), stop_subagent(SA). sa_error_2(X) -> @@ -2972,35 +2981,35 @@ next_across_sa(Config) when is_list(Config) -> {SaNode, _MgrNode, MibDir} = init_case(Config), MA = whereis(snmp_master_agent), - ?P1("start subagent (1)..."), + ?NPRINT("start subagent (1)..."), ?line {ok, SA} = start_subagent(SaNode, ?sa, "SA-MIB"), - ?P1("Loading another subagent mib (Klas1)..."), + ?NPRINT("Loading another subagent mib (Klas1)..."), ?line ok = snmpa:load_mib(SA, MibDir ++ "Klas1"), - ?P1("register subagent..."), + ?NPRINT("register subagent..."), rpc:call(SaNode, snmp, register_subagent, [MA, ?klas1, SA]), - ?P1("Load test subagent..."), + ?NPRINT("Load test subagent..."), try_test(load_test_sa), - ?P1("Testing next across subagent (endOfMibView from SA)..."), + ?NPRINT("Testing next across subagent (endOfMibView from SA)..."), try_test(next_across_sa_test), - ?P1("Unloading mib (Klas1)"), + ?NPRINT("Unloading mib (Klas1)"), snmpa:unload_mib(SA, join(MibDir, "Klas1")), rpc:call(SaNode, snmp, unregister_subagent, [MA, ?klas1]), try_test(unreg_test), - ?P1("Starting another subagent (2) "), + ?NPRINT("Starting another subagent (2) "), ?line {ok, SA2} = start_subagent(SaNode, ?klas1, "Klas1"), - ?P1("Testing next across subagent (wrong prefix from SA)..."), + ?NPRINT("Testing next across subagent (wrong prefix from SA)..."), try_test(next_across_sa_test), - ?P1("stop subagent (1)..."), + ?NPRINT("stop subagent (1)..."), stop_subagent(SA), - ?P1("stop subagent (2)..."), + ?NPRINT("stop subagent (2)..."), stop_subagent(SA2). next_across_sa_2(X) -> @@ -3025,27 +3034,27 @@ undo(Config) when is_list(Config) -> MA = whereis(snmp_master_agent), - ?P1("start subagent (1)..."), + ?NPRINT("start subagent (1)..."), ?line {ok, SA} = start_subagent(SaNode, ?sa, "SA-MIB"), - ?P1("Load Klas3 & Klas4..."), + ?NPRINT("Load Klas3 & Klas4..."), ?line ok = snmpa:load_mib(MA, join(MibDir, "Klas3")), ?line ok = snmpa:load_mib(MA, join(MibDir, "Klas4")), - ?P1("Testing undo phase at master agent..."), + ?NPRINT("Testing undo phase at master agent..."), try_test(undo_test), try_test(api_test2), - ?P1("Unload Klas3..."), + ?NPRINT("Unload Klas3..."), ?line ok = snmpa:unload_mib(MA, join(MibDir, "Klas3")), - ?P1("Testing bad return values from instrum. funcs..."), + ?NPRINT("Testing bad return values from instrum. funcs..."), try_test(bad_return), - ?P1("Unload Klas4..."), + ?NPRINT("Unload Klas4..."), ?line ok = snmpa:unload_mib(MA, join(MibDir, "Klas4")), - ?P1("Testing undo phase at subagent..."), + ?NPRINT("Testing undo phase at subagent..."), ?line ok = snmpa:load_mib(SA, join(MibDir, "Klas3")), ?line ok = snmpa:load_mib(SA, join(MibDir, "Klas4")), ?line ok = snmpa:register_subagent(MA, ?klas3, SA), @@ -3053,11 +3062,11 @@ undo(Config) when is_list(Config) -> try_test(undo_test), try_test(api_test3), - ?P1("Testing undo phase across master/subagents..."), + ?NPRINT("Testing undo phase across master/subagents..."), try_test(undo_test), try_test(api_test3), - ?P1("stop subagent..."), + ?NPRINT("stop subagent..."), stop_subagent(SA). undo_2(X) -> @@ -3081,12 +3090,12 @@ v1_processing(Config) when is_list(Config) -> ?DBG("v1_processing -> entry", []), init_case(Config), - ?P1("Load Test2..."), + ?NPRINT("Load Test2..."), ?line load_master("Test2"), try_test(v1_proc), - ?P1("Unload Test2..."), + ?NPRINT("Unload Test2..."), ?line unload_master("Test2"). %% Req. Test2 @@ -3095,12 +3104,12 @@ v2_processing(Config) when is_list(Config) -> ?P(v2_processing), init_case(Config), - ?P1("Load Test2..."), + ?NPRINT("Load Test2..."), ?line load_master("Test2"), try_test(v2_proc), - ?P1("Unload Test2..."), + ?NPRINT("Unload Test2..."), ?line unload_master("Test2"). %% Req. Test2 @@ -3109,12 +3118,12 @@ v3_processing(Config) when is_list(Config) -> ?P(v3_processing), init_case(Config), - ?P1("Load Test2..."), + ?NPRINT("Load Test2..."), ?line load_master("Test2"), try_test(v2_proc), % same as v2! - ?P1("Unload Test2..."), + ?NPRINT("Unload Test2..."), ?line unload_master("Test2"). @@ -3187,7 +3196,7 @@ v3_md5_auth(Config) when is_list(Config) -> ?P(v3_md5_auth), init_case(Config), - ?P1("Testing MD5 authentication...takes a few seconds..."), + ?NPRINT("Testing MD5 authentication...takes a few seconds..."), AgentConfDir = ?config(agent_conf_dir, Config), ?line rewrite_target_params_conf(AgentConfDir, "authMD5", authNoPriv), @@ -3214,7 +3223,7 @@ v3_sha_auth(Config) when is_list(Config) -> ?P(v3_sha_auth), init_case(Config), - ?P1("Testing SHA authentication...takes a few seconds..."), + ?NPRINT("Testing SHA authentication...takes a few seconds..."), AgentConfDir = ?config(agent_conf_dir, Config), ?line rewrite_target_params_conf(AgentConfDir, "authSHA", authNoPriv), @@ -3241,7 +3250,7 @@ v3_des_priv(Config) when is_list(Config) -> ?P(v3_des_priv), init_case(Config), - ?P1("Testing DES encryption...takes a few seconds..."), + ?NPRINT("Testing DES encryption...takes a few seconds..."), AgentConfDir = ?config(agent_conf_dir, Config), ?line rewrite_target_params_conf(AgentConfDir, "privDES", authPriv), @@ -3858,10 +3867,10 @@ big_test() -> %% Req. system group, Klas2, OLD-SNMPEA-MIB big_test_2() -> - ?P1("Testing simple next/get/set @ master agent (2)..."), + ?NPRINT("Testing simple next/get/set @ master agent (2)..."), simple_standard_test(), - ?P1("Testing simple next/get/set @ subagent (2)..."), + ?NPRINT("Testing simple next/get/set @ subagent (2)..."), gn([[klas2]]), ?line ?expect1([{[fname2,0], ""}]), g([[fname2,0]]), @@ -3873,7 +3882,7 @@ big_test_2() -> otp_1298_test(), - ?P1("Testing next from last object in master to subagent (2)..."), + ?NPRINT("Testing next from last object in master to subagent (2)..."), gn([[?v1_2(sysServices, sysORLastChange),0]]), ?line ?expect1([{[fname2,0], "test set"}]), gn([[1,1], [?v1_2(sysServices, sysORLastChange),0]]), @@ -3882,7 +3891,7 @@ big_test_2() -> table_test(), - ?P1("Adding one row in subagent table (2)"), + ?NPRINT("Adding one row in subagent table (2)"), _FTab = [friendsEntry2], s([{[friendsEntry2, [2, 3]], s, "kompis3"}, {[friendsEntry2, [3, 3]], i, ?createAndGo}]), @@ -3895,7 +3904,7 @@ big_test_2() -> s([{[friendsEntry2, [3, 3]], i, ?destroy}]), ?line ?expect1([{[friendsEntry2, [3, 3]], ?destroy}]), - ?P1("Adding two rows in subagent table with special INDEX (2)"), + ?NPRINT("Adding two rows in subagent table with special INDEX (2)"), s([{[kompissEntry2, [1, 3]], s, "kompis3"}, {[kompissEntry2, [2, 3]], i, ?createAndGo}]), ?line ?expect1([{[kompissEntry2, [1, 3]], "kompis3"}, @@ -3924,7 +3933,7 @@ big_test_2() -> %% Req. Test1 multi_threaded_test() -> - ?P1("Testing multi threaded agent..."), + ?NPRINT("Testing multi threaded agent..."), g([[multiStr,0]]), Pid = get_multi_pid(), g([[sysUpTime,0]]), @@ -3951,7 +3960,7 @@ multi_threaded_test() -> %% Req. Test1, TestTrapv2 mt_trap_test(MA) -> - ?P1("Testing trap-sending with multi threaded agent..."), + ?NPRINT("Testing trap-sending with multi threaded agent..."), ?DBG("mt_trap_test(01) -> issue testTrapv22 (standard trap)", []), snmpa:send_trap(MA, testTrapv22, "standard trap"), ?DBG("mt_trap_test(02) -> await v2trap", []), @@ -3997,7 +4006,7 @@ get_multi_pid(N) -> %% Req. Test1 types_v2_test() -> - ?P1("Testing v2 types..."), + ?NPRINT("Testing v2 types..."), s([{[bits1,0], 2#10}]), ?line ?expect1([{[bits1,0], ?str(2#10)}]), @@ -4024,8 +4033,9 @@ types_v2_test() -> %% Req. Test1 implied_test(MA) -> - ?LOG("implied_test -> start",[]), - ?P1("Testing IMPLIED..."), + ?IPRINT("implied_test -> start"), + + ?NPRINT("Testing IMPLIED..."), snmpa:verbosity(MA, trace), @@ -4083,13 +4093,14 @@ implied_test(MA) -> snmpa:verbosity(MA, log), - ?LOG("implied_test -> done", []). + ?IPRINT("implied_test -> done", []), + ok. %% Req. Test1 sparse_table_test() -> - ?P1("Testing sparse table..."), + ?NPRINT("Testing sparse table..."), %% Create two rows, check that they are get-nexted in correct order. Idx1 = 1, @@ -4119,11 +4130,12 @@ sparse_table_test() -> %% Req. Test1 cnt_64_test(MA) -> - ?LOG("start cnt64 test (~p)",[MA]), + ?IPRINT("start cnt64 test (~p)", [MA]), snmpa:verbosity(MA, trace), - ?LOG("start cnt64 test",[]), - ?P1("Testing Counter64, and at the same time, " - "RowStatus is not last column"), + ?IPRINT("start cnt64 test"), + + ?NPRINT("Testing Counter64, and at the same time, " + "RowStatus is not last column"), ?DBG("get cnt64",[]), g([[cnt64,0]]), @@ -4182,7 +4194,7 @@ cnt_64_test(MA) -> %% Req. Test1 opaque_test() -> - ?P1("Testing Opaque datatype..."), + ?NPRINT("Testing Opaque datatype..."), g([[opaqueObj,0]]), ?line ?expect1([{[opaqueObj,0], "opaque-data"}]). @@ -4324,7 +4336,7 @@ do_mul_next_err() -> %% Req. system group, Klas1, OLD-SNMPEA-MIB do_mul_set() -> - ?P1("Adding one row in subagent table, and one in master table"), + ?NPRINT("Adding one row in subagent table, and one in master table"), NewKeyc3 = [intCommunityEntry,[3],get(mip),is("test")], NewKeyc4 = [intCommunityEntry,[4],get(mip),is("test")], NewKeyc5 = [intCommunityEntry,[5],get(mip),is("test")], @@ -4358,7 +4370,7 @@ do_mul_set_err() -> NewKeyc3 = [intCommunityEntry,[3],get(mip),is("test")], NewKeyc4 = [intCommunityEntry,[4],get(mip),is("test")], NewKeyc5 = [intCommunityEntry,[5],get(mip),is("test")], - ?P1("Adding one row in subagent table, and one in master table"), + ?NPRINT("Adding one row in subagent table, and one in master table"), s([{[friendsEntry, [2, 3]], s, "kompis3"}, {NewKeyc3, 2}, {[sysUpTime,0], 45}, % sysUpTime (readOnly) @@ -4521,14 +4533,14 @@ ma_v2_inform1(MA) -> "~n with receiver: ~p", [_Addr]), ok; {snmp_targets, T, Addrs} -> - ?ERR("ma_v2_inform1 -> " - "received unexpected snmp_targets" - "~n with receivers: ~n ~p",[Addrs]), + ?EPRINT("ma_v2_inform1 -> " + "received unexpected snmp_targets" + "~n with receivers: ~n ~p",[Addrs]), {error, {bad_addrs, Addrs}} after 5000 -> - ?ERR("ma_v2_inform1 -> " - "timeout awaiting snmp_targets [~w]",[T]), + ?EPRINT("ma_v2_inform1 -> " + "timeout awaiting snmp_targets [~w]",[T]), {error, snmp_targets_timeout} end end, @@ -4542,16 +4554,16 @@ ma_v2_inform1(MA) -> "[with manager response] from: ~n ~p", [_Addr]), ok; {snmp_notification, Tag03, {no_response, _Addr}} -> - ?ERR("ma_v2_inform1 -> " - "received unexpected snmp_notification " - "[without manager response] from: ~n ~p", - [_Addr]), + ?EPRINT("ma_v2_inform1 -> " + "received unexpected snmp_notification " + "[without manager response] from: ~n ~p", + [_Addr]), {error, no_response} after 20000 -> - ?ERR("ma_v2_inform1 -> " - "timeout awaiting snmp_notification [~p]", - [Tag03]), + ?EPRINT("ma_v2_inform1 -> " + "timeout awaiting snmp_notification [~p]", + [Tag03]), {error, snmp_notification_timeout} end end, @@ -4576,9 +4588,9 @@ ma_v2_inform1(MA) -> fun() -> receive {snmp_notification, Tag07, {got_response, _Addr}} -> - ?ERR("ma_v2_inform1 -> " - "received unexpected snmp_notification " - "[with manager response] from: ~n ~p", [_Addr]), + ?EPRINT("ma_v2_inform1 -> " + "received unexpected snmp_notification " + "[with manager response] from: ~n ~p", [_Addr]), {error, got_response}; {snmp_notification, Tag07, {no_response, _Addr}} -> ?DBG("ma_v2_inform1 -> " @@ -4588,9 +4600,9 @@ ma_v2_inform1(MA) -> ok after 240000 -> - ?ERR("ma_v2_inform1 -> " - "timeout awaiting snmp_notification [~p]", - [Tag07]), + ?EPRINT("ma_v2_inform1 -> " + "timeout awaiting snmp_notification [~p]", + [Tag07]), {error, snmp_notification_timeout} end end, @@ -4640,26 +4652,28 @@ ma_v2_inform2(MA) -> %% Await callback(s) CmdAwaitDeliveryCallback = fun(Kind, Ref, Tag) -> - io:format("CmdAwaitDeliveryCallback -> entry with" - "~n Kind: ~p" - "~n Ref: ~p" - "~n Tag: ~p" - "~n", [Kind, Ref, Tag]), + ?IPRINT("CmdAwaitDeliveryCallback -> entry with" + "~n Kind: ~p" + "~n Ref: ~p" + "~n Tag: ~p", [Kind, Ref, Tag]), receive {Kind, Ref, ok} -> - io:format("CmdAwaitDeliveryCallback(~p,~p) -> received expected result: ok" - "~n", [Tag, Ref]), + ?IPRINT("CmdAwaitDeliveryCallback(~p,~p) -> " + "received expected result: ok" + "~n", [Tag, Ref]), ok; {Kind, Ref, Error} -> - io:format("CmdAwaitDeliveryCallback(~p,~p) -> received unexpected result: " - "~n Error: ~p" - "~n", [Tag, Ref, Error]), + ?IPRINT("CmdAwaitDeliveryCallback(~p,~p) -> " + "received unexpected result: " + "~n Error: ~p" + "~n", [Tag, Ref, Error]), {error, {unexpected_response, Error}} after 240000 -> - ?ERR("ma_v2_inform2 -> " - "timeout awaiting got_response for snmp_notification [~p]", - [Tag]), + ?EPRINT("ma_v2_inform2 -> " + "timeout awaiting got_response for " + "snmp_notification [~p]", + [Tag]), {error, snmp_notification_timeout} end end, @@ -4731,25 +4745,27 @@ ma_v2_inform3(MA) -> %% Await callback(s) CmdAwaitDeliveryCallback = fun(Kind, Ref, Tag) -> - io:format("CmdAwaitDeliveryCallback -> entry with" - "~n Kind: ~p" - "~n Ref: ~p" - "~n Tag: ~p" - "~n", [Kind, Ref, Tag]), + ?IPRINT("CmdAwaitDeliveryCallback -> entry with" + "~n Kind: ~p" + "~n Ref: ~p" + "~n Tag: ~p", [Kind, Ref, Tag]), receive {Kind, Ref, ok} -> - io:format("CmdAwaitDeliveryCallback(~p,~p) -> received expected result: ok" - "~n", [Tag, Ref]), + ?IPRINT("CmdAwaitDeliveryCallback(~p,~p) -> " + "received expected result: ok" + "~n", [Tag, Ref]), ok; {Kind, Ref, Error} -> - io:format("CmdAwaitDeliveryCallback(~p,~p) -> received unexpected result: " - "~n Error: ~p" - "~n", [Tag, Ref, Error]), + ?IPRINT("CmdAwaitDeliveryCallback(~p,~p) -> " + "received unexpected result: " + "~n Error: ~p" + "~n", [Tag, Ref, Error]), {error, {unexpected_response, Error}} after 240000 -> - ?ERR("ma_v2_inform3 -> " - "timeout awaiting got_response for snmp_notification [~p]", + ?EPRINT("ma_v2_inform3 -> " + "timeout awaiting got_response for " + "snmp_notification [~p]", [Tag]), {error, snmp_notification_timeout} end @@ -4832,16 +4848,16 @@ delivery_info(Tag, Address, DeliveryResult, Extra) -> command_handler([]) -> ok; command_handler([{_No, _Desc, Cmd}|Rest]) -> - ?LOG("command_handler -> command ~w: ~n ~s", [_No, _Desc]), + ?IPRINT("command_handler -> command ~w: ~n ~s", [_No, _Desc]), case (catch Cmd()) of ok -> - ?LOG("command_handler -> ~w: ok", [_No]), + ?IPRINT("command_handler -> ~w: ok", [_No]), command_handler(Rest); {error, Reason} -> - ?ERR("command_handler -> ~w error: ~n~p", [_No, Reason]), + ?EPRINT("command_handler -> ~w error: ~n~p", [_No, Reason]), ?line ?FAIL(Reason); Error -> - ?ERR("command_handler -> ~w unexpected: ~n~p", [_No, Error]), + ?EPRINT("command_handler -> ~w unexpected: ~n~p", [_No, Error]), ?line ?FAIL({unexpected_command_result, Error}) end. @@ -5119,7 +5135,7 @@ standard_mibs2_cases() -> snmpv2_mib_2(suite) -> []; snmpv2_mib_2(Config) when is_list(Config) -> ?P(snmpv2_mib_2), - ?LOG("snmpv2_mib_2 -> start",[]), + ?IPRINT("snmpv2_mib_2 -> start"), init_case(Config), ?DBG("snmpv2_mib_2 -> standard mib init",[]), @@ -5158,7 +5174,7 @@ snmpv2_mib_2(Config) when is_list(Config) -> "then disable auth traps",[]), try_test(snmpv2_mib_test_finish, [], [{community, "bad community"}]), - ?LOG("snmpv2_mib_2 -> done", []), + ?IPRINT("snmpv2_mib_2 -> done"), ok. @@ -5276,7 +5292,7 @@ snmp_community_mib_2(X) -> ?P(snmp_community_mib_2), snmp_community_mib(X). %% Req. SNMP-COMMUNITY-MIB snmp_community_mib_test() -> - ?INF("NOT YET IMPLEMENTED", []), + ?NPRINT("NOT YET IMPLEMENTED"), nyi. @@ -5325,7 +5341,7 @@ snmp_framework_mib_test() -> HighEngineTime = EngineTime + ASleep + 2, LowEngineTime = EngineTime + ASleep - 1, - ?PRINT2("snmp_framework_mib -> time(s): " + ?IPRINT("snmp_framework_mib -> time(s): " "~n EngineTime 1: ~p" "~n Time to acquire: ~w msec" "~n EngineTime 2: ~p" @@ -5341,12 +5357,12 @@ snmp_framework_mib_test() -> if (HighEngineTime < EngineTime2) -> - ?PRINT2("snmp_framework_mib -> (High) Engine Time diff (~w) too large: " + ?EPRINT("snmp_framework_mib -> (High) Engine Time diff (~w) too large: " "~n ~w < ~w", [EngineTimeDiff, HighEngineTime, EngineTime2]), ?line ?FAIL({too_large_diff, EngineTime, EngineTime2}); (LowEngineTime > EngineTime2) -> - ?PRINT2("snmp_framework_mib -> (Low) Engine Time diff (~w) too large: " + ?EPRINT("snmp_framework_mib -> (Low) Engine Time diff (~w) too large: " "~n ~w > ~w", [EngineTimeDiff, LowEngineTime, EngineTime2]), ?line ?FAIL({too_large_diff, EngineTime, EngineTime2}); @@ -5358,12 +5374,12 @@ snmp_framework_mib_test() -> ?line case get_req(4, [[snmpEngineBoots,0]]) of [Boots] when is_integer(Boots) -> T6 = snmp_misc:now(ms), - ?PRINT2("snmp_framework_mib -> " + ?IPRINT("snmp_framework_mib -> " "~n boots: ~p" "~n Time to acquire: ~w ms", [Boots, T6-T5]), ok; Else -> - ?PRINT2("snmp_framework_mib -> failed get proper boots:" + ?EPRINT("snmp_framework_mib -> failed get proper boots:" "~n ~p", [Else]), ?FAIL({invalid_boots, Else}) end, @@ -5453,7 +5469,7 @@ snmp_target_mib_2(X) -> ?P(snmp_target_mib_2), snmp_target_mib(X). snmp_target_mib_3(X) -> ?P(snmp_target_mib_3), snmp_target_mib(X). snmp_target_mib_test() -> - ?INF("NOT YET IMPLEMENTED", []), + ?NPRINT("NOT YET IMPLEMENTED"), nyi. snmp_notification_mib(suite) -> []; @@ -5471,7 +5487,7 @@ snmp_notification_mib_3(X) -> ?P(snmp_notification_mib_3), snmp_notification_mib(X). snmp_notification_mib_test() -> - ?INF("NOT YET IMPLEMENTED", []), + ?NPRINT("NOT YET IMPLEMENTED"), nyi. @@ -5507,7 +5523,7 @@ snmp_view_based_acm_mib_3(X) -> snmp_view_based_acm_mib() -> snmpa:verbosity(net_if,trace), snmpa:verbosity(master_agent,trace), - ?LOG("start snmp_view_based_acm_mib test",[]), + ?IPRINT("start snmp_view_based_acm_mib test"), %% The user "no-rights" is present in USM, and is mapped to security %% name 'no-rights", which is not present in VACM. %% So, we'll add rights for it, try them and delete them. @@ -5904,7 +5920,7 @@ usm_bad() -> loop_mib_1(suite) -> []; loop_mib_1(Config) when is_list(Config) -> ?P(loop_mib_1), - ?LOG("loop_mib_1 -> initiate case",[]), + ?IPRINT("loop_mib_1 -> initiate case"), {_SaNode, _MgrNode, _MibDir} = init_case(Config), ?DBG("loop_mib_1 -> ~n" @@ -5941,14 +5957,14 @@ loop_mib_1(Config) when is_list(Config) -> ?line unload_master("SNMP-VIEW-BASED-ACM-MIB"), %% snmpa:verbosity(master_agent,log), %% snmpa:verbosity(mib_server,silence), - ?LOG("loop_mib_1 -> done",[]), + ?IPRINT("loop_mib_1 -> done"), ok. loop_mib_2(suite) -> []; loop_mib_2(Config) when is_list(Config) -> ?P(loop_mib_2), - ?LOG("loop_mib_2 -> initiate case",[]), + ?IPRINT("loop_mib_2 -> initiate case"), {_SaNode, _MgrNode, _MibDir} = init_case(Config), ?DBG("do_loop_mib_2 -> ~n" "\tSaNode: ~p~n" @@ -5971,14 +5987,14 @@ loop_mib_2(Config) when is_list(Config) -> ?line unload_master("SNMP-NOTIFICATION-MIB"), ?line unload_master("SNMP-FRAMEWORK-MIB"), ?line unload_master("SNMP-VIEW-BASED-ACM-MIB"), - ?LOG("loop_mib_2 -> done",[]), + ?IPRINT("loop_mib_2 -> done"), ok. loop_mib_3(suite) -> []; loop_mib_3(Config) when is_list(Config) -> ?P(loop_mib_3), - ?LOG("loop_mib_3 -> initiate case",[]), + ?IPRINT("loop_mib_3 -> initiate case"), {_SaNode, _MgrNode, _MibDir} = init_case(Config), ?DBG("loop_mib_3 -> ~n" "\tSaNode: ~p~n" @@ -5997,7 +6013,7 @@ loop_mib_3(Config) when is_list(Config) -> ?line unload_master("SNMP-NOTIFICATION-MIB"), ?line unload_master("SNMP-VIEW-BASED-ACM-MIB"), ?line unload_master("SNMP-USER-BASED-SM-MIB"), - ?LOG("loop_mib_3 -> done",[]), + ?IPRINT("loop_mib_3 -> done"), ok. @@ -6492,7 +6508,7 @@ otp_1366_2(X) -> ?P(otp_1366_2), otp_1366(X). otp_1366_3(X) -> ?P(otp_1366_3), otp_1366(X). otp_1366_test() -> - ?INF("NOT YET IMPLEMENTED", []), + ?NPRINT("NOT YET IMPLEMENTED"), 'NYI'. @@ -6511,7 +6527,7 @@ otp_2776_2(X) -> ?P(otp_2776_2), otp_2776(X). otp_2776_3(X) -> ?P(otp_2776_3), otp_2776(X). otp_2776_test() -> - io:format("Testing bug reported in ticket OTP-2776...~n"), + ?NPRINT("Testing bug reported in ticket OTP-2776..."), Dt01_valid = [19,98,9,1,1,0,23,0,43,0,0], Dt02_valid = [19,98,9,1,0,0,0,0,43,0,0], % This is what is fixed: 00:00 @@ -6830,10 +6846,11 @@ otp_7157(Config) -> %% ts:run(snmp, snmp_agent_test, [batch]). otp_7157_test(MA) -> - ?LOG("start otp_7157_test test (~p)",[MA]), + ?IPRINT("start otp_7157_test test (~p)", [MA]), snmpa:verbosity(MA, trace), - ?LOG("start otp_7157_test test",[]), - ?P1("Testing that varbinds in traps/notifications are not reordered"), + ?IPRINT("start otp_7157_test test"), + + ?NPRINT("Testing that varbinds in traps/notifications are not reordered"), ?DBG("send cntTrap",[]), snmpa:send_trap(MA, cntTrap, "standard trap"), @@ -6951,8 +6968,7 @@ otp_16092_simple_start_and_stop(Config, ESO, Expected) -> ?line ConfDir = ?config(agent_conf_dir, Config), ?line DbDir = ?config(agent_db_dir, Config), - p("try start agent node~n"), - p(user, "try start agent node~n"), + ?NPRINT("try start agent node"), {ok, Node} = ?ALIB:start_node(agent_16092), Vsns = [v1], @@ -6984,27 +7000,27 @@ otp_16092_simple_start_and_stop(Config, ESO, Expected) -> otp16092_try_start_and_stop_agent(Node, Opts, Expected), - p("try stop agent node ~p~n", [Node]), - p(user, "try stop agent node ~p~n", [Node]), + ?NPRINT("try stop agent node ~p", [Node]), ?ALIB:stop_node(Node), ?SLEEP(1000), - p("done~n"), - p(user, "done~n"), + ?NPRINT("done"), ok. otp16092_try_start_and_stop_agent(Node, Opts, Expected) -> - i("try start snmp (agent) supervisor (on ~p) - expect ~p~n", [Node, Expected]), + ?IPRINT("try start snmp (agent) supervisor (on ~p) - expect ~p", + [Node, Expected]), case start_standalone_agent(Node, Opts) of Pid when is_pid(Pid) andalso (Expected =:= success) -> - i("Expected success starting snmp (agent) supervisor~n"), + ?IPRINT("Expected success starting snmp (agent) supervisor"), ?SLEEP(1000), stop_standalone_agent(Pid), ok; Pid when is_pid(Pid) andalso (Expected =:= failure) -> - e("Unexpected success starting snmp (agent) supervisor: (~p)~n", [Pid]), + ?EPRINT("Unexpected success starting snmp (agent) supervisor: (~p)", + [Pid]), ?SLEEP(1000), stop_standalone_agent(Pid), ?FAIL('unexpected-start-success'); @@ -7015,18 +7031,18 @@ otp16092_try_start_and_stop_agent(Node, Opts, Expected) -> {shutdown, {failed_to_start_child, snmpa_agent, {net_if_error, Reason}}}}} when (Expected =:= failure) -> - p("Expected (shutdown, net-if) error starting " - "snmp (agent) supervisor (on ~p):" - "~n ~p", [Node, Reason]), + ?IPRINT("Expected (shutdown, net-if) error starting " + "snmp (agent) supervisor (on ~p):" + "~n ~p", [Node, Reason]), ok; {error, {shutdown, Reason}} when (Expected =:= failure) -> - p("Expected (shutdown) error starting " - "snmp (agent) supervisor (on ~p):" - "~n ~p", [Node, Reason]), + ?IPRINT("Expected (shutdown) error starting " + "snmp (agent) supervisor (on ~p):" + "~n ~p", [Node, Reason]), ok; {error, Reason} when (Expected =:= failure) -> - p("Expected error starting snmp (agent) supervisor (on ~p):" - "~n ~p", [Node, Reason]), + ?IPRINT("Expected error starting snmp (agent) supervisor (on ~p):" + "~n ~p", [Node, Reason]), ok; {badrpc, @@ -7036,23 +7052,24 @@ otp16092_try_start_and_stop_agent(Node, Opts, Expected) -> {shutdown, {failed_to_start_child, snmpa_agent, {net_if_error, Reason}}}}}}} when (Expected =:= failure) -> - p("Expected (badrpc, shutdown, net-if) error starting " - "snmp (agent) supervisor (on ~p):" - "~n ~p", [Node, Reason]), + ?IPRINT("Expected (badrpc, shutdown, net-if) error starting " + "snmp (agent) supervisor (on ~p):" + "~n ~p", [Node, Reason]), ok; {badrpc, {'EXIT', {shutdown, Reason}}} when (Expected =:= failure) -> - p("Expected (badrpc, shutdown) error starting " - "snmp (agent) supervisor (on ~p):" - "~n ~p", [Node, Reason]), + ?IPRINT("Expected (badrpc, shutdown) error starting " + "snmp (agent) supervisor (on ~p):" + "~n ~p", [Node, Reason]), ok; {badrpc, {'EXIT', Reason}} when (Expected =:= failure) -> - p("Expected (badrpc) error starting snmp (agent) supervisor (on ~p):" - "~n ~p", [Node, Reason]), + ?IPRINT("Expected (badrpc) error starting snmp (agent) supervisor " + "(on ~p):" + "~n ~p", [Node, Reason]), ok; {badrpc, Reason} = BADRPC -> - e("Bad RPC to node ~p failed:" - "~n ~p", [Node, Reason]), + ?WPRINT("Bad RPC to node ~p failed:" + "~n ~p", [Node, Reason]), ?SKIP({BADRPC, Node}) end, @@ -7263,15 +7280,15 @@ otp9884(Config) when is_list(Config) -> otp9884_backup(Node, Pid, Tag, Dir) -> - i("[~w] backup - await continue", [Tag]), + ?IPRINT("[~w] backup - await continue", [Tag]), Pid ! {otp9884_backup_started, Tag, self()}, receive {otp9884_backup_continue, Tag, Pid} -> ok end, - i("[~w] backup start", [Tag]), + ?IPRINT("[~w] backup start", [Tag]), Res = rpc:call(Node, snmpa, backup, [Dir]), - i("[~w] backup result: ~p", [Tag, Res]), + ?IPRINT("[~w] backup result: ~p", [Tag, Res]), Pid ! {otp9884_backup_complete, Tag, Res}. @@ -7280,30 +7297,30 @@ otp9884_await_backup_started() -> otp9884_await_backup_started(First, Second) when is_pid(First) andalso is_pid(Second) -> - i("otp9884_await_backup_started -> order first continue"), + ?IPRINT("otp9884_await_backup_started -> order first continue"), First ! {otp9884_backup_continue, first, self()}, - i("otp9884_await_backup_started -> order second continue"), + ?IPRINT("otp9884_await_backup_started -> order second continue"), Second ! {otp9884_backup_continue, second, self()}, ok; otp9884_await_backup_started(First, Second) -> receive {otp9884_backup_started, first, Pid} when (First =:= undefined) -> - i("otp9884_await_backup_started -> received started from first"), + ?IPRINT("otp9884_await_backup_started -> received started from first"), otp9884_await_backup_started(Pid, Second); {otp9884_backup_started, second, Pid} when (Second =:= undefined) -> - i("otp9884_await_backup_started -> received started from second"), + ?IPRINT("otp9884_await_backup_started -> received started from second"), otp9884_await_backup_started(First, Pid) end. otp9884_await_backup_completion(ok, Second) when ((Second =/= ok) andalso (Second =/= undefined)) -> - i("otp9884_await_backup_completion -> " - "first backup succeed and second failed (~p)", [Second]), + ?IPRINT("otp9884_await_backup_completion -> " + "first backup succeed and second failed (~p)", [Second]), ok; otp9884_await_backup_completion(First, ok) when ((First =/= ok) andalso (First =/= undefined)) -> - i("otp9884_await_backup_completion -> " - "second backup succeed and first failed (~p)", [First]), + ?IPRINT("otp9884_await_backup_completion -> " + "second backup succeed and first failed (~p)", [First]), ok; otp9884_await_backup_completion(First, Second) when (((First =:= undefined) andalso (Second =:= undefined)) @@ -7311,24 +7328,25 @@ otp9884_await_backup_completion(First, Second) ((First =:= undefined) andalso (Second =/= undefined)) orelse ((First =/= undefined) andalso (Second =:= undefined))) -> - i("otp9884_await_backup_completion -> await complete messages"), + ?IPRINT("otp9884_await_backup_completion -> await complete messages"), receive {otp9884_backup_complete, first, Res} -> - i("otp9884_await_backup_completion -> " - "received complete message for first: ~p", [Res]), + ?IPRINT("otp9884_await_backup_completion -> " + "received complete message for first: ~p", [Res]), otp9884_await_backup_completion(Res, Second); {otp9884_backup_complete, second, Res} -> - i("otp9884_await_backup_completion -> " - "received complete message for second: ~p", [Res]), + ?IPRINT("otp9884_await_backup_completion -> " + "received complete message for second: ~p", [Res]), otp9884_await_backup_completion(First, Res) after 10000 -> %% we have waited long enough + ?EPRINT("otp9884_await_backup_completion -> timeout"), throw({error, {timeout, First, Second}}) end; otp9884_await_backup_completion(First, Second) -> - e("Bad Completion: " - "~n First: ~p" - "~n Second: ~p", [First, Second]), + ?EPRINT("Bad Completion: " + "~n First: ~p" + "~n Second: ~p", [First, Second]), throw({error, {bad_completion, First, Second}}). @@ -7555,15 +7573,15 @@ verify_subinfo(Info0, [Key|Keys]) -> is(S) -> [length(S) | S]. try_test(Func) -> - ?P2("try test ~w...", [Func]), + ?NPRINT("try test ~w...", [Func]), ?ALIB:try_test(?MODULE, Func). try_test(Func, A) -> - ?P2("try test ~w...", [Func]), + ?NPRINT("try test ~w...", [Func]), ?ALIB:try_test(?MODULE, Func, A). try_test(Func, A, Opts) -> - ?P2("try test ~w...", [Func]), + ?NPRINT("try test ~w...", [Func]), ?ALIB:try_test(?MODULE, Func, A, Opts). @@ -7661,25 +7679,25 @@ display_log(Config) -> LogDir = Dir, Mibs = [], OutFile = join(LogDir, "snmpa_log.txt"), - p("~n" - "=========================" - " < Audit Trail Log > " - "=========================" - "~n"), + ?IPRINT("~n" + "=========================" + " < Audit Trail Log > " + "=========================" + "~n"), rcall(Node, snmpa, log_to_txt, [LogDir, Mibs, OutFile]), rcall(Node, snmpa, log_to_io, [LogDir, Mibs]), - p("~n" - "=========================" - " < / Audit Trail Log > " - "=========================" - "~n", []); + ?IPRINT("~n" + "=========================" + " < / Audit Trail Log > " + "=========================" + "~n"); false -> - p("display_log -> no agent node found"), + ?IPRINT("display_log -> no agent node found"), ok end; false -> - p("display_log -> no agent log dir found: " - "~n ~p", [Config]), + ?IPRINT("display_log -> no agent log dir found: " + "~n ~p", [Config]), ok end. @@ -7694,8 +7712,7 @@ display_memory_usage() -> SSMU = display_symbolic_store_memory_usage(Info), LDBMU = display_local_db_memory_usage(Info), MSMU = display_mib_server_memory_usage(Info), - ?INF("Memory usage: ~n" ++ - AMU ++ NIMU ++ NSMU ++ SSMU ++ LDBMU ++ MSMU, []), + ?NPRINT("Memory usage: ~n" ++ AMU ++ NIMU ++ NSMU ++ SSMU ++ LDBMU ++ MSMU), ok. display_agent_memory_usage(Info) -> @@ -7712,62 +7729,57 @@ display_agent_memory_usage(Info) -> lists_key1search([db_memory,community_cache], AgentInfo), VacmSize = lists_key1search([db_memory,vacm], AgentInfo), - lists:flatten( - io_lib:format(" Agent memory usage: " - "~n Master process memory size: ~p" - "~n Worker process memory size: ~p" - "~n Set-worker process memory size: ~p" - "~n Agent tab size: ~p" - "~n Community cache size: ~p" - "~n Vacm tab size: ~p" - "~n", - [ProcMem, WProcMem, SWProcMem, - TabSize, CCSize, VacmSize])). + ?F(" Agent memory usage: " + "~n Master process memory size: ~p" + "~n Worker process memory size: ~p" + "~n Set-worker process memory size: ~p" + "~n Agent tab size: ~p" + "~n Community cache size: ~p" + "~n Vacm tab size: ~p" + "~n", + [ProcMem, WProcMem, SWProcMem, + TabSize, CCSize, VacmSize]). display_net_if_memory_usage(Info) -> NiInfo = lists_key1search(net_if, Info), ProcMem = lists_key1search(process_memory, NiInfo), - lists:flatten( - io_lib:format(" Net if memory usage: " - "~n Process memory size: ~p" - "~n",[ProcMem])). + ?F(" Net if memory usage: " + "~n Process memory size: ~p" + "~n", [ProcMem]). display_note_store_memory_usage(Info) -> NsInfo = lists_key1search(note_store, Info), ProcMem = lists_key1search([process_memory,notes], NsInfo), ProcTmrMem = lists_key1search([process_memory,timer], NsInfo), TabSize = lists_key1search([db_memory,notes], NsInfo), - lists:flatten( - io_lib:format(" Note store memory usage: " - "~n Notes process memory size: ~p" - "~n Timer process memory size: ~p" - "~n Notes tab size: ~p" - "~n", - [ProcMem, ProcTmrMem, TabSize])). + ?F(" Note store memory usage: " + "~n Notes process memory size: ~p" + "~n Timer process memory size: ~p" + "~n Notes tab size: ~p" + "~n", + [ProcMem, ProcTmrMem, TabSize]). display_symbolic_store_memory_usage(Info) -> SsInfo = lists_key1search(symbolic_store, Info), ProcMem = lists_key1search(process_memory, SsInfo), DbMem = lists_key1search(db_memory, SsInfo), - lists:flatten( - io_lib:format(" Symbolic store memory usage: " - "~n Process memory size: ~p" - "~n DB size: ~p" - "~n", - [ProcMem, DbMem])). + ?F(" Symbolic store memory usage: " + "~n Process memory size: ~p" + "~n DB size: ~p" + "~n", + [ProcMem, DbMem]). display_local_db_memory_usage(Info) -> LdInfo = lists_key1search(local_db, Info), ProcMem = lists_key1search(process_memory, LdInfo), EtsSize = lists_key1search([db_memory,ets], LdInfo), DetsSize = lists_key1search([db_memory,dets], LdInfo), - lists:flatten( - io_lib:format(" Local DB memory usage: " - "~n Process memory size: ~p" - "~n DB [ets] size: ~p" - "~n DB [dets] size: ~p" - "~n", - [ProcMem, EtsSize, DetsSize])). + ?F(" Local DB memory usage: " + "~n Process memory size: ~p" + "~n DB [ets] size: ~p" + "~n DB [dets] size: ~p" + "~n", + [ProcMem, EtsSize, DetsSize]). display_mib_server_memory_usage(Info) -> MibInfo = lists_key1search(mib_server, Info), @@ -7776,15 +7788,14 @@ display_mib_server_memory_usage(Info) -> MibDbSize = lists_key1search([db_memory,mib], MibInfo), NodeDbSize = lists_key1search([db_memory,node], MibInfo), TreeDbSize = lists_key1search([db_memory,tree], MibInfo), - lists:flatten( - io_lib:format(" MIB server memory usage: " - "~n Process memory size: ~p" - "~n Tree size: ~p" - "~n Mib db size: ~p" - "~n Node db size: ~p" - "~n Tree db size: ~p" - "~n", - [ProcMem, TreeSize, MibDbSize, NodeDbSize, TreeDbSize])). + ?F(" MIB server memory usage: " + "~n Process memory size: ~p" + "~n Tree size: ~p" + "~n Mib db size: ~p" + "~n Node db size: ~p" + "~n Tree db size: ~p" + "~n", + [ProcMem, TreeSize, MibDbSize, NodeDbSize, TreeDbSize]). lists_key1search([], Res) -> Res; @@ -7806,56 +7817,6 @@ lists_key1search(Key, List) when is_atom(Key) -> %% ------ -join(Parts) -> - filename:join(Parts). - -join(Dir, File) -> - filename:join(Dir, File). - - -%% ------ - -rcall(Node, Mod, Func, Args) -> - case rpc:call(Node, Mod, Func, Args) of - {badrpc, nodedown} -> - ?FAIL({rpc_failure, Node}); - Else -> - Else - end. - - -%% ------ - -%% e(F) -> -%% e(F, []). - -e(F, A) -> - p(user, "<ERROR> " ++ F, A), - p(standard_io, "<ERROR> " ++ F, A). - -i(F) -> - i(F, []). -i(F, A) -> - p(user, F, A), - p(standard_io, F, A). - -p(F) -> - p(F, []). - -p(Dev, F) when is_atom(Dev) -> - p(Dev, F, []); -p(F, A) -> - p(standard_io, F, A). - -p(Dev, F, A) -> - io:format(Dev, - "*** [~s] ***" - "~n" ++ F ++ "~n", [formated_timestamp()|A]). - -formated_timestamp() -> - snmp_test_lib:formated_timestamp(). - - init_v1_agent(Config) -> %% -- %% Start nodes @@ -7971,3 +7932,25 @@ config_ipfamily(Config) -> Value -> Value end. + + +%% ------ + +join(Parts) -> + filename:join(Parts). + +join(Dir, File) -> + filename:join(Dir, File). + + +%% ------ + +rcall(Node, Mod, Func, Args) -> + case rpc:call(Node, Mod, Func, Args) of + {badrpc, nodedown} -> + ?FAIL({rpc_failure, Node}); + Else -> + Else + end. + + diff --git a/lib/snmp/test/snmp_agent_test_lib.erl b/lib/snmp/test/snmp_agent_test_lib.erl index e343f118e9..6a4c582f36 100644 --- a/lib/snmp/test/snmp_agent_test_lib.erl +++ b/lib/snmp/test/snmp_agent_test_lib.erl @@ -122,8 +122,8 @@ init_all(Config) when is_list(Config) -> - ?LOG("init_all -> entry with" - "~n Config: ~p",[Config]), + ?IPRINT("init_all -> entry with" + "~n Config: ~p",[Config]), %% -- %% Start nodes @@ -300,7 +300,7 @@ try_test(TcRunMod, TcRunFunc, TcRunArgs, TcRunOpts) -> %% process as well. tc_try(N, M, F, A) -> - ?PRINT2("tc_try -> entry with" + ?IPRINT("tc_try -> entry with" "~n N: ~p" "~n M: ~p" "~n F: ~p" @@ -312,32 +312,32 @@ tc_try(N, M, F, A) -> get()]), case net_adm:ping(N) of pong -> - ?PRINT2("tc_try -> ~p still running - start runner~n", [N]), + ?IPRINT("tc_try -> ~p still running - start runner~n", [N]), OldFlag = trap_exit(true), % Make sure we catch it Runner = spawn_link(N, ?MODULE, tc_wait, [self(), get(), M, F, A]), await_tc_runner_started(Runner, OldFlag), await_tc_runner_done(Runner, OldFlag); pang -> - ?EPRINT2("tc_try -> ~p *not* running~n", [N]), + ?WPRINT("tc_try -> ~p *not* running~n", [N]), skip({node_not_running, N}) end. await_tc_runner_started(Runner, OldFlag) -> - ?PRINT2("await tc-runner (~p) start ack~n", [Runner]), + ?IPRINT("await tc-runner (~p) start ack~n", [Runner]), receive {'EXIT', Runner, Reason} -> - ?EPRINT2("TC runner start failed: " - "~n ~p~n", [Reason]), + ?EPRINT("TC runner start failed: " + "~n ~p~n", [Reason]), exit({tx_runner_start_failed, Reason}); {tc_runner_started, Runner} -> - ?PRINT2("TC runner start acknowledged~n"), + ?IPRINT("TC runner start acknowledged~n"), ok after 10000 -> %% We should *really* not have to wait this long, but... trap_exit(OldFlag), unlink_and_flush_exit(Runner), RunnerInfo = ?PINFO(Runner), - ?EPRINT2("TC runner start timeout: " - "~n ~p", [RunnerInfo]), + ?EPRINT("TC runner start timeout: " + "~n ~p", [RunnerInfo]), %% If we don't get a start ack within 10 seconds, we are f*ed exit(Runner, kill), exit({tc_runner_start, timeout, RunnerInfo}) @@ -352,18 +352,18 @@ await_tc_runner_done(Runner, OldFlag) -> SysEvs = snmp_test_global_sys_monitor:events(), if (SysEvs =:= []) -> - ?EPRINT2("TC runner failed: " - "~n ~p~n", [Reason]), + ?EPRINT("TC runner failed: " + "~n ~p~n", [Reason]), exit({tx_runner_failed, Reason}); true -> - ?EPRINT2("TC runner failed when we got system events: " - "~n Reason: ~p" - "~n Sys Events: ~p" - "~n", [Reason, SysEvs]), + ?WPRINT("TC runner failed when we got system events: " + "~n Reason: ~p" + "~n Sys Events: ~p" + "~n", [Reason, SysEvs]), skip([{reason, Reason}, {system_events, SysEvs}]) end; {tc_runner_done, Runner, {'EXIT', {skip, Reason}}, Loc} -> - ?PRINT2("call -> done with skip: " + ?WPRINT("call -> done with skip: " "~n Reason: ~p" "~n Loc: ~p" "~n", [Reason, Loc]), @@ -372,7 +372,7 @@ await_tc_runner_done(Runner, OldFlag) -> put(test_server_loc, Loc), skip(Reason); {tc_runner_done, Runner, {'EXIT', Rn}, Loc} -> - ?PRINT2("call -> done with exit: " + ?EPRINT("call -> done with exit: " "~n Rn: ~p" "~n Loc: ~p" "~n", [Rn, Loc]), @@ -409,7 +409,7 @@ unlink_and_flush_exit(Pid) -> end. tc_wait(From, Env, M, F, A) -> - ?PRINT2("tc_wait -> entry with" + ?IPRINT("tc_wait -> entry with" "~n From: ~p" "~n Env: ~p" "~n M: ~p" @@ -417,9 +417,9 @@ tc_wait(From, Env, M, F, A) -> "~n A: ~p", [From, Env, M, F, A]), From ! {tc_runner_started, self()}, lists:foreach(fun({K,V}) -> put(K,V) end, Env), - ?PRINT2("tc_wait -> env set - now run tc~n"), + ?IPRINT("tc_wait -> env set - now run tc~n"), Res = (catch apply(M, F, A)), - ?PRINT2("tc_wait -> tc run done: " + ?IPRINT("tc_wait -> tc run done: " "~n ~p" "~n", [Res]), From ! {tc_runner_done, self(), Res, get(test_server_loc)}, @@ -437,7 +437,7 @@ tc_wait(From, Env, M, F, A) -> end. tc_run(Mod, Func, Args, Opts) -> - ?PRINT2("tc_run -> entry with" + ?IPRINT("tc_run -> entry with" "~n Mod: ~p" "~n Func: ~p" "~n Args: ~p" @@ -456,7 +456,7 @@ tc_run(Mod, Func, Args, Opts) -> ?DBG("tc_run -> Crypto: ~p", [_CryptoRes]), StdM = join(code:priv_dir(snmp), "mibs") ++ "/", Vsn = get(vsn), - ?PRINT2("tc_run -> config:" + ?IPRINT("tc_run -> config:" "~n M: ~p" "~n Vsn: ~p" "~n Dir: ~p" @@ -469,7 +469,7 @@ tc_run(Mod, Func, Args, Opts) -> "~n", [M,Vsn,Dir,User,SecLevel,EngineID,CtxEngineID,Community,StdM]), case snmp_test_mgr:start([%% {agent, snmp_test_lib:hostname()}, {packet_server_debug, true}, - {debug, true}, + {debug, false}, {agent, get(master_host)}, {ipfamily, get(ipfamily)}, {agent_udp, 4000}, @@ -487,7 +487,7 @@ tc_run(Mod, Func, Args, Opts) -> {ok, _Pid} -> case (catch apply(Mod, Func, Args)) of {'EXIT', {skip, Reason}} -> - ?EPRINT2("apply skip detected: " + ?WPRINT("apply skip detected: " "~n ~p", [Reason]), (catch snmp_test_mgr:stop()), ?SKIP(Reason); @@ -500,11 +500,11 @@ tc_run(Mod, Func, Args, Opts) -> (catch snmp_test_mgr:stop()), if (SysEvs =:= []) -> - ?EPRINT2("TC runner failed: " - "~n ~p~n", [Reason]), + ?EPRINT("TC runner failed: " + "~n ~p~n", [Reason]), ?FAIL({apply_failed, {Mod, Func, Args}, Reason}); true -> - ?EPRINT2("apply exit catched when we got system events: " + ?WPRINT("apply exit catched when we got system events: " "~n Reason: ~p" "~n Sys Events: ~p" "~n", [Reason, SysEvs]), @@ -516,14 +516,14 @@ tc_run(Mod, Func, Args, Opts) -> end; {error, Reason} -> - ?EPRINT2("Failed starting (test) manager: " - "~n ~p", [Reason]), + ?EPRINT("Failed starting (test) manager: " + "~n ~p", [Reason]), (catch snmp_test_mgr:stop()), ?line ?FAIL({mgr_start_error, Reason}); Err -> - ?EPRINT2("Failed starting (test) manager: " - "~n ~p", [Err]), + ?EPRINT("Failed starting (test) manager: " + "~n ~p", [Err]), (catch snmp_test_mgr:stop()), ?line ?FAIL({mgr_start_failure, Err}) end. @@ -570,10 +570,10 @@ start_agent(Config, Vsns) -> start_agent(Config, Vsns, []). start_agent(Config, Vsns, Opts) -> - ?LOG("start_agent -> entry (~p) with" - "~n Config: ~p" - "~n Vsns: ~p" - "~n Opts: ~p", [node(), Config, Vsns, Opts]), + ?IPRINT("start_agent -> entry (~p) with" + "~n Config: ~p" + "~n Vsns: ~p" + "~n Opts: ~p", [node(), Config, Vsns, Opts]), ?line AgentLogDir = ?config(agent_log_dir, Config), ?line AgentConfDir = ?config(agent_conf_dir, Config), @@ -603,17 +603,17 @@ start_agent(Config, Vsns, Opts) -> process_flag(trap_exit,true), - ?PRINT2("start_agent -> try start snmp app supervisor", []), + ?IPRINT("start_agent -> try start snmp app supervisor", []), {ok, AppSup} = snmp_app_sup:start_link(), unlink(AppSup), ?DBG("start_agent -> snmp app supervisor: ~p", [AppSup]), - ?PRINT2("start_agent -> try start master agent",[]), + ?IPRINT("start_agent -> try start master agent",[]), ?line Sup = start_sup(Env), ?line unlink(Sup), ?DBG("start_agent -> snmp supervisor: ~p", [Sup]), - ?PRINT2("start_agent -> try (rpc) start sub agent on ~p", [SaNode]), + ?IPRINT("start_agent -> try (rpc) start sub agent on ~p", [SaNode]), ?line SaDir = ?config(sa_dir, Config), ?line {ok, Sub} = start_sub_sup(SaNode, SaDir), ?DBG("start_agent -> done", []), @@ -813,13 +813,13 @@ merge_agent_options([{Key, _Value} = Opt|Opts], Options) -> stop_agent(Config) when is_list(Config) -> - ?PRINT2("stop_agent -> entry with" + ?IPRINT("stop_agent -> entry with" "~n Config: ~p",[Config]), %% Stop the sub-agent (the agent supervisor) {SubSup, SubPar} = ?config(snmp_sub, Config), - ?PRINT2("stop_agent -> attempt to stop sub agent (~p)" + ?IPRINT("stop_agent -> attempt to stop sub agent (~p)" "~n Sub Sup info: " "~n ~p" "~n Sub Par info: " @@ -831,7 +831,7 @@ stop_agent(Config) when is_list(Config) -> %% Stop the master-agent (the top agent supervisor) {MasterSup, MasterPar} = ?config(snmp_sup, Config), - ?PRINT2("stop_agent -> attempt to stop master agent (~p)" + ?IPRINT("stop_agent -> attempt to stop master agent (~p)" "~n Master Sup: " "~n ~p" "~n Master Par: " @@ -847,24 +847,24 @@ stop_agent(Config) when is_list(Config) -> %% Stop the top supervisor (of the snmp app) AppSup = ?config(snmp_app_sup, Config), - ?PRINT2("stop_agent -> attempt to app sup ~p" + ?IPRINT("stop_agent -> attempt to app sup ~p" "~n App Sup: ~p", [AppSup, ?PINFO(AppSup)]), Config4 = lists:keydelete(snmp_app_sup, 1, Config3), - ?PRINT2("stop_agent -> done", []), + ?IPRINT("stop_agent -> done", []), Config4. start_sup(Env) -> case (catch snmp_app_sup:start_agent(normal, Env)) of {ok, S} -> - ?DBG("start_agent -> started, Sup: ~p",[S]), + ?DBG("start_agent -> started, Sup: ~p", [S]), S; Else -> - ?DBG("start_agent -> unknown result: ~n~p",[Else]), + ?EPRINT("start_agent -> unknown result: ~n~p", [Else]), %% Get info about the apps we depend on ?FAIL({start_failed, Else, ?IS_MNESIA_RUNNING()}) end. @@ -872,18 +872,18 @@ start_sup(Env) -> stop_sup(Pid, _) when (node(Pid) =:= node()) -> case (catch process_info(Pid)) of PI when is_list(PI) -> - ?LOG("stop_sup -> attempt to stop ~p", [Pid]), + ?IPRINT("stop_sup -> attempt to stop ~p", [Pid]), Ref = erlang:monitor(process, Pid), exit(Pid, kill), await_stopped(Pid, Ref); {'EXIT', _Reason} -> - ?LOG("stop_sup -> ~p not running", [Pid]), + ?IPRINT("stop_sup -> ~p not running", [Pid]), ok end; stop_sup(Pid, _) -> - ?LOG("stop_sup -> attempt to stop ~p", [Pid]), + ?IPRINT("stop_sup -> attempt to stop ~p", [Pid]), Ref = erlang:monitor(process, Pid), - ?LOG("stop_sup -> Ref: ~p", [Ref]), + ?IPRINT("stop_sup -> Ref: ~p", [Ref]), exit(Pid, kill), await_stopped(Pid, Ref). @@ -893,7 +893,7 @@ await_stopped(Pid, Ref) -> ?DBG("received down message for ~p", [Pid]), ok after 10000 -> - ?INF("await_stopped -> timeout for ~p",[Pid]), + ?EPRINT("await_stopped -> timeout for ~p",[Pid]), erlang:demonitor(Ref), ?FAIL({failed_stop,Pid}) end. @@ -1072,7 +1072,7 @@ io_format_expect(F) -> io_format_expect(F, []). io_format_expect(F, A) -> - ?PRINT2("EXPECT " ++ F, A). + ?IPRINT("EXPECT " ++ F, A). do_expect(Expect) when is_atom(Expect) -> @@ -1525,11 +1525,11 @@ get_next_req(Vars) -> %% --- start and stop nodes --- start_node(Name) -> - ?LOG("start_node -> entry with" - "~n Name: ~p" - "~n when" - "~n hostname of this node: ~p", - [Name, list_to_atom(?HOSTNAME(node()))]), + ?IPRINT("start_node -> entry with" + "~n Name: ~p" + "~n when" + "~n hostname of this node: ~p", + [Name, list_to_atom(?HOSTNAME(node()))]), Pa = filename:dirname(code:which(?MODULE)), ?DBG("start_node -> Pa: ~p", [Pa]), @@ -1543,18 +1543,18 @@ start_node(Name) -> global:sync(), {ok, Node}; {error, Reason} -> - ?ERR("start_node -> failed starting node ~p:" - "~n Reason: ~p", [Name, Reason]), + ?WPRINT("start_node -> failed starting node ~p:" + "~n Reason: ~p", [Name, Reason]), ?line ?SKIP({failed_start_node, Reason}); Else -> - ?ERR("start_node -> failed starting node ~p:" - "~n ~p", [Name, Else]), + ?EPRINT("start_node -> failed starting node ~p:" + "~n ~p", [Name, Else]), ?line ?FAIL(Else) end. stop_node(Node) -> - ?LOG("stop_node -> Node: ~p", [Node]), + ?IPRINT("stop_node -> Node: ~p", [Node]), ?STOP_NODE(Node). @@ -1566,14 +1566,14 @@ config(Vsns, MgrDir, AgentConfDir, MIp, AIp) -> config(Vsns, MgrDir, AgentConfDir, MIp, AIp, inet). config(Vsns, MgrDir, AgentConfDir, MIp, AIp, IpFamily) -> - ?LOG("config -> entry with" - "~n Vsns: ~p" - "~n MgrDir: ~p" - "~n AgentConfDir: ~p" - "~n MIp: ~p" - "~n AIp: ~p" - "~n IpFamily: ~p", - [Vsns, MgrDir, AgentConfDir, MIp, AIp, IpFamily]), + ?IPRINT("config -> entry with" + "~n Vsns: ~p" + "~n MgrDir: ~p" + "~n AgentConfDir: ~p" + "~n MIp: ~p" + "~n AIp: ~p" + "~n IpFamily: ~p", + [Vsns, MgrDir, AgentConfDir, MIp, AIp, IpFamily]), ?line {Domain, ManagerAddr} = case IpFamily of inet6 -> @@ -1744,8 +1744,8 @@ rewrite_target_addr_conf(Dir, NewPort) -> {ok, _} -> ok; {error, _R} -> - ?ERR("failure reading file info of " - "target address config file: ~p", [_R]), + ?WPRINT("failure reading file info of " + "target address config file: ~p", [_R]), ok end, @@ -1769,10 +1769,10 @@ rewrite_target_addr_conf_check(O) -> rewrite_target_addr_conf2(NewPort, {Name, Ip, _Port, Timeout, Retry, "std_trap", EngineId}) -> - ?LOG("rewrite_target_addr_conf2 -> entry with std_trap",[]), + ?IPRINT("rewrite_target_addr_conf2 -> entry with std_trap",[]), {Name,Ip,NewPort,Timeout,Retry,"std_trap",EngineId}; rewrite_target_addr_conf2(_NewPort,O) -> - ?LOG("rewrite_target_addr_conf2 -> entry with " + ?IPRINT("rewrite_target_addr_conf2 -> entry with " "~n O: ~p",[O]), O. @@ -1826,12 +1826,12 @@ display_memory_usage() -> MibDbSize = key1search([db_memory,mib], Info), NodeDbSize = key1search([db_memory,node], Info), TreeDbSize = key1search([db_memory,tree], Info), - ?INF("Memory usage: " - "~n Tree size: ~p" - "~n Process memory size: ~p" - "~n Mib db size: ~p" - "~n Node db size: ~p" - "~n Tree db size: ~p", + ?IPRINT("Memory usage: " + "~n Tree size: ~p" + "~n Process memory size: ~p" + "~n Mib db size: ~p" + "~n Node db size: ~p" + "~n Tree db size: ~p", [TreeSize, ProcMem, MibDbSize, NodeDbSize, TreeDbSize]). key1search([], Res) -> @@ -1867,51 +1867,3 @@ join(Dir, File) -> skip(R) -> exit({skip, R}). -%% await_pdu(To) -> -%% await_response(To, pdu). -%% -%% await_trap(To) -> -%% await_response(To, trap). -%% -%% await_any(To) -> -%% await_response(To, any). -%% -%% -%% await_response(To, What) -> -%% await_response(To, What, []). -%% -%% await_response(To, What, Stuff) when is_integer(To) andalso (To >= 0) -> -%% T = t(), -%% receive -%% {snmp_pdu, PDU} when is_record(Trap, pdu) andalso (What =:= pdu) -> -%% {ok, PDU}; -%% {snmp_pdu, Trap} is_when record(Trap, trappdu) andalso (What =:= trap) -> -%% {ok, Trap}; -%% Any when What =:= any -> -%% {ok, Any}; -%% Any -> -%% %% Recalc time -%% NewTo = To - (t() - T) -%% await_reponse(NewTo, What, [{NewTo, Any}|Stuff]) -%% after To -> -%% {error, {timeout, Stuff}} -%% end; -%% await_response(_, Stuff) -> -%% {error, {timeout, Stuff}}. -%% -%% -%% t() -> -%% {A,B,C} = os:timestamp(), -%% A*1000000000+B*1000+(C div 1000). -%% -%% -%% timeout() -> -%% timeout(os:type()). -%% -%% timeout(_) -> 3500. - - -%% Time in milli seconds -%% t() -> -%% {A,B,C} = os:timestamp(), -%% A*1000000000+B*1000+(C div 1000). diff --git a/lib/snmp/test/snmp_test_mgr.erl b/lib/snmp/test/snmp_test_mgr.erl index f50147a852..0a80860ed1 100644 --- a/lib/snmp/test/snmp_test_mgr.erl +++ b/lib/snmp/test/snmp_test_mgr.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2019. All Rights Reserved. +%% Copyright Ericsson AB 1996-2020. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -191,40 +191,41 @@ receive_trap(Timeout) -> %% {mibs, List of Filenames}, {trap_udp, UDPPort (default 5000)}, %%---------------------------------------------------------------------- init({Options, CallerPid}) -> + %% This causes "verbosity printouts" to print (from level debug) + %% in the modules we "borrow" from the agent code (burr,,,) + %% With "our" name (mgr). put(sname, mgr), - put(verbosity, debug), + put(verbosity, debug), + %% Make use of the "test name" print "feature" + put(tname, "MGR"), ?SNMP_RAND_SEED(), - %% rand:seed(exrop, - %% {erlang:phash2([node()]), - %% erlang:monotonic_time(), - %% erlang:unique_integer()}), case (catch is_options_ok(Options)) of true -> put(debug, get_value(debug, Options, false)), - d("init -> (~p) extract options",[self()]), + d("init -> extract options"), PacksDbg = get_value(packet_server_debug, Options, false), - print("[~w] ~p -> PacksDbg: ~p~n", [?MODULE, self(), PacksDbg]), + ?IPRINT("init -> PacksDbg: ~p", [PacksDbg]), RecBufSz = get_value(recbuf, Options, 1024), - print("[~w] ~p -> RecBufSz: ~p~n", [?MODULE, self(), RecBufSz]), + ?IPRINT("init -> RecBufSz: ~p", [RecBufSz]), Mibs = get_value(mibs, Options, []), - print("[~w] ~p -> Mibs: ~p~n", [?MODULE, self(), Mibs]), + ?IPRINT("init -> Mibs: ~p", [Mibs]), Udp = get_value(agent_udp, Options, 4000), - print("[~w] ~p -> Udp: ~p~n", [?MODULE, self(), Udp]), + ?IPRINT("init -> Udp: ~p", [Udp]), User = get_value(user, Options, "initial"), - print("[~w] ~p -> User: ~p~n", [?MODULE, self(), User]), + ?IPRINT("init -> User: ~p", [User]), EngineId = get_value(engine_id, Options, "agentEngine"), - print("[~w] ~p -> EngineId: ~p~n", [?MODULE, self(), EngineId]), + ?IPRINT("init -> EngineId: ~p", [EngineId]), CtxEngineId = get_value(context_engine_id, Options, EngineId), - print("[~w] ~p -> CtxEngineId: ~p~n", [?MODULE, self(), CtxEngineId]), + ?IPRINT("init -> CtxEngineId: ~p", [CtxEngineId]), TrapUdp = get_value(trap_udp, Options, 5000), - print("[~w] ~p -> TrapUdp: ~p~n", [?MODULE, self(), TrapUdp]), + ?IPRINT("init -> TrapUdp: ~p", [TrapUdp]), Dir = get_value(dir, Options, "."), - print("[~w] ~p -> Dir: ~p~n", [?MODULE, self(), Dir]), + ?IPRINT("init -> Dir: ~p", [Dir]), SecLevel = get_value(sec_level, Options, noAuthNoPriv), - print("[~w] ~p -> SecLevel: ~p~n", [?MODULE, self(), SecLevel]), + ?IPRINT("init -> SecLevel: ~p", [SecLevel]), MiniMIB = snmp_mini_mib:create(Mibs), - d("[~w] ~p -> MiniMIB: " - "~n ~p", [?MODULE, self(), MiniMIB]), + d("init -> MiniMIB: " + "~n ~p", [MiniMIB]), Version = case lists:member(v2, Options) of true -> 'version-2'; false -> @@ -233,41 +234,38 @@ init({Options, CallerPid}) -> false -> 'version-1' end end, - print("[~w] ~p -> Version: ~p~n", [?MODULE, self(), Version]), + ?IPRINT("init -> Version: ~p", [Version]), Com = case Version of 'version-3' -> get_value(context, Options, ""); _ -> get_value(community, Options, "public") end, - print("[~w] ~p -> Com: ~p~n", [?MODULE, self(), Com]), + ?IPRINT("init -> Com: ~p", [Com]), VsnHdrD = {Com, User, EngineId, CtxEngineId, mk_seclevel(SecLevel)}, - print("[~w] ~p -> VsnHdrD: ~p~n", [?MODULE, self(), VsnHdrD]), + ?IPRINT("init -> VsnHdrD: ~p", [VsnHdrD]), IpFamily = get_value(ipfamily, Options, inet), - print("[~w] ~p -> IpFamily: ~p~n", [?MODULE, self(), IpFamily]), + ?IPRINT("init -> IpFamily: ~p", [IpFamily]), AgIp = case snmp_misc:assq(agent, Options) of {value, Addr} when is_tuple(Addr) andalso (size(Addr) =:= 4) andalso (IpFamily =:= inet) -> - print("[~w] ~p -> Addr: ~p~n", - [?MODULE, self(), Addr]), + ?IPRINT("init -> Addr: ~p", [Addr]), Addr; {value, Addr} when is_tuple(Addr) andalso (size(Addr) =:= 8) andalso (IpFamily =:= inet6) -> - print("[~w] ~p -> Addr: ~p~n", - [?MODULE, self(), Addr]), + ?IPRINT("init -> Addr: ~p", [Addr]), Addr; {value, Host} when is_list(Host) -> - print("[~w] ~p -> Host: ~p~n", - [?MODULE, self(), Host]), + ?IPRINT("init -> Host: ~p", [Host]), {ok, Ip} = snmp_misc:ip(Host, IpFamily), Ip end, - print("[~w] ~p -> AgIp: ~p~n", [?MODULE, self(), AgIp]), + ?IPRINT("init -> AgIp: ~p", [AgIp]), Quiet = lists:member(quiet, Options), - print("[~w] ~p -> Quiet: ~p~n", [?MODULE, self(), Quiet]), + ?IPRINT("init -> Quiet: ~p", [Quiet]), PackServ = start_packet_server( Quiet, Options, CallerPid, AgIp, Udp, TrapUdp, @@ -692,16 +690,16 @@ echo_pdu(PDU, MiniMIB) -> %% Test Sequence %%---------------------------------------------------------------------- echo_errors({error, Id, {ExpectedFormat, ExpectedData}, {Format, Data}})-> - io:format("* Unexpected Behaviour * Id: ~w.~n" - " Expected: " ++ ExpectedFormat ++ "~n" - " Got: " ++ Format ++ "~n", - [Id] ++ ExpectedData ++ Data), + ?IPRINT("*** Unexpected Behaviour *** Id: ~w.~n" + " Expected: " ++ ExpectedFormat ++ "~n" + " Got: " ++ Format ++ "~n", + [Id] ++ ExpectedData ++ Data), {error, Id, {ExpectedFormat, ExpectedData}, {Format, Data}}; echo_errors(ok) -> ok; echo_errors({ok, Val}) -> {ok, Val}. get_response_impl(Id, ExpVars) -> - ?PRINT2("await response ~w with" + ?IPRINT("await response ~w with" "~n Expected Varbinds: ~p", [Id, ExpVars]), PureVars = find_pure_oids2(ExpVars), @@ -710,7 +708,7 @@ get_response_impl(Id, ExpVars) -> error_status = noError, error_index = 0, varbinds = VBs} -> - ?PRINT2("received expected response pdu (~w) - match vars" + ?IPRINT("received expected response pdu (~w) - match vars" "~n Expected VBs: ~p" "~n Received VBs: ~p", [Id, PureVars, VBs]), @@ -720,10 +718,10 @@ get_response_impl(Id, ExpVars) -> request_id = ReqId, error_status = Err2, error_index = Index2} -> - ?EPRINT2("received unexpected response pdu: ~w, ~w, ~w" - "~n Received Error: ~p" - "~n Received Index: ~p", - [Type2, Id, ReqId, Err2, Index2]), + ?EPRINT("received unexpected response pdu: ~w, ~w, ~w" + "~n Received Error: ~p" + "~n Received Index: ~p", + [Type2, Id, ReqId, Err2, Index2]), {error, Id, {"Type: ~w, ErrStat: ~w, Idx: ~w, RequestId: ~w", @@ -732,8 +730,8 @@ get_response_impl(Id, ExpVars) -> [Type2, Err2, Index2]}}; {error, Reason} -> - ?EPRINT2("unexpected receive pdu error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive pdu error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end. @@ -743,81 +741,81 @@ get_response_impl(Id, ExpVars) -> %% Returns: ok | {error, Id, {ExpectedFormat, ExpectedData}, {Format, Data}} %%---------------------------------------------------------------------- expect_impl(Id, any) -> - ?PRINT2("await ~w pdu (any)", [Id]), + ?IPRINT("await ~w pdu (any)", [Id]), case receive_response() of PDU when is_record(PDU, pdu) -> - ?PRINT2("received expected pdu (~w)", [Id]), + ?IPRINT("received expected pdu (~w)", [Id]), ok; {error, Reason} -> - ?EPRINT1("unexpected receive error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end; expect_impl(Id, return) -> - ?PRINT2("await ~w pdu", [Id]), + ?IPRINT("await ~w pdu", [Id]), case receive_response() of PDU when is_record(PDU, pdu) -> - ?PRINT2("received expected pdu (~w)", [Id]), + ?IPRINT("received expected pdu (~w)", [Id]), {ok, PDU}; {error, Reason} -> - ?EPRINT1("unexpected receive error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end; expect_impl(Id, trap) -> - ?PRINT2("await ~w trap", [Id]), + ?IPRINT("await ~w trap", [Id]), case receive_trap(3500) of PDU when is_record(PDU, trappdu) -> - ?PRINT2("received expected trap (~w)", [Id]), + ?IPRINT("received expected trap (~w)", [Id]), ok; {error, Reason} -> - ?EPRINT1("unexpected receive error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end; expect_impl(Id, timeout) -> - ?PRINT2("await ~w nothing", [Id]), + ?IPRINT("await ~w nothing", [Id]), receive X -> - ?EPRINT1("received unexpected message: ~w" - "~n ~p", - [Id, X]), + ?EPRINT("received unexpected message: ~w" + "~n ~p", + [Id, X]), {error, Id, {"Timeout", []}, {"Message ~w", [X]}} after 3500 -> ok end; expect_impl(Id, Err) when is_atom(Err) -> - ?PRINT2("await ~w with" + ?IPRINT("await ~w with" "~n Err: ~p", [Id, Err]), case receive_response() of #pdu{error_status = Err} -> - ?PRINT2("received pdu with expected error status (~w, ~w)", + ?IPRINT("received pdu with expected error status (~w, ~w)", [Id, Err]), ok; #pdu{type = Type2, request_id = ReqId, error_status = Err2} -> - ?EPRINT1("received pdu with unexpected error status: ~w, ~w, ~w" - "~n Expected Error: ~p" - "~n Received Error: ~p", - [Type2, Id, ReqId, Err, Err2]), + ?EPRINT("received pdu with unexpected error status: ~w, ~w, ~w" + "~n Expected Error: ~p" + "~n Received Error: ~p", + [Type2, Id, ReqId, Err, Err2]), {error, Id, {"ErrorStatus: ~w, RequestId: ~w", [Err,ReqId]}, {"ErrorStatus: ~w", [Err2]}}; {error, Reason} -> - ?EPRINT1("unexpected receive error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end; expect_impl(Id, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> - ?PRINT2("await ~w with" + ?IPRINT("await ~w with" "~n ExpectedVarbinds: ~p", [Id, ExpectedVarbinds]), PureVars = find_pure_oids(ExpectedVarbinds), @@ -826,7 +824,7 @@ expect_impl(Id, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> error_status = noError, error_index = 0, varbinds = VBs} -> - ?PRINT2("received expected response pdu (~w) - check varbinds" + ?IPRINT("received expected response pdu (~w) - check varbinds" "~n Expected VBs: ~p" "~n Received VBs: ~p", [Id, PureVars, VBs]), @@ -836,22 +834,22 @@ expect_impl(Id, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> request_id = ReqId, error_status = Err2, error_index = Index2} -> - ?EPRINT1("received unexpected pdu: ~w, ~w, ~w" - "~n Received Error: ~p" - "~n Received Index: ~p", + ?EPRINT("received unexpected pdu: ~w, ~w, ~w" + "~n Received Error: ~p" + "~n Received Index: ~p", [Type2, Id, ReqId, Err2, Index2]), {error, Id, {"Type: ~w, ErrStat: ~w, Idx: ~w, RequestId: ~w", ['get-response', noError, 0, ReqId]}, {"Type: ~w, ErrStat: ~w, Idx: ~w", [Type2, Err2, Index2]}}; {error, Reason} -> - ?EPRINT1("unexpected receive error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end. expect_impl(Id, v2trap, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> - ?PRINT2("await v2 trap ~w with" + ?IPRINT("await v2 trap ~w with" "~n ExpectedVarbinds: ~p", [Id, ExpectedVarbinds]), PureVars = find_pure_oids(ExpectedVarbinds), @@ -860,7 +858,7 @@ expect_impl(Id, v2trap, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> error_status = noError, error_index = 0, varbinds = VBs} -> - ?PRINT2("received expected v2 trap (~w) - check varbinds" + ?IPRINT("received expected v2 trap (~w) - check varbinds" "~n Expected VBs: ~p" "~n Received VBs: ~p", [Id, PureVars, VBs]), @@ -870,22 +868,22 @@ expect_impl(Id, v2trap, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> request_id = ReqId, error_status = Err2, error_index = Index2} -> - ?EPRINT1("received unexpected pdu: ~w, ~w, ~w" - "~n Received Error: ~p" - "~n Received Index: ~p", - [Type2, Id, ReqId, Err2, Index2]), + ?EPRINT("received unexpected pdu: ~w, ~w, ~w" + "~n Received Error: ~p" + "~n Received Index: ~p", + [Type2, Id, ReqId, Err2, Index2]), {error, Id, {"Type: ~w, ErrStat: ~w, Idx: ~w, RequestId: ~w", ['snmpv2-trap', noError, 0, ReqId]}, {"Type: ~w, ErrStat: ~w, Idx: ~w", [Type2, Err2, Index2]}}; {error, Reason} -> - ?EPRINT1("unexpected receive error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end; expect_impl(Id, report, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> - ?PRINT2("await report ~w with" + ?IPRINT("await report ~w with" "~n ExpectedVarbinds: ~p", [Id, ExpectedVarbinds]), PureVBs = find_pure_oids(ExpectedVarbinds), @@ -894,7 +892,7 @@ expect_impl(Id, report, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> error_status = noError, error_index = 0, varbinds = VBs} -> - ?PRINT2("received expected report (~w) - check varbinds" + ?IPRINT("received expected report (~w) - check varbinds" "~n Expected VBs: ~p" "~n Received VBs: ~p", [Id, PureVBs, VBs]), @@ -904,23 +902,23 @@ expect_impl(Id, report, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> request_id = ReqId, error_status = Err2, error_index = Index2} -> - ?EPRINT1("received unexpected pdu: ~w, ~w, ~w" - "~n Received Error: ~p" - "~n Received Index: ~p", - [Type2, Id, ReqId, Err2, Index2]), + ?EPRINT("received unexpected pdu: ~w, ~w, ~w" + "~n Received Error: ~p" + "~n Received Index: ~p", + [Type2, Id, ReqId, Err2, Index2]), {error, Id, {"Type: ~w, ErrStat: ~w, Idx: ~w, RequestId: ~w", [report, noError, 0, ReqId]}, {"Type: ~w, ErrStat: ~w, Idx: ~w", [Type2, Err2, Index2]}}; {error, Reason} -> - ?EPRINT1("unexpected receive error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end; expect_impl(Id, {inform, Reply}, ExpectedVarbinds) when is_list(ExpectedVarbinds) -> - ?PRINT2("await inform ~w with" + ?IPRINT("await inform ~w with" "~n Reply: ~p" "~n ExpectedVarbinds: ~p", [Id, Reply, ExpectedVarbinds]), @@ -931,20 +929,20 @@ expect_impl(Id, {inform, Reply}, ExpectedVarbinds) error_status = noError, error_index = 0, varbinds = VBs} -> - ?PRINT2("received inform (~w) - check varbinds" + ?IPRINT("received inform (~w) - check varbinds" "~n Expected VBs: ~p" "~n Received VBs: ~p", [Id, PureVBs, VBs]), case check_vars(Id, PureVBs, VBs) of ok when (Reply == true) -> - ?PRINT2("varbinds ok (~w) - send ok inform response", [Id]), + ?IPRINT("varbinds ok (~w) - send ok inform response", [Id]), RespPDU = Resp#pdu{type = 'get-response', error_status = noError, error_index = 0}, ?MODULE:rpl(RespPDU), ok; ok when (element(1, Reply) == error) -> - ?PRINT2("varbinds ok (~w) - send error inform response", [Id]), + ?IPRINT("varbinds ok (~w) - send error inform response", [Id]), {error, Status, Index} = Reply, RespPDU = Resp#pdu{type = 'get-response', error_status = Status, @@ -952,13 +950,12 @@ expect_impl(Id, {inform, Reply}, ExpectedVarbinds) ?MODULE:rpl(RespPDU), ok; ok when (Reply == false) -> - ?PRINT2("varbinds ok (~w) - don't send inform response", [Id]), + ?IPRINT("varbinds ok (~w) - don't send inform response", [Id]), ok; Else -> - ?EPRINT1("unexpected varbinds (~w)", [Id]), - io:format("expect_impl(~w, inform) -> " - "~n Else: ~p" - "~n", [Id, Else]), + ?EPRINT("unexpected (inform) varbinds (~w):" + "~n VBs: ~p" + "~n ~p", [Id, VBs, Else]), Else end; @@ -966,22 +963,22 @@ expect_impl(Id, {inform, Reply}, ExpectedVarbinds) request_id = ReqId, error_status = Err2, error_index = Index2} -> - ?EPRINT1("received unexpected pdu: ~w, ~w, ~w" - "~n Received Error: ~p" - "~n Received Index: ~p", - [Type2, Id, ReqId, Err2, Index2]), + ?EPRINT("received unexpected pdu: ~w, ~w, ~w" + "~n Received Error: ~p" + "~n Received Index: ~p", + [Type2, Id, ReqId, Err2, Index2]), {error, Id, {"Type: ~w, ErrStat: ~w, Idx: ~w, RequestId: ~w", ['inform-request', noError, 0, ReqId]}, {"Type: ~w, ErrStat: ~w, Idx: ~w", [Type2, Err2, Index2]}}; {error, Reason} -> - ?EPRINT1("unexpected receive error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end. expect_impl(Id, Err, Index, any = _ExpectedVarbinds) -> - ?PRINT2("await response ~w with" + ?IPRINT("await response ~w with" "~n Err: ~p" "~n Index: ~p" "~n ExpectedVarbinds: ~p", @@ -990,13 +987,13 @@ expect_impl(Id, Err, Index, any = _ExpectedVarbinds) -> #pdu{type = 'get-response', error_status = Err, error_index = Index} -> - ?PRINT2("received expected response pdu (~w, ~w, ~w)", + ?IPRINT("received expected response pdu (~w, ~w, ~w)", [Id, Err, Index]), ok; #pdu{type = 'get-response', error_status = Err} when (Index == any) -> - ?PRINT2("received expected response pdu (~w, ~w)", + ?IPRINT("received expected response pdu (~w, ~w)", [Id, Err]), ok; @@ -1006,14 +1003,14 @@ expect_impl(Id, Err, Index, any = _ExpectedVarbinds) -> error_index = Idx} when is_list(Index) -> case lists:member(Idx, Index) of true -> - ?PRINT2("received expected response pdu (~w, ~w, ~w)", + ?IPRINT("received expected response pdu (~w, ~w, ~w)", [Id, Err, Idx]), ok; false -> - ?EPRINT1("received response pdu with unexpected index (~w, ~w):" - "~n Expected Index: ~p" - "~n Received Index: ~p", - [Id, Err, Index, Idx]), + ?EPRINT("received response pdu with unexpected index (~w, ~w):" + "~n Expected Index: ~p" + "~n Received Index: ~p", + [Id, Err, Index, Idx]), {error, Id, {"ErrStat: ~w, Idx: ~w, RequestId: ~w", [Err, Index, ReqId]}, {"ErrStat: ~w, Idx: ~w", [Err, Idx]}} @@ -1023,22 +1020,24 @@ expect_impl(Id, Err, Index, any = _ExpectedVarbinds) -> request_id = ReqId, error_status = Err2, error_index = Index2} -> - ?EPRINT1("received unexpected response pdu: ~w, ~w, ~w" - "~n Expected Error: ~p" - "~n Received Error: ~p" - "~n Expected Index: ~p" - "~n Received Index: ~p", - [Type2, Id, ReqId, Err, Err2, Index, Index2]), + ?EPRINT("received unexpected response pdu: ~w, ~w, ~w" + "~n Expected Error: ~p" + "~n Received Error: ~p" + "~n Expected Index: ~p" + "~n Received Index: ~p", + [Type2, Id, ReqId, Err, Err2, Index, Index2]), {error, Id, {"Type: ~w, ErrStat: ~w, Idx: ~w, RequestId: ~w", ['get-response', Err, Index, ReqId]}, {"Type: ~w, ErrStat: ~w, Idx: ~w", [Type2, Err2, Index2]}}; {error, Reason} -> + ?EPRINT("unexpected (receive) response: " + "~n ~p", [Reason]), format_reason(Id, Reason) end; expect_impl(Id, Err, Index, ExpectedVarbinds) -> - ?PRINT2("await response ~w with" + ?IPRINT("await response ~w with" "~n Err: ~p" "~n Index: ~p" "~n ExpectedVarbinds: ~p", @@ -1049,7 +1048,7 @@ expect_impl(Id, Err, Index, ExpectedVarbinds) -> error_status = Err, error_index = Index, varbinds = VBs} -> - ?PRINT2("received expected response pdu (~w, ~w, ~w) - check varbinds" + ?IPRINT("received expected response pdu (~w, ~w, ~w) - check varbinds" "~n Expected VBs: ~p" "~n Received VBs: ~p", [Id, Err, Index, PureVBs, VBs]), @@ -1058,7 +1057,7 @@ expect_impl(Id, Err, Index, ExpectedVarbinds) -> #pdu{type = 'get-response', error_status = Err, varbinds = VBs} when (Index == any) -> - ?PRINT2("received expected response pdu (~w, ~w) - check varbinds" + ?IPRINT("received expected response pdu (~w, ~w) - check varbinds" "~n Expected VBs: ~p" "~n Received VBs: ~p", [Id, Err, PureVBs, VBs]), @@ -1071,18 +1070,18 @@ expect_impl(Id, Err, Index, ExpectedVarbinds) -> varbinds = VBs} when is_list(Index) -> case lists:member(Idx, Index) of true -> - ?PRINT2("received expected pdu (~w, ~w, ~w) - check varbinds" + ?IPRINT("received expected pdu (~w, ~w, ~w) - check varbinds" "~n Expected VBs: ~p" "~n Received VBs: ~p", [Id, Err, Idx, PureVBs, VBs]), check_vars(Id, PureVBs, VBs); false -> - ?EPRINT1("received response pdu with unexpected index (~w, ~w):" - "~n Expected Index: ~p" - "~n Received Index: ~p" - "~n Expected VBs: ~p" - "~n Received VBs: ~p", - [Id, Err, Index, Idx, PureVBs, VBs]), + ?EPRINT("received response pdu with unexpected index (~w, ~w):" + "~n Expected Index: ~p" + "~n Received Index: ~p" + "~n Expected VBs: ~p" + "~n Received VBs: ~p", + [Id, Err, Index, Idx, PureVBs, VBs]), {error,Id, {"ErrStat: ~w, Idx: ~w, Varbinds: ~w, RequestId: ~w", [Err,Index,PureVBs,ReqId]}, @@ -1095,15 +1094,15 @@ expect_impl(Id, Err, Index, ExpectedVarbinds) -> error_status = Err2, error_index = Index2, varbinds = VBs} -> - ?EPRINT1("received unexpected response pdu: ~w, ~w, ~w" - "~n Expected Error: ~p" - "~n Received Error: ~p" - "~n Expected Index: ~p" - "~n Received Index: ~p" - "~n Expected VBs: ~p" - "~n Received VBs: ~p", - [Type2, Id, ReqId, - Err, Err2, Index, Index2, PureVBs, VBs]), + ?EPRINT("received unexpected response pdu: ~w, ~w, ~w" + "~n Expected Error: ~p" + "~n Received Error: ~p" + "~n Expected Index: ~p" + "~n Received Index: ~p" + "~n Expected VBs: ~p" + "~n Received VBs: ~p", + [Type2, Id, ReqId, + Err, Err2, Index, Index2, PureVBs, VBs]), {error,Id, {"Type: ~w, ErrStat: ~w, Idx: ~w, Varbinds: ~w, RequestId: ~w", ['get-response',Err,Index,PureVBs,ReqId]}, @@ -1111,13 +1110,13 @@ expect_impl(Id, Err, Index, ExpectedVarbinds) -> [Type2,Err2,Index2,VBs]}}; {error, Reason} -> - ?EPRINT1("unexpected receive pdu error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive pdu error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end. expect_impl(Id, trap, Enterp, Generic, Specific, ExpectedVarbinds) -> - ?PRINT2("await trap pdu ~w with" + ?IPRINT("await trap pdu ~w with" "~n Enterprise: ~p" "~n Generic: ~p" "~n Specific: ~p" @@ -1130,7 +1129,7 @@ expect_impl(Id, trap, Enterp, Generic, Specific, ExpectedVarbinds) -> generic_trap = Generic, specific_trap = Specific, varbinds = VBs} -> - ?PRINT2("received expected trap pdu - check varbinds" + ?IPRINT("received expected trap pdu - check varbinds" "~n Expected VBs: ~p" "~n Received VBs: ~p", [PureVBs, VBs]), @@ -1140,20 +1139,20 @@ expect_impl(Id, trap, Enterp, Generic, Specific, ExpectedVarbinds) -> generic_trap = G2, specific_trap = Spec2, varbinds = VBs} -> - ?EPRINT1("received unexpected trap pdu: ~w" - "~n Expected Enterprise: ~p" - "~n Received Enterprise: ~p" - "~n Expected Generic: ~p" - "~n Received Generic: ~p" - "~n Expected Specific: ~p" - "~n Received Specific: ~p" - "~n Expected VBs: ~p" - "~n Received VBs: ~p", - [Id, - PureE, Ent2, - Generic, G2, - Specific, Spec2, - PureVBs, VBs]), + ?EPRINT("received unexpected trap pdu: ~w" + "~n Expected Enterprise: ~p" + "~n Received Enterprise: ~p" + "~n Expected Generic: ~p" + "~n Received Generic: ~p" + "~n Expected Specific: ~p" + "~n Received Specific: ~p" + "~n Expected VBs: ~p" + "~n Received VBs: ~p", + [Id, + PureE, Ent2, + Generic, G2, + Specific, Spec2, + PureVBs, VBs]), {error, Id, {"Enterprise: ~w, Generic: ~w, Specific: ~w, Varbinds: ~w", [PureE, Generic, Specific, ExpectedVarbinds]}, @@ -1161,8 +1160,8 @@ expect_impl(Id, trap, Enterp, Generic, Specific, ExpectedVarbinds) -> [Ent2, G2, Spec2, VBs]}}; {error, Reason} -> - ?EPRINT1("unexpected receive trap pdu error: ~w" - "~n ~p", [Id, Reason]), + ?EPRINT("unexpected receive trap pdu error: ~w" + "~n ~p", [Id, Reason]), format_reason(Id, Reason) end. @@ -1252,15 +1251,11 @@ sizeOf(L) when is_list(L) -> sizeOf(B) when is_binary(B) -> size(B). +d(F) -> d(F, []). d(F, A) -> d(get(debug), F, A). d(true, F, A) -> - print(F, A); + ?IPRINT(F, A); d(_,_F,_A) -> ok. -print(F, A) -> - ?PRINT2("MGR " ++ F, A). - -%% formated_timestamp() -> -%% snmp_test_lib:formated_timestamp(). diff --git a/lib/snmp/test/snmp_test_mgr_misc.erl b/lib/snmp/test/snmp_test_mgr_misc.erl index 6608a88c00..738f45a1b0 100644 --- a/lib/snmp/test/snmp_test_mgr_misc.erl +++ b/lib/snmp/test/snmp_test_mgr_misc.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2019. All Rights Reserved. +%% Copyright Ericsson AB 1996-2020. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -102,13 +102,21 @@ init_packet( Parent, SnmpMgr, AgentIp, UdpPort, TrapUdp, VsnHdr, Version, Dir, BufSz, DbgOptions, IpFamily) -> + %% This causes "verbosity printouts" to print (from the + %% specified level) in the modules we "borrow" from the + %% agent code (burr,,,). + %% With "our" name (mgr_misc). put(sname, mgr_misc), init_debug(DbgOptions), + %% Make use of the "test name" print "feature" + put(tname, "MGR-MISC"), + ?IPRINT("starting"), UdpOpts = [{recbuf,BufSz}, {reuseaddr, true}, IpFamily], {ok, UdpId} = gen_udp:open(TrapUdp, UdpOpts), put(msg_id, 1), init_usm(Version, Dir), proc_lib:init_ack(Parent, self()), + ?IPRINT("started"), packet_loop(SnmpMgr, UdpId, AgentIp, UdpPort, VsnHdr, Version, []). init_debug(Dbg) when is_atom(Dbg) -> @@ -601,43 +609,51 @@ set_pdu(Msg, RePdu) -> Msg#message{data = RePdu}. +%% Disgustingly, we borrow stuff from the agent, including the +%% local-db. Also, disgustingly, the local-db may actually not +%% have died yet. But since we actually *need* a clean local-db, +%% we must make sure its dead before we try to start the new +%% instance... init_usm('version-3', Dir) -> - ?vlog("init_usm -> create (and init) fake \"agent\" table", []), + ?IPRINT("init_usm -> create (and init) fake \"agent\" table", []), ets:new(snmp_agent_table, [set, public, named_table]), ets:insert(snmp_agent_table, {agent_mib_storage, persistent}), %% The local-db process may *still* be running (from a previous %% test case), on the way down, but not yet dead. - %% Either way, before we start it, make sure its dead and *gone*! + %% Either way, before we try to start it, make sure its old instance + %% dead and *gone*! %% How do we do that without getting hung up? Calling the stop %% function, will not do since it uses Timeout=infinity. - ?vlog("init_usm -> ensure (old) fake local-db is dead", []), + ?IPRINT("init_usm -> ensure (old) fake local-db is dead", []), ensure_local_db_dead(), - ?vlog("init_usm -> try start fake local-db", []), + ?IPRINT("init_usm -> try start fake local-db", []), case snmpa_local_db:start_link(normal, Dir, [{sname, "MGR-LOCAL-DB"}, {verbosity, trace}]) of {ok, Pid} -> - ?vlog("started: ~p" - "~n ~p", [Pid, process_info(Pid)]); + ?IPRINT("init_usm -> local-db started: ~p" + "~n ~p", [Pid, process_info(Pid)]); {error, {already_started, Pid}} -> LDBInfo = process_info(Pid), - ?vlog("already started: ~p" - "~n ~p", [Pid, LDBInfo]), + ?EPRINT("init_usm -> local-db already started: ~p" + "~n ~p", [Pid, LDBInfo]), ?FAIL({still_running, snmpa_local_db, LDBInfo}); {error, Reason} -> + ?EPRINT("init_usm -> failed start local-db: " + "~n ~p", [Reason]), ?FAIL({failed_starting, snmpa_local_db, Reason}) end, NameDb = snmpa_agent:db(snmpEngineID), - ?vlog("init_usm -> try set manager engine-id", []), + ?IPRINT("init_usm -> try set manager engine-id"), R = snmp_generic:variable_set(NameDb, "mgrEngine"), snmp_verbosity:print(info, info, "init_usm -> engine-id set result: ~p", [R]), - ?vlog("init_usm -> try set engine boots (framework-mib)", []), + ?IPRINT("init_usm -> try set engine boots (framework-mib)"), snmp_framework_mib:set_engine_boots(1), - ?vlog("init_usm -> try set engine time (framework-mib)", []), + ?IPRINT("init_usm -> try set engine time (framework-mib)"), snmp_framework_mib:set_engine_time(1), - ?vlog("init_usm -> try usm (mib) reconfigure", []), + ?IPRINT("init_usm -> try usm (mib) reconfigure"), snmp_user_based_sm_mib:reconfigure(Dir), - ?vlog("init_usm -> done", []), + ?IPRINT("init_usm -> done"), ok; init_usm(_Vsn, _Dir) -> ok. @@ -659,27 +675,28 @@ ensure_dead(Pid, Timeout) when is_pid(Pid) -> ok end; ensure_dead(_, _) -> - ?vlog("ensure_dead -> already dead", []), + ?IPRINT("ensure_dead -> already dead", []), ok. ensure_dead_wait(Pid, MRef, Timeout) -> receive {'DOWN', MRef, process, Pid, _Info} -> - ?vlog("ensure_dead_wait -> died peacefully", []), + ?IPRINT("ensure_dead_wait -> died peacefully"), throw(ok) after Timeout -> - ?vlog("ensure_dead_wait -> giving up", []), + ?WPRINT("ensure_dead_wait -> giving up"), ok end. ensure_dead_stop(Pid, MRef, Timeout) -> + %% Spawn a stop'er process StopPid = spawn(fun() -> snmpa_local_db:stop() end), receive {'DOWN', MRef, process, Pid, _Info} -> - ?vlog("ensure_dead -> dead (stopped)", []), + ?NPRINT("ensure_dead -> dead (stopped)"), throw(ok) after Timeout -> - ?vlog("ensure_dead_stop -> giving up", []), + ?WPRINT("ensure_dead_stop -> giving up"), exit(StopPid, kill), ok end. @@ -688,10 +705,10 @@ ensure_dead_kill(Pid, MRef, Timeout) -> exit(Pid, kill), receive {'DOWN', MRef, process, Pid, _Info} -> - ?vlog("ensure_dead -> dead (killed)", []), + ?NPRINT("ensure_dead -> dead (killed)"), throw(ok) after Timeout -> - ?vlog("ensure_dead_kill -> giving up", []), + ?WPRINT("ensure_dead_kill -> giving up"), ok end. @@ -891,10 +908,7 @@ d(F) -> d(F, []). d(F,A) -> d(get(debug), F, A). d(true, F, A) -> - print(F, A); + ?IPRINT(F, A); d(_,_F,_A) -> ok. -print(F, A) -> - ?PRINT2("MGR_PS " ++ F, A). - |