summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicael Karlberg <bmk@erlang.org>2020-03-04 16:09:13 +0100
committerMicael Karlberg <bmk@erlang.org>2020-03-04 16:09:13 +0100
commitd4f014b9f58ecd326eabb80b3b98da0065171c97 (patch)
treeb8d722072aeaf975f01bf5a15b2ca5cee812621d
parentc01aea5c127c63d57dcc2745c83d61bcb158e71a (diff)
parent792820e57d257342cf8ac17d6b04da97dce870e3 (diff)
downloaderlang-d4f014b9f58ecd326eabb80b3b98da0065171c97.tar.gz
Merge branch 'bmk/snmp/20200219/test_tweaking' into maint
-rw-r--r--lib/snmp/test/Makefile12
-rw-r--r--lib/snmp/test/modules.mk10
-rw-r--r--lib/snmp/test/snmp_agent_SUITE.erl833
-rw-r--r--lib/snmp/test/snmp_agent_conf_SUITE.erl4
-rw-r--r--lib/snmp/test/snmp_agent_mibs_SUITE.erl50
-rw-r--r--lib/snmp/test/snmp_agent_test_lib.erl210
-rw-r--r--lib/snmp/test/snmp_compiler_SUITE.erl187
-rw-r--r--lib/snmp/test/snmp_conf_SUITE.erl40
-rw-r--r--lib/snmp/test/snmp_log_SUITE.erl127
-rw-r--r--lib/snmp/test/snmp_manager_SUITE.erl1279
-rw-r--r--lib/snmp/test/snmp_manager_config_SUITE.erl1117
-rw-r--r--lib/snmp/test/snmp_manager_user_SUITE.erl290
-rw-r--r--lib/snmp/test/snmp_note_store_SUITE.erl185
-rw-r--r--lib/snmp/test/snmp_pdus_SUITE.erl166
-rw-r--r--lib/snmp/test/snmp_test_lib.erl307
-rw-r--r--lib/snmp/test/snmp_test_lib.hrl58
-rw-r--r--lib/snmp/test/snmp_test_mgr.erl323
-rw-r--r--lib/snmp/test/snmp_test_mgr_misc.erl64
-rw-r--r--lib/snmp/test/snmp_to_snmpnet_SUITE.erl41
19 files changed, 2868 insertions, 2435 deletions
diff --git a/lib/snmp/test/Makefile b/lib/snmp/test/Makefile
index a9a88ccbfa..0e24506c5d 100644
--- a/lib/snmp/test/Makefile
+++ b/lib/snmp/test/Makefile
@@ -2,7 +2,7 @@
# %CopyrightBegin%
#
-# Copyright Ericsson AB 1997-2016. All Rights Reserved.
+# Copyright Ericsson AB 1997-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.
@@ -89,14 +89,8 @@ ifeq ($(SNMP_DEBUG),)
# SNMP_DEBUG = d
endif
-ifeq ($(SNMP_DEBUG),e)
- SNMP_FLAGS += -Dsnmp_error
-endif
-ifeq ($(SNMP_DEBUG),l)
- SNMP_FLAGS += -Dsnmp_error -Dsnmp_log
-endif
ifeq ($(SNMP_DEBUG),d)
- SNMP_FLAGS += -Dsnmp_error -Dsnmp_log -Dsnmp_debug
+ SNMP_FLAGS += -Dsnmp_debug
endif
ifeq ($(DONT_USE_TS),true)
@@ -175,7 +169,7 @@ emakebuild: $(EMAKEFILE)
targets: mib $(EMAKEFILE)
erl -make
-old_targets: mib $(TARGET_FILES) $(TEST_SERVER_TARGETS)
+old_targets: mib $(TARGET_FILES)
$(EMAKEFILE): Makefile
$(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) '*_SUITE_make' > $(EMAKEFILE)
diff --git a/lib/snmp/test/modules.mk b/lib/snmp/test/modules.mk
index a1554815d9..ba0aea21dd 100644
--- a/lib/snmp/test/modules.mk
+++ b/lib/snmp/test/modules.mk
@@ -2,7 +2,7 @@
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2004-2019. All Rights Reserved.
+# Copyright Ericsson AB 2004-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.
@@ -35,14 +35,14 @@ SUITE_MODULES = \
snmp_to_snmpnet_SUITE
TEST_UTIL_MODULES = \
- snmp_agent_test_get \
+ snmp_test_lib \
snmp_agent_test_lib \
+ snmp_agent_test_get \
snmp_manager_user \
snmp_manager_user_old \
snmp_manager_user_test_lib \
snmp_test_global_sys_monitor \
snmp_test_sys_monitor \
- snmp_test_lib \
snmp_test_manager \
snmp_test_mgr \
snmp_test_mgr_misc \
@@ -52,10 +52,6 @@ TEST_UTIL_MODULES = \
test1 \
test2
-TEST_SERVER_MODULES = \
- snmp_test_server \
- snmp_test_suite
-
MODULES = \
$(TEST_UTIL_MODULES) \
$(SUITE_MODULES)
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_conf_SUITE.erl b/lib/snmp/test/snmp_agent_conf_SUITE.erl
index 889af630a4..1f0ad3708b 100644
--- a/lib/snmp/test/snmp_agent_conf_SUITE.erl
+++ b/lib/snmp/test/snmp_agent_conf_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2003-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.
@@ -101,7 +101,7 @@ init_per_testcase(_Case, Config) when is_list(Config) ->
Config.
end_per_testcase(_Case, Config) when is_list(Config) ->
- ?PRINT2("system events during test: "
+ ?IPRINT("system events during test: "
"~n ~p", [snmp_test_global_sys_monitor:events()]),
Config.
diff --git a/lib/snmp/test/snmp_agent_mibs_SUITE.erl b/lib/snmp/test/snmp_agent_mibs_SUITE.erl
index f6464da880..150e015554 100644
--- a/lib/snmp/test/snmp_agent_mibs_SUITE.erl
+++ b/lib/snmp/test/snmp_agent_mibs_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2003-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.
@@ -199,7 +199,7 @@ init_per_testcase2(_Case, Config) when is_list(Config) ->
end_per_testcase(Case, Config) when is_list(Config) ->
- ?PRINT2("system events during test: "
+ ?IPRINT("system events during test: "
"~n ~p", [snmp_test_global_sys_monitor:events()]),
end_per_testcase1(Case, Config).
@@ -410,7 +410,7 @@ unique(PreName) ->
list_to_atom(?F("~w_~w", [PreName, erlang:system_time(millisecond)])).
do_size_check(Config) ->
- ?PRINT2("do_size_check -> start with"
+ ?IPRINT("do_size_check -> start with"
"~n Config: ~p", [Config]),
Prio = normal,
Verbosity = trace,
@@ -457,7 +457,7 @@ do_size_check(Config) ->
?DBG("do_size_check -> stop symbolic store", []),
?line sym_stop(),
- ?PRINT2("do_size_check -> done", []),
+ ?IPRINT("do_size_check -> done", []),
ok.
@@ -688,7 +688,7 @@ mnesia_start(Opts, Nodes) ->
%% We can accept mnesia beeing loaded but *not* started.
%% If its started it *may* contain data that will invalidate
%% this test case.
- ?PRINT2("mnesia_start -> try load mnesia when:"
+ ?IPRINT("mnesia_start -> try load mnesia when:"
"~n Loaded: ~p"
"~n Running: ~p", [apps_loaded(), apps_running()]),
?line ok = case application:load(mnesia) of
@@ -700,12 +700,12 @@ mnesia_start(Opts, Nodes) ->
ERROR
end,
F = fun({Key, Val}) ->
- ?PRINT2("mnesia_start -> try set mnesia env: "
+ ?IPRINT("mnesia_start -> try set mnesia env: "
"~n ~p -> ~p", [Key, Val]),
?line application_controller:set_env(mnesia, Key, Val)
end,
lists:foreach(F, Opts),
- ?PRINT2("mnesia_start -> create mnesia schema on ~p", [Nodes]),
+ ?IPRINT("mnesia_start -> create mnesia schema on ~p", [Nodes]),
?line case mnesia:create_schema(Nodes) of
ok ->
ok;
@@ -715,7 +715,7 @@ mnesia_start(Opts, Nodes) ->
throw({skip,
?F("Failed create mnesia schema: ~p", [SchemaReason])})
end,
- ?PRINT2("mnesia_start -> start mnesia", []),
+ ?IPRINT("mnesia_start -> start mnesia", []),
?line case application:start(mnesia) of
ok ->
ok;
@@ -725,19 +725,19 @@ mnesia_start(Opts, Nodes) ->
throw({skip,
?F("Failed starting mnesia: ~p", [StartReason])})
end,
- ?PRINT2("mnesia_start -> mnesia started", []),
+ ?IPRINT("mnesia_start -> mnesia started", []),
ok.
mnesia_stop() ->
- ?PRINT2("mnesia_stop -> try stop mnesia when:"
+ ?IPRINT("mnesia_stop -> try stop mnesia when:"
"~n Loaded: ~p"
"~n Running: ~p", [apps_loaded(), apps_running()]),
application:stop(mnesia),
- ?PRINT2("mnesia_stop -> try unload mnesia when"
+ ?IPRINT("mnesia_stop -> try unload mnesia when"
"~n Loaded: ~p"
"~n Running: ~p", [apps_loaded(), apps_running()]),
application:unload(mnesia),
- ?PRINT2("mnesia_stop -> done when:"
+ ?IPRINT("mnesia_stop -> done when:"
"~n Loaded: ~p"
"~n Running: ~p", [apps_loaded(), apps_running()]),
ok.
@@ -909,19 +909,19 @@ display_memory_usage(MibsPid) ->
MibDbSize = key1search([db_memory,mib], MibsInfo),
NodeDbSize = key1search([db_memory,node], MibsInfo),
TreeDbSize = key1search([db_memory,tree], MibsInfo),
- ?INF("Symbolic store memory usage: "
- "~n Process memory size: ~p"
- "~n Db size: ~p"
- "~n"
- "~nMib server 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"
- "~n",
- [SymProcSize, DbSize,
- TreeSize, MibsProcMem, MibDbSize, NodeDbSize, TreeDbSize]).
+ ?IPRINT("Symbolic store memory usage: "
+ "~n Process memory size: ~p"
+ "~n Db size: ~p"
+ "~n"
+ "~nMib server 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"
+ "~n",
+ [SymProcSize, DbSize,
+ TreeSize, MibsProcMem, MibDbSize, NodeDbSize, TreeDbSize]).
key1search([], Res) ->
Res;
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_compiler_SUITE.erl b/lib/snmp/test/snmp_compiler_SUITE.erl
index aeb055742e..f4ba914919 100644
--- a/lib/snmp/test/snmp_compiler_SUITE.erl
+++ b/lib/snmp/test/snmp_compiler_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2003-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.
@@ -106,26 +106,48 @@ tickets_cases() ->
init_per_suite(Config0) when is_list(Config0) ->
- ?DBG("init_per_suite -> entry with"
- "~n Config0: ~p", [Config0]),
+ ?IPRINT("init_per_suite -> entry with"
+ "~n Config: ~p"
+ "~n Nodes: ~p", [Config0, erlang:nodes()]),
- Config1 = snmp_test_lib:init_suite_top_dir(?MODULE, Config0),
- Config2 = snmp_test_lib:fix_data_dir(Config1),
+ case ?LIB:init_per_suite(Config0) of
+ {skip, _} = SKIP ->
+ SKIP;
- %% Mib-dirs
- %% data_dir is trashed by the test-server / common-test
- %% so there is no point in fixing it...
- MibDir = snmp_test_lib:lookup(data_dir, Config2),
- StdMibDir = filename:join([code:priv_dir(snmp), "mibs"]),
+ Config1 when is_list(Config1) ->
+ Config2 = snmp_test_lib:init_suite_top_dir(?MODULE, Config1),
+ Config3 = snmp_test_lib:fix_data_dir(Config2),
- [{mib_dir, MibDir}, {std_mib_dir, StdMibDir} | Config2].
+ %% Mib-dirs
+ %% data_dir is trashed by the test-server / common-test
+ %% so there is no point in fixing it...
+ MibDir = snmp_test_lib:lookup(data_dir, Config3),
+ StdMibDir = filename:join([code:priv_dir(snmp), "mibs"]),
-end_per_suite(Config) when is_list(Config) ->
+ Config4 = [{mib_dir, MibDir}, {std_mib_dir, StdMibDir} | Config3],
+
+ %% We need a monitor on this node also
+ snmp_test_sys_monitor:start(),
- ?DBG("end_per_suite -> entry with"
- "~n Config: ~p", [Config]),
+ snmp_test_mgr_counter_server:start(),
- Config.
+ ?IPRINT("init_per_suite -> end when"
+ "~n Config: ~p", [Config4]),
+
+ Config4
+ end.
+
+
+end_per_suite(Config0) when is_list(Config0) ->
+ ?IPRINT("end_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
+
+ snmp_test_sys_monitor:stop(),
+ Config1 = ?LIB:end_per_suite(Config0),
+
+ ?IPRINT("end_per_suite -> end"),
+
+ Config1.
%%
@@ -165,7 +187,8 @@ end_per_testcase(_Case, Config) when is_list(Config) ->
description(suite) -> [];
description(Config) when is_list(Config) ->
put(tname,desc),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
Filename = join(Dir,"test"),
@@ -179,14 +202,14 @@ description(Config) when is_list(Config) ->
{warnings, false},
{description, false}]),
MIB1 = read_mib(MibBinName),
- %% io:format("description -> MIB1: ~n~p~n", [MIB1]),
+ %% ?IPRINT("description -> MIB1: ~n~p~n", [MIB1]),
check_mib(MIB1#mib.mes, Oid, undefined),
?line {ok,_} = snmpc:compile(MibSrcName, [{outdir, Dir},
{group_check, false},
{warnings, false},
{description, true}]),
MIB2 = read_mib(MibBinName),
- %% io:format("description -> MIB2: ~n~p~n", [MIB2]),
+ %% ?IPRINT("description -> MIB2: ~n~p~n", [MIB2]),
check_mib(MIB2#mib.mes, Oid, Desctext),
%% Cleanup
@@ -200,7 +223,8 @@ description(Config) when is_list(Config) ->
oid_conflicts(suite) -> [];
oid_conflicts(Config) when is_list(Config) ->
put(tname,oid_conflicts),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
Mib = join(Dir,"TESTv2.mib"),
@@ -232,7 +256,8 @@ agent_capabilities(suite) ->
[];
agent_capabilities(Config) when is_list(Config) ->
put(tname,agent_capabilities),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
SnmpPrivDir = which_priv_dir(snmp),
SnmpMibsDir = join(SnmpPrivDir, "mibs"),
@@ -253,11 +278,10 @@ agent_capabilities(Config) when is_list(Config) ->
?line {ok, Mib2} = snmp_misc:read_mib(MibFile2),
MEDiff = Mib2#mib.mes -- Mib1#mib.mes,
%% This is a rather pathetic test, but it is somthing...
- io:format("agent_capabilities -> "
- "~n MEDiff: ~p"
- "~n Mib1: ~p"
- "~n Mib2: ~p"
- "~n", [MEDiff, Mib1, Mib2]),
+ ?IPRINT("agent_capabilities -> "
+ "~n MEDiff: ~p"
+ "~n Mib1: ~p"
+ "~n Mib2: ~p", [MEDiff, Mib1, Mib2]),
case length(MEDiff) of
2 ->
ok;
@@ -272,8 +296,9 @@ agent_capabilities(Config) when is_list(Config) ->
module_compliance(suite) ->
[];
module_compliance(Config) when is_list(Config) ->
- put(tname,module_compliance),
- p("starting with Config: ~p~n", [Config]),
+ put(tname, module_compliance),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
SnmpPrivDir = which_priv_dir(snmp),
SnmpMibsDir = join(SnmpPrivDir, "mibs"),
@@ -294,11 +319,10 @@ module_compliance(Config) when is_list(Config) ->
?line {ok, Mib2} = snmp_misc:read_mib(MibFile2),
MEDiff = Mib2#mib.mes -- Mib1#mib.mes,
%% This is a rather pathetic test, but it is somthing...
- io:format("module_compliance -> "
- "~n MEDiff: ~p"
- "~n Mib1: ~p"
- "~n Mib2: ~p"
- "~n", [MEDiff, Mib1, Mib2]),
+ ?IPRINT("module_compliance -> "
+ "~n MEDiff: ~p"
+ "~n Mib1: ~p"
+ "~n Mib2: ~p", [MEDiff, Mib1, Mib2]),
case length(MEDiff) of
1 ->
ok;
@@ -314,7 +338,8 @@ warnings_as_errors(suite) ->
["OTP-9437"];
warnings_as_errors(Config) when is_list(Config) ->
put(tname,warnings_as_errors),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "OTP8574-MIB.mib"),
@@ -338,14 +363,16 @@ otp_6150(suite) ->
[];
otp_6150(Config) when is_list(Config) ->
put(tname, otp6150),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "ERICSSON-TOP-MIB.mib"),
?line {ok, Mib} =
snmpc:compile(MibFile, [{outdir, Dir}, {verbosity, trace}]),
- io:format("otp_6150 -> Mib: ~n~p~n", [Mib]),
+ ?IPRINT("otp_6150 -> Mib: "
+ "~n ~p", [Mib]),
ok.
@@ -355,29 +382,30 @@ otp_8574(suite) ->
[];
otp_8574(Config) when is_list(Config) ->
put(tname, otp8574),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "OTP8574-MIB.mib"),
- p("ensure compile fail without relaxed assign check"),
+ ?IPRINT("ensure compile fail without relaxed assign check"),
case snmpc:compile(MibFile, [{group_check, false}, {outdir, Dir}]) of
{error, compilation_failed} ->
- p("with relaxed assign check MIB compiles with warning"),
+ ?IPRINT("with relaxed assign check MIB compiles with warning"),
case snmpc:compile(MibFile, [{group_check, false},
{outdir, Dir},
relaxed_row_name_assign_check]) of
{ok, _Mib} ->
ok;
{error, Reason} ->
- p("unexpected compile failure: "
- "~n Reason: ~p", [Reason]),
+ ?EPRINT("unexpected compile failure: "
+ "~n Reason: ~p", [Reason]),
exit({unexpected_compile_failure, Reason})
end;
{ok, _} ->
- p("unexpected compile success"),
+ ?EPRINT("unexpected compile success"),
exit(unexpected_compile_success)
end.
@@ -388,7 +416,8 @@ otp_8595(suite) ->
[];
otp_8595(Config) when is_list(Config) ->
put(tname, otp8595),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
@@ -397,7 +426,7 @@ otp_8595(Config) when is_list(Config) ->
snmpc:compile(MibFile, [{outdir, Dir},
{verbosity, trace},
{group_check, false}]),
- p("Mib: ~n~p~n", [Mib]),
+ ?IPRINT("Mib: ~n~p~n", [Mib]),
ok.
@@ -407,14 +436,16 @@ otp_10799(suite) ->
[];
otp_10799(Config) when is_list(Config) ->
put(tname, otp10799),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "OTP10799-MIB.mib"),
?line {ok, Mib} =
snmpc:compile(MibFile, [{outdir, Dir}, {verbosity, trace}]),
- p("Mib: ~n~p~n", [Mib]),
+ ?IPRINT("Mib: "
+ "~n ~p", [Mib]),
ok.
@@ -424,7 +455,8 @@ otp_10808(suite) ->
[];
otp_10808(Config) when is_list(Config) ->
put(tname, otp10808),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
@@ -433,7 +465,8 @@ otp_10808(Config) when is_list(Config) ->
snmpc:compile(MibFile, [{outdir, Dir},
{verbosity, trace},
{group_check, false}]),
- p("Mib: ~n~p~n", [Mib]),
+ ?IPRINT("Mib: "
+ "~n ~p", [Mib]),
ok.
@@ -443,7 +476,8 @@ otp_14145(suite) ->
[];
otp_14145(Config) when is_list(Config) ->
put(tname, otp14145),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
@@ -454,7 +488,8 @@ otp_14145(Config) when is_list(Config) ->
{verbosity, trace},
{group_check, false},
module_compliance]),
- p("Mib: ~n~p~n", [MibBin]),
+ ?IPRINT("Mib: "
+ "~n ~p", [MibBin]),
MIB = read_mib(MibBin),
Oid = [1,3,6,1,2,1,67,4],
check_mib(MIB#mib.mes, Oid, undefined),
@@ -467,7 +502,8 @@ otp_13014(suite) ->
[];
otp_13014(Config) when is_list(Config) ->
put(tname, otp13014),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
@@ -478,7 +514,8 @@ otp_13014(Config) when is_list(Config) ->
{verbosity, log},
{group_check, false},
module_compliance]),
- p("Mib: ~n~p~n", [MibBin]),
+ ?IPRINT("Mib: "
+ "~n ~p", [MibBin]),
#mib{mes = MEs} = read_mib(MibBin),
Oid = [1,0,8802,1,1,2,1,1,7],
#me{
@@ -494,20 +531,23 @@ otp_13014(Config) when is_list(Config) ->
TableInfo,
ok.
+
%%======================================================================
otp_14196(suite) ->
[];
otp_14196(Config) when is_list(Config) ->
put(tname, otp14196),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "OTP14196-MIB.mib"),
?line {ok, Mib} =
snmpc:compile(MibFile, [{outdir, Dir}, {verbosity, trace}]),
- p("Mib: ~n~p~n", [Mib]),
+ ?IPRINT("Mib: "
+ "~n ~p", [Mib]),
ok.
@@ -517,7 +557,8 @@ augments_extra_info(suite) ->
[];
augments_extra_info(Config) when is_list(Config) ->
put(tname, augments_extra_info),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
@@ -527,28 +568,30 @@ augments_extra_info(Config) when is_list(Config) ->
snmpc:compile(Test2File, [{outdir, Dir},
{verbosity, silence},
{group_check, false}]),
- io:format("Test2BinFile: ~n~p~n", [Test2BinFile]),
+ ?IPRINT("Test2BinFile: "
+ "~n ~p", [Test2BinFile]),
?line {ok, Test3BinFile} =
snmpc:compile(Test3File, [{i, [MibDir]},
{outdir, Dir},
{verbosity, silence},
{group_check, true}]),
- io:format("Test3BinFile: ~n~p~n", [Test3BinFile]),
+ ?IPRINT("Test3BinFile: "
+ "~n ~p", [Test3BinFile]),
{ok, Test3Mib} = snmp_misc:read_mib(Test3BinFile),
- io:format("Test3Mib: ~n~p~n", [Test3Mib]),
+ ?IPRINT("Test3Mib: "
+ "~n ~p", [Test3Mib]),
%% There is only one table in this mib
#mib{table_infos = [{TableName, TI}]} = Test3Mib,
- io:format("TableName: ~p"
- "~n Table Info: ~p"
- "~n", [TableName, TI]),
+ ?IPRINT("TableName: ~p"
+ "~n Table Info: ~p", [TableName, TI]),
#table_info{nbr_of_cols = 4,
defvals = DefVals,
not_accessible = [2,4],
index_types = {augments, {tEntry, undefined}},
first_accessible = 1} = TI,
- io:format("Table info: ~p"
- "~n DefVals: ~p"
- "~n", [TableName, DefVals]),
+ ?IPRINT("Table info: ~p"
+ "~n DefVals: ~p"
+ "~n", [TableName, DefVals]),
ok.
@@ -750,21 +793,3 @@ which_priv_dir(App) ->
join(A,B) ->
filename:join(A,B).
-
-%% ------
-
-%% p(F) ->
-%% p(F, []).
-
-p(F) ->
- p(F, []).
-
-p(F, A) ->
- p(get(tname), F, A).
-
-p(TName, F, A) ->
- io:format("*** [~w][~s] ***"
- "~n" ++ F ++ "~n", [TName, formated_timestamp()|A]).
-
-formated_timestamp() ->
- snmp_test_lib:formated_timestamp().
diff --git a/lib/snmp/test/snmp_conf_SUITE.erl b/lib/snmp/test/snmp_conf_SUITE.erl
index bd8375b400..7d60485060 100644
--- a/lib/snmp/test/snmp_conf_SUITE.erl
+++ b/lib/snmp/test/snmp_conf_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2003-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.
@@ -97,11 +97,34 @@ groups() ->
%% -----
%%
-init_per_suite(Config) when is_list(Config) ->
- Config.
+init_per_suite(Config0) when is_list(Config0) ->
+ ?IPRINT("init_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
-end_per_suite(Config) when is_list(Config) ->
- Config.
+ case ?LIB:init_per_suite(Config0) of
+ {skip, _} = SKIP ->
+ SKIP;
+
+ Config1 when is_list(Config1) ->
+ %% We need a monitor on this node also
+ snmp_test_sys_monitor:start(),
+
+ ?IPRINT("init_per_suite -> end when"
+ "~n Config: ~p", [Config1]),
+
+ Config1
+ end.
+
+end_per_suite(Config0) when is_list(Config0) ->
+ ?IPRINT("end_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
+
+ snmp_test_sys_monitor:stop(),
+ Config1 = ?LIB:end_per_suite(Config0),
+
+ ?IPRINT("end_per_suite -> end"),
+
+ Config1.
@@ -136,7 +159,7 @@ end_per_testcase(_Case, Config) when is_list(Config) ->
check_mandatory(suite) -> [];
check_mandatory(Config) when is_list(Config) ->
?P(check_mandatory),
- %% d("check_mandatory -> entry"),
+ %% ?IPRINT("check_mandatory -> entry"),
A1 = [{a, hej}, {b, hopp}, {c, 10}, {d, 10101}, {f, 10.88}],
B1 = [{a, {value, hejsan}},
{b, mandatory},
@@ -696,8 +719,3 @@ read_files(Config) when is_list(Config) ->
%% Internal functions
%%======================================================================
-% d(F) ->
-% d(F, []).
-
-% d(F, A) ->
-% io:format("~w:" ++ F ++ "~n", [?MODULE|A]).
diff --git a/lib/snmp/test/snmp_log_SUITE.erl b/lib/snmp/test/snmp_log_SUITE.erl
index 01a1d9ce8c..b63c9e3b34 100644
--- a/lib/snmp/test/snmp_log_SUITE.erl
+++ b/lib/snmp/test/snmp_log_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2003-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.
@@ -175,7 +175,7 @@ init_per_testcase(Case, Config) when is_list(Config) ->
end_per_testcase(_Case, Config) when is_list(Config) ->
- ?PRINT2("system events during test: "
+ ?IPRINT("system events during test: "
"~n ~p", [snmp_test_global_sys_monitor:events()]),
%% Leave the dirs created above (enable debugging of the test case(s))
@@ -191,7 +191,7 @@ end_per_testcase(_Case, Config) when is_list(Config) ->
open_and_close(suite) -> [];
open_and_close(Config) when is_list(Config) ->
- p(open_and_close),
+ ?P(open_and_close),
put(sname,open_and_close),
put(verbosity,trace),
Dir = ?config(log_dir, Config),
@@ -213,7 +213,7 @@ open_write_and_close1(suite) ->
open_write_and_close1(doc) ->
"Open a plain (no sequence-numbering) log file";
open_write_and_close1(Config) when is_list(Config) ->
- p(open_write_and_close1),
+ ?P(open_write_and_close1),
put(sname,open_write_and_close1),
put(verbosity,trace),
?DBG("open_write_and_close1 -> start", []),
@@ -232,7 +232,7 @@ open_write_and_close2(suite) ->
open_write_and_close2(doc) ->
"Open a log file with sequence-numbering explicitly disabled";
open_write_and_close2(Config) when is_list(Config) ->
- p(open_write_and_close2),
+ ?P(open_write_and_close2),
put(sname,open_write_and_close2),
put(verbosity,trace),
?DBG("open_write_and_close2 -> start", []),
@@ -251,7 +251,7 @@ open_write_and_close3(suite) ->
open_write_and_close3(doc) ->
"Open a log file with sequence-numbering using MFA";
open_write_and_close3(Config) when is_list(Config) ->
- p(open_write_and_close3),
+ ?P(open_write_and_close3),
put(sname,open_write_and_close3),
put(verbosity,trace),
?DBG("open_write_and_close2 -> start", []),
@@ -272,7 +272,7 @@ open_write_and_close4(suite) ->
open_write_and_close4(doc) ->
"Open a log file with sequence-numbering using fun";
open_write_and_close4(Config) when is_list(Config) ->
- p(open_write_and_close4),
+ ?P(open_write_and_close4),
put(sname,open_write_and_close4),
put(verbosity,trace),
?DBG("open_write_and_close2 -> start", []),
@@ -371,7 +371,7 @@ log_to_io1(suite) -> [];
log_to_io1(doc) -> "Log to io from the same process that opened "
"and wrote the log";
log_to_io1(Config) when is_list(Config) ->
- p(log_to_io1),
+ ?P(log_to_io1),
put(sname,l2i1),
put(verbosity,debug),
?DBG("log_to_io1 -> start", []),
@@ -426,7 +426,7 @@ log_to_io2(doc) -> "Log to io from a different process than which "
"opened and wrote the log";
log_to_io2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- p(log_to_io2),
+ ?P(log_to_io2),
put(sname, l2i2),
put(verbosity,debug),
?DBG("log_to_io2 -> start", []),
@@ -487,7 +487,7 @@ log_to_io2(Config) when is_list(Config) ->
log_to_txt1(suite) -> [];
log_to_txt1(Config) when is_list(Config) ->
- p(log_to_txt1),
+ ?P(log_to_txt1),
put(sname,l2t1),
put(verbosity,debug),
?DBG("log_to_txt1 -> start", []),
@@ -505,7 +505,7 @@ log_to_txt1(Config) when is_list(Config) ->
log_to_txt2(suite) -> [];
log_to_txt2(Config) when is_list(Config) ->
- p(log_to_txt2),
+ ?P(log_to_txt2),
put(sname,l2t2),
put(verbosity,debug),
?DBG("log_to_txt2 -> start", []),
@@ -642,7 +642,7 @@ log_to_txt3(doc) ->
"opened and wrote the log";
log_to_txt3(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- p(log_to_txt3),
+ ?P(log_to_txt3),
put(sname,l2t3),
put(verbosity,debug),
?DBG("log_to_txt3 -> start", []),
@@ -683,9 +683,7 @@ log_to_txt3(Config) when is_list(Config) ->
R = snmp_log:log_to_txt(Log, LogFile, Dir,
Mibs, TxtFile),
T2 = snmp_misc:now(ms),
- io:format(user,
- "Time converting file: ~w ms~n",
- [T2 - T1]),
+ ?IPRINT("Time converting file: ~w ms", [T2 - T1]),
{R, I}
end),
@@ -697,9 +695,9 @@ log_to_txt3(Config) when is_list(Config) ->
?DBG("log_to_txt3 -> text file size: ~p", [FileSize]),
validate_size(FileSize);
{Error, Info} ->
- ?DBG("log_to_txt3 -> log to txt failed: "
- "~n Error: ~p"
- "~n Info: ~p", [Error, Info]),
+ ?EPRINT("log to txt failed: "
+ "~n Error: ~p"
+ "~n Info: ~p", [Error, Info]),
?line ?FAIL({log_lo_txt_failed, Error, Info})
end,
@@ -709,7 +707,7 @@ log_to_txt3(Config) when is_list(Config) ->
?DBG("log_to_txt3 -> instruct the log reader to stop", []),
?line log_reader_stop(Reader),
- ?DBG("log_to_txt3 -> done", []),
+ ?IPRINT("log_to_txt3 -> done", []),
ok.
@@ -754,8 +752,7 @@ log_writer_stop(Pid) ->
receive
{'EXIT', Pid, normal} ->
_T2 = snmp_misc:now(ms),
- io:format("[~s] it took ~w ms to stop the writer~n",
- [?FTS(), _T2 - _T1]),
+ ?IPRINT("it took ~w ms to stop the writer", [_T2 - _T1]),
ok
after 60000 ->
Msg = receive Any -> Any after 0 -> nothing end,
@@ -772,8 +769,7 @@ log_writer_sleep(Pid, Time) ->
receive
{sleeping, Pid} ->
_T2 = snmp_misc:now(ms),
- io:format("[~s] it took ~w ms to put the writer to sleep~n",
- [?FTS(), _T2 - _T1]),
+ ?IPRINT("it took ~w ms to put the writer to sleep", [_T2 - _T1]),
ok;
{'EXIT', Pid, Reason} ->
{error, Reason}
@@ -785,8 +781,7 @@ log_writer_sleep(Pid, Time) ->
log_writer_main(Name, File, Size, Repair, P, Factor) ->
process_flag(trap_exit, true),
- %% put(sname,log_writer),
- %% put(verbosity,trace),
+ put(tname, "LOG-WRITER"),
{ok, Log} = snmp_log:create(Name, File, Size, Repair),
P ! {log, Log, self()},
Msgs = lists:flatten(lists:duplicate(if
@@ -807,39 +802,34 @@ log_writer_main(Name, File, Size, Repair, P, Factor) ->
log_writer(Log, BatchLogger, P).
log_writer(Log, Fun, P) ->
- lp("entry"),
+ ?IPRINT("entry"),
receive
{stop, P} ->
- lp("received stop request"),
+ ?IPRINT("received stop request"),
ok = snmp_log:close(Log),
exit(normal);
{info, P} ->
- lp("received info request"),
+ ?IPRINT("received info request"),
{ok, Info} = snmp_log:info(Log),
display_info(Info),
log_writer(Log, Fun, P);
{sleep, Time, P} ->
- lp("received sleep (~w) request", [Time]),
+ ?IPRINT("received sleep (~w) request", [Time]),
P ! {sleeping, self()},
?SLEEP(Time),
- lp("done sleeping"),
+ ?IPRINT("done sleeping"),
log_writer(Log, Fun, P);
ELSE ->
- error_logger:error_msg("ERROR:logger - received unknown message: "
- "~n ~p~n", [ELSE]),
+ ?EPRINT("Received unknown message: "
+ "~n ~p", [ELSE]),
log_writer(Log, Fun, P)
after 1000 ->
- lp("log some messages"),
+ ?IPRINT("log some messages"),
To = lists:duplicate(100, 100),
lists:foreach(Fun, To),
log_writer(Log, Fun, P)
end.
-lp(F) ->
- lp(F, []).
-
-lp(F, A) ->
- io:format("[~s] writer [~w] " ++ F ++ "~n", [?FTS(),self()|A]).
%% --
@@ -849,8 +839,7 @@ log_reader_start() ->
receive
{started, Pid} ->
_T2 = snmp_misc:now(ms),
- io:format("[~s] it took ~w ms to start the reader~n",
- [?FTS(), _T2 - _T1]),
+ ?IPRINT("it took ~w ms to start the reader", [_T2 - _T1]),
{ok, Pid};
{'EXIT', Pid, Reason} ->
{error, Reason}
@@ -864,8 +853,7 @@ log_reader_stop(Pid) ->
receive
{'EXIT', Pid, normal} ->
_T2 = snmp_misc:now(ms),
- io:format("[~s] it took ~w ms to stop the reader~n",
- [?FTS(), _T2 - _T1]),
+ ?IPRINT("it took ~w ms to stop the reader", [_T2 - _T1]),
ok
after 1000 ->
Msg = receive Any -> Any after 0 -> nothing end,
@@ -880,35 +868,28 @@ log_reader_log_to(Pid, LogToFun) when is_function(LogToFun) ->
end.
log_reader_main(P) ->
- put(sname,log_reader),
- put(verbosity,trace),
+ put(tname, "LOG-READER"),
P ! {started, self()},
log_reader(P).
log_reader(P) ->
- rp("entry"),
+ ?IPRINT("entry"),
receive
{stop, P} ->
- rp("received stop request"),
+ ?IPRINT("received stop request"),
exit(normal);
{log_to, F, P} ->
- rp("received log_to request"),
+ ?IPRINT("received log_to request"),
Res = F(),
- rp("done with log_to - sending reply"),
+ ?IPRINT("done with log_to - sending reply"),
P ! {log_to_reply, Res, self()},
log_reader(P);
ELSE ->
- error_logger:error_msg("reader - received unknown message: "
- "~n ~p~n", [ELSE]),
+ ?EPRINT("Received unknown message: "
+ "~n ~p", [ELSE]),
log_reader(P)
end.
-rp(F) ->
- rp(F, []).
-
-rp(F, A) ->
- io:format("[~s] reader [~w] " ++ F ++ "~n", [?FTS(),self()|A]).
-
%%======================================================================
@@ -1127,23 +1108,6 @@ varbinds([{Oid, Type, Value, Idx}|T], Acc) ->
org_index = Idx},
varbinds(T, [Varbind|Acc]).
-% enc_message('version-3' = Vsn, Community, Pdu) ->
-% ScopedPDU = #scopedPdu{contextEngineID = ContextEngineID,
-% contextName = ContextName,
-% data = Pdu},
-% NUsmSecParams =
-% UsmSecParams#usmSecurityParameters{msgAuthenticationParameters =
-% AuthParams},
-% SecBytes = snmp_pdus:enc_usm_security_parameters(NUsmSecParams),
-% V3Hdr = #v3_hdr{msgID = MsgID,
-% msgMaxSize = AgentMS,
-% msgFlags = snmp_misc:mk_msg_flags(Type, SecLevel),
-% msgSecurityParameters = SecBytes
-% msgSecurityModel = MsgSecurityModel},
-% Msg = #message{version = Vsn, vsn_hdr = V3Hdr,
-% data = ScopedPDUBytes},
-% snmp_pdus:enc_message_only(Message2);
-
enc_message(Vsn, Community, Pdu) ->
PduBytes = snmp_pdus:enc_pdu(Pdu),
Msg = #message{version = Vsn,
@@ -1156,14 +1120,13 @@ display_info(Info) ->
CurrentFile = get_info(current_file, Info, -1),
NoItems = get_info(no_current_items, Info, -1),
NoBytes = get_info(no_current_bytes, Info, -1),
- io:format(user, "Disk log info: "
- "~n Number of filled since opened: ~p"
- "~n Number of filled since last info: ~p"
- "~n Current file: ~p"
- "~n Number of items in file: ~p"
- "~n Number of bytes in file: ~p"
- "~n",
- [SinceOpened, SinceLastInfo, CurrentFile, NoItems, NoBytes]).
+ ?NPRINT("Disk log info: "
+ "~n Number of filled since opened: ~p"
+ "~n Number of filled since last info: ~p"
+ "~n Current file: ~p"
+ "~n Number of items in file: ~p"
+ "~n Number of bytes in file: ~p",
+ [SinceOpened, SinceLastInfo, CurrentFile, NoItems, NoBytes]).
get_info(Key, Info, Def) ->
case lists:keysearch(Key, 1, Info) of
@@ -1176,5 +1139,3 @@ get_info(Key, Info, Def) ->
join(D, F) ->
filename:join(D, F).
-p(Case) ->
- io:format(user, "test case: ~w~n", [Case]).
diff --git a/lib/snmp/test/snmp_manager_SUITE.erl b/lib/snmp/test/snmp_manager_SUITE.erl
index bc7c5cd46d..01e92ff730 100644
--- a/lib/snmp/test/snmp_manager_SUITE.erl
+++ b/lib/snmp/test/snmp_manager_SUITE.erl
@@ -337,8 +337,8 @@ ipv6_tests() ->
init_per_suite(Config0) when is_list(Config0) ->
- p("init_per_suite -> entry with"
- "~n Config0: ~p", [Config0]),
+ ?IPRINT("init_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
case ?LIB:init_per_suite(Config0) of
{skip, _} = SKIP ->
@@ -346,8 +346,8 @@ init_per_suite(Config0) when is_list(Config0) ->
Config1 ->
- p("init_per_suite -> common init done"
- "~n Config1: ~p", [Config1]),
+ ?IPRINT("init_per_suite -> common init done"
+ "~n Config1: ~p", [Config1]),
%% Preferably this test SUITE should be divided into groups
%% so that if crypto does not work only v3 tests that
@@ -375,15 +375,15 @@ init_per_suite(Config0) when is_list(Config0) ->
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()]),
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.
@@ -453,8 +453,10 @@ end_per_group(_GroupName, Config) ->
%%
init_per_testcase(Case, Config) when is_list(Config) ->
- p(Case, "init_per_testcase begin when"
- "~n Nodes: ~p~n~n", [erlang:nodes()]),
+
+ ?IPRINT("init_per_testcase -> entry with"
+ "~n Config: ~p"
+ "~n Nodes: ~p", [Config, erlang:nodes()]),
snmp_test_global_sys_monitor:reset_events(),
@@ -477,10 +479,10 @@ init_per_testcase(Case, Config) when is_list(Config) ->
{skip, {catched, C, E}}
end
end,
- p(Case, "init_per_testcase end when"
- "~n Nodes: ~p"
- "~n Result: ~p"
- "~n~n", [Result, erlang:nodes()]),
+ ?IPRINT("init_per_testcase end when"
+ "~n Nodes: ~p"
+ "~n Result: ~p"
+ "~n~n", [Result, erlang:nodes()]),
Result.
init_per_testcase2(Case, Config) ->
@@ -527,10 +529,14 @@ init_per_testcase2(Case, Config) ->
InformSwarm when (InformSwarm =:= inform_swarm_cbp_def) orelse
(InformSwarm =:= inform_swarm_cbp_temp) orelse
(InformSwarm =:= inform_swarm_cbp_perm) ->
- ?MINS(60);
+ case ?config(snmp_factor, Config) of
+ N when is_integer(N) -> ?MINS(2*N);
+ _ -> ?MINS(2)
+ end;
_ ->
?MINS(1)
end,
+ ?IPRINT("Set test case timetrap: ~p", [TO]),
ct:timetrap(TO),
Conf = [{ipfamily, Family},
@@ -670,20 +676,21 @@ init_per_testcase_fail_agent_cleanup(Conf) ->
(catch fin_agent(Conf)).
end_per_testcase(Case, Config) when is_list(Config) ->
- p(Case, "end_per_testcase begin when"
- "~n Nodes: ~p~n~n", [erlang:nodes()]),
+ ?IPRINT("end_per_testcase -> entry with"
+ "~n Config: ~p"
+ "~n Nodes: ~p",
+ [Config, erlang:nodes()]),
- ?PRINT2("system events during test: "
+ ?IPRINT("system events during test: "
"~n ~p", [snmp_test_global_sys_monitor:events()]),
- %% Dog = ?config(watchdog, Config),
- %% ?WD_STOP(Dog),
- %% Conf1 = lists:keydelete(watchdog, 1, Config),
Conf1 = Config,
Conf2 = end_per_testcase2(Case, Conf1),
- p(Case, "end_per_testcase end when"
- "~n Nodes: ~p~n~n", [erlang:nodes()]),
+ ?IPRINT("end_per_testcase -> done with"
+ "~n Condif: ~p"
+ "~n Nodes: ~p", [Conf2, erlang:nodes()]),
+
Conf2.
end_per_testcase2(Case, Config) ->
@@ -763,7 +770,8 @@ simple_start_and_stop1(Config) when is_list(Config) ->
fun() -> do_simple_start_and_stop1(Config) end).
do_simple_start_and_stop1(Config) ->
- p("starting with Config: ~n~p", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -774,12 +782,12 @@ do_simple_start_and_stop1(Config) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start_link(Opts),
?SLEEP(1000),
- p("manager started, now try to stop"),
+ ?IPRINT("manager started, now try to stop"),
ok = snmpm:stop(),
?SLEEP(1000),
@@ -800,7 +808,9 @@ simple_start_and_stop2(Config) when is_list(Config) ->
?TC_TRY(simple_start_and_stop2, Pre, Case, Post).
do_simple_start_and_stop2([ManagerNode], Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -813,23 +823,24 @@ do_simple_start_and_stop2([ManagerNode], Config) ->
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try load snmp application"),
+ ?IPRINT("try load snmp application"),
?line ok = load_snmp(ManagerNode),
- p("try set manager env for the snmp application"),
+ ?IPRINT("try set manager env for the snmp application"),
?line ok = set_mgr_env(ManagerNode, Opts),
- p("try starting snmp application (with only manager)"),
+ ?IPRINT("try starting snmp application (with only manager)"),
?line ok = start_snmp(ManagerNode),
- p("started"),
+ ?IPRINT("started"),
?SLEEP(1000),
- p("try stopping snmp application (with only manager)"),
+ ?IPRINT("try stopping snmp application (with only manager)"),
?line ok = stop_snmp(ManagerNode),
?SLEEP(1000),
+ ?IPRINT("end"),
ok.
@@ -842,7 +853,9 @@ simple_start_and_stop3(Config) when is_list(Config) ->
fun() -> do_simple_start_and_stop3(Config) end).
do_simple_start_and_stop3(Config) ->
- p("starting with Config: ~n~p", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
+
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -853,17 +866,19 @@ do_simple_start_and_stop3(Config) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
try snmpm:start_link(Opts) of
ok ->
+ (catch snmpm:stop()),
?FAIL('unexpected-success')
catch
_:_:_ ->
- p("expected start failure"),
+ ?IPRINT("expected start failure"),
ok
end,
?SLEEP(1000),
+ ?IPRINT("end"),
ok.
@@ -876,7 +891,8 @@ simple_start_and_monitor_crash1(Config) when is_list(Config) ->
fun() -> do_simple_start_and_monitor_crash1(Config) end).
do_simple_start_and_monitor_crash1(Config) ->
- p("starting with Config: ~n~p", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -888,15 +904,15 @@ do_simple_start_and_monitor_crash1(Config) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start(Opts),
?SLEEP(1000),
- p("create the monitor"),
+ ?IPRINT("create the monitor"),
Ref = snmpm:monitor(),
- p("make sure it has not already crashed..."),
+ ?IPRINT("make sure it has not already crashed..."),
receive
{'DOWN', Ref, process, Obj1, Reason1} ->
?FAIL({unexpected_down, Obj1, Reason1})
@@ -904,20 +920,28 @@ do_simple_start_and_monitor_crash1(Config) ->
ok
end,
- p("stop the manager"),
+ ?IPRINT("stop the manager"),
ok = snmpm:stop(),
- p("await the down-message"),
+ ?IPRINT("await the down-message"),
receive
{'DOWN', Ref, process, Obj2, Reason2} ->
- p("received expected down-message: "
- "~n Obj2: ~p"
- "~n Reason2: ~p",
- [Obj2, Reason2]),
+ ?IPRINT("received expected down-message: "
+ "~n Obj2: ~p"
+ "~n Reason2: ~p",
+ [Obj2, Reason2]),
ok
after 1000 ->
+ %% The manager is an entire process tree and we can't
+ %% wait for all of them. Instead, we assume that if
+ %% we deal with the top supervisor, all the other procs
+ %% will also follow...
+ ?ENSURE_NOT_RUNNING(snmpm_supervisor,
+ fun() -> snmpm:stop() end,
+ 1000),
?FAIL(timeout)
end,
+ ?IPRINT("end"),
ok.
@@ -930,7 +954,8 @@ simple_start_and_monitor_crash2(Config) when is_list(Config) ->
fun() -> do_simple_start_and_monitor_crash2(Config) end).
do_simple_start_and_monitor_crash2(Config) ->
- p("starting with Config: ~n~p", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -943,15 +968,15 @@ do_simple_start_and_monitor_crash2(Config) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start(Opts),
?SLEEP(1000),
- p("create the monitor"),
+ ?IPRINT("create the monitor"),
Ref = snmpm:monitor(),
- p("make sure it has not already crashed..."),
+ ?IPRINT("make sure it has not already crashed..."),
receive
{'DOWN', Ref, process, Obj1, Reason1} ->
?FAIL({unexpected_down, Obj1, Reason1})
@@ -959,16 +984,16 @@ do_simple_start_and_monitor_crash2(Config) ->
ok
end,
- p("crash the manager"),
+ ?IPRINT("crash the manager"),
simulate_crash(),
- p("await the down-message"),
+ ?IPRINT("await the down-message"),
receive
{'DOWN', Ref, process, Obj2, Reason2} ->
- p("received expected down-message: "
- "~n Obj2: ~p"
- "~n Reason2: ~p",
- [Obj2, Reason2]),
+ ?IPRINT("received expected down-message: "
+ "~n Obj2: ~p"
+ "~n Reason2: ~p",
+ [Obj2, Reason2]),
ok
after 1000 ->
?FAIL(timeout)
@@ -995,16 +1020,17 @@ simulate_crash(?MAX_KILLS, _) ->
ok
end;
simulate_crash(NumKills, Pid) when (NumKills < ?MAX_KILLS) and is_pid(Pid) ->
- p("similate_crash -> ~w, ~p", [NumKills, Pid]),
+ ?IPRINT("similate_crash -> ~w, ~p", [NumKills, Pid]),
Ref = erlang:monitor(process, Pid),
exit(Pid, kill),
receive
{'DOWN', Ref, process, _Object, _Info} ->
- p("received expected 'DOWN' message"),
+ ?IPRINT("received expected 'DOWN' message"),
simulate_crash(NumKills + 1, server_pid())
after 1000 ->
case server_pid() of
P when is_pid(P) ->
+ ?EPRINT("received expected 'DOWN' message"),
exit({error, {no_down_from_server, P}});
_ ->
ok
@@ -1023,7 +1049,8 @@ notify_started01(Config) when is_list(Config) ->
fun() -> do_notify_started01(Config) end).
do_notify_started01(Config) ->
- p("starting with Config: ~n~p", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -1035,11 +1062,11 @@ do_notify_started01(Config) ->
{note_store, [{verbosity, silence}]},
{config, [{verbosity, log}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("request start notification (1)"),
+ ?IPRINT("request start notification (1)"),
Pid1 = snmpm:notify_started(10000),
receive
{snmpm_start_timeout, Pid1} ->
- p("received expected start timeout"),
+ ?IPRINT("received expected start timeout"),
ok;
Any1 ->
?FAIL({unexpected_message, Any1})
@@ -1047,17 +1074,17 @@ do_notify_started01(Config) ->
?FAIL({unexpected_timeout, Pid1})
end,
- p("request start notification (2)"),
+ ?IPRINT("request start notification (2)"),
Pid2 = snmpm:notify_started(10000),
- p("start the snmpm starter"),
+ ?IPRINT("start the snmpm starter"),
Pid = snmpm_starter(Opts, 5000),
- p("await the start notification"),
+ ?IPRINT("await the start notification"),
Ref =
receive
{snmpm_started, Pid2} ->
- p("received started message -> create the monitor"),
+ ?IPRINT("received started message -> create the monitor"),
snmpm:monitor();
Any2 ->
?FAIL({unexpected_message, Any2})
@@ -1065,7 +1092,7 @@ do_notify_started01(Config) ->
?FAIL({unexpected_timeout, Pid2})
end,
- p("[~p] make sure it has not already crashed...", [Ref]),
+ ?IPRINT("[~p] make sure it has not already crashed...", [Ref]),
receive
{'DOWN', Ref, process, Obj1, Reason1} ->
?FAIL({unexpected_down, Obj1, Reason1})
@@ -1073,22 +1100,22 @@ do_notify_started01(Config) ->
ok
end,
- p("stop the manager"),
+ ?IPRINT("stop the manager"),
Pid ! {stop, self()}, %ok = snmpm:stop(),
- p("await the down-message"),
+ ?IPRINT("await the down-message"),
receive
{'DOWN', Ref, process, Obj2, Reason2} ->
- p("received expected down-message: "
- "~n Obj2: ~p"
- "~n Reason2: ~p",
- [Obj2, Reason2]),
+ ?IPRINT("received expected down-message: "
+ "~n Obj2: ~p"
+ "~n Reason2: ~p",
+ [Obj2, Reason2]),
ok
after 5000 ->
?FAIL(down_timeout)
end,
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -1137,7 +1164,8 @@ notify_started02_cond(Config) ->
?NON_PC_TC_MAYBE_SKIP(Config, Condition).
do_notify_started02(Config) ->
- p("starting with Config: ~n~p", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -1149,11 +1177,11 @@ do_notify_started02(Config) ->
{note_store, [{verbosity, silence}]},
{config, [{verbosity, debug}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("start snmpm client process"),
+ ?IPRINT("start snmpm client process"),
NumIterations = 5,
Pid1 = ns02_client_start(NumIterations),
- p("start snmpm ctrl (starter) process"),
+ ?IPRINT("start snmpm ctrl (starter) process"),
Pid2 = ns02_ctrl_start(Opts, NumIterations),
%% On a reasonably fast machine, one iteration takes approx 4 seconds.
@@ -1175,7 +1203,8 @@ do_notify_started02(Config) ->
?SKIP(Reason)
end,
- p("await snmpm client process exit (max ~p+10000 msec)", [ApproxStartTime]),
+ ?IPRINT("await snmpm client process exit (max ~p+10000 msec)",
+ [ApproxStartTime]),
receive
%% We take this opportunity to check if we got a skip from
%% the ctrl process.
@@ -1193,7 +1222,7 @@ do_notify_started02(Config) ->
?FAIL(timeout)
end,
- p("await snmpm starter process exit"),
+ ?IPRINT("await snmpm starter process exit"),
receive
{'EXIT', Pid2, normal} ->
ok;
@@ -1207,7 +1236,7 @@ do_notify_started02(Config) ->
?FAIL(timeout)
end,
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -1220,8 +1249,8 @@ ns02_client_await_approx_runtime(Pid) ->
{?MODULE, client_time, Time} ->
{ok, Time};
{'EXIT', Pid, Reason} ->
- p("client (~p) failed: "
- "~n ~p", [Pid, Reason]),
+ ?EPRINT("client (~p) failed: "
+ "~n ~p", [Pid, Reason]),
{error, Reason}
after 30000 ->
@@ -1233,48 +1262,48 @@ ns02_client_await_approx_runtime(Pid) ->
ns02_client(Parent, N) when is_pid(Parent) ->
put(tname, ns02_client),
- p("starting"),
+ ?IPRINT("starting"),
ns02_client_loop(Parent,
dummy, snmpm:notify_started(?NS_TIMEOUT),
snmp_misc:now(ms), undefined,
N).
ns02_client_loop(_Parent, _Ref, _Pid, _Begin, _End, 0) ->
- %% p("loop -> done"),
+ %% ?IPRINT("loop -> done"),
exit(normal);
ns02_client_loop(Parent, Ref, Pid, Begin, End, N)
when is_pid(Parent) andalso is_integer(Begin) andalso is_integer(End) ->
- %% p("loop -> [~w] inform parent: ~w, ~w => ~w", [N, Begin, End, End-Begin]),
+ %% ?IPRINT("loop -> [~w] inform parent: ~w, ~w => ~w", [N, Begin, End, End-Begin]),
Parent ! {?MODULE, client_time, N*(End-Begin)},
ns02_client_loop(undefined, Ref, Pid, snmp_misc:now(ms), undefined, N);
ns02_client_loop(Parent, Ref, Pid, Begin, End, N)
when is_integer(Begin) andalso is_integer(End) ->
- %% p("loop -> [~w] entry when"
+ %% ?IPRINT("loop -> [~w] entry when"
%% "~n Ref: ~p"
%% "~n Pid: ~p"
%% "~n Begin: ~p"
%% "~n End: ~p", [N, Ref, Pid, Begin, End]),
ns02_client_loop(Parent, Ref, Pid, snmp_misc:now(ms), undefined, N);
ns02_client_loop(Parent, Ref, Pid, Begin, End, N) ->
- %% p("loop(await message) -> [~w] entry when"
+ %% ?IPRINT("loop(await message) -> [~w] entry when"
%% "~n Ref: ~p"
%% "~n Pid: ~p"
%% "~n Begin: ~p"
%% "~n End: ~p", [N, Ref, Pid, Begin, End]),
receive
{snmpm_started, Pid} ->
- p("received expected started message (~w)", [N]),
+ ?IPRINT("received expected started message (~w)", [N]),
ns02_client_loop(Parent,
snmpm:monitor(), dummy,
Begin, End,
N);
{snmpm_start_timeout, Pid} ->
- p("unexpected timout"),
+ ?EPRINT("unexpected timeout"),
?FAIL({unexpected_start_timeout, Pid});
{'DOWN', Ref, process, Obj, Reason} ->
- p("received expected DOWN message (~w) with"
- "~n Obj: ~p"
- "~n Reason: ~p", [N, Obj, Reason]),
+ ?IPRINT("received expected DOWN message (~w) with"
+ "~n Obj: ~p"
+ "~n Reason: ~p", [N, Obj, Reason]),
ns02_client_loop(Parent,
dummy, snmpm:notify_started(?NS_TIMEOUT),
Begin, snmp_misc:now(ms),
@@ -1286,7 +1315,7 @@ ns02_ctrl_start(Opts, N) ->
ns02_ctrl(Opts, N) ->
put(tname, ns02_ctrl),
- p("starting"),
+ ?IPRINT("starting"),
ns02_ctrl_loop(Opts, N).
@@ -1296,36 +1325,36 @@ ns02_ctrl(Opts, N) ->
%% So, we try to monitor each start attempt. We allow 5 sec (just
%% to give slow boxes a chance).
ns02_ctrl_loop(_Opts, 0) ->
- p("done"),
+ ?IPRINT("done"),
exit(normal);
ns02_ctrl_loop(Opts, N) ->
- p("entry when N: ~p", [N]),
+ ?IPRINT("entry when N: ~p", [N]),
?SLEEP(2000),
- p("start manager"),
+ ?IPRINT("start manager"),
TS1 = erlang:system_time(millisecond),
{StarterPid, StarterMRef} =
erlang:spawn_monitor(fun() -> exit(snmpm:start(Opts)) end),
receive
{'DOWN', StarterMRef, process, StarterPid, ok} ->
TS2 = erlang:system_time(millisecond),
- p("manager started: ~w ms", [TS2-TS1]),
+ ?IPRINT("manager started: ~w ms", [TS2-TS1]),
ok
after 5000 ->
- p("manager (~p) start timeout - kill", [StarterPid]),
+ ?EPRINT("manager (~p) start timeout - kill", [StarterPid]),
exit(StarterPid, kill),
exit({skip, start_timeout})
end,
?SLEEP(2000),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?SLEEP(100), % Give the verbosity to take effect...
TS3 = erlang:system_time(millisecond),
case snmpm:stop(5000) of
ok ->
TS4 = erlang:system_time(millisecond),
- p("manager stopped: ~p ms", [TS4-TS3]),
+ ?IPRINT("manager stopped: ~p ms", [TS4-TS3]),
ok;
{error, timeout} ->
- p("manager stop timeout - kill (cleanup) and skip"),
+ ?EPRINT("manager stop timeout - kill (cleanup) and skip"),
exit(whereis(snmpm_supervisor), kill),
exit({skip, stop_timeout})
end,
@@ -1337,37 +1366,44 @@ ns02_ctrl_loop(Opts, N) ->
info(suite) -> [];
info(Config) when is_list(Config) ->
- ?TC_TRY(info,
- fun() -> do_info(Config) end).
-
-do_info(Config) ->
- p("starting with Config: ~n~p", [Config]),
-
- ConfDir = ?config(manager_conf_dir, Config),
- DbDir = ?config(manager_db_dir, Config),
-
- write_manager_conf(ConfDir),
-
- Opts = [{server, [{verbosity, trace}]},
- {net_if, [{verbosity, trace}]},
- {note_store, [{verbosity, trace}]},
- {config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
+ Pre = fun() ->
+ ConfDir = ?config(manager_conf_dir, Config),
+ DbDir = ?config(manager_db_dir, Config),
+
+ write_manager_conf(ConfDir),
+
+ Opts = [{server, [{verbosity, trace}]},
+ {net_if, [{verbosity, trace}]},
+ {note_store, [{verbosity, trace}]},
+ {config, [{verbosity, trace},
+ {dir, ConfDir},
+ {db_dir, DbDir}]}],
+ ?IPRINT("try starting manager"),
+ ok = snmpm:start(Opts),
+ ?SLEEP(1000),
+ ok
+ end,
+ Case = fun(_) -> do_info(Config) end,
+ Post = fun(_) ->
+ ?IPRINT("info verified, now try to stop"),
+ snmpm:stop(),
+ ?SLEEP(1000),
+ ok
+ end,
+ ?TC_TRY(info, Pre, Case, Post).
- p("try starting manager"),
- ok = snmpm:start(Opts),
- ?SLEEP(1000),
+do_info(Config) ->
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
- p("manager started, now get info"),
+ ?IPRINT("get info"),
Info = snmpm:info(),
- p("got info, now verify: ~n~p", [Info]),
+ ?IPRINT("got info, now verify: "
+ "~n ~p", [Info]),
ok = verify_info( Info ),
- p("info verified, now try to stop"),
- ok = snmpm:stop(),
-
- ?SLEEP(1000),
-
+ ?IPRINT("end"),
ok.
verify_info(Info) when is_list(Info) ->
@@ -1416,7 +1452,9 @@ register_user1(Config) when is_list(Config) ->
?TC_TRY(register_user1, Pre, Case, Post).
do_register_user1([ManagerNode], Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -1429,56 +1467,56 @@ do_register_user1([ManagerNode], Config) ->
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("load snmp application"),
+ ?IPRINT("load snmp application"),
?line ok = load_snmp(ManagerNode),
- p("set manager env for the snmp application"),
+ ?IPRINT("set manager env for the snmp application"),
?line ok = set_mgr_env(ManagerNode, Opts),
- p("starting snmp application (with only manager)"),
+ ?IPRINT("starting snmp application (with only manager)"),
?line ok = start_snmp(ManagerNode),
- p("started"),
+ ?IPRINT("started"),
?SLEEP(1000),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("try register user(s)"),
+ ?IPRINT("try register user(s)"),
?line ok = mgr_register_user(ManagerNode, calvin, snmpm_user_default,
[self(), "various misc info"]),
Users1 = mgr_which_users(ManagerNode),
- p("users: ~p~n", [Users1]),
+ ?IPRINT("users: ~p~n", [Users1]),
?line ok = verify_users(Users1, [calvin]),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
?line ok = mgr_register_user(ManagerNode, hobbe, snmpm_user_default,
{"misc info", self()}),
Users2 = mgr_which_users(ManagerNode),
- p("users: ~p~n", [Users2]),
+ ?IPRINT("users: ~p~n", [Users2]),
?line ok = verify_users(Users2, [calvin, hobbe]),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("try unregister user(s)"),
+ ?IPRINT("try unregister user(s)"),
?line ok = mgr_unregister_user(ManagerNode, calvin),
Users3 = mgr_which_users(ManagerNode),
- p("users: ~p~n", [Users3]),
+ ?IPRINT("users: ~p~n", [Users3]),
?line ok = verify_users(Users3, [hobbe]),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
?line ok = mgr_unregister_user(ManagerNode, hobbe),
Users4 = mgr_which_users(ManagerNode),
- p("users: ~p~n", [Users4]),
+ ?IPRINT("users: ~p~n", [Users4]),
?line ok = verify_users(Users4, []),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
?SLEEP(1000),
- p("stop snmp application (with only manager)"),
+ ?IPRINT("stop snmp application (with only manager)"),
?line ok = stop_snmp(ManagerNode),
?SLEEP(1000),
@@ -1514,7 +1552,9 @@ register_agent_old(Config) when is_list(Config) ->
?TC_TRY(register_agent_old, Pre, Case, Post).
do_register_agent_old([ManagerNode], Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -1527,100 +1567,105 @@ do_register_agent_old([ManagerNode], Config) ->
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("load snmp application"),
+ ?IPRINT("load snmp application"),
?line ok = load_snmp(ManagerNode),
- p("set manager env for the snmp application"),
+ ?IPRINT("set manager env for the snmp application"),
?line ok = set_mgr_env(ManagerNode, Opts),
- p("starting snmp application (with only manager)"),
+ ?IPRINT("starting snmp application (with only manager)"),
?line ok = start_snmp(ManagerNode),
- p("started"),
+ ?IPRINT("started"),
?SLEEP(1000),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("register user(s) user_alfa & user_beta"),
+ ?IPRINT("register user(s) user_alfa & user_beta"),
?line ok = mgr_register_user(ManagerNode, user_alfa, snmpm_user_default, []),
?line ok = mgr_register_user(ManagerNode, user_beta, snmpm_user_default, []),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("register agent(s)"),
+ ?IPRINT("register agent(s)"),
?line ok = mgr_register_agent(ManagerNode, user_alfa, 5000, []),
?line ok = mgr_register_agent(ManagerNode, user_alfa, 5001, []),
?line ok = mgr_register_agent(ManagerNode, user_beta, 5002, []),
?line ok = mgr_register_agent(ManagerNode, user_beta, 5003, []),
- p("verify all agent(s): expect 4"),
+ ?IPRINT("verify all agent(s): expect 4"),
case mgr_which_agents(ManagerNode) of
Agents1 when length(Agents1) =:= 4 ->
- p("all agents: ~p~n", [Agents1]),
+ ?IPRINT("all agents: ~p~n", [Agents1]),
ok;
Agents1 ->
?FAIL({agent_registration_failure, Agents1})
end,
- p("verify user_alfa agent(s)"),
+ ?IPRINT("verify user_alfa agent(s)"),
case mgr_which_agents(ManagerNode, user_alfa) of
Agents2 when length(Agents2) =:= 2 ->
- p("calvin agents: ~p~n", [Agents2]),
+ ?IPRINT("calvin agents: ~p", [Agents2]),
ok;
Agents2 ->
?FAIL({agent_registration_failure, Agents2})
end,
- p("verify user_beta agent(s)"),
+ ?IPRINT("verify user_beta agent(s)"),
case mgr_which_agents(ManagerNode, user_beta) of
Agents3 when length(Agents3) =:= 2 ->
- p("hobbe agents: ~p~n", [Agents3]),
+ ?IPRINT("hobbe agents: ~p", [Agents3]),
ok;
Agents3 ->
?FAIL({agent_registration_failure, Agents3})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(ManagerNode)]),
- p("unregister user user_alfa"),
+ ?IPRINT("unregister user user_alfa"),
?line ok = mgr_unregister_user(ManagerNode, user_alfa),
- p("verify all agent(s): expect 2"),
+ ?IPRINT("verify all agent(s): expect 2"),
case mgr_which_agents(ManagerNode) of
Agents4 when length(Agents4) =:= 2 ->
- p("all agents: ~p~n", [Agents4]),
+ ?IPRINT("all agents: ~p", [Agents4]),
ok;
Agents4 ->
?FAIL({agent_unregistration_failure, Agents4})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p~n", [mgr_info(ManagerNode)]),
- p("unregister user_beta agents"),
+ ?IPRINT("unregister user_beta agents"),
?line ok = mgr_unregister_agent(ManagerNode, user_beta, 5002),
?line ok = mgr_unregister_agent(ManagerNode, user_beta, 5003),
- p("verify all agent(s): expect 0"),
+ ?IPRINT("verify all agent(s): expect 0"),
case mgr_which_agents(ManagerNode) of
[] ->
ok;
Agents5 ->
- p("all agents: ~p~n", [Agents5]),
+ ?IPRINT("all agents: ~p~n", [Agents5]),
?FAIL({agent_unregistration_failure, Agents5})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(ManagerNode)]),
- p("unregister user hobbe"),
+ ?IPRINT("unregister user hobbe"),
?line ok = mgr_unregister_user(ManagerNode, user_beta),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(ManagerNode)]),
?SLEEP(1000),
- p("stop snmp application (with only manager)"),
+ ?IPRINT("stop snmp application (with only manager)"),
?line ok = stop_snmp(ManagerNode),
?SLEEP(1000),
+ ?IPRINT("end"),
ok.
@@ -1641,7 +1686,8 @@ register_agent2(Config) when is_list(Config) ->
?TC_TRY(register_agent2, Pre, Case, Post).
do_register_agent2([ManagerNode], Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
@@ -1654,27 +1700,27 @@ do_register_agent2([ManagerNode], Config) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("load snmp application"),
+ ?IPRINT("load snmp application"),
?line ok = load_snmp(ManagerNode),
- p("set manager env for the snmp application"),
+ ?IPRINT("set manager env for the snmp application"),
?line ok = set_mgr_env(ManagerNode, Opts),
- p("starting snmp application (with only manager)"),
+ ?IPRINT("starting snmp application (with only manager)"),
?line ok = start_snmp(ManagerNode),
- p("started"),
+ ?IPRINT("started"),
?SLEEP(1000),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("register user(s) user_alfa & user_beta"),
+ ?IPRINT("register user(s) user_alfa & user_beta"),
?line ok = mgr_register_user(ManagerNode, user_alfa, snmpm_user_default, []),
?line ok = mgr_register_user(ManagerNode, user_beta, snmpm_user_default, []),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("register agent(s)"),
+ ?IPRINT("register agent(s)"),
TargetName1 = "agent1",
?line ok = mgr_register_agent(ManagerNode, user_alfa, TargetName1,
[{address, LocalHost},
@@ -1696,71 +1742,71 @@ do_register_agent2([ManagerNode], Config) ->
{port, 5004},
{engine_id, "agentEngineId-4"}]),
- p("verify all agent(s): expect 4"),
+ ?IPRINT("verify all agent(s): expect 4"),
case mgr_which_agents(ManagerNode) of
Agents1 when length(Agents1) =:= 4 ->
- p("all agents: ~p~n", [Agents1]),
+ ?IPRINT("all agents: ~p~n", [Agents1]),
ok;
Agents1 ->
?FAIL({agent_registration_failure, Agents1})
end,
- p("verify user_alfa agent(s)"),
+ ?IPRINT("verify user_alfa agent(s)"),
case mgr_which_agents(ManagerNode, user_alfa) of
Agents2 when length(Agents2) =:= 2 ->
- p("calvin agents: ~p~n", [Agents2]),
+ ?IPRINT("calvin agents: ~p~n", [Agents2]),
ok;
Agents2 ->
?FAIL({agent_registration_failure, Agents2})
end,
- p("verify user_beta agent(s)"),
+ ?IPRINT("verify user_beta agent(s)"),
case mgr_which_agents(ManagerNode, user_beta) of
Agents3 when length(Agents3) =:= 2 ->
- p("hobbe agents: ~p~n", [Agents3]),
+ ?IPRINT("hobbe agents: ~p~n", [Agents3]),
ok;
Agents3 ->
?FAIL({agent_registration_failure, Agents3})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("unregister user user_alfa"),
+ ?IPRINT("unregister user user_alfa"),
?line ok = mgr_unregister_user(ManagerNode, user_alfa),
- p("verify all agent(s): expect 2"),
+ ?IPRINT("verify all agent(s): expect 2"),
case mgr_which_agents(ManagerNode) of
Agents4 when length(Agents4) =:= 2 ->
- p("all agents: ~p~n", [Agents4]),
+ ?IPRINT("all agents: ~p~n", [Agents4]),
ok;
Agents4 ->
?FAIL({agent_unregistration_failure, Agents4})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("unregister user_beta agents"),
+ ?IPRINT("unregister user_beta agents"),
?line ok = mgr_unregister_agent(ManagerNode, user_beta, TargetName3),
?line ok = mgr_unregister_agent(ManagerNode, user_beta, TargetName4),
- p("verify all agent(s): expect 0"),
+ ?IPRINT("verify all agent(s): expect 0"),
case mgr_which_agents(ManagerNode) of
[] ->
ok;
Agents5 ->
- p("all agents: ~p~n", [Agents5]),
+ ?IPRINT("all agents: ~p~n", [Agents5]),
?FAIL({agent_unregistration_failure, Agents5})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("unregister user user_beta"),
+ ?IPRINT("unregister user user_beta"),
?line ok = mgr_unregister_user(ManagerNode, user_beta),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
?SLEEP(1000),
- p("stop snmp application (with only manager)"),
+ ?IPRINT("stop snmp application (with only manager)"),
?line ok = stop_snmp(ManagerNode),
?SLEEP(1000),
@@ -1785,10 +1831,11 @@ register_agent3(Config) when is_list(Config) ->
?TC_TRY(register_agent3, Pre, Case, Post).
do_register_agent3([ManagerNode], Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
- ConfDir = ?config(manager_conf_dir, Config),
- DbDir = ?config(manager_db_dir, Config),
+ ConfDir = ?config(manager_conf_dir, Config),
+ DbDir = ?config(manager_db_dir, Config),
LocalHost = snmp_test_lib:localhost(),
@@ -1800,27 +1847,27 @@ do_register_agent3([ManagerNode], Config) ->
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("load snmp application"),
+ ?IPRINT("load snmp application"),
?line ok = load_snmp(ManagerNode),
- p("set manager env for the snmp application"),
+ ?IPRINT("set manager env for the snmp application"),
?line ok = set_mgr_env(ManagerNode, Opts),
- p("starting snmp application (with only manager)"),
+ ?IPRINT("starting snmp application (with only manager)"),
?line ok = start_snmp(ManagerNode),
- p("started"),
+ ?IPRINT("started"),
?SLEEP(1000),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("register user(s) user_alfa & user_beta"),
+ ?IPRINT("register user(s) user_alfa & user_beta"),
?line ok = mgr_register_user(ManagerNode, user_alfa, snmpm_user_default, []),
?line ok = mgr_register_user(ManagerNode, user_beta, snmpm_user_default, []),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("register agent(s)"),
+ ?IPRINT("register agent(s)"),
TargetName1 = "agent2",
?line ok = mgr_register_agent(ManagerNode, user_alfa, TargetName1,
[{tdomain, transportDomainUdpIpv4},
@@ -1840,7 +1887,7 @@ do_register_agent3([ManagerNode], Config) ->
{address, LocalHost},
{port, 5003},
{engine_id, "agentEngineId-3"}]),
- p("Expected registration failure: ~p", [Reason4]),
+ ?IPRINT("Expected registration failure: ~p", [Reason4]),
TargetName4 = "agent5",
?line {error, {unknown_domain, _} = Reason5} =
mgr_register_agent(ManagerNode, user_beta, TargetName4,
@@ -1848,69 +1895,69 @@ do_register_agent3([ManagerNode], Config) ->
{address, LocalHost},
{port, 5004},
{engine_id, "agentEngineId-4"}]),
- p("Expected registration failure: ~p", [Reason5]),
+ ?IPRINT("Expected registration failure: ~p", [Reason5]),
- p("verify all agent(s): expect 2"),
+ ?IPRINT("verify all agent(s): expect 2"),
case mgr_which_agents(ManagerNode) of
Agents1 when length(Agents1) =:= 2 ->
- p("all agents: ~p~n", [Agents1]),
+ ?IPRINT("all agents: ~p~n", [Agents1]),
ok;
Agents1 ->
?FAIL({agent_registration_failure, Agents1})
end,
- p("verify user_alfa agent(s)"),
+ ?IPRINT("verify user_alfa agent(s)"),
case mgr_which_agents(ManagerNode, user_alfa) of
Agents2 when length(Agents2) =:= 2 ->
- p("calvin agents: ~p~n", [Agents2]),
+ ?IPRINT("calvin agents: ~p~n", [Agents2]),
ok;
Agents2 ->
?FAIL({agent_registration_failure, Agents2})
end,
- p("verify user_beta agent(s)"),
+ ?IPRINT("verify user_beta agent(s)"),
case mgr_which_agents(ManagerNode, user_beta) of
Agents3 when length(Agents3) =:= 0 ->
- p("hobbe agents: ~p~n", [Agents3]),
+ ?IPRINT("hobbe agents: ~p~n", [Agents3]),
ok;
Agents3 ->
?FAIL({agent_registration_failure, Agents3})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("unregister user user_alfa"),
+ ?IPRINT("unregister user user_alfa"),
?line ok = mgr_unregister_user(ManagerNode, user_alfa),
- p("verify all agent(s): expect 0"),
+ ?IPRINT("verify all agent(s): expect 0"),
case mgr_which_agents(ManagerNode) of
Agents4 when length(Agents4) =:= 0 ->
- p("all agents: ~p~n", [Agents4]),
+ ?IPRINT("all agents: ~p~n", [Agents4]),
ok;
Agents4 ->
?FAIL({agent_unregistration_failure, Agents4})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("verify all agent(s): expect 0"),
+ ?IPRINT("verify all agent(s): expect 0"),
case mgr_which_agents(ManagerNode) of
[] ->
ok;
Agents5 ->
- p("all agents: ~p~n", [Agents5]),
+ ?EPRINT("all agents: ~p~n", [Agents5]),
?FAIL({agent_unregistration_failure, Agents5})
end,
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
- p("unregister user user_beta"),
+ ?IPRINT("unregister user user_beta"),
?line ok = mgr_unregister_user(ManagerNode, user_beta),
- p("manager info: ~p~n", [mgr_info(ManagerNode)]),
+ ?IPRINT("manager info: ~p~n", [mgr_info(ManagerNode)]),
?SLEEP(1000),
- p("stop snmp application (with only manager)"),
+ ?IPRINT("stop snmp application (with only manager)"),
?line ok = stop_snmp(ManagerNode),
?SLEEP(1000),
@@ -1928,7 +1975,8 @@ simple_sync_get2(Config) when is_list(Config) ->
fun() -> do_simple_sync_get2(Config) end).
do_simple_sync_get2(Config) ->
- p("starting with Config: ~n~p", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Get = fun(Node, TargetName, Oids) ->
mgr_user_sync_get(Node, TargetName, Oids)
end,
@@ -1938,16 +1986,17 @@ do_simple_sync_get2(Config) ->
Res.
do_simple_sync_get2(Config, Get, PostVerify) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Node = ?config(manager_node, Config),
TargetName = ?config(manager_agent_target_name, Config),
- p("issue get-request without loading the mib"),
+ ?IPRINT("issue get-request without loading the mib"),
Oids1 = [?sysObjectID_instance, ?sysDescr_instance, ?sysUpTime_instance],
?line ok = do_simple_sync_get2(Node, TargetName, Oids1, Get, PostVerify),
- p("issue get-request after first loading the mibs"),
+ ?IPRINT("issue get-request after first loading the mibs"),
?line ok = mgr_user_load_mib(Node, std_mib()),
Oids2 = [[sysObjectID, 0], [sysDescr, 0], [sysUpTime, 0]],
?line ok = do_simple_sync_get2(Node, TargetName, Oids2, Get, PostVerify),
@@ -1969,17 +2018,19 @@ do_simple_sync_get2(Node, TargetName, Oids, Get, PostVerify)
value = SysDescr},
#varbind{oid = ?sysUpTime_instance,
value = SysUpTime}]} ->
- p("expected result from get: "
- "~n SysObjectID: ~p"
- "~n SysDescr: ~s"
- "~n SysUpTime: ~w",
- [SysObjectID, SysDescr, SysUpTime]),
+ ?IPRINT("expected result from get: "
+ "~n SysObjectID: ~p"
+ "~n SysDescr: ~s"
+ "~n SysUpTime: ~w",
+ [SysObjectID, SysDescr, SysUpTime]),
PostVerify();
{noError, 0, Vbs} ->
- p("unexpected varbinds: ~n~p", [Vbs]),
+ ?EPRINT("unexpected varbinds: "
+ "~n ~p", [Vbs]),
{error, {unexpected_vbs, Vbs}};
Else ->
- p("unexpected reply: ~n~p", [Else]),
+ ?EPRINT("unexpected reply: "
+ "~n ~p", [Else]),
{error, {unexpected_response, Else}}
end,
ok.
@@ -1995,7 +2046,8 @@ simple_sync_get3(Config) when is_list(Config) ->
fun() -> do_simple_sync_get3(Config) end).
do_simple_sync_get3(Config) ->
- p("starting with Config: ~n~p", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Self = self(),
Msg = simple_sync_get3,
Fun = fun() -> Self ! Msg end,
@@ -2024,7 +2076,7 @@ do_simple_sync_get3(Config) ->
%%======================================================================
sag_verify({noError, 0, _Vbs}, any) ->
- p("verified [any]"),
+ ?IPRINT("verified [any]"),
ok;
sag_verify({noError, 0, Vbs}, Exp) ->
?DBG("verified first stage ok: "
@@ -2042,13 +2094,13 @@ sag_verify_vbs(Vbs, []) ->
sag_verify_vbs([], Exp) ->
{error, {expected_vbs, Exp}};
sag_verify_vbs([#varbind{oid = Oid}|Vbs], [any|Exp]) ->
- p("verified [any] oid ~w", [Oid]),
+ ?IPRINT("verified [any] oid ~w", [Oid]),
sag_verify_vbs(Vbs, Exp);
sag_verify_vbs([#varbind{oid = Oid, value = Value}|Vbs], [Oid|Exp]) ->
- p("verified oid ~w [~p]", [Oid, Value]),
+ ?IPRINT("verified oid ~w [~p]", [Oid, Value]),
sag_verify_vbs(Vbs, Exp);
sag_verify_vbs([#varbind{oid = Oid, value = Value}|Vbs], [{Oid,Value}|Exp]) ->
- p("verified oid ~w and ~p", [Oid, Value]),
+ ?IPRINT("verified oid ~w and ~p", [Oid, Value]),
sag_verify_vbs(Vbs, Exp);
sag_verify_vbs([Vb|_], [E|_]) ->
{error, {unexpected_vb, Vb, E}}.
@@ -2064,7 +2116,8 @@ simple_async_get2(Config) when is_list(Config) ->
fun() -> do_simple_async_get2(Config) end).
do_simple_async_get2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
TargetName = ?config(manager_agent_target_name, Config),
@@ -2123,13 +2176,17 @@ do_simple_async_sync_get2(MgrInfo, AgentInfo, Get, PostVerify)
end}
],
- p("manager info when starting test: ~n~p", [MgrInfo()]),
- p("agent info when starting test: ~n~p", [AgentInfo()]),
+ ?IPRINT("manager info when starting test: "
+ "~n ~p", [MgrInfo()]),
+ ?IPRINT("agent info when starting test: "
+ "~n ~p", [AgentInfo()]),
?line ok = async_exec(Requests, []),
- p("manager info when ending test: ~n~p", [MgrInfo()]),
- p("agent info when ending test: ~n~p", [AgentInfo()]),
+ ?IPRINT("manager info when ending test: "
+ "~n ~p", [MgrInfo()]),
+ ?IPRINT("agent info when ending test: "
+ "~n ~p", [AgentInfo()]),
ok.
@@ -2147,7 +2204,8 @@ simple_async_get3(Config) when is_list(Config) ->
fun() -> do_simple_async_get3(Config) end).
do_simple_async_get3(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
TargetName = ?config(manager_agent_target_name, Config),
@@ -2215,7 +2273,8 @@ simple_sync_get_next2(Config) when is_list(Config) ->
fun() -> do_simple_sync_get_next2(Config) end).
do_simple_sync_get_next2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
GetNext = fun(Node, TargetName, Oids) ->
mgr_user_sync_get_next(Node, TargetName, Oids)
@@ -2318,7 +2377,7 @@ do_simple_sync_get_next2(Config, GetNext, PostVerify)
do_simple_get_next(N, Node, TargetName, Oids, Verify, GetNext, PostVerify) ->
- p("issue get-next command ~w", [N]),
+ ?IPRINT("issue get-next command ~w", [N]),
case GetNext(Node, TargetName, Oids) of
{ok, Reply, _Rem} ->
?DBG("get-next ok:"
@@ -2340,7 +2399,8 @@ simple_sync_get_next3(suite) -> [];
simple_sync_get_next3(Config) when is_list(Config) ->
process_flag(trap_exit, true),
put(tname, ssgn3),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Self = self(),
Msg = simple_sync_get_next3,
Fun = fun() -> Self ! Msg end,
@@ -2370,7 +2430,8 @@ simple_async_get_next2(Config) when is_list(Config) ->
fun() -> do_simple_async_get_next2(Config) end).
do_simple_async_get_next2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -2457,13 +2518,17 @@ do_simple_async_get_next2(MgrNode, AgentNode, GetNext, PostVerify)
end}
],
- p("manager info when starting test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when starting test: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info when starting test: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info when starting test: "
+ "~n ~p", [agent_info(AgentNode)]),
?line ok = async_exec(Requests, []),
- p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info when ending test: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info when ending test: "
+ "~n ~p", [agent_info(AgentNode)]),
ok.
@@ -2501,7 +2566,8 @@ simple_async_get_next3(Case, Config) when is_list(Config) ->
do_simple_async_get_next3(Config) ->
%% process_flag(trap_exit, true),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -2559,7 +2625,8 @@ simple_sync_set2(Config) when is_list(Config) ->
fun() -> do_simple_sync_set2(Config) end).
do_simple_sync_set2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Set = fun(Node, TargetName, VAVs) ->
mgr_user_sync_set(Node, TargetName, VAVs)
@@ -2576,7 +2643,7 @@ do_simple_sync_set2(Config, Set, PostVerify)
Node = ?config(manager_node, Config),
TargetName = ?config(manager_agent_target_name, Config),
- p("issue set-request without loading the mib"),
+ ?IPRINT("issue set-request without loading the mib"),
Val11 = "Arne Anka",
Val12 = "Stockholm",
VAVs1 = [
@@ -2585,7 +2652,7 @@ do_simple_sync_set2(Config, Set, PostVerify)
],
?line ok = do_simple_set2(Node, TargetName, VAVs1, Set, PostVerify),
- p("issue set-request after first loading the mibs"),
+ ?IPRINT("issue set-request after first loading the mibs"),
?line ok = mgr_user_load_mib(Node, std_mib()),
Val21 = "Sune Anka",
Val22 = "Gothenburg",
@@ -2615,7 +2682,8 @@ do_simple_set2(Node, TargetName, VAVs, Set, PostVerify) ->
{noError, 0, Vbs} ->
{error, {unexpected_vbs, Vbs}};
Else ->
- p("unexpected reply: ~n~p", [Else]),
+ ?EPRINT("unexpected reply: "
+ "~n ~p", [Else]),
{error, {unexpected_response, Else}}
end,
ok.
@@ -2631,7 +2699,8 @@ simple_sync_set3(Config) when is_list(Config) ->
fun() -> do_simple_sync_set3(Config) end).
do_simple_sync_set3(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p", [Config]),
Self = self(),
Msg = simple_sync_set3,
@@ -2655,7 +2724,7 @@ do_simple_sync_set3(Config) ->
%%======================================================================
sas_verify({noError, 0, _Vbs}, any) ->
- p("verified [any]"),
+ ?IPRINT("verified [any]"),
ok;
sas_verify({noError, 0, Vbs}, Expected) ->
?DBG("verified stage 1: "
@@ -2672,13 +2741,13 @@ sas_verify_vbs(Vbs, []) ->
sas_verify_vbs([], Exp) ->
{error, {expected_vbs, Exp}};
sas_verify_vbs([#varbind{oid = Oid}|Vbs], [any|Exp]) ->
- p("verified [any] oid ~w", [Oid]),
+ ?IPRINT("verified [any] oid ~w", [Oid]),
sas_verify_vbs(Vbs, Exp);
sas_verify_vbs([#varbind{oid = Oid, value = Value}|Vbs], [Oid|Exp]) ->
- p("verified oid ~w [~p]", [Oid, Value]),
+ ?IPRINT("verified oid ~w [~p]", [Oid, Value]),
sas_verify_vbs(Vbs, Exp);
sas_verify_vbs([#varbind{oid = Oid, value = Value}|Vbs], [{Oid,Value}|Exp]) ->
- p("verified oid ~w and ~p", [Oid, Value]),
+ ?IPRINT("verified oid ~w and ~p", [Oid, Value]),
sas_verify_vbs(Vbs, Exp);
sas_verify_vbs([Vb|_], [E|_]) ->
{error, {unexpected_vb, Vb, E}}.
@@ -2694,7 +2763,9 @@ simple_async_set2(Config) when is_list(Config) ->
fun() -> do_simple_async_set2(Config) end).
do_simple_async_set2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -2744,13 +2815,17 @@ do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify) ->
end}
],
- p("manager info when starting test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when starting test: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info when starting test: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info when starting test: "
+ "~n ~p", [agent_info(AgentNode)]),
?line ok = async_exec(Requests, []),
- p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info when ending test: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info when ending test: "
+ "~n ~p", [agent_info(AgentNode)]),
ok.
@@ -2784,7 +2859,8 @@ simple_async_set3(Case, Config) ->
fun() -> do_simple_async_set3(Config) end).
do_simple_async_set3(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -2867,7 +2943,8 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
fun() -> do_simple_sync_get_bulk2(Config) end).
do_simple_sync_get_bulk2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -2982,7 +3059,7 @@ do_simple_sync_get_bulk2(Config, MgrNode, AgentNode, GetBulk, PostVerify) ->
%% -- 11 --
?line {ok, [TCnt2|_]} = mgr_user_name_to_oid(MgrNode, tCnt2),
- p("TCnt2: ~p", [TCnt2]),
+ ?IPRINT("TCnt2: ~p", [TCnt2]),
VF11 = fun(X) ->
verify_ssgb_reply2(X,
[{fl([TCnt2,2]), 100},
@@ -3001,7 +3078,7 @@ do_simple_get_bulk2(N,
when is_function(Verify, 1) andalso
is_function(GetBulk, 3) andalso
is_function(PostVerify) ->
- p("issue get-bulk command ~w", [N]),
+ ?IPRINT("issue get-bulk command ~w", [N]),
case GetBulk(NonRep, MaxRep, Oids) of
{ok, Reply, _Rem} ->
?DBG("get-bulk ok:"
@@ -3025,7 +3102,8 @@ simple_sync_get_bulk3(Config) when is_list(Config) ->
fun() -> do_simple_sync_get_bulk3(Config) end).
do_simple_sync_get_bulk3(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -3064,7 +3142,8 @@ simple_async_get_bulk2(Config) when is_list(Config) ->
fun() -> do_simple_async_get_bulk2(Config) end).
do_simple_async_get_bulk2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~p ~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -3196,13 +3275,17 @@ do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify) ->
VF10}
],
- p("manager info when starting test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when starting test: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info when starting test: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info when starting test: "
+ "~n ~p", [agent_info(AgentNode)]),
?line ok = async_exec(Requests, []),
- p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info when ending test: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info when ending test: "
+ "~n ~p", [agent_info(AgentNode)]),
ok.
@@ -3226,7 +3309,8 @@ simple_async_get_bulk3(Case, Config) ->
do_simple_async_get_bulk3(Config) ->
process_flag(trap_exit, true),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -3292,7 +3376,9 @@ misc_async2(Config) when is_list(Config) ->
fun() -> do_misc_async2(Config) end).
do_misc_async2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -3461,13 +3547,17 @@ do_misc_async2(Config) ->
end}
],
- p("manager info when starting test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when starting test: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info when starting test: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info when starting test: "
+ "~n ~p", [agent_info(AgentNode)]),
?line ok = async_exec(Requests, []),
- p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info when ending test: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info when ending test: "
+ "~n ~p", [agent_info(AgentNode)]),
display_log(Config),
ok.
@@ -3493,45 +3583,47 @@ collect_traps(0, TrapInfo) ->
collect_traps(N, Acc) ->
receive
{async_event, _From, {trap, TrapInfo}} ->
- p("collect_traps -> received trap: ~n ~p", [TrapInfo]),
+ ?IPRINT("collect_traps -> received trap: "
+ "~n ~p", [TrapInfo]),
collect_traps(N-1, [TrapInfo|Acc])
after 10000 ->
- p("collect_traps -> still awaiting ~w trap(s) - giving up", [N]),
+ ?WPRINT("collect_traps -> still awaiting ~w trap(s) - giving up", [N]),
Acc
end.
verify_traps([], []) ->
- p("verify_traps -> done"),
+ ?IPRINT("verify_traps -> done"),
ok;
verify_traps([], Verifiers) ->
- p("verify_traps -> done when ~w verifiers remain", [length(Verifiers)]),
+ ?IPRINT("verify_traps -> done when ~w verifiers remain", [length(Verifiers)]),
{error, {failed_verify, [Id || {Id, _} <- Verifiers]}};
verify_traps([Trap|Traps], Verifiers0) ->
- p("verify_traps -> entry"),
+ ?IPRINT("verify_traps -> entry"),
case verify_trap(Trap, Verifiers0) of
{ok, Id} ->
- p("verify_traps -> trap verified: ~p", [Id]),
+ ?IPRINT("verify_traps -> trap verified: ~p", [Id]),
Verifiers = lists:keydelete(Id, 1, Verifiers0),
verify_traps(Traps, Verifiers);
error ->
- p("verify_traps -> failed verifying trap: ~n ~p", [Trap]),
+ ?EPRINT("verify_traps -> failed verifying trap: "
+ "~n ~p", [Trap]),
{error, {failed_verifying_trap, Trap}}
end.
verify_trap(Trap, []) ->
- p("verify_trap -> could not verify trap:"
- "~n Trap: ~p", [Trap]),
+ ?EPRINT("verify_trap -> could not verify trap:"
+ "~n Trap: ~p", [Trap]),
error;
verify_trap(Trap, [{Id, Verifier}|Verifiers]) ->
- p("verify_trap -> entry with"
- "~n Id: ~p"
- "~n Trap: ~p", [Id, Trap]),
+ ?IPRINT("verify_trap -> entry with"
+ "~n Id: ~p"
+ "~n Trap: ~p", [Id, Trap]),
case Verifier(Trap) of
ok ->
- p("verify_trap -> verified"),
+ ?IPRINT("verify_trap -> verified"),
{ok, Id};
{error, _} ->
- p("verify_trap -> not verified"),
+ ?NPRINT("verify_trap -> not verified"),
verify_trap(Trap, Verifiers)
end.
@@ -3544,7 +3636,9 @@ trap1(Config) when is_list(Config) ->
fun() -> do_trap1(Config) end).
do_trap1(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -3565,32 +3659,33 @@ do_trap1(Config) ->
fun(Ent, Gen, Spec, ExpVBs, Trap) ->
case Trap of
{Ent, Gen, Spec, _Timestamp, VBs} ->
- p("trap info as expected"),
+ ?IPRINT("trap info as expected"),
case (catch validate_vbs(MgrNode,
ExpVBs, VBs)) of
ok ->
- p("valid trap"),
+ ?IPRINT("valid trap"),
ok;
Error ->
- p("invalid trap: ~n Error: ~p", [Error]),
+ ?EPRINT("invalid trap: "
+ "~n ~p", [Error]),
Error
end;
{Enteprise, Generic, Spec, Timestamp, VBs} ->
- p("unepxected v1 trap info:"
- "~n Enteprise: ~p"
- "~n Generic: ~p"
- "~n Spec: ~p"
- "~n Timestamp: ~p"
- "~n VBs: ~p",
- [Enteprise, Generic, Spec, Timestamp, VBs]),
+ ?EPRINT("unepxected v1 trap info:"
+ "~n Enteprise: ~p"
+ "~n Generic: ~p"
+ "~n Spec: ~p"
+ "~n Timestamp: ~p"
+ "~n VBs: ~p",
+ [Enteprise, Generic, Spec, Timestamp, VBs]),
ExpTrap = {Ent, Gen, Spec, ignore, ExpVBs},
Reason = {unexpected_trap, {ExpTrap, Trap}},
{error, Reason};
{Err, Idx, VBs} ->
- p("unexpected trap info: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected trap info: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -3601,24 +3696,25 @@ do_trap1(Config) ->
fun(ExpVBs, Trap) ->
case Trap of
{noError, 0, VBs0} ->
- p("trap info as expected: ~n~p", [VBs0]),
+ ?IPRINT("trap info as expected: "
+ "~n ~p", [VBs0]),
%% The first two are a timestamp and oid
[_,_|VBs] = VBs0,
case (catch validate_vbs(MgrNode,
ExpVBs, VBs)) of
ok ->
- p("valid trap"),
+ ?IPRINT("valid trap"),
ok;
Error ->
- p("invalid trap: ~n Error: ~p",
- [Error]),
+ ?EPRINT("invalid trap: "
+ "~n ~p", [Error]),
Error
end;
{Err, Idx, VBs} ->
- p("unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -3629,8 +3725,10 @@ do_trap1(Config) ->
%% Collect various info about the manager and the agent
Cmd1 =
fun() ->
- p("manager info: ~n~p", [mgr_info(MgrNode)]),
- p("agent info: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info: "
+ "~n ~p", [agent_info(AgentNode)]),
ok
end,
@@ -3699,7 +3797,9 @@ trap2(Config) when is_list(Config) ->
fun() -> do_trap2(Config) end).
do_trap2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -3720,32 +3820,32 @@ do_trap2(Config) ->
fun(Ent, Gen, Spec, ExpVBs, Trap) ->
case Trap of
{Ent, Gen, Spec, _Timestamp, VBs} ->
- p("trap info as expected"),
+ ?IPRINT("trap info as expected"),
case (catch validate_vbs(MgrNode,
ExpVBs, VBs)) of
ok ->
- p("valid trap"),
+ ?IPRINT("valid trap"),
ok;
Error ->
- p("invalid trap: ~n Error: ~p", [Error]),
+ ?EPRINT("invalid trap: ~n Error: ~p", [Error]),
Error
end;
{Enteprise, Generic, Spec, Timestamp, VBs} ->
- p("unepxected v1 trap info:"
- "~n Enteprise: ~p"
- "~n Generic: ~p"
- "~n Spec: ~p"
- "~n Timestamp: ~p"
- "~n VBs: ~p",
- [Enteprise, Generic, Spec, Timestamp, VBs]),
+ ?EPRINT("unepxected v1 trap info:"
+ "~n Enteprise: ~p"
+ "~n Generic: ~p"
+ "~n Spec: ~p"
+ "~n Timestamp: ~p"
+ "~n VBs: ~p",
+ [Enteprise, Generic, Spec, Timestamp, VBs]),
ExpTrap = {Ent, Gen, Spec, ignore, ExpVBs},
Reason = {unexpected_trap, {ExpTrap, Trap}},
{error, Reason};
{Err, Idx, VBs} ->
- p("unexpected trap info: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected trap info: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -3756,24 +3856,24 @@ do_trap2(Config) ->
fun(ExpVBs, Trap) ->
case Trap of
{noError, 0, VBs0} ->
- p("trap info as expected: ~n~p", [VBs0]),
+ ?IPRINT("trap info as expected: ~n~p", [VBs0]),
%% The first two are a timestamp and oid
[_,_|VBs] = VBs0,
case (catch validate_vbs(MgrNode,
ExpVBs, VBs)) of
ok ->
- p("valid trap"),
+ ?IPRINT("valid trap"),
ok;
Error ->
- p("invalid trap: ~n Error: ~p",
- [Error]),
+ ?EPRINT("invalid trap: "
+ "~n ~p", [Error]),
Error
end;
{Err, Idx, VBs} ->
- p("unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -3783,8 +3883,10 @@ do_trap2(Config) ->
%% Collect various info about the manager and the agent
Cmd1 =
fun() ->
- p("manager info: ~n~p", [mgr_info(MgrNode)]),
- p("agent info: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info: "
+ "~n ~p", [agent_info(AgentNode)]),
ok
end,
@@ -3894,7 +3996,9 @@ inform1(Config) when is_list(Config) ->
fun() -> do_inform1(Config) end).
do_inform1(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -3913,9 +4017,12 @@ do_inform1(Config) ->
Cmd1 =
fun() ->
- p("manager info: ~n~p", [mgr_info(MgrNode)]),
- p("manager system info: ~n~p", [mgr_sys_info(MgrNode)]),
- p("agent info: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("manager system info: "
+ "~n ~p", [mgr_sys_info(MgrNode)]),
+ ?IPRINT("agent info: "
+ "~n ~p", [agent_info(AgentNode)]),
ok
end,
@@ -3929,26 +4036,26 @@ do_inform1(Config) ->
fun() ->
receive
{async_event, From, {inform, Pid, Inform}} ->
- p("received inform"),
+ ?IPRINT("received inform"),
case Inform of
{noError, 0, VBs} when is_list(VBs) ->
case (catch validate_testTrapv22_vbs(MgrNode,
VBs)) of
ok ->
- p("valid inform"),
+ ?IPRINT("valid inform"),
Pid ! {handle_inform_no_response,
From},
ok;
Error ->
- p("invalid inform: ~n Error: ~p",
- [Error]),
+ ?EPRINT("invalid inform: "
+ "~n ~p", [Error]),
Error
end;
{Err, Idx, VBs} ->
- p("unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -3966,25 +4073,25 @@ do_inform1(Config) ->
fun() ->
receive
{async_event, From, {inform, Pid, Inform}} ->
- p("received inform"),
+ ?IPRINT("received inform"),
case Inform of
{noError, 0, VBs} when is_list(VBs) ->
case (catch validate_testTrapv22_vbs(MgrNode,
VBs)) of
ok ->
- p("valid inform"),
+ ?IPRINT("valid inform"),
Pid ! {handle_inform_response, From},
ok;
Error ->
- p("invalid inform: ~n Error: ~p",
- [Error]),
+ ?EPRINT("invalid inform: "
+ "~n ~p", [Error]),
Error
end;
{Err, Idx, VBs} ->
- p("unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -4023,7 +4130,9 @@ inform2(Config) when is_list(Config) ->
fun() -> do_inform2(Config) end).
do_inform2(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -4043,8 +4152,10 @@ do_inform2(Config) ->
Cmd1 =
fun() ->
- p("manager info: ~n~p", [mgr_info(MgrNode)]),
- p("agent info: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info: "
+ "~n ~p", [agent_info(AgentNode)]),
ok
end,
@@ -4062,7 +4173,7 @@ do_inform2(Config) ->
fun() ->
receive
{snmp_targets, inform2_tag1, Addrs} ->
- p("sent inform to ~p", [Addrs]),
+ ?IPRINT("sent inform to ~p", [Addrs]),
ok
after 10000 ->
receive
@@ -4078,26 +4189,26 @@ do_inform2(Config) ->
fun() ->
receive
{async_event, From, {inform, Pid, Inform}} ->
- p("received inform"),
+ ?IPRINT("received inform"),
case Inform of
{noError, 0, VBs} when is_list(VBs) ->
case (catch validate_testTrapv22_vbs(MgrNode,
VBs)) of
ok ->
- p("valid inform"),
+ ?IPRINT("valid inform"),
Pid ! {handle_inform_no_response,
From},
ok;
Error ->
- p("invalid inform: ~n Error: ~p",
- [Error]),
+ ?IPRINT("invalid inform: "
+ "~n ~p", [Error]),
Error
end;
{Err, Idx, VBs} ->
- p("unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -4115,25 +4226,25 @@ do_inform2(Config) ->
fun() ->
receive
{async_event, From, {inform, Pid, Inform}} ->
- p("received inform"),
+ ?IPRINT("received inform"),
case Inform of
{noError, 0, VBs} when is_list(VBs) ->
case (catch validate_testTrapv22_vbs(MgrNode,
VBs)) of
ok ->
- p("valid inform"),
+ ?IPRINT("valid inform"),
Pid ! {handle_inform_response, From},
ok;
Error ->
- p("invalid inform: ~n Error: ~p",
- [Error]),
+ ?EPRINT("invalid inform: "
+ "~n ~p", [Error]),
Error
end;
{Err, Idx, VBs} ->
- p("unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -4151,14 +4262,14 @@ do_inform2(Config) ->
fun() ->
receive
{snmp_notification, inform2_tag1, {got_response, Addr}} ->
- p("received expected \"got response\" notification "
- "from: "
- "~n ~p", [Addr]),
+ ?IPRINT("received expected \"got response\" notification "
+ "from: "
+ "~n ~p", [Addr]),
ok;
{snmp_notification, inform2_tag1, {no_response, Addr}} ->
- e("Received unexpected \"no response\" "
- "notification from: "
- "~n ~p", [Addr]),
+ ?EPRINT("Received unexpected \"no response\" "
+ "notification from: "
+ "~n ~p", [Addr]),
{error, no_response}
after 10000 ->
receive
@@ -4197,7 +4308,8 @@ inform3(Config) when is_list(Config) ->
fun() -> do_inform3(Config) end).
do_inform3(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -4215,8 +4327,10 @@ do_inform3(Config) ->
Cmd1 =
fun() ->
- p("manager info: ~n~p", [mgr_info(MgrNode)]),
- p("agent info: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info: "
+ "~n ~p", [agent_info(AgentNode)]),
ok
end,
@@ -4234,7 +4348,7 @@ do_inform3(Config) ->
fun() ->
receive
{snmp_targets, inform3_tag1, [_Addr]} ->
- p("received inform-sent acknowledgement", []),
+ ?IPRINT("received inform-sent ack"),
ok
after 10000 ->
receive
@@ -4250,26 +4364,25 @@ do_inform3(Config) ->
fun() ->
receive
{async_event, From, {inform, Pid, Inform}} ->
- p("received inform"),
+ ?IPRINT("received inform"),
case Inform of
{noError, 0, VBs} when is_list(VBs) ->
case (catch validate_testTrapv22_vbs(MgrNode,
VBs)) of
ok ->
- p("valid inform"),
- Pid ! {handle_inform_no_response,
- From},
+ ?IPRINT("valid inform"),
+ Pid ! {handle_inform_no_response, From},
ok;
Error ->
- p("invalid inform: ~n Error: ~p",
- [Error]),
+ ?EPRINT("invalid inform: "
+ "~n ~p", [Error]),
Error
end;
{Err, Idx, VBs} ->
- p("unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -4287,15 +4400,15 @@ do_inform3(Config) ->
fun() ->
receive
{snmp_notification, inform3_tag1, {no_response, Addr}} ->
- p("received expected \"no response\" notification "
- "from: "
- "~n ~p", [Addr]),
+ ?IPRINT("received expected \"no response\" notification "
+ "from: "
+ "~n ~p", [Addr]),
ok;
{snmp_notification, inform3_tag1, {got_response, Addr}} ->
- e("Received unexpected \"got response\" "
- "notification from: "
- "~n ~p",
- [Addr]),
+ ?EPRINT("Received unexpected \"got response\" "
+ "notification from: "
+ "~n ~p",
+ [Addr]),
{error, {got_response, Addr}}
after 120000 ->
receive
@@ -4335,7 +4448,8 @@ inform4(Config) when is_list(Config) ->
fun() -> do_inform4(Config) end).
do_inform4(Config) ->
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~n ~p~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -4353,8 +4467,10 @@ do_inform4(Config) ->
Cmd1 =
fun() ->
- p("manager info: ~n~p", [mgr_info(MgrNode)]),
- p("agent info: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info: "
+ "~n ~p", [agent_info(AgentNode)]),
ok
end,
@@ -4368,13 +4484,13 @@ do_inform4(Config) ->
fun() ->
receive
{async_event, From, {inform, Pid, Inform}} ->
- p("received inform"),
+ ?IPRINT("received inform"),
case Inform of
{noError, 0, VBs} when is_list(VBs) ->
case (catch validate_testTrapv22_vbs(MgrNode,
VBs)) of
ok ->
- p("valid inform"),
+ ?IPRINT("valid inform"),
%% Actually, as we have
%% configured the manager in
%% this test case (irb = auto)
@@ -4382,15 +4498,15 @@ do_inform4(Config) ->
Pid ! {handle_inform_response, From},
ok;
Error ->
- p("invalid inform: ~n Error: ~p",
- [Error]),
+ ?EPRINT("invalid inform: "
+ "~n ~p", [Error]),
Error
end;
{Err, Idx, VBs} ->
- p("unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end
@@ -4409,11 +4525,11 @@ do_inform4(Config) ->
%% fun() ->
%% receive
%% {async_event, _ReqId, {error, Reason}} ->
-%% p("received error"),
+%% ?IPRINT("received error"),
%% case Reason of
%% {failed_processing_message,
%% {securityError, usmStatsUnknownEngineIDs}} ->
-%% p("expected error"),
+%% ?IPRINT("expected error"),
%% ok;
%% _ ->
%% p("unexpected error: "
@@ -4469,7 +4585,8 @@ inform_swarm(Case, Config) ->
do_inform_swarm(Config) ->
%% process_flag(trap_exit, true),
- p("starting with Config: ~p~n", [Config]),
+ ?IPRINT("starting with Config: "
+ "~p ~n", [Config]),
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, Config),
@@ -4498,7 +4615,7 @@ do_inform_swarm(Config) ->
Seqs = lists:seq(1, NumInforms),
lists:foreach(
fun(N) ->
- p("send notification ~w", [N]),
+ ?IPRINT("send notification ~w", [N]),
agent_send_notif(AgentNode,
testTrapv22,
{{inform2_tag1, N}, Collector},
@@ -4509,11 +4626,11 @@ do_inform_swarm(Config) ->
if
N rem 100 == 0 ->
Sleep = 1000,
- p("sleep ~w [~w]", [Sleep, N]),
+ ?IPRINT("sleep ~w [~w]", [Sleep, N]),
?SLEEP(Sleep);
N rem 10 == 0 ->
Sleep = 100,
- p("sleep ~w [~w]", [Sleep, N]),
+ ?IPRINT("sleep ~w [~w]", [Sleep, N]),
?SLEEP(Sleep);
true ->
ok
@@ -4525,8 +4642,10 @@ do_inform_swarm(Config) ->
Cmd1 =
fun() ->
- p("manager info: ~n~p", [mgr_info(MgrNode)]),
- p("agent info: ~n~p", [agent_info(AgentNode)]),
+ ?IPRINT("manager info: "
+ "~n ~p", [mgr_info(MgrNode)]),
+ ?IPRINT("agent info: "
+ "~n ~p", [agent_info(AgentNode)]),
ok
end,
@@ -4555,7 +4674,7 @@ do_inform_swarm(Config) ->
inform_swarm_collector(N) ->
- inform_swarm_collector(N, 0, 0, 0, 10000).
+ inform_swarm_collector(N, 0, 0, 0, ?SECS(60)).
%% Note that we need to deal with re-transmissions!
%% That is, the agent did not receive the ack in time,
@@ -4571,60 +4690,65 @@ inform_swarm_collector(N, SentAckCnt, RecvCnt, RespCnt, _)
when ((N == SentAckCnt) and
(N == RespCnt) and
(N =< RecvCnt)) ->
- p("inform_swarm_collector -> done when"
- "~n N: ~w"
- "~n SentAckCnt: ~w"
- "~n RecvCnt: ~w"
- "~n RespCnt: ~w", [N, SentAckCnt, RecvCnt, RespCnt]),
+ ?IPRINT("inform_swarm_collector -> done when"
+ "~n N: ~w"
+ "~n SentAckCnt: ~w"
+ "~n RecvCnt: ~w"
+ "~n RespCnt: ~w", [N, SentAckCnt, RecvCnt, RespCnt]),
ok;
inform_swarm_collector(N, SentAckCnt, RecvCnt, RespCnt, Timeout) ->
- p("inform_swarm_collector -> entry with"
- "~n N: ~w"
- "~n SentAckCnt: ~w"
- "~n RecvCnt: ~w"
- "~n RespCnt: ~w", [N, SentAckCnt, RecvCnt, RespCnt]),
+ %% ?IPRINT("inform_swarm_collector -> entry with"
+ %% "~n N: ~w"
+ %% "~n SentAckCnt: ~w"
+ %% "~n RecvCnt: ~w"
+ %% "~n RespCnt: ~w", [N, SentAckCnt, RecvCnt, RespCnt]),
receive
{snmp_targets, {inform2_tag1, Id}, [_Addr]} ->
- p("received inform-sent acknowledgement for ~w", [Id]),
+ ?IPRINT("received inform-sent acknowledgement for ~w", [Id]),
inform_swarm_collector(N, SentAckCnt+1, RecvCnt, RespCnt,
Timeout);
%% The manager has received the actual inform
{async_event, From, {inform, Pid, Inform}} ->
- p("received inform"),
+ ?IPRINT("received inform"),
case Inform of
{noError, 0, VBs} when is_list(VBs) ->
Pid ! {handle_inform_response, From},
inform_swarm_collector(N, SentAckCnt, RecvCnt+1, RespCnt,
Timeout);
{Err, Idx, VBs} ->
- e("Unexpected error status: "
- "~n Err: ~p"
- "~n Idx: ~p"
- "~n VBs: ~p", [Err, Idx, VBs]),
+ ?EPRINT("Unexpected error status: "
+ "~n Err: ~p"
+ "~n Idx: ~p"
+ "~n VBs: ~p", [Err, Idx, VBs]),
Reason = {unexpected_status, {Err, Idx, VBs}},
{error, Reason}
end;
%% The agent has received ack from the manager
{snmp_notification, {inform2_tag1, Id}, {got_response, Addr}} ->
- p("received expected \"got response\" for ~w "
- "notification from: "
- "~n ~p",
- [Id, Addr]),
+ ?IPRINT("received expected \"got response\" for ~w "
+ "notification from: "
+ "~n ~p", [Id, Addr]),
inform_swarm_collector(N, SentAckCnt, RecvCnt, RespCnt+1,
Timeout);
%% The agent did not received ack from the manager in time
{snmp_notification, inform2_tag1, {no_response, Addr}} ->
- e("Received expected \"no response\" notification "
- "from: "
- "~n ~p", [Addr]),
+ ?EPRINT("Received expected \"no response\" notification "
+ "from: "
+ "~n ~p", [Addr]),
Reason = {no_response, Addr, {N, SentAckCnt, RecvCnt, RespCnt}},
{error, Reason}
after Timeout ->
%% Give up when we have been dead in the water for Timeout ms
+ ?EPRINT("timeout when"
+ "~n N: ~p"
+ "~n SentAckCnt: ~p"
+ "~n RecvCnt: ~p"
+ "~n RespCnt: ~p",
+ [N, SentAckCnt, RecvCnt, RespCnt]),
{error, {timeout, N, SentAckCnt, RecvCnt, RespCnt}}
end.
@@ -4642,48 +4766,54 @@ report(Config) when is_list(Config) ->
otp8015_1(doc) -> ["OTP-8015:1 - testing the new api-function."];
otp8015_1(suite) -> [];
otp8015_1(Config) when is_list(Config) ->
- ?TC_TRY(otp8015_1,
- fun() -> do_otp8015_1(Config) end).
+ Pre = fun() ->
+ ConfDir = ?config(manager_conf_dir, Config),
+ DbDir = ?config(manager_db_dir, Config),
+
+ write_manager_conf(ConfDir),
+
+ Opts = [{server, [{verbosity, trace}]},
+ {net_if, [{verbosity, trace}]},
+ {note_store, [{verbosity, trace}]},
+ {config, [{verbosity, trace},
+ {dir, ConfDir},
+ {db_dir, DbDir}]}],
+
+ ?IPRINT("starting manager"),
+ ok = snmpm:start_link(Opts),
+
+ ?SLEEP(1000),
+ ok
+ end,
+ Case = fun(_) -> do_otp8015_1(Config) end,
+ Post = fun(_) ->
+ ?IPRINT("stop manager"),
+ ok = snmpm:stop(),
+ ?SLEEP(1000),
+ ok
+ end,
+ ?TC_TRY(otp8015_1, Pre, Case, Post).
do_otp8015_1(Config) ->
- p("starting with Config: ~p~n", [Config]),
-
- ConfDir = ?config(manager_conf_dir, Config),
- DbDir = ?config(manager_db_dir, Config),
-
- write_manager_conf(ConfDir),
-
- Opts = [{server, [{verbosity, trace}]},
- {net_if, [{verbosity, trace}]},
- {note_store, [{verbosity, trace}]},
- {config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
-
- p("starting manager"),
- ok = snmpm:start_link(Opts),
-
- ?SLEEP(1000),
+ ?IPRINT("starting with Config: "
+ "~n ~p"
+ "~n", [Config]),
snmpm:load_mib(std_mib()),
snmpm:load_mib(test_trap_mib(Config)),
- p("manager started, now sleep some"),
+ ?IPRINT("manager started, now sleep some"),
?SLEEP(1000),
- p("loaded mibs: ~p", [snmpm:which_mibs()]),
+ ?IPRINT("loaded mibs: ~p", [snmpm:which_mibs()]),
- p("get some type(s) from the mibs"),
+ ?IPRINT("get some type(s) from the mibs"),
{ok, 'Counter32'} = snmpm:oid_to_type(?snmpOutTraps),
- {ok, [IfIndex]} = snmpm:name_to_oid(ifIndex),
- {ok, 'INTEGER'} = snmpm:oid_to_type(IfIndex),
+ {ok, [IfIndex]} = snmpm:name_to_oid(ifIndex),
+ {ok, 'INTEGER'} = snmpm:oid_to_type(IfIndex),
-
- p("stop manager"),
- ok = snmpm:stop(),
-
- ?SLEEP(1000),
-
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -4704,27 +4834,30 @@ do_otp8395_1(Config) ->
%%======================================================================
async_exec([], Acc) ->
- p("all async request's sent => now await reponses"),
+ ?IPRINT("all async request's sent => now await responses"),
async_verify(async_collector(Acc, []));
async_exec([{Id, Data, Exec, Ver}|Reqs], Acc) ->
- p("issue async request ~w", [Id]),
+ ?IPRINT("issue async request ~w", [Id]),
?line {ok, ReqId} = Exec(Data),
async_exec(Reqs, [{ReqId, Id, Ver}|Acc]).
async_collector([], Acc) ->
- p("received replies for all requests - now sort"),
+ ?IPRINT("received replies for all requests - now sort"),
lists:keysort(1, Acc);
async_collector(Expected, Acc) ->
receive
{async_event, ReqId, Reply} ->
- p("received async event with request-id ~w", [ReqId]),
+ ?IPRINT("received async event with request-id ~w", [ReqId]),
case lists:keysearch(ReqId, 1, Expected) of
{value, {_, Id, Ver}} ->
- p("event was for request ~w", [Id]),
+ ?IPRINT("event was for request ~w", [Id]),
Expected2 = lists:keydelete(ReqId, 1, Expected),
async_collector(Expected2, [{Id, Ver, Reply}|Acc]);
false ->
% Duplicate reply?
+ ?EPRINT("unexpected async event: "
+ "~n ReqId: ~p"
+ "~n Reply: ~p", [ReqId, Reply]),
?FAIL({unexpected_async_event, ReqId, Reply})
end
after 10000 ->
@@ -4734,7 +4867,7 @@ async_collector(Expected, Acc) ->
async_verify([]) ->
ok;
async_verify([{Id, Verify, Reply}|Replies]) ->
- p("verify reply ~w", [Id]),
+ ?IPRINT("verify reply ~w", [Id]),
Verify(Reply),
async_verify(Replies).
@@ -4791,17 +4924,19 @@ purify_oid(Node, Oid) ->
command_handler([]) ->
ok;
command_handler([{No, Desc, Cmd}|Cmds]) ->
- p("command_handler -> command ~w: "
- "~n ~s", [No, Desc]),
+ ?IPRINT("command_handler -> command ~w: "
+ "~n ~s", [No, Desc]),
case (catch Cmd()) of
ok ->
- p("command_handler -> ~w: ok",[No]),
+ ?IPRINT("command_handler -> ~w: ok", [No]),
command_handler(Cmds);
{error, Reason} ->
- e("Command_handler -> ~w error: ~n~p",[No, Reason]),
+ ?EPRINT("Command_handler -> ~w error: "
+ "~n ~p", [No, Reason]),
?line ?FAIL({command_failed, No, Reason});
Error ->
- e("Command_handler -> ~w unexpected: ~n~p",[No, Error]),
+ ?EPRINT("Command_handler -> ~w unexpected: "
+ "~n ~p", [No, Error]),
?line ?FAIL({unexpected_command_result, No, Error})
end.
@@ -4810,9 +4945,9 @@ command_handler([{No, Desc, Cmd}|Cmds]) ->
init_manager(AutoInform, Config) ->
- ?LOG("init_manager -> entry with"
- "~n AutoInform: ~p"
- "~n Config: ~p", [AutoInform, Config]),
+ ?IPRINT("init_manager -> entry with"
+ "~n AutoInform: ~p"
+ "~n Config: ~p", [AutoInform, Config]),
%% --
%% Start node
@@ -4853,10 +4988,10 @@ init_manager(AutoInform, Config) ->
end
catch
C:E:S ->
- p("Failure during manager start: "
- "~n Error Class: ~p"
- "~n Error: ~p"
- "~n StackTrace: ~p", [C, E, S]),
+ ?EPRINT("Failure during manager start: "
+ "~n Error Class: ~p"
+ "~n Error: ~p"
+ "~n StackTrace: ~p", [C, E, S]),
%% And now, *try* to cleanup
(catch stop_node(Node)),
?FAIL({failed_starting_manager, C, E, S})
@@ -4867,19 +5002,19 @@ fin_manager(Config) ->
StopMgrRes = stop_manager(Node),
StopCryptoRes = fin_crypto(Node),
StopNode = stop_node(Node),
- p("fin_manager -> stop apps and (mgr node ~p) node results: "
- "~n SNMP Mgr: ~p"
- "~n Crypto: ~p"
- "~n Node: ~p",
- [Node, StopMgrRes, StopCryptoRes, StopNode]),
+ ?IPRINT("fin_manager -> stop apps and (mgr node ~p) node results: "
+ "~n SNMP Mgr: ~p"
+ "~n Crypto: ~p"
+ "~n Node: ~p",
+ [Node, StopMgrRes, StopCryptoRes, StopNode]),
Config.
%% -- Misc agent functions --
init_agent(Config) ->
- ?LOG("init_agent -> entry with"
- "~n Config: ~p", [Config]),
+ ?IPRINT("init_agent -> entry with"
+ "~n Config: ~p", [Config]),
%% --
%% Retrieve some dir's
@@ -4934,10 +5069,10 @@ init_agent(Config) ->
end
catch
C:E:S ->
- p("Failure during agent start: "
- "~n Error Class: ~p"
- "~n Error: ~p"
- "~n StackTrace: ~p", [C, E, S]),
+ ?EPRINT("Failure during agent start: "
+ "~n Error Class: ~p"
+ "~n Error: ~p"
+ "~n StackTrace: ~p", [C, E, S]),
%% And now, *try* to cleanup
(catch stop_node(Node)),
?FAIL({failed_starting_agent, C, E, S})
@@ -4945,17 +5080,17 @@ init_agent(Config) ->
fin_agent(Config) ->
- Node = ?config(agent_node, Config),
+ Node = ?config(agent_node, Config),
StopAgentRes = stop_agent(Node),
StopCryptoRes = fin_crypto(Node),
StopMnesiaRes = fin_mnesia(Node),
StopNode = stop_node(Node),
- p("fin_agent -> stop apps and (agent node ~p) node results: "
- "~n SNMP Agent: ~p"
- "~n Crypto: ~p"
- "~n Mnesia: ~p"
- "~n Node: ~p",
- [Node, StopAgentRes, StopCryptoRes, StopMnesiaRes, StopNode]),
+ ?IPRINT("fin_agent -> stop apps and (agent node ~p) node results: "
+ "~n SNMP Agent: ~p"
+ "~n Crypto: ~p"
+ "~n Mnesia: ~p"
+ "~n Node: ~p",
+ [Node, StopAgentRes, StopCryptoRes, StopMnesiaRes, StopNode]),
Config.
init_mnesia(Node, Dir, MnesiaDebug)
@@ -5021,8 +5156,8 @@ load_app(Node, App) ->
({error, {already_loaded, LoadedApp}}) when (LoadedApp =:= App) ->
ok;
({error, Reason}) ->
- p("failed loading app ~w on ~p: "
- "~n ~p", [App, Node, Reason]),
+ ?EPRINT("failed loading app ~w on ~p: "
+ "~n ~p", [App, Node, Reason]),
?FAIL({failed_load, Node, App, Reason})
end,
do_load_app(Node, App, VerifySuccess).
@@ -5042,8 +5177,8 @@ start_app(Node, App) ->
({error, {already_started, LoadedApp}}) when (LoadedApp =:= App) ->
ok;
({error, Reason}) ->
- p("failed starting app ~w on ~p: "
- "~n ~p", [App, Node, Reason]),
+ ?EPRINT("failed starting app ~w on ~p: "
+ "~n ~p", [App, Node, Reason]),
?FAIL({failed_start, Node, App, Reason})
end,
start_app(Node, App, VerifySuccess).
@@ -5061,8 +5196,8 @@ stop_app(Node, App) ->
({error, {not_started, LoadedApp}}) when (LoadedApp =:= App) ->
ok;
({error, Reason}) ->
- p("failed stopping app ~w on ~p: "
- "~n ~p", [App, Node, Reason]),
+ ?EPRINT("failed stopping app ~w on ~p: "
+ "~n ~p", [App, Node, Reason]),
?FAIL({failed_stop, Node, App, Reason})
end,
stop_app(Node, App, VerifySuccess).
@@ -5078,11 +5213,11 @@ set_app_env(Node, App, Key, Val) ->
VerifySuccess = fun(ok) ->
ok;
({error, Reason}) ->
- p("failed setting app ~w env on ~p"
- "~n Key: ~p"
- "~n Val: ~p"
- "~n Reason: ~p"
- "~n ~p", [App, Node, Key, Val, Reason]),
+ ?EPRINT("failed setting app ~w env on ~p"
+ "~n Key: ~p"
+ "~n Val: ~p"
+ "~n Reason: ~p",
+ [App, Node, Key, Val, Reason]),
?FAIL({failed_set_app_env,
Node, App, Key, Val, Reason})
end,
@@ -5637,7 +5772,7 @@ start_node(Name, Retry) ->
global:sync(),
Node;
{error, timeout} ->
- e("Failed starting node ~p: timeout", [Name]),
+ ?EPRINT("Failed starting node ~p: timeout", [Name]),
?line ?FAIL({error_starting_node, Name, timeout});
{error, {already_running, Node}} when (Retry =:= true) ->
%% Ouch
@@ -5646,24 +5781,24 @@ start_node(Name, Retry) ->
%% timeout) but actually succeeded. Regardless, we don't know
%% the state of this node, so (try) stop it and then (re-) try
%% start again.
- e("Failed starting node ~p: Already Running - try stop", [Node]),
+ ?WPRINT("Failed starting node ~p: Already Running - try stop", [Node]),
case ?STOP_NODE(Node) of
true ->
- p("Successfully stopped old node ~p", [Node]),
+ ?IPRINT("Successfully stopped old node ~p", [Node]),
start_node(Name, false);
false ->
- e("Failed stop old node ~p", [Node]),
+ ?EPRINT("Failed stop old node ~p", [Node]),
?line ?FAIL({error_starting_node, Node, Retry, already_running})
end;
{error, {already_running, Node}} ->
- e("Failed starting node ~p: Already Running", [Node]),
+ ?EPRINT("Failed starting node ~p: Already Running", [Node]),
?line ?FAIL({error_starting_node, Node, Retry, already_running});
{error, Reason} ->
- e("Failed starting node ~p: ~p", [Name, Reason]),
+ ?EPRINT("Failed starting node ~p: ~p", [Name, Reason]),
?line ?FAIL({error_starting_node, Name, Reason})
catch
exit:{suite_failed, Reason} ->
- e("(suite) Failed starting node ~p: ~p", [Name, Reason]),
+ ?EPRINT("(suite) Failed starting node ~p: ~p", [Name, Reason]),
?line ?FAIL({failed_starting_node, Name, Reason})
end.
@@ -5842,24 +5977,24 @@ display_log(Config) ->
LogDir = Dir,
Mibs = [],
OutFile = j(LogDir, "snmpm_log.txt"),
- p("~n"
- "========================="
- " < Audit Trail Log > "
- "========================="
- "~n"),
+ ?IPRINT("~n"
+ "========================="
+ " < Audit Trail Log > "
+ "========================="
+ "~n"),
rcall(Node, snmpm, log_to_txt, [LogDir, Mibs, OutFile]),
rcall(Node, snmpm, log_to_io, [LogDir, Mibs]),
- p("~n"
- "========================="
- " < / Audit Trail Log > "
- "========================="
- "~n");
+ ?IPRINT("~n"
+ "========================="
+ " < / Audit Trail Log > "
+ "========================="
+ "~n");
false ->
- p("display_log -> no manager node found"),
+ ?IPRINT("display_log -> no manager node found"),
ok
end;
false ->
- p("display_log -> no manager log dir found"),
+ ?IPRINT("display_log -> no manager log dir found"),
ok
end.
@@ -5910,35 +6045,5 @@ rcall(Node, Mod, Func, Args) ->
%% ------
-%% Time in milli sec
-%% t() ->
-%% {A,B,C} = os:timestamp(),
-%% A*1000000000+B*1000+(C div 1000).
-
-
-%% ------
-
-e(F, A) ->
- p("<ERROR> " ++ F, A).
-
-p(F) ->
- p(F, []).
-
-p(F, A) ->
- p(get(tname), F, A).
-
-p(undefined, F, A) ->
- io:format("*** [~s] ***"
- "~n " ++ F ++ "~n", [formated_timestamp()|A]);
-p(TName, F, A) ->
- io:format("*** [~s][~w] ***"
- "~n " ++ F ++ "~n", [formated_timestamp(),TName|A]).
-
-formated_timestamp() ->
- snmp_test_lib:formated_timestamp().
-
-%% p(TName, F, A) ->
-%% io:format("~w -> " ++ F ++ "~n", [TName|A]).
-
ipv6_init(Config) when is_list(Config) ->
[{ipfamily, inet6} | Config].
diff --git a/lib/snmp/test/snmp_manager_config_SUITE.erl b/lib/snmp/test/snmp_manager_config_SUITE.erl
index b5c1894294..7724392491 100644
--- a/lib/snmp/test/snmp_manager_config_SUITE.erl
+++ b/lib/snmp/test/snmp_manager_config_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2004-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.
@@ -29,6 +29,7 @@
%%----------------------------------------------------------------------
-module(snmp_manager_config_SUITE).
+
%%----------------------------------------------------------------------
%% Include files
%%----------------------------------------------------------------------
@@ -97,6 +98,7 @@
]).
+
%%----------------------------------------------------------------------
%% Internal exports
%%----------------------------------------------------------------------
@@ -219,24 +221,40 @@ otp_8395_cases() ->
otp_8395_4
].
+
init_per_suite(Config0) when is_list(Config0) ->
- ?DBG("init_per_suite -> entry with"
- "~n Config0: ~p", [Config0]),
+ ?IPRINT("init_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
- Config1 = snmp_test_lib:init_suite_top_dir(?MODULE, Config0),
+ case ?LIB:init_per_suite(Config0) of
+ {skip, _} = SKIP ->
+ SKIP;
- ?DBG("init_per_suite -> done when"
- "~n Config1: ~p", [Config1]),
+ Config1 ->
- Config1.
+ Config2 = snmp_test_lib:init_suite_top_dir(?MODULE, Config1),
-end_per_suite(Config) when is_list(Config) ->
+ %% We need one on this node also
+ snmp_test_sys_monitor:start(),
- ?DBG("end_per_suite -> entry with"
- "~n Config: ~p", [Config]),
+ ?IPRINT("init_per_suite -> end when"
+ "~n Config: ~p", [Config2]),
- Config.
+ Config2
+ end.
+
+end_per_suite(Config0) when is_list(Config0) ->
+
+ ?IPRINT("end_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
+
+ snmp_test_sys_monitor:stop(),
+ Config1 = ?LIB:end_per_suite(Config0),
+
+ ?IPRINT("end_per_suite -> end"),
+
+ Config1.
init_per_group(_GroupName, Config) ->
@@ -247,11 +265,16 @@ end_per_group(_GroupName, Config) ->
init_per_testcase(Case, Config) when is_list(Config) ->
- p("init_per_testcase -> Case: ~p", [Case]),
+ ?IPRINT("init_per_testcase -> entry with"
+ "~n Config: ~p", [Config]),
+
+ snmp_test_global_sys_monitor:reset_events(),
+
SuiteTopDir = ?config(snmp_suite_top_dir, Config),
CaseTopDir = filename:join(SuiteTopDir, atom_to_list(Case)),
?line ok = file:make_dir(CaseTopDir),
- p("init_per_testcase -> CaseTopDir: ~p", [CaseTopDir]),
+
+ ?IPRINT("init_per_testcase -> CaseTopDir: ~p", [CaseTopDir]),
MgrTopDir = filename:join(CaseTopDir, "manager/"),
?line ok = file:make_dir(MgrTopDir),
MgrConfDir = filename:join(MgrTopDir, "conf/"),
@@ -265,15 +288,26 @@ init_per_testcase(Case, Config) when is_list(Config) ->
end,
MgrLogDir = filename:join(MgrTopDir, "log/"),
?line ok = file:make_dir(MgrLogDir),
- [{case_top_dir, CaseTopDir},
- {manager_dir, MgrTopDir},
- {manager_conf_dir, MgrConfDir},
- {manager_db_dir, MgrDbDir},
- {manager_log_dir, MgrLogDir} | Config].
+ Config1 = [{case_top_dir, CaseTopDir},
+ {manager_dir, MgrTopDir},
+ {manager_conf_dir, MgrConfDir},
+ {manager_db_dir, MgrDbDir},
+ {manager_log_dir, MgrLogDir} | Config],
+
+ ?IPRINT("init_per_testcase -> done when"
+ "~n Config1: ~p", [Config1]),
+
+ Config1.
+
+
+end_per_testcase(_Case, Config) when is_list(Config) ->
+
+ ?IPRINT("end_per_testcase -> entry with"
+ "~n Config: ~p", [Config]),
+ ?IPRINT("system events during test: "
+ "~n ~p", [snmp_test_global_sys_monitor:events()]),
-end_per_testcase(Case, Config) when is_list(Config) ->
- p("end_per_testcase -> Case: ~p", [Case]),
%% The cleanup is removed due to some really discusting NFS behaviour...
%% Also, it can always be useful to retain "all the stuff" after
%% the test case in case of debugging...
@@ -293,8 +327,8 @@ simple_start_and_stop(doc) ->
"Start the snmp manager config process with the \n"
"minimum setof options (config dir).";
simple_start_and_stop(Conf) when is_list(Conf) ->
- put(tname,ssas),
- p("start"),
+ put(tname, "SIME-START_AND_STOP"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -319,9 +353,9 @@ start_without_mandatory_opts1(doc) ->
"Start the snmp manager config process with some of the \n"
"mandatory options missing.";
start_without_mandatory_opts1(Conf) when is_list(Conf) ->
- put(tname,swomo1),
- put(verbosity,trace),
- p("start"),
+ put(tname, "START-WO-MAND-OPTS-1"),
+ put(verbosity, trace),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -330,12 +364,12 @@ start_without_mandatory_opts1(Conf) when is_list(Conf) ->
%% config, but no dir:
- p("config option, but no dir"),
+ ?IPRINT("config option, but no dir"),
Opts = [{priority, normal},
{config, [{verbosity, trace}, {db_dir, DbDir}]}, {mibs, []}],
?line {error, {missing_mandatory,dir}} = config_start(Opts),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -348,9 +382,9 @@ start_without_mandatory_opts2(doc) ->
"Start the snmp manager config process with some of the \n"
"mandatory options missing.";
start_without_mandatory_opts2(Conf) when is_list(Conf) ->
- put(tname,swomo2),
+ put(tname, "START-WO-MAND-OPTS-2"),
put(verbosity,trace),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -358,13 +392,13 @@ start_without_mandatory_opts2(Conf) when is_list(Conf) ->
%% Second set of options (no config):
- p("no config option"),
+ ?IPRINT("no config option"),
Opts = [{priority, normal},
{mibs, []}],
?line {error, {missing_mandatory,config,[dir, db_dir]}} =
config_start(Opts),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -377,8 +411,9 @@ start_with_all_valid_opts(doc) ->
"Start the snmp manager config process with the \n"
"complete set of all the valid options.";
start_with_all_valid_opts(Conf) when is_list(Conf) ->
+ put(tname, "START-W-ALL-VALID-OPTS"),
put(tname,swavo),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -389,7 +424,7 @@ start_with_all_valid_opts(Conf) when is_list(Conf) ->
%% Third set of options (no versions):
- p("all options"),
+ ?IPRINT("all options"),
NetIfOpts = [{module, snmpm_net_if},
{verbosity, trace},
{options, [{recbuf, 30000},
@@ -418,7 +453,7 @@ start_with_all_valid_opts(Conf) when is_list(Conf) ->
?line {ok, _Pid} = config_start(Opts),
?line ok = config_stop(),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -431,8 +466,8 @@ start_with_unknown_opts(doc) ->
"Start the snmp manager config process when some of\n"
"the options are unknown.";
start_with_unknown_opts(Conf) when is_list(Conf) ->
- put(tname,swuo),
- p("start"),
+ put(tname, "START-W-UNKNOWN-OPTS"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -443,7 +478,7 @@ start_with_unknown_opts(Conf) when is_list(Conf) ->
%% Third set of options (no versions):
- p("all options"),
+ ?IPRINT("all options"),
NetIfOpts = [{module, snmpm_net_if},
{verbosity, trace},
{options, [{recbuf, 30000},
@@ -471,7 +506,10 @@ start_with_unknown_opts(Conf) when is_list(Conf) ->
{versions, Vsns}],
?line {ok, _Pid} = config_start(Opts),
- p("done"),
+ ?IPRINT("(config) started - now stop"),
+ ?line ok = config_stop(),
+
+ ?IPRINT("done"),
ok.
@@ -484,8 +522,8 @@ start_with_incorrect_opts(doc) ->
"Start the snmp manager config process when some of\n"
"the options has incorrect values.";
start_with_incorrect_opts(Conf) when is_list(Conf) ->
- put(tname,swio),
- p("start"),
+ put(tname, "START-W-INCORRECT-OPTS"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -496,135 +534,135 @@ start_with_incorrect_opts(Conf) when is_list(Conf) ->
ConfigOpts = [{verbosity,trace}, {dir, ConfDir}, {db_dir, DbDir}],
- p("net-if - incorrect module"),
+ ?IPRINT("net-if - incorrect module"),
NetIfOpts1 = [{module, snmpm_user}], %% Behaviour check will fail
Opts01 = [{config, ConfigOpts}, {versions, [v1]},
{net_if, NetIfOpts1}],
?line {error, Reason01} = config_start(Opts01),
- p("net-if (module) res: ~p", [Reason01]),
+ ?IPRINT("net-if (module) res: ~p", [Reason01]),
- p("net-if - incorrect verbosity"),
+ ?IPRINT("net-if - incorrect verbosity"),
NetIfOpts2 = [{verbosity, invalid_verbosity}],
Opts02 = [{config, ConfigOpts}, {versions, [v1]},
{net_if, NetIfOpts2}],
?line {error, Reason02} = config_start(Opts02),
- p("net-if (verbosity) res: ~p", [Reason02]),
+ ?IPRINT("net-if (verbosity) res: ~p", [Reason02]),
- p("net-if - incorrect options"),
+ ?IPRINT("net-if - incorrect options"),
NetIfOpts3 = [{options, invalid_options}],
Opts03 = [{config, ConfigOpts}, {versions, [v1]},
{net_if, NetIfOpts3}],
?line {error, Reason03} = config_start(Opts03),
- p("net-if (options) res: ~p", [Reason03]),
+ ?IPRINT("net-if (options) res: ~p", [Reason03]),
- p("server - incorrect timeout (1)"),
+ ?IPRINT("server - incorrect timeout (1)"),
ServerOpts1 = [{timeout, invalid_timeout}],
Opts08 = [{config, ConfigOpts}, {versions, [v1]},
{server, ServerOpts1}],
?line {error, Reason08} = config_start(Opts08),
- p("server (timeout) res: ~p", [Reason08]),
+ ?IPRINT("server (timeout) res: ~p", [Reason08]),
- p("server - incorrect timeout (2)"),
+ ?IPRINT("server - incorrect timeout (2)"),
ServerOpts2 = [{timeout, 0}],
Opts09 = [{config, ConfigOpts}, {versions, [v1]},
{server, ServerOpts2}],
?line {error, Reason09} = config_start(Opts09),
- p("server (timeout) res: ~p", [Reason09]),
+ ?IPRINT("server (timeout) res: ~p", [Reason09]),
- p("server - incorrect timeout (3)"),
+ ?IPRINT("server - incorrect timeout (3)"),
ServerOpts3 = [{timeout, -1000}],
Opts10 = [{config, ConfigOpts},
{versions, [v1]},
{server, ServerOpts3}],
?line {error, Reason10} = config_start(Opts10),
- p("server (timeout) res: ~p", [Reason10]),
+ ?IPRINT("server (timeout) res: ~p", [Reason10]),
- p("server - incorrect verbosity"),
+ ?IPRINT("server - incorrect verbosity"),
ServerOpts4 = [{verbosity, invalid_verbosity}],
Opts11 = [{config, ConfigOpts},
{versions, [v1]},
{server, ServerOpts4}],
?line {error, Reason11} = config_start(Opts11),
- p("server (verbosity) res: ~p", [Reason11]),
+ ?IPRINT("server (verbosity) res: ~p", [Reason11]),
- p("note-store - incorrect timeout (1)"),
+ ?IPRINT("note-store - incorrect timeout (1)"),
NoteStoreOpts1 = [{timeout, invalid_timeout}],
Opts12 = [{config, ConfigOpts},
{versions, [v1]},
{note_store, NoteStoreOpts1}],
?line {error, Reason12} = config_start(Opts12),
- p("note-store (timeout) res: ~p", [Reason12]),
+ ?IPRINT("note-store (timeout) res: ~p", [Reason12]),
- p("note-store - incorrect timeout (2)"),
+ ?IPRINT("note-store - incorrect timeout (2)"),
NoteStoreOpts2 = [{timeout, 0}],
Opts13 = [{config, ConfigOpts},
{versions, [v1]},
{note_store, NoteStoreOpts2}],
?line {error, Reason13} = config_start(Opts13),
- p("note-store (timeout) res: ~p", [Reason13]),
+ ?IPRINT("note-store (timeout) res: ~p", [Reason13]),
- p("note-store - incorrect timeout (3)"),
+ ?IPRINT("note-store - incorrect timeout (3)"),
NoteStoreOpts3 = [{timeout, -2000}],
Opts14 = [{config, ConfigOpts},
{versions, [v1]},
{note_store, NoteStoreOpts3}],
?line {error, Reason14} = config_start(Opts14),
- p("note-store (timeout) res: ~p", [Reason14]),
+ ?IPRINT("note-store (timeout) res: ~p", [Reason14]),
- p("note-store - incorrect verbosity"),
+ ?IPRINT("note-store - incorrect verbosity"),
NoteStoreOpts4 = [{timeout, 20000}, {verbosity, invalid_verbosity}],
Opts15 = [{config, ConfigOpts},
{versions, [v1]},
{note_store, NoteStoreOpts4}],
?line {error, Reason15} = config_start(Opts15),
- p("note-store (verbosity) res: ~p", [Reason15]),
+ ?IPRINT("note-store (verbosity) res: ~p", [Reason15]),
- p("config - incorrect dir (1)"),
+ ?IPRINT("config - incorrect dir (1)"),
ConfigOpts1 = [{dir, invalid_dir}],
Opts16 = [{config, ConfigOpts1},
{versions, [v1]}],
?line {error, Reason16} = config_start(Opts16),
- p("config (dir) res: ~p", [Reason16]),
+ ?IPRINT("config (dir) res: ~p", [Reason16]),
- p("config - incorrect dir (2)"),
+ ?IPRINT("config - incorrect dir (2)"),
ConfigOpts2 = [{dir, "/invalid/dir"}],
Opts17 = [{config, ConfigOpts2},
{versions, [v1]}],
?line {error, Reason17} = config_start(Opts17),
- p("config (dir) res: ~p", [Reason17]),
+ ?IPRINT("config (dir) res: ~p", [Reason17]),
- p("config - incorrect verbosity"),
+ ?IPRINT("config - incorrect verbosity"),
ConfigOpts3 = [{dir, ConfDir}, {verbosity, invalid_verbosity}],
Opts18 = [{config, ConfigOpts3},
{versions, [v1]}],
?line {error, Reason18} = config_start(Opts18),
- p("config (verbosity) res: ~p", [Reason18]),
+ ?IPRINT("config (verbosity) res: ~p", [Reason18]),
- p("mibs - incorrect mibs (1)"),
+ ?IPRINT("mibs - incorrect mibs (1)"),
Mibs1 = invalid_mibs,
Opts19 = [{config, ConfigOpts},
{versions, [v1]},
{mibs, Mibs1}],
?line {error, Reason19} = config_start(Opts19),
- p("mibs (mibs) res: ~p", [Reason19]),
+ ?IPRINT("mibs (mibs) res: ~p", [Reason19]),
- p("mibs - incorrect mibs (2)"),
+ ?IPRINT("mibs - incorrect mibs (2)"),
Mibs2 = [join(StdMibDir, "INVALID-MIB")],
Opts20 = [{config, ConfigOpts},
{versions, [v1]},
{mibs, Mibs2}],
?line {error, Reason20} = config_start(Opts20),
- p("mibs (mibs) res: ~p", [Reason20]),
+ ?IPRINT("mibs (mibs) res: ~p", [Reason20]),
- p("prio - incorrect prio"),
+ ?IPRINT("prio - incorrect prio"),
Prio1 = invalid_prio,
Opts21 = [{config, ConfigOpts},
{versions, [v1]},
{priority, Prio1}],
?line {error, Reason21} = config_start(Opts21),
- p("prio (prio) res: ~p", [Reason21]),
+ ?IPRINT("prio (prio) res: ~p", [Reason21]),
- p("atl - incorrect type"),
+ ?IPRINT("atl - incorrect type"),
ATL1 = [{type, invalid_type},
{dir, LogDir},
{size, {10,10240}},
@@ -633,9 +671,9 @@ start_with_incorrect_opts(Conf) when is_list(Conf) ->
{versions, [v1]},
{audit_trail_log, ATL1}],
?line {error, Reason22} = config_start(Opts22),
- p("atl (type) res: ~p", [Reason22]),
+ ?IPRINT("atl (type) res: ~p", [Reason22]),
- p("atl - incorrect dir (1)"),
+ ?IPRINT("atl - incorrect dir (1)"),
ATL2 = [{type, read_write},
{dir, invalid_dir},
{size, {10,10240}},
@@ -644,9 +682,9 @@ start_with_incorrect_opts(Conf) when is_list(Conf) ->
{versions, [v1]},
{audit_trail_log, ATL2}],
?line {error, Reason23} = config_start(Opts23),
- p("atl (dir) res: ~p", [Reason23]),
+ ?IPRINT("atl (dir) res: ~p", [Reason23]),
- p("atl - incorrect dir (2)"),
+ ?IPRINT("atl - incorrect dir (2)"),
ATL3 = [{type, read_write},
{dir, "/invalid/dir"},
{size, {10,10240}},
@@ -655,9 +693,9 @@ start_with_incorrect_opts(Conf) when is_list(Conf) ->
{versions, [v1]},
{audit_trail_log, ATL3}],
?line {error, Reason24} = config_start(Opts24),
- p("atl (dir) res: ~p", [Reason24]),
+ ?IPRINT("atl (dir) res: ~p", [Reason24]),
- p("atl - incorrect size (1)"),
+ ?IPRINT("atl - incorrect size (1)"),
ATL4 = [{type, read_write},
{dir, LogDir},
{size, invalid_size},
@@ -666,9 +704,9 @@ start_with_incorrect_opts(Conf) when is_list(Conf) ->
{versions, [v1]},
{audit_trail_log, ATL4}],
?line {error, Reason25} = config_start(Opts25),
- p("atl (size) res: ~p", [Reason25]),
+ ?IPRINT("atl (size) res: ~p", [Reason25]),
- p("atl - incorrect size (2)"),
+ ?IPRINT("atl - incorrect size (2)"),
ATL5 = [{type, read_write},
{dir, LogDir},
{size, {10,invalid_file_size}},
@@ -677,9 +715,9 @@ start_with_incorrect_opts(Conf) when is_list(Conf) ->
{versions, [v1]},
{audit_trail_log, ATL5}],
?line {error, Reason26} = config_start(Opts26),
- p("atl (size) res: ~p", [Reason26]),
+ ?IPRINT("atl (size) res: ~p", [Reason26]),
- p("atl - incorrect size (3)"),
+ ?IPRINT("atl - incorrect size (3)"),
ATL6 = [{type, read_write},
{dir, LogDir},
{size, {invalid_file_num,10240}},
@@ -688,9 +726,9 @@ start_with_incorrect_opts(Conf) when is_list(Conf) ->
{versions, [v1]},
{audit_trail_log, ATL6}],
?line {error, Reason27} = config_start(Opts27),
- p("atl (size) res: ~p", [Reason27]),
+ ?IPRINT("atl (size) res: ~p", [Reason27]),
- p("atl - incorrect repair"),
+ ?IPRINT("atl - incorrect repair"),
ATL7 = [{type, read_write},
{dir, LogDir},
{size, {10,10240}},
@@ -699,23 +737,23 @@ start_with_incorrect_opts(Conf) when is_list(Conf) ->
{versions, [v1]},
{audit_trail_log, ATL7}],
?line {error, Reason28} = config_start(Opts28),
- p("atl (repair) res: ~p", [Reason28]),
+ ?IPRINT("atl (repair) res: ~p", [Reason28]),
- p("version - incorrect versions (1)"),
+ ?IPRINT("version - incorrect versions (1)"),
Vsns1 = invalid_vsns,
Opts29 = [{config, ConfigOpts},
{versions, Vsns1}],
?line {error, Reason29} = config_start(Opts29),
- p("versions (versions) res: ~p", [Reason29]),
+ ?IPRINT("versions (versions) res: ~p", [Reason29]),
- p("version - incorrect versions (2)"),
+ ?IPRINT("version - incorrect versions (2)"),
Vsns2 = [v1,v2,v3,v9],
Opts30 = [{config, ConfigOpts},
{versions, Vsns2}],
?line {error, Reason30} = config_start(Opts30),
- p("versions (versions) res: ~p", [Reason30]),
+ ?IPRINT("versions (versions) res: ~p", [Reason30]),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -727,8 +765,8 @@ start_with_invalid_manager_conf_file1(suite) -> [];
start_with_invalid_manager_conf_file1(doc) ->
"Start with invalid manager config file (1).";
start_with_invalid_manager_conf_file1(Conf) when is_list(Conf) ->
- put(tname,swimcf),
- p("start"),
+ put(tname, "START-W-INV-MGR-CONF-FILE-1"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -737,142 +775,142 @@ start_with_invalid_manager_conf_file1(Conf) when is_list(Conf) ->
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
%% --
- p("write manager config file with invalid IP address (1)"),
+ ?IPRINT("write manager config file with invalid IP address (1)"),
write_manager_conf(ConfDir,
"arne-anka", "4001", "500", "\"bmkEngine\""),
?line {error, Reason11} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason11]),
+ ?IPRINT("start failed (as expected): ~p", [Reason11]),
?line {failed_reading, _, _, 1, {parse_error, _}} = Reason11,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid IP address (2)"),
+ ?IPRINT("write manager config file with invalid IP address (2)"),
write_manager_conf(ConfDir,
"arne_anka", "4001", "500", "\"bmkEngine\""),
?line {error, Reason12} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason12]),
+ ?IPRINT("start failed (as expected): ~p", [Reason12]),
?line {failed_check, _, _, 2, {bad_address, _}} = Reason12,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid IP address (3)"),
+ ?IPRINT("write manager config file with invalid IP address (3)"),
write_manager_conf(ConfDir,
"9999", "4001", "500", "\"bmkEngine\""),
?line {error, Reason13} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason13]),
+ ?IPRINT("start failed (as expected): ~p", [Reason13]),
?line {failed_check, _, _, 2, {bad_address, _}} = Reason13,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid port (2)"),
+ ?IPRINT("write manager config file with invalid port (2)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "kalle-anka", "500", "\"bmkEngine\""),
?line {error, Reason21} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason21]),
+ ?IPRINT("start failed (as expected): ~p", [Reason21]),
?line {failed_reading, _, _, 2, {parse_error, _}} = Reason21,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid port (1)"),
+ ?IPRINT("write manager config file with invalid port (1)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "-1", "500", "\"bmkEngine\""),
?line {error, Reason22} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason22]),
+ ?IPRINT("start failed (as expected): ~p", [Reason22]),
io:format("Reason22: ~p~n", [Reason22]),
?line {failed_check, _, _, 3, {bad_port, _}} = Reason22,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid port (3)"),
+ ?IPRINT("write manager config file with invalid port (3)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "\"kalle-anka\"", "500", "\"bmkEngine\""),
?line {error, Reason23} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason23]),
+ ?IPRINT("start failed (as expected): ~p", [Reason23]),
?line {failed_check, _, _, 3, {bad_port, _}} = Reason23,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid EngineID (1)"),
+ ?IPRINT("write manager config file with invalid EngineID (1)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "4001", "500", "bmkEngine"),
?line {error, Reason31} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason31]),
+ ?IPRINT("start failed (as expected): ~p", [Reason31]),
?line {failed_check, _, _, 5, {invalid_string, _}} = Reason31,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid EngineID (2)"),
+ ?IPRINT("write manager config file with invalid EngineID (2)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "4001", "500", "{1,2,3}"),
?line {error, Reason32} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason32]),
+ ?IPRINT("start failed (as expected): ~p", [Reason32]),
?line {failed_check, _, _, 5, {invalid_string, _}} = Reason32,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid EngineID (3)"),
+ ?IPRINT("write manager config file with invalid EngineID (3)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "4001", "500", "10101"),
?line {error, Reason33} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason33]),
+ ?IPRINT("start failed (as expected): ~p", [Reason33]),
?line {failed_check, _, _, 5, {invalid_string, _}} = Reason33,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid MMS (1)"),
+ ?IPRINT("write manager config file with invalid MMS (1)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "4001", "483", "\"bmkEngine\""),
?line {error, Reason41} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason41]),
+ ?IPRINT("start failed (as expected): ~p", [Reason41]),
?line {failed_check, _, _, 4, {invalid_integer, _}} = Reason41,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid MMS (2)"),
+ ?IPRINT("write manager config file with invalid MMS (2)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "4001", "-1", "\"bmkEngine\""),
?line {error, Reason42} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason42]),
+ ?IPRINT("start failed (as expected): ~p", [Reason42]),
?line {failed_check, _, _, 4, {invalid_integer, _}} = Reason42,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid MMS (3)"),
+ ?IPRINT("write manager config file with invalid MMS (3)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "4001", "\"kalle-anka\"", "\"bmkEngine\""),
?line {error, Reason43} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason43]),
+ ?IPRINT("start failed (as expected): ~p", [Reason43]),
?line {failed_check, _, _, 4, {invalid_integer, _}} = Reason43,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with invalid MMS (4)"),
+ ?IPRINT("write manager config file with invalid MMS (4)"),
write_manager_conf(ConfDir,
"[134,138,177,189]", "4001", "kalle_anka", "\"bmkEngine\""),
?line {error, Reason44} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason44]),
+ ?IPRINT("start failed (as expected): ~p", [Reason44]),
?line {failed_check, _, _, 4, {invalid_integer, _}} = Reason44,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with unknown option"),
+ ?IPRINT("write manager config file with unknown option"),
write_manager_conf(ConfDir,
"{kalle, anka}."),
?line {error, Reason51} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason51]),
+ ?IPRINT("start failed (as expected): ~p", [Reason51]),
?line {failed_check, _, _, 1, {unknown_config, _}} = Reason51,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write manager config file with unknown option"),
+ ?IPRINT("write manager config file with unknown option"),
write_manager_conf(ConfDir,
"kalle_anka."),
?line {error, Reason52} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason52]),
+ ?IPRINT("start failed (as expected): ~p", [Reason52]),
?line {failed_check, _, _, 1, {unknown_config, _}} = Reason52,
- await_config_not_running(),
+ config_ensure_not_running(),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -884,8 +922,8 @@ start_with_invalid_users_conf_file1(suite) -> [];
start_with_invalid_users_conf_file1(doc) ->
"Start with invalid users config file.";
start_with_invalid_users_conf_file1(Conf) when is_list(Conf) ->
- put(tname,swiucf),
- p("start"),
+ put(tname, "START-W-INV-USER-CONF-FILE-1"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -899,74 +937,74 @@ start_with_invalid_users_conf_file1(Conf) when is_list(Conf) ->
write_manager_conf(ConfDir),
%% --
- p("write users config file with invalid module (1)"),
+ ?IPRINT("write users config file with invalid module (1)"),
write_users_conf(ConfDir, [{"kalle", "kalle", "dummy"}]),
?line {error, Reason11} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason11]),
+ ?IPRINT("start failed (as expected): ~p", [Reason11]),
?line {failed_check, _, _, _, {bad_module, kalle}} = Reason11,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write users config file with invalid module (1)"),
+ ?IPRINT("write users config file with invalid module (1)"),
write_users_conf(ConfDir, [{"kalle", "snmpm", "dummy"}]),
?line {error, Reason12} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason12]),
+ ?IPRINT("start failed (as expected): ~p", [Reason12]),
?line {failed_check, _, _, _, {bad_module, _}} = Reason12,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write users config file with invalid module (2)"),
+ ?IPRINT("write users config file with invalid module (2)"),
write_users_conf(ConfDir, [{"kalle1", "10101", "dummy"}]),
?line {error, Reason13} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason13]),
+ ?IPRINT("start failed (as expected): ~p", [Reason13]),
?line {failed_check, _, _, _, {bad_module, _}} = Reason13,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write users config file with invalid user tuple (1)"),
+ ?IPRINT("write users config file with invalid user tuple (1)"),
write_users_conf2(ConfDir, "{kalle, snmpm_user_default}."),
?line {error, Reason21} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason21]),
+ ?IPRINT("start failed (as expected): ~p", [Reason21]),
?line {failed_check, _, _, _, {bad_user_config, _}} = Reason21,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write users config file with invalid user tuple (2)"),
+ ?IPRINT("write users config file with invalid user tuple (2)"),
write_users_conf2(ConfDir, "{kalle, snmpm_user_default, kalle, [], olle}."),
?line {error, Reason22} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason22]),
+ ?IPRINT("start failed (as expected): ~p", [Reason22]),
?line {failed_check, _, _, _, {bad_user_config, _}} = Reason22,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write users config file with invalid user tuple (3)"),
+ ?IPRINT("write users config file with invalid user tuple (3)"),
write_users_conf2(ConfDir, "snmpm_user_default."),
?line {error, Reason23} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason23]),
+ ?IPRINT("start failed (as expected): ~p", [Reason23]),
?line {failed_check, _, _, _, {bad_user_config, _}} = Reason23,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write users config file with invalid user tuple (4)"),
+ ?IPRINT("write users config file with invalid user tuple (4)"),
write_users_conf2(ConfDir, "[kalle, snmpm_user_default, kalle]."),
?line {error, Reason24} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason24]),
+ ?IPRINT("start failed (as expected): ~p", [Reason24]),
?line {failed_check, _, _, _, {bad_user_config, _}} = Reason24,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write users config file with invalid user agent default config (1)"),
+ ?IPRINT("write users config file with invalid user agent default config (1)"),
write_users_conf2(ConfDir, "{kalle, snmpm_user_default, kalle, olle}."),
?line {error, Reason31} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason31]),
+ ?IPRINT("start failed (as expected): ~p", [Reason31]),
?line {failed_check, _, _, _, {bad_default_agent_config, _}} = Reason31,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("write users config file with invalid user agent default config (2)"),
+ ?IPRINT("write users config file with invalid user agent default config (2)"),
write_users_conf2(ConfDir, "{kalle, snmpm_user_default, kalle, [olle]}."),
?line {error, Reason32} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason32]),
+ ?IPRINT("start failed (as expected): ~p", [Reason32]),
%% ?line {failed_check, _, _, _, {bad_default_agent_config, _}} = Reason32,
case Reason32 of
{failed_check, _, _, _, {bad_default_agent_config, _}} ->
@@ -974,9 +1012,9 @@ start_with_invalid_users_conf_file1(Conf) when is_list(Conf) ->
{A, B, C, D} ->
exit({bad_error, A, B, C, D})
end,
- await_config_not_running(),
+ config_ensure_not_running(),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -988,8 +1026,8 @@ start_with_invalid_agents_conf_file1(suite) -> [];
start_with_invalid_agents_conf_file1(doc) ->
"Start with invalid agents config file.";
start_with_invalid_agents_conf_file1(Conf) when is_list(Conf) ->
- put(tname, swiacf),
- p("start"),
+ put(tname, "START-W-INV-AGS-CONF-FILE-1"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -1009,375 +1047,391 @@ start_with_invalid_agents_conf_file1(Conf) when is_list(Conf) ->
"any", "\"initial\"", "noAuthNoPriv"},
%% --
- p("[test 11] write agents config file with invalid user (1)"),
+ ?IPRINT("[test 11] write agents config file with invalid user (1)"),
Agent11 = setelement(1, Agent0, "kalle-anka"),
write_agents_conf(ConfDir, [Agent11]),
case config_start(Opts) of
{error, Reason11} ->
- p("start failed (as expected): ~p", [Reason11]),
+ ?IPRINT("start failed (as expected): ~p", [Reason11]),
?line {failed_reading, _, _, _, {parse_error, _}} = Reason11,
- await_config_not_running();
+ config_ensure_not_running();
OK_11 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "11", OK_11}})
end,
%% --
- p("[test 21] write agents config file with invalid target name (1)"),
+ ?IPRINT("[test 21] write agents config file with invalid target name (1)"),
Agent21 = setelement(2, Agent0, "targ-hobbes"),
write_agents_conf(ConfDir, [Agent21]),
case config_start(Opts) of
{error, Reason21} ->
- p("start failed (as expected): ~p", [Reason21]),
+ ?IPRINT("start failed (as expected): ~p", [Reason21]),
?line {failed_reading, _, _, _, {parse_error, _}} = Reason21,
- await_config_not_running();
+ config_ensure_not_running();
OK_21 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "21", OK_21}})
end,
%% --
- p("[test 22] write agents config file with invalid target name (2)"),
+ ?IPRINT("[test 22] write agents config file with invalid target name (2)"),
Agent22 = setelement(2, Agent0, "targ_hobbes"),
write_agents_conf(ConfDir, [Agent22]),
case config_start(Opts) of
{error, Reason22} ->
- p("start failed (as expected): ~p", [Reason22]),
+ ?IPRINT("start failed (as expected): ~p", [Reason22]),
?line {failed_check, _, _, _, {invalid_string, _}} = Reason22,
- await_config_not_running();
+ config_ensure_not_running();
OK_22 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "22", OK_22}})
end,
%% --
- p("[test 23] write agents config file with invalid target name (3)"),
+ ?IPRINT("[test 23] write agents config file with invalid target name (3)"),
Agent23 = setelement(2, Agent0, "10101"),
write_agents_conf(ConfDir, [Agent23]),
case config_start(Opts) of
{error, Reason23} ->
- p("start failed (as expected): ~p", [Reason23]),
+ ?IPRINT("start failed (as expected): ~p", [Reason23]),
?line {failed_check, _, _, _, {invalid_string, _}} = Reason23,
- await_config_not_running();
+ config_ensure_not_running();
OK_23 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "23", OK_23}})
end,
%% --
- p("[test 31] write agents config file with invalid community (1)"),
+ ?IPRINT("[test 31] write agents config file with invalid community (1)"),
Agent31 = setelement(3, Agent0, "targ-hobbes"),
write_agents_conf(ConfDir, [Agent31]),
case config_start(Opts) of
{error, Reason31} ->
- p("start failed (as expected): ~p", [Reason31]),
+ ?IPRINT("start failed (as expected): ~p", [Reason31]),
?line {failed_reading, _, _, _, {parse_error, _}} = Reason31,
- await_config_not_running();
+ config_ensure_not_running();
OK_31 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "31", OK_31}})
end,
%% --
- p("[test 32] write agents config file with invalid community (2)"),
+ ?IPRINT("[test 32] write agents config file with invalid community (2)"),
Agent32 = setelement(3, Agent0, "targ_hobbes"),
write_agents_conf(ConfDir, [Agent32]),
case config_start(Opts) of
{error, Reason32} ->
- p("start failed (as expected): ~p", [Reason32]),
+ ?IPRINT("start failed (as expected): ~p", [Reason32]),
?line {failed_check, _, _, _, {invalid_string, _}} = Reason32,
- await_config_not_running();
+ config_ensure_not_running();
OK_32 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "32", OK_32}})
end,
%% --
- p("[test 33] write agents config file with invalid community (3)"),
+ ?IPRINT("[test 33] write agents config file with invalid community (3)"),
Agent33 = setelement(3, Agent0, "10101"),
write_agents_conf(ConfDir, [Agent33]),
case config_start(Opts) of
{error, Reason33} ->
- p("start failed (as expected): ~p", [Reason33]),
+ ?IPRINT("start failed (as expected): ~p", [Reason33]),
?line {failed_check, _, _, _, {invalid_string, _}} = Reason33,
- await_config_not_running();
+ config_ensure_not_running();
OK_33 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "33", OK_33}})
end,
%% --
- p("[test 51] write agents config file with invalid ip (1)"),
+ ?IPRINT("[test 51] write agents config file with invalid ip (1)"),
Agent51 = setelement(4, Agent0, "kalle_anka"),
write_agents_conf(ConfDir, [Agent51]),
case config_start(Opts) of
{error, Reason51} ->
- p("start failed (as expected): ~p", [Reason51]),
+ ?IPRINT("start failed (as expected): ~p", [Reason51]),
?line {failed_check, _, _, _, {bad_domain, _}} = Reason51,
- await_config_not_running();
+ config_ensure_not_running();
OK_51 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "51", OK_51}})
end,
%% --
- p("[test 52] write agents config file with invalid ip (2)"),
+ ?IPRINT("[test 52] write agents config file with invalid ip (2)"),
Agent52 = setelement(4, Agent0, "10101"),
write_agents_conf(ConfDir, [Agent52]),
case config_start(Opts) of
{error, Reason52} ->
- p("start failed (as expected): ~p", [Reason52]),
+ ?IPRINT("start failed (as expected): ~p", [Reason52]),
?line {failed_check, _, _, _, {bad_address, _}} = Reason52,
- await_config_not_running();
+ config_ensure_not_running();
OK_52 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "52", OK_52}})
end,
%% --
- p("[test 53] write agents config file with invalid ip (3)"),
+ ?IPRINT("[test 53] write agents config file with invalid ip (3)"),
Agent53 = setelement(4, Agent0, "[192,168,0]"),
write_agents_conf(ConfDir, [Agent53]),
case config_start(Opts) of
{error, Reason53} ->
- p("start failed (as expected): ~p", [Reason53]),
+ ?IPRINT("start failed (as expected): ~p", [Reason53]),
?line {failed_check, _, _, _, {bad_address, _}} = Reason53,
- await_config_not_running();
+ config_ensure_not_running();
OK_53 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "53", OK_53}})
end,
%% --
- p("[test 54] write agents config file with invalid ip (4)"),
+ ?IPRINT("[test 54] write agents config file with invalid ip (4)"),
Agent54 = setelement(4, Agent0, "[192,168,0,100,99]"),
write_agents_conf(ConfDir, [Agent54]),
case config_start(Opts) of
{error, Reason54} ->
- p("start failed (as expected): ~p", [Reason54]),
+ ?IPRINT("start failed (as expected): ~p", [Reason54]),
?line {failed_check, _, _, _, {bad_address, _}} = Reason54,
- await_config_not_running();
+ config_ensure_not_running();
OK_54 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "54", OK_54}})
end,
%% --
- p("[test 55] write agents config file with invalid ip (5)"),
+ ?IPRINT("[test 55] write agents config file with invalid ip (5)"),
Agent55 = setelement(4, Agent0, "[192,168,0,arne]"),
write_agents_conf(ConfDir, [Agent55]),
?line {error, Reason55} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason55]),
+ ?IPRINT("start failed (as expected): ~p", [Reason55]),
?line {failed_check, _, _, _, {bad_address, _}} = Reason55,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 61] write agents config file with invalid port (1)"),
+ ?IPRINT("[test 61] write agents config file with invalid port (1)"),
Agent61 = setelement(5, Agent0, "kalle_anka"),
write_agents_conf(ConfDir, [Agent61]),
?line {error, Reason61} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason61]),
+ ?IPRINT("start failed (as expected): ~p", [Reason61]),
?line {failed_check, _, _, _, {bad_address, _}} = Reason61,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 62] write agents config file with invalid port (2)"),
+ ?IPRINT("[test 62] write agents config file with invalid port (2)"),
Agent62 = setelement(5, Agent0, "-1"),
write_agents_conf(ConfDir, [Agent62]),
?line {error, Reason62} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason62]),
+ ?IPRINT("start failed (as expected): ~p", [Reason62]),
?line {failed_check, _, _, _, {bad_address, _}} = Reason62,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 63] write agents config file with invalid port (3)"),
+ ?IPRINT("[test 63] write agents config file with invalid port (3)"),
Agent63 = setelement(5, Agent0, "\"100\""),
write_agents_conf(ConfDir, [Agent63]),
?line {error, Reason63} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason63]),
+ ?IPRINT("start failed (as expected): ~p", [Reason63]),
?line {failed_check, _, _, _, {bad_address, _}} = Reason63,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 71] write agents config file with invalid engine-id (1)"),
+ ?IPRINT("[test 71] write agents config file with invalid engine-id (1)"),
Agent71 = setelement(6, Agent0, "kalle_anka"),
write_agents_conf(ConfDir, [Agent71]),
?line {error, Reason71} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason71]),
+ ?IPRINT("start failed (as expected): ~p", [Reason71]),
?line {failed_check, _, _, _, {invalid_string, _}} = Reason71,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 72] write agents config file with invalid engine-id (2)"),
+ ?IPRINT("[test 72] write agents config file with invalid engine-id (2)"),
Agent72 = setelement(6, Agent0, "10101"),
write_agents_conf(ConfDir, [Agent72]),
?line {error, Reason72} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason72]),
+ ?IPRINT("start failed (as expected): ~p", [Reason72]),
?line {failed_check, _, _, _, {invalid_string, _}} = Reason72,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 81] write agents config file with invalid timeout (1)"),
+ ?IPRINT("[test 81] write agents config file with invalid timeout (1)"),
Agent81 = setelement(7, Agent0, "kalle_anka"),
write_agents_conf(ConfDir, [Agent81]),
?line {error, Reason81} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason81]),
+ ?IPRINT("start failed (as expected): ~p", [Reason81]),
?line {failed_check, _, _, _, {invalid_timer, _}} = Reason81,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 82] write agents config file with invalid timeout (2)"),
+ ?IPRINT("[test 82] write agents config file with invalid timeout (2)"),
Agent82 = setelement(7, Agent0, "-1"),
write_agents_conf(ConfDir, [Agent82]),
?line {error, Reason82} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason82]),
+ ?IPRINT("start failed (as expected): ~p", [Reason82]),
?line {failed_check, _, _, _, {invalid_timer, _}} = Reason82,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 83] write agents config file with invalid timeout (3)"),
+ ?IPRINT("[test 83] write agents config file with invalid timeout (3)"),
Agent83 = setelement(7, Agent0, "{1000, 1, 10, kalle}"),
write_agents_conf(ConfDir, [Agent83]),
?line {error, Reason83} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason83]),
+ ?IPRINT("start failed (as expected): ~p", [Reason83]),
?line {failed_check, _, _, _, {invalid_timer, _}} = Reason83,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 84] write agents config file with invalid timeout (4)"),
+ ?IPRINT("[test 84] write agents config file with invalid timeout (4)"),
Agent84 = setelement(7, Agent0, "{1000, -1, 10, 10}"),
write_agents_conf(ConfDir, [Agent84]),
?line {error, Reason84} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason84]),
+ ?IPRINT("start failed (as expected): ~p", [Reason84]),
?line {failed_check, _, _, _, {invalid_timer, _}} = Reason84,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 85] write agents config file with invalid timeout (5)"),
+ ?IPRINT("[test 85] write agents config file with invalid timeout (5)"),
Agent85 = setelement(7, Agent0, "{1000, 1, -100, 10}"),
write_agents_conf(ConfDir, [Agent85]),
?line {error, Reason85} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason85]),
+ ?IPRINT("start failed (as expected): ~p", [Reason85]),
?line {failed_check, _, _, _, {invalid_timer, _}} = Reason85,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 86] write agents config file with invalid timeout (6)"),
+ ?IPRINT("[test 86] write agents config file with invalid timeout (6)"),
Agent86 = setelement(7, Agent0, "{1000, 1, 100, -1}"),
write_agents_conf(ConfDir, [Agent86]),
?line {error, Reason86} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason86]),
+ ?IPRINT("start failed (as expected): ~p", [Reason86]),
?line {failed_check, _, _, _, {invalid_timer, _}} = Reason86,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 91] write agents config file with invalid max-message-size (1)"),
+ ?IPRINT("[test 91] write agents config file with invalid max-message-size (1)"),
Agent91 = setelement(8, Agent0, "483"),
write_agents_conf(ConfDir, [Agent91]),
?line {error, Reason91} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason91]),
+ ?IPRINT("start failed (as expected): ~p", [Reason91]),
?line {failed_check, _, _, _, {invalid_packet_size, _}} = Reason91,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 92] write agents config file with invalid max-message-size (2)"),
+ ?IPRINT("[test 92] write agents config file with invalid max-message-size (2)"),
Agent92 = setelement(8, Agent0, "kalle_anka"),
write_agents_conf(ConfDir, [Agent92]),
?line {error, Reason92} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason92]),
+ ?IPRINT("start failed (as expected): ~p", [Reason92]),
?line {failed_check, _, _, _, {invalid_packet_size, _}} = Reason92,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test A1] write agents config file with invalid version (1)"),
+ ?IPRINT("[test A1] write agents config file with invalid version (1)"),
AgentA1 = setelement(9, Agent0, "1"),
write_agents_conf(ConfDir, [AgentA1]),
?line {error, ReasonA1} = config_start(Opts),
- p("start failed (as expected): ~p", [ReasonA1]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonA1]),
?line {failed_check, _, _, _, {bad_version, _}} = ReasonA1,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test A2] write agents config file with invalid version (2)"),
+ ?IPRINT("[test A2] write agents config file with invalid version (2)"),
AgentA2 = setelement(9, Agent0, "v30"),
write_agents_conf(ConfDir, [AgentA2]),
?line {error, ReasonA2} = config_start(Opts),
- p("start failed (as expected): ~p", [ReasonA2]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonA2]),
?line {failed_check, _, _, _, {bad_version, _}} = ReasonA2,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test B1] write agents config file with invalid sec-model (1)"),
+ ?IPRINT("[test B1] write agents config file with invalid sec-model (1)"),
AgentB1 = setelement(10, Agent0, "\"any\""),
write_agents_conf(ConfDir, [AgentB1]),
?line {error, ReasonB1} = config_start(Opts),
- p("start failed (as expected): ~p", [ReasonB1]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonB1]),
?line {failed_check, _, _, _, {invalid_sec_model, _}} = ReasonB1,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test B2] write agents config file with invalid sec-model (2)"),
+ ?IPRINT("[test B2] write agents config file with invalid sec-model (2)"),
AgentB2 = setelement(10, Agent0, "v3"),
write_agents_conf(ConfDir, [AgentB2]),
?line {error, ReasonB2} = config_start(Opts),
- p("start failed (as expected): ~p", [ReasonB2]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonB2]),
?line {failed_check, _, _, _, {invalid_sec_model, _}} = ReasonB2,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test C1] write agents config file with invalid sec-name (1)"),
+ ?IPRINT("[test C1] write agents config file with invalid sec-name (1)"),
AgentC1 = setelement(11, Agent0, "initial"),
write_agents_conf(ConfDir, [AgentC1]),
case config_start(Opts) of
{error, ReasonC1} ->
- p("start failed (as expected): ~p", [ReasonC1]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonC1]),
?line {failed_check, _, _, _, {bad_sec_name, _}} = ReasonC1,
- await_config_not_running();
+ config_ensure_not_running();
OK_C1 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "C1", OK_C1}})
end,
%% --
- p("[test C2] write agents config file with invalid sec-name (2)"),
+ ?IPRINT("[test C2] write agents config file with invalid sec-name (2)"),
AgentC2 = setelement(11, Agent0, "10101"),
write_agents_conf(ConfDir, [AgentC2]),
case config_start(Opts) of
{error, ReasonC2} ->
- p("start failed (as expected): ~p", [ReasonC2]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonC2]),
?line {failed_check, _, _, _, {bad_sec_name, _}} = ReasonC2,
- await_config_not_running();
+ config_ensure_not_running();
OK_C2 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "C2", OK_C2}})
end,
%% --
- p("[test D1] write agents config file with invalid sec-level (1)"),
+ ?IPRINT("[test D1] write agents config file with invalid sec-level (1)"),
AgentD1 = setelement(12, Agent0, "\"noAuthNoPriv\""),
write_agents_conf(ConfDir, [AgentD1]),
case config_start(Opts) of
{error, ReasonD1} ->
- p("start failed (as expected): ~p", [ReasonD1]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonD1]),
?line {failed_check, _, _, _, {invalid_sec_level, _}} = ReasonD1,
- await_config_not_running();
+ config_ensure_not_running();
OK_D1 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "D1", OK_D1}})
end,
%% --
- p("[test D2] write agents config file with invalid sec-level (2)"),
+ ?IPRINT("[test D2] write agents config file with invalid sec-level (2)"),
AgentD2 = setelement(12, Agent0, "99"),
write_agents_conf(ConfDir, [AgentD2]),
case config_start(Opts) of
{error, ReasonD2} ->
- p("start failed (as expected): ~p", [ReasonD2]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonD2]),
?line {failed_check, _, _, _, {invalid_sec_level, _}} = ReasonD2,
- await_config_not_running();
+ config_ensure_not_running();
OK_D2 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "D2", OK_D2}})
end,
%% --
- p("[test E1] write agents config file with invalid agent (1)"),
+ ?IPRINT("[test E1] write agents config file with invalid agent (1)"),
write_agents_conf2(ConfDir, "{swiacf, \"targ-hobbes\"}."),
case config_start(Opts) of
{error, ReasonE1} ->
- p("start failed (as expected): ~p", [ReasonE1]),
+ ?IPRINT("start failed (as expected): ~p", [ReasonE1]),
?line {failed_check, _, _, _, {bad_agent_config, _}} = ReasonE1,
- await_config_not_running();
+ config_ensure_not_running();
OK_E1 ->
+ config_ensure_not_running(),
exit({error, {unexpected_success, "E1", OK_E1}})
end,
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -1389,8 +1443,8 @@ start_with_invalid_usm_conf_file1(suite) -> [];
start_with_invalid_usm_conf_file1(doc) ->
"Start with invalid usm config file.";
start_with_invalid_usm_conf_file1(Conf) when is_list(Conf) ->
- put(tname,swiusmcf),
- p("start"),
+ put(tname, "START-W-INV-USM-CONF-FILE-1"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
case ?CRYPTO_START() of
@@ -1424,179 +1478,179 @@ start_with_invalid_usm_conf_file1(Conf) when is_list(Conf) ->
"usmNoPrivProtocol", "[]"},
%% --
- p("[test 11] write usm config file with invalid engine-id (1)"),
+ ?IPRINT("[test 11] write usm config file with invalid engine-id (1)"),
Usm11 = setelement(1, Usm0, "kalle-anka"),
write_usm_conf(ConfDir, [Usm11]),
?line {error, Reason11} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason11]),
+ ?IPRINT("start failed (as expected): ~p", [Reason11]),
?line {failed_reading, _, _, _, {parse_error, _}} = Reason11,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 12] write usm config file with invalid engine-id (2)"),
+ ?IPRINT("[test 12] write usm config file with invalid engine-id (2)"),
Usm12 = setelement(1, Usm0, "kalle_anka"),
write_usm_conf(ConfDir, [Usm12]),
?line {error, Reason12} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason12]),
+ ?IPRINT("start failed (as expected): ~p", [Reason12]),
?line {failed_check, _, _, _, {bad_usm_engine_id, _}} = Reason12,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 13] write usm config file with invalid engine-id (3)"),
+ ?IPRINT("[test 13] write usm config file with invalid engine-id (3)"),
Usm13 = setelement(1, Usm1, "10101"),
write_usm_conf(ConfDir, [Usm13]),
?line {error, Reason13} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason13]),
+ ?IPRINT("start failed (as expected): ~p", [Reason13]),
?line {failed_check, _, _, _, {bad_usm_engine_id, _}} = Reason13,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 21] write usm config file with invalid user-name (1)"),
+ ?IPRINT("[test 21] write usm config file with invalid user-name (1)"),
Usm21 = setelement(2, Usm0, "kalle_anka"),
write_usm_conf(ConfDir, [Usm21]),
?line {error, Reason21} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason21]),
+ ?IPRINT("start failed (as expected): ~p", [Reason21]),
?line {failed_check, _, _, _, {bad_usm_user_name, _}} = Reason21,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 22] write usm config file with invalid user-name (1)"),
+ ?IPRINT("[test 22] write usm config file with invalid user-name (1)"),
Usm22 = setelement(2, Usm1, "10101"),
write_usm_conf(ConfDir, [Usm22]),
?line {error, Reason22} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason22]),
+ ?IPRINT("start failed (as expected): ~p", [Reason22]),
?line {failed_check, _, _, _, {bad_usm_user_name, _}} = Reason22,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 31] write usm config file with invalid sec-name (1)"),
+ ?IPRINT("[test 31] write usm config file with invalid sec-name (1)"),
Usm31 = setelement(3, Usm1, "kalle_anka"),
write_usm_conf(ConfDir, [Usm31]),
?line {error, Reason31} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason31]),
+ ?IPRINT("start failed (as expected): ~p", [Reason31]),
?line {failed_check, _, _, _, {bad_usm_sec_name, _}} = Reason31,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 32] write usm config file with invalid sec-name (2)"),
+ ?IPRINT("[test 32] write usm config file with invalid sec-name (2)"),
Usm32 = setelement(3, Usm1, "10101"),
write_usm_conf(ConfDir, [Usm32]),
?line {error, Reason32} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason32]),
+ ?IPRINT("start failed (as expected): ~p", [Reason32]),
?line {failed_check, _, _, _, {bad_usm_sec_name, _}} = Reason32,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 41] write usm config file with invalid auth-protocol (1)"),
+ ?IPRINT("[test 41] write usm config file with invalid auth-protocol (1)"),
Usm41 = setelement(3, Usm0, "\"usmNoAuthProtocol\""),
write_usm_conf(ConfDir, [Usm41]),
?line {error, Reason41} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason41]),
+ ?IPRINT("start failed (as expected): ~p", [Reason41]),
?line {failed_check, _, _, _, {invalid_auth_protocol, _}} = Reason41,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 42] write usm config file with invalid auth-protocol (2)"),
+ ?IPRINT("[test 42] write usm config file with invalid auth-protocol (2)"),
Usm42 = setelement(3, Usm0, "kalle"),
write_usm_conf(ConfDir, [Usm42]),
?line {error, Reason42} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason42]),
+ ?IPRINT("start failed (as expected): ~p", [Reason42]),
?line {failed_check, _, _, _, {invalid_auth_protocol, _}} = Reason42,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 43] write usm config file with invalid auth-protocol (3)"),
+ ?IPRINT("[test 43] write usm config file with invalid auth-protocol (3)"),
Usm43 = setelement(3, Usm0, "10101"),
write_usm_conf(ConfDir, [Usm43]),
?line {error, Reason43} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason43]),
+ ?IPRINT("start failed (as expected): ~p", [Reason43]),
?line {failed_check, _, _, _, {invalid_auth_protocol, _}} = Reason43,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 51] write usm config file with invalid auth-key (1)"),
+ ?IPRINT("[test 51] write usm config file with invalid auth-key (1)"),
Usm51 = setelement(3, Usm0, "usmHMACMD5AuthProtocol"),
write_usm_conf(ConfDir, [Usm51]),
?line {error, Reason51} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason51]),
+ ?IPRINT("start failed (as expected): ~p", [Reason51]),
?line {failed_check, _, _, _, {invalid_auth_key, _, _}} = Reason51,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 52] write usm config file with invalid auth-key (2)"),
+ ?IPRINT("[test 52] write usm config file with invalid auth-key (2)"),
Usm52 = setelement(4, Usm51, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5]"),
write_usm_conf(ConfDir, [Usm52]),
?line {error, Reason52} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason52]),
+ ?IPRINT("start failed (as expected): ~p", [Reason52]),
?line {failed_check, _, _, _, {invalid_auth_key, _, 15}} = Reason52,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 53] write usm config file with invalid auth-key (3)"),
+ ?IPRINT("[test 53] write usm config file with invalid auth-key (3)"),
Usm53 = setelement(4, Usm51, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7]"),
write_usm_conf(ConfDir, [Usm53]),
?line {error, Reason53} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason53]),
+ ?IPRINT("start failed (as expected): ~p", [Reason53]),
?line {failed_check, _, _, _, {invalid_auth_key, _, 17}} = Reason53,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 54] write usm config file with invalid auth-key (4)"),
+ ?IPRINT("[test 54] write usm config file with invalid auth-key (4)"),
Usm54 = setelement(4, Usm51, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,kalle]"),
write_usm_conf(ConfDir, [Usm54]),
?line maybe_start_crypto(), %% Make sure it's started...
?line {error, Reason54} = config_start(Opts),
?line ok = maybe_stop_crypto(),
- p("start failed (as expected): ~p", [Reason54]),
+ ?IPRINT("start failed (as expected): ~p", [Reason54]),
?line {failed_check, _, _, _, {invalid_auth_key, _}} = Reason54,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 55] write usm config file with invalid auth-key (5)"),
+ ?IPRINT("[test 55] write usm config file with invalid auth-key (5)"),
Usm55 = setelement(4, Usm51, "arne_anka"),
write_usm_conf(ConfDir, [Usm55]),
?line {error, Reason55} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason55]),
+ ?IPRINT("start failed (as expected): ~p", [Reason55]),
?line {failed_check, _, _, _, {invalid_auth_key, _}} = Reason55,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 56] write usm config file with invalid auth-key (6)"),
+ ?IPRINT("[test 56] write usm config file with invalid auth-key (6)"),
Usm56 = setelement(4, Usm51, "10101"),
write_usm_conf(ConfDir, [Usm56]),
?line {error, Reason56} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason56]),
+ ?IPRINT("start failed (as expected): ~p", [Reason56]),
?line {failed_check, _, _, _, {invalid_auth_key, _}} = Reason56,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 57] write usm config file with invalid auth-key (7)"),
+ ?IPRINT("[test 57] write usm config file with invalid auth-key (7)"),
Usm57 = setelement(3, Usm0, "usmHMACSHAAuthProtocol"),
write_usm_conf(ConfDir, [Usm57]),
?line {error, Reason57} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason57]),
+ ?IPRINT("start failed (as expected): ~p", [Reason57]),
?line {failed_check, _, _, _, {invalid_auth_key, _, _}} = Reason57,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 58] write usm config file with invalid auth-key (8)"),
+ ?IPRINT("[test 58] write usm config file with invalid auth-key (8)"),
Usm58 = setelement(4, Usm57, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]"),
write_usm_conf(ConfDir, [Usm58]),
?line {error, Reason58} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason58]),
+ ?IPRINT("start failed (as expected): ~p", [Reason58]),
?line {failed_check, _, _, _, {invalid_auth_key, _, 16}} = Reason58,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 59] write usm config file with invalid auth-key (9)"),
+ ?IPRINT("[test 59] write usm config file with invalid auth-key (9)"),
Usm59 = setelement(4, Usm57, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,ka]"),
write_usm_conf(ConfDir, [Usm59]),
?line ok = maybe_start_crypto(),
?line {error, Reason59} = config_start(Opts),
?line ok = maybe_stop_crypto(),
- p("start failed (as expected): ~p", [Reason59]),
+ ?IPRINT("start failed (as expected): ~p", [Reason59]),
?line {failed_check, _, _, _, {invalid_auth_key, _}} = Reason59,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
%% <CRYPTO-MODIFICATIONS>
@@ -1604,16 +1658,16 @@ start_with_invalid_usm_conf_file1(Conf) when is_list(Conf) ->
%% explicitly (all of it is as of R14 implemented with NIFs).
case (catch crypto:version()) of
{'EXIT', {undef, _}} ->
- p("[test 5A] write usm config file with valid auth-key "
+ ?IPRINT("[test 5A] write usm config file with valid auth-key "
"when crypto not started (10)"),
Usm5A = setelement(4,
Usm57,
"[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0]"),
write_usm_conf(ConfDir, [Usm5A]),
?line {error, Reason5A} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason5A]),
+ ?IPRINT("start failed (as expected): ~p", [Reason5A]),
?line {failed_check, _, _, _, {unsupported_crypto, _}} = Reason5A,
- await_config_not_running();
+ config_ensure_not_running();
_ ->
%% This function is only present in version 2.0 or greater.
%% The crypto app no longer needs to be explicitly started
@@ -1622,87 +1676,87 @@ start_with_invalid_usm_conf_file1(Conf) when is_list(Conf) ->
%% </CRYPTO-MODIFICATIONS>
%% --
- p("[test 61] write usm config file with invalid priv-protocol (1)"),
+ ?IPRINT("[test 61] write usm config file with invalid priv-protocol (1)"),
Usm61 = setelement(5, Usm0, "\"usmNoPrivProtocol\""),
write_usm_conf(ConfDir, [Usm61]),
?line {error, Reason61} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason61]),
+ ?IPRINT("start failed (as expected): ~p", [Reason61]),
?line {failed_check, _, _, _, {invalid_priv_protocol, _}} = Reason61,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 62] write usm config file with invalid priv-protocol (2)"),
+ ?IPRINT("[test 62] write usm config file with invalid priv-protocol (2)"),
Usm62 = setelement(5, Usm0, "kalle"),
write_usm_conf(ConfDir, [Usm62]),
?line {error, Reason62} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason62]),
+ ?IPRINT("start failed (as expected): ~p", [Reason62]),
?line {failed_check, _, _, _, {invalid_priv_protocol, _}} = Reason62,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 63] write usm config file with invalid priv-protocol (3)"),
+ ?IPRINT("[test 63] write usm config file with invalid priv-protocol (3)"),
Usm63 = setelement(5, Usm0, "10101"),
write_usm_conf(ConfDir, [Usm63]),
?line {error, Reason63} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason63]),
+ ?IPRINT("start failed (as expected): ~p", [Reason63]),
?line {failed_check, _, _, _, {invalid_priv_protocol, _}} = Reason63,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 71] write usm config file with invalid priv-key (1)"),
+ ?IPRINT("[test 71] write usm config file with invalid priv-key (1)"),
Usm71 = setelement(5, Usm0, "usmDESPrivProtocol"),
write_usm_conf(ConfDir, [Usm71]),
?line {error, Reason71} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason71]),
+ ?IPRINT("start failed (as expected): ~p", [Reason71]),
?line {failed_check, _, _, _, {invalid_priv_key, _, _}} = Reason71,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 72] write usm config file with invalid priv-key (2)"),
+ ?IPRINT("[test 72] write usm config file with invalid priv-key (2)"),
Usm72 = setelement(6, Usm71, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5]"),
write_usm_conf(ConfDir, [Usm72]),
?line {error, Reason72} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason72]),
+ ?IPRINT("start failed (as expected): ~p", [Reason72]),
?line {failed_check, _, _, _, {invalid_priv_key, _, 15}} = Reason72,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 73] write usm config file with invalid priv-key (3)"),
+ ?IPRINT("[test 73] write usm config file with invalid priv-key (3)"),
Usm73 = setelement(6, Usm71, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7]"),
write_usm_conf(ConfDir, [Usm73]),
?line {error, Reason73} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason73]),
+ ?IPRINT("start failed (as expected): ~p", [Reason73]),
?line {failed_check, _, _, _, {invalid_priv_key, _, 17}} = Reason73,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 74] write usm config file with invalid priv-key (4)"),
+ ?IPRINT("[test 74] write usm config file with invalid priv-key (4)"),
Usm74 = setelement(6, Usm71, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,kalle]"),
write_usm_conf(ConfDir, [Usm74]),
?line ok = maybe_start_crypto(),
?line {error, Reason74} = config_start(Opts),
?line ok = maybe_stop_crypto(),
- p("start failed (as expected): ~p", [Reason74]),
+ ?IPRINT("start failed (as expected): ~p", [Reason74]),
?line {failed_check, _, _, _, {invalid_priv_key, _}} = Reason74,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 75] write usm config file with invalid priv-key (5)"),
+ ?IPRINT("[test 75] write usm config file with invalid priv-key (5)"),
Usm75 = setelement(6, Usm71, "arne_anka"),
write_usm_conf(ConfDir, [Usm75]),
?line {error, Reason75} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason75]),
+ ?IPRINT("start failed (as expected): ~p", [Reason75]),
?line {failed_check, _, _, _, {invalid_priv_key, _}} = Reason75,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("[test 76] write usm config file with invalid priv-key (6)"),
+ ?IPRINT("[test 76] write usm config file with invalid priv-key (6)"),
Usm76 = setelement(6, Usm71, "10101"),
write_usm_conf(ConfDir, [Usm76]),
?line {error, Reason76} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason76]),
+ ?IPRINT("start failed (as expected): ~p", [Reason76]),
?line {failed_check, _, _, _, {invalid_priv_key, _}} = Reason76,
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
%% <CRYPTO-MODIFICATIONS>
@@ -1710,14 +1764,14 @@ start_with_invalid_usm_conf_file1(Conf) when is_list(Conf) ->
%% explicitly (all of it is as of R14 implemented with NIFs).
case (catch crypto:version()) of
{'EXIT', {undef, _}} ->
- p("[test 77] write usm config file with valid priv-key "
+ ?IPRINT("[test 77] write usm config file with valid priv-key "
"when crypto not started (7)"),
Usm77 = setelement(6, Usm71, "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]"),
write_usm_conf(ConfDir, [Usm77]),
?line {error, Reason77} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason77]),
+ ?IPRINT("start failed (as expected): ~p", [Reason77]),
?line {failed_check, _, _, _, {unsupported_crypto, _}} = Reason77,
- await_config_not_running();
+ config_ensure_not_running();
_ ->
%% This function is only present in version 2.0 or greater.
%% The crypto app no longer needs to be explicitly started
@@ -1726,14 +1780,14 @@ start_with_invalid_usm_conf_file1(Conf) when is_list(Conf) ->
%% </CRYPTO-MODIFICATIONS>
%% --
- p("[test 78] write usm config file with invalid usm (1)"),
+ ?IPRINT("[test 78] write usm config file with invalid usm (1)"),
write_usm_conf2(ConfDir, "{\"bmkEngine\", \"swiusmcf\"}."),
?line {error, Reason81} = config_start(Opts),
- p("start failed (as expected): ~p", [Reason81]),
+ ?IPRINT("start failed (as expected): ~p", [Reason81]),
?line {failed_check, _, _, _, {bad_usm_config, _}} = Reason81,
- await_config_not_running(),
+ config_ensure_not_running(),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -1746,28 +1800,28 @@ start_with_create_db_and_dir_opt(doc) ->
"Start the snmp manager config process with the\n"
"create_db_and_dir option.";
start_with_create_db_and_dir_opt(Conf) when is_list(Conf) ->
- put(tname, swcdado),
- p("start"),
+ put(tname, "START-W-CRE-DB-AND-DIR-OPT"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
true = not filelib:is_dir(DbDir) and not filelib:is_file(DbDir),
write_manager_conf(ConfDir),
- p("verify nonexistent db_dir"),
+ ?IPRINT("verify nonexistent db_dir"),
ConfigOpts01 = [{verbosity,trace}, {dir, ConfDir}, {db_dir, DbDir}],
{error, Reason01} = config_start([{config, ConfigOpts01}]),
- p("nonexistent db_dir res: ~p", [Reason01]),
+ ?IPRINT("nonexistent db_dir res: ~p", [Reason01]),
{invalid_conf_db_dir, _, not_found} = Reason01,
- p("verify nonexistent db_dir gets created"),
+ ?IPRINT("verify nonexistent db_dir gets created"),
ConfigOpts02 = [{db_init_error, create_db_and_dir} | ConfigOpts01],
{ok, _Pid} = config_start([{config, ConfigOpts02}]),
true = filelib:is_dir(DbDir),
- p("verified: nonexistent db_dir was correctly created"),
+ ?IPRINT("verified: nonexistent db_dir was correctly created"),
ok = config_stop(),
- p("done"),
+ ?IPRINT("done"),
ok.
%%
@@ -1780,8 +1834,8 @@ simple_system_op(doc) ->
"Access some of the known system info and some \n"
"system info that does not exist.";
simple_system_op(Conf) when is_list(Conf) ->
- put(tname,sso),
- p("start"),
+ put(tname, "SIMPLE-SYS-OP"),
+ ?IPRINT("start"),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -1790,21 +1844,21 @@ simple_system_op(Conf) when is_list(Conf) ->
Opts = [{versions, [v1]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("start config"),
+ ?IPRINT("start config"),
?line {ok, _Pid} = config_start(Opts),
- p("retreive various configs"),
+ ?IPRINT("retreive various configs"),
?line {ok, _Time} = snmpm_config:system_start_time(),
?line {ok, _EngineId} = snmpm_config:get_engine_id(),
?line {ok, _MMS} = snmpm_config:get_engine_max_message_size(),
- p("attempt to retreive nonexisting"),
+ ?IPRINT("attempt to retreive nonexisting"),
?line {error, not_found} = snmpm_config:system_info(kalle),
?line ok = config_stop(),
- await_config_not_running(),
+ config_ensure_not_running(),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -1822,8 +1876,8 @@ register_user_using_file(suite) -> [];
register_user_using_file(doc) ->
"Register user using the 'users.conf' file.";
register_user_using_file(Conf) when is_list(Conf) ->
- put(tname,ruufi),
- p("start"),
+ put(tname, "REG-USER-USING-FILE"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
_ConfDir = ?config(manager_conf_dir, Conf),
_DbDir = ?config(manager_db_dir, Conf),
@@ -1838,8 +1892,8 @@ register_user_using_function(suite) -> [];
register_user_using_function(doc) ->
"Register user using the API (function).";
register_user_using_function(Conf) when is_list(Conf) ->
- put(tname,ruufu),
- p("start"),
+ put(tname, "REG-USER-USING-FUNC"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
_ConfDir = ?config(manager_conf_dir, Conf),
_DbDir = ?config(manager_db_dir, Conf),
@@ -1854,8 +1908,8 @@ register_user_failed_using_function1(suite) -> [];
register_user_failed_using_function1(doc) ->
"Register user failed using incorrect arguments to API (function).";
register_user_failed_using_function1(Conf) when is_list(Conf) ->
- put(tname,rufufu1),
- p("start"),
+ put(tname, "REG-USER-FAIL-USING-FUNC-1"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
_ConfDir = ?config(manager_conf_dir, Conf),
_DbDir = ?config(manager_db_dir, Conf),
@@ -1872,13 +1926,29 @@ register_user_failed_using_function1(Conf) when is_list(Conf) ->
%% ---
%%
+%% This test case tests that we can "register" agents using a config file.
+%% So, starting the config process is part of the actual test, but even
+%% if the test fails, we want to make sure the config process is actually
+%% stop'ed. So, we put config stop in the post.
+
register_agent_using_file(suite) -> [];
register_agent_using_file(doc) ->
"Register agents using the 'agents'conf' file.";
register_agent_using_file(Conf) when is_list(Conf) ->
- put(tname,raufi),
- p("start"),
+ put(tname, "REG-AG-USING-FILE"),
process_flag(trap_exit, true),
+ Pre = fun() -> ok end,
+ Case = fun(_) -> do_register_agent_using_file(Conf) end,
+ Post = fun(_) ->
+ ?IPRINT("stop config process"),
+ ?line ok = snmpm_config:stop(),
+ config_ensure_not_running(),
+ ok
+ end,
+ ?TC_TRY(register_agent_using_file, Pre, Case, Post).
+
+do_register_agent_using_file(Conf) ->
+ ?IPRINT("start"),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -1887,11 +1957,11 @@ register_agent_using_file(Conf) when is_list(Conf) ->
%% --
- p("write manager config file"),
+ ?IPRINT("write manager config file"),
write_manager_conf(ConfDir),
%% --
- p("write users config file"),
+ ?IPRINT("write users config file"),
UserId1 = raufi1,
UserId1Str = str(UserId1),
UserId2 = raufi2,
@@ -1901,7 +1971,7 @@ register_agent_using_file(Conf) when is_list(Conf) ->
write_users_conf(ConfDir, [User1, User2]),
%% --
- p("write agents config file"),
+ ?IPRINT("write agents config file"),
AgentAddr1 = [192,168,0,101],
AgentAddr1Str = str(AgentAddr1),
AgentPort1 = 162,
@@ -1929,38 +1999,38 @@ register_agent_using_file(Conf) when is_list(Conf) ->
write_agents_conf(ConfDir, [Agent1Str, Agent2Str]),
%% --
- p("start the config process"),
+ ?IPRINT("start the config process"),
?line {ok, _Pid} = config_start(Opts),
%% --
- p("which agents"),
+ ?IPRINT("which agents"),
?line [_, _] = All = snmpm_config:which_agents(),
- p("all agents: ~n ~p", [All]),
+ ?IPRINT("all agents: ~n ~p", [All]),
?line [A1] = snmpm_config:which_agents(UserId1),
- p("agents belonging to ~w: ~n ~p", [UserId1, A1]),
+ ?IPRINT("agents belonging to ~w: ~n ~p", [UserId1, A1]),
?line [A2] = snmpm_config:which_agents(UserId2),
- p("agents belonging to ~w: ~n ~p", [UserId2, A2]),
+ ?IPRINT("agents belonging to ~w: ~n ~p", [UserId2, A2]),
%% --
- p("All info for agent <~w,~w>", [AgentAddr1, AgentPort1]),
+ ?IPRINT("All info for agent <~w,~w>", [AgentAddr1, AgentPort1]),
?line {ok, AllInfo1} =
snmpm_config:agent_info(AgentAddr1, AgentPort1, all),
- p("all agent info for agent: ~n ~p", [AllInfo1]),
+ ?IPRINT("all agent info for agent: ~n ~p", [AllInfo1]),
%% --
- p("EngineID (~p) for agent <~w,~w>", [EngineID1, AgentAddr1, AgentPort1]),
+ ?IPRINT("EngineID (~p) for agent <~w,~w>", [EngineID1, AgentAddr1, AgentPort1]),
?line {ok, EngineID1} =
snmpm_config:agent_info(AgentAddr1, AgentPort1, engine_id),
%% --
- p("All info for agent <~w,~w>", [AgentAddr2, AgentPort2]),
+ ?IPRINT("All info for agent <~w,~w>", [AgentAddr2, AgentPort2]),
?line {ok, AllInfo2} =
snmpm_config:agent_info(AgentAddr2, AgentPort2, all),
- p("all agent info for agent: ~n ~p", [AllInfo2]),
+ ?IPRINT("all agent info for agent: ~n ~p", [AllInfo2]),
%% --
- p("EngineID (~p) for agent <~w,~w>", [EngineID2, AgentAddr2, AgentPort2]),
+ ?IPRINT("EngineID (~p) for agent <~w,~w>", [EngineID2, AgentAddr2, AgentPort2]),
?line {ok, EngineID2} =
snmpm_config:agent_info(AgentAddr2, AgentPort2, engine_id),
@@ -1968,7 +2038,7 @@ register_agent_using_file(Conf) when is_list(Conf) ->
?line {ok, MMS2} =
snmpm_config:agent_info(AgentAddr2, AgentPort2, max_message_size),
NewMMS21 = 2048,
- p("try update agent info max-message-size to ~w for agent <~w,~w>",
+ ?IPRINT("try update agent info max-message-size to ~w for agent <~w,~w>",
[NewMMS21, AgentAddr2, AgentPort2]),
?line ok = snmpm_config:update_agent_info(UserId2, AgentAddr2, AgentPort2,
max_message_size, NewMMS21),
@@ -1976,34 +2046,29 @@ register_agent_using_file(Conf) when is_list(Conf) ->
snmpm_config:agent_info(AgentAddr2, AgentPort2, max_message_size),
%% --
- p("try (and fail) to update agent info max-message-size to ~w "
+ ?IPRINT("try (and fail) to update agent info max-message-size to ~w "
"for agent <~w,~w> "
"with user ~w (not owner)",
[NewMMS21, AgentAddr2, AgentPort2, UserId1]),
?line {error, Reason01} =
snmpm_config:update_agent_info(UserId1, AgentAddr2, AgentPort2,
max_message_size, NewMMS21),
- p("expected failure. Reason01: ~p", [Reason01]),
+ ?IPRINT("expected failure. Reason01: ~p", [Reason01]),
?line {ok, NewMMS21} =
snmpm_config:agent_info(AgentAddr2, AgentPort2, max_message_size),
%% --
NewMMS22 = 400,
- p("try (and fail) to update agent info max-message-size to ~w "
+ ?IPRINT("try (and fail) to update agent info max-message-size to ~w "
"for agent <~w,~w>",
[NewMMS22, AgentAddr2, AgentPort2]),
?line {error, Reason02} =
snmpm_config:update_agent_info(UserId1, AgentAddr2, AgentPort2,
max_message_size, NewMMS22),
- p("expected failure. Reason02: ~p", [Reason02]),
+ ?IPRINT("expected failure. Reason02: ~p", [Reason02]),
%% --
- p("stop config process"),
- ?line ok = snmpm_config:stop(),
- await_config_not_running(),
-
- %% --
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -2015,8 +2080,8 @@ register_agent_using_function(suite) -> [];
register_agent_using_function(doc) ->
"Register agents using the API (function).";
register_agent_using_function(Conf) when is_list(Conf) ->
- put(tname,raufu),
- p("start"),
+ put(tname, "REG-AG-USING-FUNC"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
_ConfDir = ?config(manager_conf_dir, Conf),
_DbDir = ?config(manager_db_dir, Conf),
@@ -2032,8 +2097,8 @@ register_agent_failed_using_function1(doc) ->
"Register agents failng using the API (function) with incorrect "
"config (1).";
register_agent_failed_using_function1(Conf) when is_list(Conf) ->
- put(tname,rafuf1),
- p("start"),
+ put(tname, "REG-AG-FAIL-USING-FUNC-1"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
_ConfDir = ?config(manager_conf_dir, Conf),
_DbDir = ?config(manager_db_dir, Conf),
@@ -2054,8 +2119,8 @@ register_usm_user_using_file(suite) -> [];
register_usm_user_using_file(doc) ->
"Register usm user using the 'usm.conf' file.";
register_usm_user_using_file(Conf) when is_list(Conf) ->
- put(tname,ruuufi),
- p("start"),
+ put(tname, "REG-USM-USER-USING-FILE"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
case ?CRYPTO_START() of
@@ -2077,11 +2142,11 @@ register_usm_user_using_file(Conf) when is_list(Conf) ->
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
%% --
- p("write manager config file"),
+ ?IPRINT("write manager config file"),
write_manager_conf(ConfDir),
%% --
- p("write usm user config file"),
+ ?IPRINT("write usm user config file"),
SecEngineID = "loctzp's engine",
SecName1 = "samu_auth1",
UserName1 = SecName1,
@@ -2101,31 +2166,31 @@ register_usm_user_using_file(Conf) when is_list(Conf) ->
write_usm_conf(ConfDir, [UsmUser1, UsmUser2]),
%% --
- p("start the config process"),
+ ?IPRINT("start the config process"),
?line {ok, _Pid} = config_start(Opts),
%% --
- p("lookup 1 (ok)"),
+ ?IPRINT("lookup 1 (ok)"),
?line {ok, #usm_user{name = UserName1} = User1} =
snmpm_config:get_usm_user_from_sec_name(SecEngineID, SecName1),
- p("User: ~p", [User1]),
+ ?IPRINT("User: ~p", [User1]),
- p("lookup 2 (ok)"),
+ ?IPRINT("lookup 2 (ok)"),
?line {ok, #usm_user{name = UserName2} = User2} =
snmpm_config:get_usm_user_from_sec_name(SecEngineID, SecName2),
- p("User: ~p", [User2]),
+ ?IPRINT("User: ~p", [User2]),
- p("lookup 3 (error)"),
+ ?IPRINT("lookup 3 (error)"),
?line {error, not_found} =
snmpm_config:get_usm_user_from_sec_name(SecEngineID, SecName2 ++ "_1"),
%% --
- p("stop config process"),
+ ?IPRINT("stop config process"),
?line ok = snmpm_config:stop(),
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -2137,8 +2202,8 @@ register_usm_user_using_function(suite) -> [];
register_usm_user_using_function(doc) ->
"Register usm user using the API (function).";
register_usm_user_using_function(Conf) when is_list(Conf) ->
- put(tname,ruuufu),
- p("start"),
+ put(tname, "REG-USM-USER-USING-FUNC"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
case ?CRYPTO_START() of
@@ -2160,18 +2225,18 @@ register_usm_user_using_function(Conf) when is_list(Conf) ->
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
%% --
- p("write manager config file"),
+ ?IPRINT("write manager config file"),
write_manager_conf(ConfDir),
%% --
- p("start the config process"),
+ ?IPRINT("start the config process"),
?line {ok, _Pid} = config_start(Opts),
%% --
- p("register usm user's"),
+ ?IPRINT("register usm user's"),
EngineID = "loctzp's engine",
- p("register user 1 (ok)"),
+ ?IPRINT("register user 1 (ok)"),
UserName1 = "samu_auth1",
SecName1 = UserName1,
UsmConfig1 = [{sec_name, SecName1},
@@ -2179,11 +2244,11 @@ register_usm_user_using_function(Conf) when is_list(Conf) ->
{auth_key, [1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]},
{priv, usmNoPrivProtocol}],
?line ok = snmpm_config:register_usm_user(EngineID, UserName1, UsmConfig1),
- p("try register user 1 again (error)"),
+ ?IPRINT("try register user 1 again (error)"),
?line {error, {already_registered, EngineID, UserName1}} =
snmpm_config:register_usm_user(EngineID, UserName1, UsmConfig1),
- p("register user 2 (ok)"),
+ ?IPRINT("register user 2 (ok)"),
UserName2 = "samu_auth2",
SecName2 = UserName2,
UsmConfig2 = [{auth, usmHMACMD5AuthProtocol},
@@ -2191,7 +2256,7 @@ register_usm_user_using_function(Conf) when is_list(Conf) ->
{priv, usmNoPrivProtocol}],
?line ok = snmpm_config:register_usm_user(EngineID, UserName2, UsmConfig2),
- p("register user 3 (ok)"),
+ ?IPRINT("register user 3 (ok)"),
UserName3 = "samu3",
SecName3 = "samu_auth3",
UsmConfig3 = [{sec_name, SecName3},
@@ -2200,32 +2265,32 @@ register_usm_user_using_function(Conf) when is_list(Conf) ->
{priv, usmNoPrivProtocol}],
?line ok = snmpm_config:register_usm_user(EngineID, UserName3, UsmConfig3),
- p("lookup 1 (ok)"),
+ ?IPRINT("lookup 1 (ok)"),
?line {ok, #usm_user{name = UserName1} = User1} =
snmpm_config:get_usm_user_from_sec_name(EngineID, SecName1),
- p("User: ~p", [User1]),
+ ?IPRINT("User: ~p", [User1]),
- p("lookup 2 (ok)"),
+ ?IPRINT("lookup 2 (ok)"),
?line {ok, #usm_user{name = UserName2} = User2} =
snmpm_config:get_usm_user_from_sec_name(EngineID, SecName2),
- p("User: ~p", [User2]),
+ ?IPRINT("User: ~p", [User2]),
- p("lookup 3 (ok)"),
+ ?IPRINT("lookup 3 (ok)"),
?line {ok, #usm_user{name = UserName3} = User3} =
snmpm_config:get_usm_user_from_sec_name(EngineID, SecName3),
- p("User: ~p", [User3]),
+ ?IPRINT("User: ~p", [User3]),
- p("lookup 4 (error)"),
+ ?IPRINT("lookup 4 (error)"),
?line {error, not_found} =
snmpm_config:get_usm_user_from_sec_name(EngineID, SecName3 ++ "_1"),
%% --
- p("stop config process"),
+ ?IPRINT("stop config process"),
?line ok = snmpm_config:stop(),
- await_config_not_running(),
+ config_ensure_not_running(),
%% --
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -2237,8 +2302,8 @@ register_usm_user_failed_using_function1(suite) -> [];
register_usm_user_failed_using_function1(doc) ->
"Register usm user failed using incorrect arguments to API (function).";
register_usm_user_failed_using_function1(Conf) when is_list(Conf) ->
- put(tname,ruufufu1),
- p("start"),
+ put(tname, "REG-USM-USER-FAIL-USING-FUNC"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
case ?CRYPTO_START() of
@@ -2266,8 +2331,8 @@ update_usm_user_info(suite) -> [];
update_usm_user_info(doc) ->
"Update usm user info.";
update_usm_user_info(Conf) when is_list(Conf) ->
- put(tname,ruufufu1),
- p("start"),
+ put(tname, "UPD-USM-USER-INFO"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
case ?CRYPTO_START() of
@@ -2301,8 +2366,8 @@ create_and_increment(suite) -> [];
create_and_increment(doc) ->
"Craete and increment counters.";
create_and_increment(Conf) when is_list(Conf) ->
- put(tname,cai),
- p("start"),
+ put(tname, "CRE-AND-INC"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -2330,7 +2395,7 @@ create_and_increment(Conf) when is_list(Conf) ->
?line EndVal = snmpm_config:incr_counter(test_id, IncVal),
?line ok = snmpm_config:stop(),
- await_config_not_running(),
+ config_ensure_not_running(),
ok.
@@ -2348,8 +2413,8 @@ stats_create_and_increment(suite) -> [];
stats_create_and_increment(doc) ->
"Create and increment statistics counters.";
stats_create_and_increment(Conf) when is_list(Conf) ->
- put(tname,scai),
- p("start"),
+ put(tname, "STATS-CRE-AND-INC"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -2362,26 +2427,26 @@ stats_create_and_increment(Conf) when is_list(Conf) ->
?line {ok, _Pid} = snmpm_config:start_link(Opts),
- p("stats table (1): ~p", [ets:tab2list(snmpm_stats_table)]),
+ ?IPRINT("stats table (1): ~p", [ets:tab2list(snmpm_stats_table)]),
?line 0 = snmpm_config:maybe_cre_stats_counter(stats1, 0),
- p("stats table (2): ~p", [ets:tab2list(snmpm_stats_table)]),
+ ?IPRINT("stats table (2): ~p", [ets:tab2list(snmpm_stats_table)]),
?line ok = snmpm_config:maybe_cre_stats_counter(stats1, 0),
- p("stats table (3): ~p", [ets:tab2list(snmpm_stats_table)]),
+ ?IPRINT("stats table (3): ~p", [ets:tab2list(snmpm_stats_table)]),
?line 1 = snmpm_config:maybe_cre_stats_counter(stats2, 1),
- p("stats table (4): ~p", [ets:tab2list(snmpm_stats_table)]),
+ ?IPRINT("stats table (4): ~p", [ets:tab2list(snmpm_stats_table)]),
?line 10 = snmpm_config:cre_stats_counter(stats3, 10),
- p("stats table (5): ~p", [ets:tab2list(snmpm_stats_table)]),
+ ?IPRINT("stats table (5): ~p", [ets:tab2list(snmpm_stats_table)]),
Stats1Inc = fun() -> snmpm_config:incr_stats_counter(stats1, 1) end,
?line 10 = loop(10, -1, Stats1Inc),
- p("stats table (6): ~p", [ets:tab2list(snmpm_stats_table)]),
+ ?IPRINT("stats table (6): ~p", [ets:tab2list(snmpm_stats_table)]),
?line ok = snmpm_config:reset_stats_counter(stats1),
?line 10 = loop(10, -1, Stats1Inc),
?line ok = snmpm_config:stop(),
- await_config_not_running(),
+ config_ensure_not_running(),
ok.
@@ -2403,46 +2468,46 @@ otp_7219(suite) ->
otp_7219(doc) ->
"Test-case for ticket OTP-7219";
otp_7219(Config) when is_list(Config) ->
- put(tname, otp7219),
- p("start"),
+ put(tname, "OTP-7219"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Config),
DbDir = ?config(manager_db_dir, Config),
- p("write manager configuration"),
+ ?IPRINT("write manager configuration"),
write_manager_conf(ConfDir),
Opts1 = [{versions, [v1]},
{inform_request_behaviour, user},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("start manager config"),
+ ?IPRINT("start manager config"),
?line {ok, _Pid1} = snmpm_config:start_link(Opts1),
- p("get some manager config"),
+ ?IPRINT("get some manager config"),
{ok, {user, _}} = snmpm_config:system_info(net_if_irb),
- p("stop manager config"),
+ ?IPRINT("stop manager config"),
?line ok = snmpm_config:stop(),
- await_config_not_running(),
+ config_ensure_not_running(),
IRB_TO = 15322,
Opts2 = [{versions, [v1]},
{inform_request_behaviour, {user, IRB_TO}},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("start manager config"),
+ ?IPRINT("start manager config"),
?line {ok, _Pid2} = snmpm_config:start_link(Opts2),
- p("get some manager config"),
+ ?IPRINT("get some manager config"),
{ok, {user, IRB_TO}} = snmpm_config:system_info(net_if_irb),
- p("stop manager config"),
+ ?IPRINT("stop manager config"),
?line ok = snmpm_config:stop(),
- await_config_not_running(),
+ config_ensure_not_running(),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -2452,8 +2517,8 @@ otp_8395_1(suite) -> [];
otp_8395_1(doc) ->
"OTP-8395(1)";
otp_8395_1(Conf) when is_list(Conf) ->
- put(tname, otp_8395_1),
- p("start"),
+ put(tname, "OTP-8395-1"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
otp8395(Conf, false, ok),
ok.
@@ -2462,8 +2527,8 @@ otp_8395_2(suite) -> [];
otp_8395_2(doc) ->
"OTP-8395(2)";
otp_8395_2(Conf) when is_list(Conf) ->
- put(tname, otp_8395_2),
- p("start"),
+ put(tname, "OTP-8395-2"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
otp8395(Conf, true, ok),
ok.
@@ -2472,8 +2537,8 @@ otp_8395_3(suite) -> [];
otp_8395_3(doc) ->
"OTP-8395(3)";
otp_8395_3(Conf) when is_list(Conf) ->
- put(tname, otp_8395_3),
- p("start"),
+ put(tname, "OTP-8395-3"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
otp8395(Conf, gurka, error),
ok.
@@ -2487,7 +2552,7 @@ otp8395(Conf, SeqNoVal, Expect) ->
write_manager_conf(ConfDir),
%% Third set of options (no versions):
- p("all options"),
+ ?IPRINT("all options"),
NetIfOpts = [{module, snmpm_net_if},
{verbosity, trace},
{options, [{recbuf, 30000},
@@ -2526,7 +2591,7 @@ otp8395(Conf, SeqNoVal, Expect) ->
Error when (Expect =:= ok) ->
exit({unexpected_failed_starting_config, SeqNoVal, Error})
end,
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -2534,8 +2599,8 @@ otp_8395_4(suite) -> [];
otp_8395_4(doc) ->
"OTP-8395(4)";
otp_8395_4(Conf) when is_list(Conf) ->
- put(tname, otp_8395_4),
- p("start"),
+ put(tname, "OTP-8395-4"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
snmp:print_version_info(),
@@ -2548,7 +2613,7 @@ otp_8395_4(Conf) when is_list(Conf) ->
write_manager_conf(ConfDir),
%% Third set of options (no versions):
- p("all options"),
+ ?IPRINT("all options"),
NetIfOpts = [{module, snmpm_net_if},
{verbosity, trace},
{options, [{recbuf, 30000},
@@ -2595,7 +2660,7 @@ otp_8395_4(Conf) when is_list(Conf) ->
?line ok = config_stop(),
- p("done"),
+ ?IPRINT("done"),
ok.
@@ -2607,52 +2672,17 @@ otp8395_incr_counter(Counter, Initial, Increment, Max) ->
%% Internal functions
%%======================================================================
-await_config_not_running() ->
- await_not_running(snmpm_config, 5).
-
-await_not_running(Name, 0) ->
- p("await_not_running -> done waiting for ~w to die - try kill it", [Name]),
- %% Ok, we tried it the nice way, now use brute force
- await_killed(Name, 5);
-await_not_running(Name, N) when N > 0 ->
- p("await_not_running -> is process ~w still running (~w)", [Name, N]),
- case erlang:whereis(Name) of
- undefined ->
- p("await_not_running -> no such (~w) process - sleep some",[Name]),
- ?SLEEP(1000),
- p("await_not_running -> no such (~w) process - done", [Name]),
- ok;
- Pid when is_pid(Pid) ->
- p("~w process still running", [Name]),
- ?SLEEP(500),
- await_not_running(Name, N-1)
- end.
-
-await_killed(Name, 0) ->
- p("await_killed -> could not kill ~w => giving up", [Name]),
- exit({error, {failed_terminating, Name}});
-await_killed(Name, N) when N > 0 ->
- p("await_killed -> is process ~w still running (~w)", [Name, N]),
- case whereis(Name) of
- undefined ->
- p("await_killed -> no such (~w) process - sleep some", [Name]),
- ?SLEEP(1000),
- p("await_killed -> no such (~w) process - done", [Name]),
- ok;
- Pid when is_pid(Pid) ->
- p("await_killed -> ~w still running - try kill it", [Name]),
- exit(Pid, kill),
- ?SLEEP(1000),
- await_killed(Name, N-1)
- end.
-
-
config_start(Opts) ->
(catch snmpm_config:start_link(Opts)).
config_stop() ->
(catch snmpm_config:stop()).
+config_ensure_not_running() ->
+ ?ENSURE_NOT_RUNNING(snmpm_config,
+ fun() -> snmpm_config:stop() end,
+ 1000).
+
%% ------
@@ -2809,20 +2839,5 @@ verify_dir_existing(DirName, Dir) ->
%% ------
str(X) ->
- lists:flatten(io_lib:format("~w", [X])).
-
-
-%% ------
-
-p(F) ->
- p(F, []).
-
-p(F, A) ->
- p(get(tname), F, A).
-
-p(TName, F, A) ->
- io:format("*** [~s] ***"
- " ~w -> " ++ F ++ "~n", [formated_timestamp(),TName|A]).
+ ?F("~w", [X]).
-formated_timestamp() ->
- snmp_test_lib:formated_timestamp().
diff --git a/lib/snmp/test/snmp_manager_user_SUITE.erl b/lib/snmp/test/snmp_manager_user_SUITE.erl
index 353f1b21f3..eca0d8a4f9 100644
--- a/lib/snmp/test/snmp_manager_user_SUITE.erl
+++ b/lib/snmp/test/snmp_manager_user_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2004-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.
@@ -143,8 +143,8 @@ tickets_cases() ->
init_per_suite(Config0) when is_list(Config0) ->
- p("init_per_suite -> entry with"
- "~n Config0: ~p", [Config0]),
+ ?IPRINT("init_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
case ?LIB:init_per_suite(Config0) of
{skip, _} = SKIP ->
@@ -153,19 +153,23 @@ init_per_suite(Config0) when is_list(Config0) ->
snmp_test_sys_monitor:start(),
Config2 = snmp_test_lib:init_suite_top_dir(?MODULE, Config1),
- p("init_per_suite -> done when"
- "~n Config: ~p", [Config2]),
+ ?IPRINT("init_per_suite -> done when"
+ "~n Config: ~p", [Config2]),
Config2
end.
end_per_suite(Config) when is_list(Config) ->
- p("end_per_suite -> entry with"
- "~n Config: ~p", [Config]),
+ ?IPRINT("end_per_suite -> entry with"
+ "~n Config: ~p", [Config]),
snmp_test_sys_monitor:stop(),
- ?LIB:end_per_suite(Config).
+ Config1 = ?LIB:end_per_suite(Config),
+
+ ?IPRINT("end_per_suite -> end"),
+
+ Config1.
@@ -186,14 +190,15 @@ end_per_group(_GroupName, Config) ->
%%
init_per_testcase(Case, Config) when is_list(Config) ->
- p("init_per_testcase -> Case: ~p", [Case]),
+ ?IPRINT("init_per_testcase -> entry with"
+ "~n Config: ~p", [Config]),
snmp_test_global_sys_monitor:reset_events(),
SuiteTopDir = ?config(snmp_suite_top_dir, Config),
CaseTopDir = filename:join(SuiteTopDir, atom_to_list(Case)),
?line ok = file:make_dir(CaseTopDir),
- p("init_per_testcase -> CaseTopDir: ~p", [CaseTopDir]),
+ ?IPRINT("init_per_testcase -> CaseTopDir: ~p", [CaseTopDir]),
MgrTopDir = filename:join(CaseTopDir, "manager/"),
?line ok = file:make_dir(MgrTopDir),
MgrConfDir = filename:join(MgrTopDir, "conf/"),
@@ -202,18 +207,27 @@ init_per_testcase(Case, Config) when is_list(Config) ->
?line ok = file:make_dir(MgrDbDir),
MgrLogDir = filename:join(MgrTopDir, "log/"),
?line ok = file:make_dir(MgrLogDir),
- [{case_top_dir, CaseTopDir},
- {manager_dir, MgrTopDir},
- {manager_conf_dir, MgrConfDir},
- {manager_db_dir, MgrDbDir},
- {manager_log_dir, MgrLogDir} | Config].
+ Config1 = [{case_top_dir, CaseTopDir},
+ {manager_dir, MgrTopDir},
+ {manager_conf_dir, MgrConfDir},
+ {manager_db_dir, MgrDbDir},
+ {manager_log_dir, MgrLogDir} | Config],
+
+ ?IPRINT("init_per_testcase -> done when"
+ "~n Config: ~p", [Config1]),
+
+ Config1.
+
+
+end_per_testcase(_Case, Config) when is_list(Config) ->
-end_per_testcase(Case, Config) when is_list(Config) ->
- p("end_per_testcase -> Case: ~p", [Case]),
+ ?IPRINT("end_per_testcase -> entry with"
+ "~n Config: ~p",
+ [Config]),
- p("system events during test: "
- "~n ~p~n", [snmp_test_global_sys_monitor:events()]),
+ ?IPRINT("system events during test: ~p",
+ [snmp_test_global_sys_monitor:events()]),
Config.
@@ -228,7 +242,7 @@ simple_register_and_unregister1(doc) ->
"Start a user, register and unregister the user.";
simple_register_and_unregister1(Conf) when is_list(Conf) ->
put(tname,srar1),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -241,7 +255,7 @@ simple_register_and_unregister1(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -251,23 +265,23 @@ simple_register_and_unregister1(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user(Pid, Id),
?line [Id] = Users2 = which_users(),
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = unregister_user(Pid),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
?line stop_user(Pid),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -279,7 +293,7 @@ simple_register_and_unregister2(doc) ->
"register 2 users (per that process) and unregister the 2 users.";
simple_register_and_unregister2(Conf) when is_list(Conf) ->
put(tname,srar2),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -292,7 +306,7 @@ simple_register_and_unregister2(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -303,7 +317,7 @@ simple_register_and_unregister2(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user(Pid, Id1),
?line ok = register_user(Pid, Id2),
@@ -316,20 +330,20 @@ simple_register_and_unregister2(Conf) when is_list(Conf) ->
Else ->
?FAIL({invalid_users, Else})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = unregister_user(Pid, Id1),
?line ok = unregister_user(Pid, Id2),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
?line stop_user(Pid),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -341,7 +355,7 @@ simple_register_and_unregister3(doc) ->
"register one users per process and unregister the 2 users.";
simple_register_and_unregister3(Conf) when is_list(Conf) ->
put(tname,srar2),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -354,7 +368,7 @@ simple_register_and_unregister3(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -366,7 +380,7 @@ simple_register_and_unregister3(Conf) when is_list(Conf) ->
?line Pid2 = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user(Pid1, Id1),
?line ok = register_user(Pid2, Id2),
@@ -379,21 +393,21 @@ simple_register_and_unregister3(Conf) when is_list(Conf) ->
Else ->
?FAIL({invalid_users, Else})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = unregister_user(Pid1, Id1),
?line ok = unregister_user(Pid2, Id2),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
?line stop_user(Pid1),
?line stop_user(Pid2),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -404,7 +418,7 @@ register_and_crash1(doc) ->
"Start a user, register and crash user.";
register_and_crash1(Conf) when is_list(Conf) ->
put(tname,racau1),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -417,7 +431,7 @@ register_and_crash1(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
?line ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -427,22 +441,22 @@ register_and_crash1(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user(Pid, Id),
?line [Id] = Users2 = which_users(),
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = simulate_crash(Pid),
?line [Id] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -454,7 +468,7 @@ register_and_crash2(doc) ->
"register 2 users (per that process) and crash the process.";
register_and_crash2(Conf) when is_list(Conf) ->
put(tname,racau2),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -467,7 +481,7 @@ register_and_crash2(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
?line ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -478,7 +492,7 @@ register_and_crash2(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user(Pid, Id1),
?line ok = register_user(Pid, Id2),
@@ -491,7 +505,7 @@ register_and_crash2(Conf) when is_list(Conf) ->
Else1 ->
?FAIL({invalid_users, Else1})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = simulate_crash(Pid),
@@ -503,12 +517,12 @@ register_and_crash2(Conf) when is_list(Conf) ->
Else2 ->
?FAIL({invalid_users, Else2})
end,
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -521,7 +535,7 @@ register_and_crash3(doc) ->
"crash the first user process.";
register_and_crash3(Conf) when is_list(Conf) ->
%% put(tname,rac3),
- %% p("start"),
+ %% ?IPRINT("start"),
%% process_flag(trap_exit, true),
?SKIP(not_yet_implemented).
@@ -534,7 +548,7 @@ register_request_and_crash1(doc) ->
"register user, send request and crash user.";
register_request_and_crash1(Conf) when is_list(Conf) ->
%% put(tname,rrac1),
- %% p("start"),
+ %% ?IPRINT("start"),
%% process_flag(trap_exit, true),
?SKIP(not_yet_implemented).
@@ -548,7 +562,7 @@ register_request_and_crash2(doc) ->
"send a request for each user and crash the single user process.";
register_request_and_crash2(Conf) when is_list(Conf) ->
%% put(tname,rrac2),
- %% p("start"),
+ %% ?IPRINT("start"),
%% process_flag(trap_exit, true),
?SKIP(not_yet_implemented).
@@ -562,7 +576,7 @@ register_request_and_crash3(doc) ->
"send a request for each user and crash the first user process.";
register_request_and_crash3(Conf) when is_list(Conf) ->
%% put(tname,rrac3),
- %% p("start"),
+ %% ?IPRINT("start"),
%% process_flag(trap_exit, true),
?SKIP(not_yet_implemented).
@@ -574,7 +588,7 @@ simple_register_monitor_and_unregister1(doc) ->
"Start a user, register-link and unregister the user.";
simple_register_monitor_and_unregister1(Conf) when is_list(Conf) ->
put(tname,srlau1),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -587,41 +601,41 @@ simple_register_monitor_and_unregister1(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start_link(Opts),
?SLEEP(1000),
Id = make_ref(),
- p("start user"),
+ ?IPRINT("start user"),
?line Pid = start_user(),
- p("get users (=0)"),
+ ?IPRINT("get users (=0)"),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
- p("register monitored user"),
+ ?IPRINT("register monitored user"),
?line ok = register_user_monitor(Pid, Id),
- p("get users (=1)"),
+ ?IPRINT("get users (=1)"),
?line [Id] = Users2 = which_users(),
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
- p("unregister monitored user"),
+ ?IPRINT("unregister monitored user"),
?line unregister_user(Pid),
- p("get users (=0)"),
+ ?IPRINT("get users (=0)"),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
- p("start user"),
+ ?IPRINT("start user"),
?line stop_user(Pid),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -634,7 +648,7 @@ simple_register_monitor_and_unregister2(doc) ->
"unregister the 2 users.";
simple_register_monitor_and_unregister2(Conf) when is_list(Conf) ->
put(tname,srlau2),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -647,7 +661,7 @@ simple_register_monitor_and_unregister2(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -658,7 +672,7 @@ simple_register_monitor_and_unregister2(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user_monitor(Pid, Id1),
?line ok = register_user_monitor(Pid, Id2),
@@ -671,19 +685,19 @@ simple_register_monitor_and_unregister2(Conf) when is_list(Conf) ->
Else ->
?FAIL({invalid_users, Else})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = unregister_user(Pid, Id1),
?line ok = unregister_user(Pid, Id2),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
?line stop_user(Pid),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -697,7 +711,7 @@ simple_register_monitor_and_unregister3(doc) ->
"unregister the 2 users.";
simple_register_monitor_and_unregister3(Conf) when is_list(Conf) ->
put(tname,srlau3),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -710,7 +724,7 @@ simple_register_monitor_and_unregister3(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -721,7 +735,7 @@ simple_register_monitor_and_unregister3(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user(Pid, Id1),
?line ok = register_user_monitor(Pid, Id2),
@@ -734,18 +748,18 @@ simple_register_monitor_and_unregister3(Conf) when is_list(Conf) ->
Else ->
?FAIL({invalid_users, Else})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line unregister_user(Pid),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
?line stop_user(Pid),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -756,7 +770,7 @@ register_monitor_and_crash1(doc) ->
"Start a user, register-monitor and crash the user.";
register_monitor_and_crash1(Conf) when is_list(Conf) ->
put(tname,rlac1),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -769,7 +783,7 @@ register_monitor_and_crash1(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
?line ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -779,24 +793,24 @@ register_monitor_and_crash1(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user_monitor(Pid, Id),
?line [Id] = Users2 = which_users(),
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = simulate_crash(Pid),
?SLEEP(1000),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -809,7 +823,7 @@ register_monitor_and_crash2(doc) ->
"and crash the single user process.";
register_monitor_and_crash2(Conf) when is_list(Conf) ->
put(tname,rlac2),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -822,7 +836,7 @@ register_monitor_and_crash2(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
?line ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -833,7 +847,7 @@ register_monitor_and_crash2(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user_monitor(Pid, Id1),
?line ok = register_user_monitor(Pid, Id2),
@@ -846,19 +860,19 @@ register_monitor_and_crash2(Conf) when is_list(Conf) ->
Else ->
?FAIL({invalid_users, Else})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = simulate_crash(Pid),
?SLEEP(1000),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -901,7 +915,7 @@ register_monitor_and_crash3(Conf) when is_list(Conf) ->
?NON_PC_TC_MAYBE_SKIP(Conf, Condition),
%% </CONDITIONAL-SKIP>
- p("start"),
+ ?IPRINT("start"),
ConfDir = ?config(manager_conf_dir, Conf),
DbDir = ?config(manager_db_dir, Conf),
@@ -913,7 +927,7 @@ register_monitor_and_crash3(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
?line ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -924,7 +938,7 @@ register_monitor_and_crash3(Conf) when is_list(Conf) ->
?line Pid = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user(Pid, Id1),
?line ok = register_user_monitor(Pid, Id2),
@@ -937,19 +951,19 @@ register_monitor_and_crash3(Conf) when is_list(Conf) ->
Else ->
?FAIL({invalid_users, Else})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = simulate_crash(Pid),
?SLEEP(1000),
?line [Id1] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -962,7 +976,7 @@ register_monitor_and_crash4(doc) ->
"and crash the first user process.";
register_monitor_and_crash4(Conf) when is_list(Conf) ->
put(tname,rlac4),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -975,7 +989,7 @@ register_monitor_and_crash4(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("start manager"),
+ ?IPRINT("start manager"),
?line ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -983,12 +997,12 @@ register_monitor_and_crash4(Conf) when is_list(Conf) ->
Id1 = make_ref(),
Id2 = make_ref(),
- p("start user processes"),
+ ?IPRINT("start user processes"),
?line Pid1 = start_user(),
?line Pid2 = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user_monitor(Pid1, Id1),
?line ok = register_user_monitor(Pid2, Id2),
@@ -1001,21 +1015,21 @@ register_monitor_and_crash4(Conf) when is_list(Conf) ->
Else ->
?FAIL({invalid_users, Else})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = simulate_crash(Pid1),
?SLEEP(1000),
?line [Id2] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
?line stop_user(Pid2),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -1030,7 +1044,7 @@ register_monitor_and_crash5(doc) ->
"and crash the first user process.";
register_monitor_and_crash5(Conf) when is_list(Conf) ->
put(tname,rlac4),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -1043,7 +1057,7 @@ register_monitor_and_crash5(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("start manager"),
+ ?IPRINT("start manager"),
?line ok = snmpm:start_link(Opts),
?SLEEP(1000),
@@ -1051,12 +1065,12 @@ register_monitor_and_crash5(Conf) when is_list(Conf) ->
Id1 = gurka, %% make_ref(),
Id2 = tomat, %% make_ref(),
- p("start user processes"),
+ ?IPRINT("start user processes"),
?line Pid1 = start_user(),
?line Pid2 = start_user(),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = register_user_monitor(Pid1, Id1),
?line ok = register_user_monitor(Pid2, Id2),
@@ -1090,9 +1104,9 @@ register_monitor_and_crash5(Conf) when is_list(Conf) ->
U3 ->
?FAIL({invalid_users, U3})
end,
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
- p("verify all agent(s): expect 2"),
+ ?IPRINT("verify all agent(s): expect 2"),
?line Agents1 = case which_agents() of
[TargetName1, TargetName2] = A1 ->
A1;
@@ -1101,25 +1115,25 @@ register_monitor_and_crash5(Conf) when is_list(Conf) ->
A3 ->
?FAIL({invalid_agents, A3})
end,
- p("Agents1: ~p", [Agents1]),
+ ?IPRINT("Agents1: ~p", [Agents1]),
?line ok = simulate_crash(Pid1),
- p("wait some time"),
+ ?IPRINT("wait some time"),
?SLEEP(1000),
?line [Id2] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
?line [TargetName2] = Agents2 = which_agents(),
- p("Agents2: ~p", [Agents2]),
+ ?IPRINT("Agents2: ~p", [Agents2]),
?line stop_user(Pid2),
- p("stop manager"),
+ ?IPRINT("stop manager"),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -1132,7 +1146,7 @@ register_monitor_request_and_crash1(doc) ->
"send request and crash the user.";
register_monitor_request_and_crash1(Conf) when is_list(Conf) ->
%% put(tname,rlrac1),
- %% p("start"),
+ %% ?IPRINT("start"),
%% process_flag(trap_exit, true),
?SKIP(not_yet_implemented).
@@ -1146,7 +1160,7 @@ register_monitor_request_and_crash2(doc) ->
"send a request for each user and crash the single user process.";
register_monitor_request_and_crash2(Conf) when is_list(Conf) ->
%% put(tname,rlrac2),
- %% p("start"),
+ %% ?IPRINT("start"),
%% process_flag(trap_exit, true),
?SKIP(not_yet_implemented).
@@ -1160,7 +1174,7 @@ register_monitor_request_and_crash3(doc) ->
"send a request for each user and crash the single user process.";
register_monitor_request_and_crash3(Conf) when is_list(Conf) ->
%% put(tname,rlrac3),
- %% p("start"),
+ %% ?IPRINT("start"),
%% process_flag(trap_exit, true),
?SKIP(not_yet_implemented).
@@ -1176,7 +1190,7 @@ register_monitor_request_and_crash4(doc) ->
"crash the first user process.";
register_monitor_request_and_crash4(Conf) when is_list(Conf) ->
%% put(tname,rlrac4),
- %% p("start"),
+ %% ?IPRINT("start"),
%% process_flag(trap_exit, true),
?SKIP(not_yet_implemented).
@@ -1189,7 +1203,7 @@ otp7902(doc) ->
"OTP-7902 - Start old user and make sure it wors.";
otp7902(Conf) when is_list(Conf) ->
put(tname, otp7902),
- p("start"),
+ ?IPRINT("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
@@ -1202,27 +1216,27 @@ otp7902(Conf) when is_list(Conf) ->
{note_store, [{verbosity, trace}]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
- p("try starting manager"),
+ ?IPRINT("try starting manager"),
ok = snmpm:start_link(Opts),
?SLEEP(1000),
?line [] = Users1 = which_users(),
- p("Users1: ~p", [Users1]),
+ ?IPRINT("Users1: ~p", [Users1]),
?line ok = snmp_manager_user_old:start(),
?line [_] = Users2 = which_users(),
- p("Users2: ~p", [Users2]),
+ ?IPRINT("Users2: ~p", [Users2]),
?line ok = snmp_manager_user_old:stop(),
?line [] = Users3 = which_users(),
- p("Users3: ~p", [Users3]),
+ ?IPRINT("Users3: ~p", [Users3]),
?line ok = snmpm:stop(),
- p("end"),
+ ?IPRINT("end"),
ok.
@@ -1306,15 +1320,3 @@ write_conf_file(Dir, File, Str) ->
?line ok = io:format(Fd, "~s", [Str]),
file:close(Fd).
-
-%% ------
-
-p(F) ->
- p(F, []).
-
-p(F, A) ->
- p(get(tname), F, A).
-
-p(TName, F, A) ->
- io:format("~w -> " ++ F ++ "~n", [TName|A]).
-
diff --git a/lib/snmp/test/snmp_note_store_SUITE.erl b/lib/snmp/test/snmp_note_store_SUITE.erl
index 832c03029e..3b6d9f9fcd 100644
--- a/lib/snmp/test/snmp_note_store_SUITE.erl
+++ b/lib/snmp/test/snmp_note_store_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2004-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.
@@ -81,11 +81,34 @@ groups() ->
%% -----
%%
-init_per_suite(Config) when is_list(Config) ->
- Config.
+init_per_suite(Config0) when is_list(Config0) ->
+ ?IPRINT("init_per_suite -> entry with"
+ "~n Config: ~p", [Config0]),
-end_per_suite(Config) when is_list(Config) ->
- Config.
+ case ?LIB:init_per_suite(Config0) of
+ {skip, _} = SKIP ->
+ SKIP;
+
+ Config1 when is_list(Config1) ->
+ %% We need a monitor on this node also
+ snmp_test_sys_monitor:start(),
+
+ ?IPRINT("init_per_suite -> end when"
+ "~n Config1: ~p", [Config1]),
+
+ Config1
+ end.
+
+end_per_suite(Config0) when is_list(Config0) ->
+ ?IPRINT("end_per_suite -> entry with"
+ "~n Config: ~p", [Config0]),
+
+ snmp_test_sys_monitor:stop(),
+ Config1 = ?LIB:end_per_suite(Config0),
+
+ ?IPRINT("end_per_suite -> end"),
+
+ Config1.
@@ -106,9 +129,24 @@ end_per_group(_GroupName, Config) ->
%%
init_per_testcase(_Case, Config) when is_list(Config) ->
+ ?IPRINT("init_per_testcase -> entry with"
+ "~n Config: ~p", [Config]),
+
+ snmp_test_global_sys_monitor:reset_events(),
+
+ ?IPRINT("init_per_testcase -> end"),
+
Config.
end_per_testcase(_Case, Config) when is_list(Config) ->
+
+ ?IPRINT("end_per_testcase -> entry with"
+ "~n Config: ~p",
+ [Config]),
+
+ ?IPRINT("system events during test: ~p",
+ [snmp_test_global_sys_monitor:events()]),
+
Config.
@@ -143,42 +181,55 @@ notes(doc) ->
["Testing that it does what it is actually supposed to do, "
"namilly to handle notes. "];
notes(Config) when is_list(Config) ->
-
- {ok, Handler, Pid} = note_store_handler_start(),
-
- io:format("sleep some before we begin the tests~n", []),
- ?SLEEP(timer:seconds(1)),
+ Pre = fun() ->
+ ?IPRINT("try start note-store"),
+ case note_store_handler_start() of
+ {ok, Handler, Pid} ->
+ ?IPRINT("started - sleep some before we begin the tests"),
+ ?SLEEP(?SECS(1)),
+ {Handler, Pid};
+ {error, Reason} ->
+ {skip, ?F("Failed starting note-store: ~p", [Reason])}
+ end
+ end,
+ Case = fun(State) -> do_notes(State, Config) end,
+ Post = fun({Handler, _Pid}) ->
+ note_store_handler_stop(Handler)
+ end,
+ ?TC_TRY(notes, Pre, Case, Post).
+
+do_notes({_, Pid}, _Config) ->
%% Default lifetime is infinity. A note with lifetime
%% infinity is permanent
- io:format("create permanent note sune~n", []),
+ ?IPRINT("create permanent note: sune"),
true = snmp_note_store:set_note(Pid, sune, 10),
10 = snmp_note_store:get_note(Pid, sune),
10 = snmp_note_store:get_note(Pid, sune),
%% Lifetime is in 1/100 sec ticks, so 500 equals 5 seconds
- io:format("create 5 sec note kalle~n", []),
+ ?IPRINT("create 5 sec note kalle"),
true = snmp_note_store:set_note(Pid, 500, kalle, hobbe),
- io:format("wait 1 sec~n", []),
+ ?IPRINT("wait 1 sec"),
?SLEEP(timer:seconds(1)),
- io:format("get note kalle~n", []),
+ ?IPRINT("get note kalle"),
hobbe = snmp_note_store:get_note(Pid, kalle),
- io:format("wait 5 sec~n", []),
+ ?IPRINT("wait 5 sec"),
?SLEEP(timer:seconds(5)),
- io:format("get note kalle again (now it should not exist)~n", []),
+ ?IPRINT("get note kalle again (now it should not exist)"),
undefined = snmp_note_store:get_note(Pid, kalle),
- io:format("create 5 sec note kalle~n", []),
+ ?IPRINT("create 5 sec note kalle"),
true = snmp_note_store:set_note(Pid, 500, kalle, hobbe),
- io:format("wait 6 sec (to allow timer to clean up note)~n", []),
+ ?IPRINT("wait 6 sec (to allow timer to clean up note)"),
?SLEEP(timer:seconds(6)),
- io:format("get note kalle - should not exist~n", []),
+ ?IPRINT("get note kalle - should not exist"),
undefined = snmp_note_store:get_note(Pid, kalle),
- io:format("read the permanent note sune again~n", []),
+ ?IPRINT("read the permanent note sune again"),
10 = snmp_note_store:get_note(Pid, sune),
- note_store_handler_stop(Handler),
+ ?IPRINT("done"),
ok.
@@ -190,47 +241,65 @@ info(suite) ->
info(doc) ->
["Testing that we can retreive process info."];
info(Config) when is_list(Config) ->
-
- Prio = normal,
- Mod = ?MODULE,
- Opts = [{verbosity, trace}],
- {ok, Pid} = snmp_note_store:start_link(Prio, Mod, Opts),
+ Pre = fun() ->
+ ?IPRINT("try start note-store"),
+ Prio = normal,
+ Mod = ?MODULE,
+ Opts = [{verbosity, trace}],
+ case snmp_note_store:start_link(Prio, Mod, Opts) of
+ {ok, Pid} ->
+ ?IPRINT("note-store started: ~p", [Pid]),
+ Pid;
+ {error, Reason} ->
+ {skip, ?F("Failed starting note-store: ~p", [Reason])}
+ end
+ end,
+ Case = fun(State) -> do_info(State, Config) end,
+ Post = fun(Pid) ->
+ ?IPRINT("attempt stop note-store"),
+ snmp_note_store:stop(Pid)
+ end,
+ ?TC_TRY(info, Pre, Case, Post).
+
+do_info(Pid, _Config) ->
%% Get the info:
+ ?IPRINT("get initial info"),
Info = snmp_note_store:info(Pid),
- io:format("Info: ~p~n", [Info]),
+ ?IPRINT("Info: "
+ "~n ~p", [Info]),
%% Verify content
- io:format("get process memory~n", []),
+ ?IPRINT("verify content: get notes process memory"),
{value, {process_memory, ProcMem}} =
lists:keysearch(process_memory, 1, Info),
- io:format("get notes process memory~n", []),
+ ?IPRINT("get notes process memory"),
{value, {notes, NotesProcMem}} =
lists:keysearch(notes, 1, ProcMem),
- io:format("verify notes process memory~n", []),
+ ?IPRINT("verify notes process memory"),
if
is_integer(NotesProcMem) andalso (NotesProcMem > 0) ->
ok;
true ->
throw({error, {bad_notes_proc_memery, NotesProcMem}})
end,
- io:format("get timer process memory~n", []),
+ ?IPRINT("verify content: get timer process memory"),
{value, {timer, TmrProcMem}} =
lists:keysearch(timer, 1, ProcMem),
- io:format("verify timer process memory~n", []),
+ ?IPRINT("verify content: timer process memory"),
if
is_integer(TmrProcMem) andalso (TmrProcMem > 0) ->
ok;
true ->
throw({error, {bad_timer_proc_memery, TmrProcMem}})
end,
- io:format("get db memory~n", []),
+ ?IPRINT("verify content: get db memory"),
{value, {db_memory, DbMem}} =
lists:keysearch(db_memory, 1, Info),
- io:format("get notes db memory~n", []),
+ ?IPRINT("verify content: get notes db memory"),
{value, {notes, NotesDbMem}} =
lists:keysearch(notes, 1, DbMem),
- io:format("verify notes db memory~n", []),
+ ?IPRINT("verify content: notes db memory"),
if
is_integer(NotesDbMem) andalso (NotesDbMem > 0) ->
ok;
@@ -238,9 +307,7 @@ info(Config) when is_list(Config) ->
throw({error, {bad_notes_db_memery, NotesDbMem}})
end,
-
- snmp_note_store:stop(Pid),
-
+ ?IPRINT("done"),
ok.
@@ -251,23 +318,38 @@ garbage_in(suite) ->
garbage_in(doc) ->
["Test that the process handles garbage sent to it."];
garbage_in(Config) when is_list(Config) ->
-
- io:format("start note_store server~n", []),
- Prio = normal,
- Mod = ?MODULE,
- Opts = [{verbosity, trace}],
- {ok, Pid} = snmp_note_store:start_link(Prio, Mod, Opts),
-
- io:format("issue bad request~n", []),
+ Pre = fun() ->
+ ?IPRINT("try start note-store"),
+ Prio = normal,
+ Mod = ?MODULE,
+ Opts = [{verbosity, trace}],
+ case snmp_note_store:start_link(Prio, Mod, Opts) of
+ {ok, Pid} ->
+ ?IPRINT("note-store started: ~p", [Pid]),
+ Pid;
+ {error, Reason} ->
+ {skip, ?F("Failed starting note-store: ~p", [Reason])}
+ end
+ end,
+ Case = fun(State) -> do_garbage_in(State, Config) end,
+ Post = fun(Pid) ->
+ ?IPRINT("attempt stop note-store"),
+ snmp_note_store:stop(Pid)
+ end,
+ ?TC_TRY(garbage_in, Pre, Case, Post).
+
+do_garbage_in(Pid, _Config) ->
+
+ ?IPRINT("issue bad request"),
{error, _} = gen_server:call(Pid, bad_request),
- io:format("cast bad message~n", []),
+ ?IPRINT("cast bad message"),
gen_server:cast(Pid, bad_message),
- io:format("bang bad info~n", []),
+ ?IPRINT("bang bad info"),
Pid ! bad_info,
- io:format("verify note_Store server still alive and kicking~n", []),
+ ?IPRINT("verify note-store server still alive and kicking"),
Info = snmp_note_store:info(Pid),
if
is_list(Info) andalso (length(Info) > 0) ->
@@ -276,10 +358,7 @@ garbage_in(Config) when is_list(Config) ->
throw({error, {bad_info, Info}})
end,
- io:format("stop note_store server~n", []),
- snmp_note_store:stop(Pid),
-
- io:format("done~n", []),
+ ?IPRINT("done"),
ok.
diff --git a/lib/snmp/test/snmp_pdus_SUITE.erl b/lib/snmp/test/snmp_pdus_SUITE.erl
index f49e2eb602..d70e7aebd0 100644
--- a/lib/snmp/test/snmp_pdus_SUITE.erl
+++ b/lib/snmp/test/snmp_pdus_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2003-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.
@@ -75,11 +75,34 @@ tickets_cases() ->
%% -----
%%
-init_per_suite(Config) when is_list(Config) ->
- Config.
+init_per_suite(Config0) when is_list(Config0) ->
+ ?IPRINT("init_per_suite -> entry with"
+ "~n Config: ~p", [Config0]),
-end_per_suite(Config) when is_list(Config) ->
- Config.
+ case ?LIB:init_per_suite(Config0) of
+ {skip, _} = SKIP ->
+ SKIP;
+
+ Config1 when is_list(Config1) ->
+ %% We need a monitor on this node also
+ snmp_test_sys_monitor:start(),
+
+ ?IPRINT("init_per_suite -> end when"
+ "~n Config1: ~p", [Config1]),
+
+ Config1
+ end.
+
+end_per_suite(Config0) when is_list(Config0) ->
+ ?IPRINT("end_per_suite -> entry with"
+ "~n Config: ~p", [Config0]),
+
+ snmp_test_sys_monitor:stop(),
+ Config1 = ?LIB:end_per_suite(Config0),
+
+ ?IPRINT("end_per_suite -> end"),
+
+ Config1.
@@ -100,9 +123,24 @@ end_per_group(_GroupName, Config) ->
%%
init_per_testcase(_Case, Config) when is_list(Config) ->
+ ?IPRINT("init_per_testcase -> entry with"
+ "~n Config: ~p", [Config]),
+
+ snmp_test_global_sys_monitor:reset_events(),
+
+ ?IPRINT("init_per_testcase -> end"),
+
Config.
end_per_testcase(_Case, Config) when is_list(Config) ->
+
+ ?IPRINT("end_per_testcase -> entry with"
+ "~n Config: ~p",
+ [Config]),
+
+ ?IPRINT("system events during test: ~p",
+ [snmp_test_global_sys_monitor:events()]),
+
Config.
@@ -114,7 +152,7 @@ end_per_testcase(_Case, Config) when is_list(Config) ->
otp7575(suite) -> [];
otp7575(doc) -> ["OTP-7575 - Message version"];
otp7575(Config) when is_list(Config) ->
- io:format("attempt to decode message with valid version~n", []),
+ ?IPRINT("attempt to decode message with valid version"),
MsgWithOkVersion = <<48,39,2,1,0,4,6,112,117,98,108,105,99,160,26,2,2,1,49,2,1,0,2,1,0,48,14,48,12,6,8,43,6,1,2,1,1,5,0,5,0>>,
case (catch dec_message(MsgWithOkVersion)) of
Msg when is_record(Msg, message) ->
@@ -123,7 +161,7 @@ otp7575(Config) when is_list(Config) ->
exit({unexpected_decode_result, 1, Unexpected1})
end,
- io:format("attempt to decode message with bad version~n", []),
+ ?IPRINT("attempt to decode message with bad version"),
MsgWithBadVersion = <<48,48,2,10,1,1,1,1,1,1,1,1,1,1,4,6,112,117,98,108,105,99,160,26,2,2,1,49,2,1,0,2,1,0,48,14,48,12,6,8,43,6,1,2,1,1,5,0,5,0>>,
case (catch dec_message(MsgWithBadVersion)) of
{'EXIT', {bad_version, BadVersion}} when is_integer(BadVersion) ->
@@ -132,7 +170,7 @@ otp7575(Config) when is_list(Config) ->
exit({unexpected_decode_result, 2, Unexpected2})
end,
- io:format("attempt to decode message with very bad version~n", []),
+ ?IPRINT("attempt to decode message with very bad version"),
MsgWithVeryBadVersion = <<48,49,2,11,1,1,1,1,1,1,1,1,1,1,1,4,6,112,117,98,108,105,99,160,26,2,2,1,49,2,1,0,2,1,0,48,14,48,12,6,8,43,6,1,2,1,1,5,0,5,0>>,
case (catch dec_message(MsgWithVeryBadVersion)) of
{'EXIT', {bad_version, {VersionSize, MaxVersionSize}}} when (VersionSize > MaxVersionSize) ->
@@ -140,7 +178,7 @@ otp7575(Config) when is_list(Config) ->
Unexpected3 ->
exit({unexpected_decode_result, 3, Unexpected3})
end,
- io:format("done~n", []),
+ ?IPRINT("done"),
ok.
@@ -148,52 +186,52 @@ otp8563(suite) -> [];
otp8563(doc) -> ["OTP-8563 - Counter64"];
otp8563(Config) when is_list(Config) ->
Val1 = 16#7fffffffffffffff,
- io:format("try encode and decode value 1: ~w (0x~.16b)~n", [Val1, Val1]),
+ ?IPRINT("try encode and decode value 1: ~w (0x~.16b)", [Val1, Val1]),
Enc1 = snmp_pdus:enc_value('Counter64', Val1),
- io:format(" => ~w~n", [Enc1]),
+ ?IPRINT(" => ~w", [Enc1]),
{{'Counter64', Val1}, []} = snmp_pdus:dec_value(Enc1),
Val2 = Val1 + 1,
- io:format("try encode and decode value 2: ~w (0x~.16b)~n", [Val2, Val2]),
+ ?IPRINT("try encode and decode value 2: ~w (0x~.16b)", [Val2, Val2]),
Enc2 = snmp_pdus:enc_value('Counter64', Val2),
- io:format(" => ~w~n", [Enc2]),
+ ?IPRINT(" => ~w", [Enc2]),
{{'Counter64', Val2}, []} = snmp_pdus:dec_value(Enc2),
Val3 = Val2 + 1,
- io:format("try encode and decode value 3: ~w (0x~.16b)~n", [Val3, Val3]),
+ ?IPRINT("try encode and decode value 3: ~w (0x~.16b)", [Val3, Val3]),
Enc3 = snmp_pdus:enc_value('Counter64', Val3),
- io:format(" => ~w~n", [Enc3]),
+ ?IPRINT(" => ~w", [Enc3]),
{{'Counter64', Val3}, []} = snmp_pdus:dec_value(Enc3),
Val4 = 16#fffffffffffffffe,
- io:format("try encode and decode value 4: ~w (0x~.16b)~n", [Val4, Val4]),
+ ?IPRINT("try encode and decode value 4: ~w (0x~.16b)", [Val4, Val4]),
Enc4 = snmp_pdus:enc_value('Counter64', Val4),
- io:format(" => ~w~n", [Enc4]),
+ ?IPRINT(" => ~w", [Enc4]),
{{'Counter64', Val4}, []} = snmp_pdus:dec_value(Enc4),
Val5 = Val4 + 1,
- io:format("try encode and decode value 5: ~w (0x~.16b)~n", [Val5, Val5]),
+ ?IPRINT("try encode and decode value 5: ~w (0x~.16b)", [Val5, Val5]),
Enc5 = snmp_pdus:enc_value('Counter64', Val5),
- io:format(" => ~w~n", [Enc5]),
+ ?IPRINT(" => ~w", [Enc5]),
{{'Counter64', Val5}, []} = snmp_pdus:dec_value(Enc5),
Val6 = 16#ffffffffffffffff + 1,
- io:format("try and fail to encode value 6: ~w (0x~.16b)~n", [Val6, Val6]),
+ ?IPRINT("try and fail to encode value 6: ~w (0x~.16b)", [Val6, Val6]),
case (catch snmp_pdus:enc_value('Counter64', Val6)) of
{'EXIT', {error, {bad_counter64, Val6}}} ->
ok;
Unexpected6 ->
- io:format(" => ~w~n", [Unexpected6]),
+ ?IPRINT(" => ~w", [Unexpected6]),
exit({unexpected_encode_result, Unexpected6, Val6})
end,
Val7 = -1,
- io:format("try and fail to encode value 7: ~w~n", [Val7]),
+ ?IPRINT("try and fail to encode value 7: ~w", [Val7]),
case (catch snmp_pdus:enc_value('Counter64', Val7)) of
{'EXIT', {error, {bad_counter64, Val7}}} ->
ok;
Unexpected7 ->
- io:format(" => ~w~n", [Unexpected7]),
+ ?IPRINT(" => ~w", [Unexpected7]),
exit({unexpected_encode_result, Unexpected7, Val7})
end,
@@ -204,70 +242,70 @@ otp9022(suite) -> [];
otp9022(doc) -> ["OTP-9022 - Counter32"];
otp9022(Config) when is_list(Config) ->
Val0 = 2908389204,
- io:format("try encode and decode value 0: ~w (0x~.16b)~n", [Val0, Val0]),
+ ?IPRINT("try encode and decode value 0: ~w (0x~.16b)", [Val0, Val0]),
Enc0 = snmp_pdus:enc_value('Counter32', Val0),
- io:format(" => ~w~n", [Enc0]),
+ ?IPRINT(" => ~w", [Enc0]),
{{'Counter32', Val0}, []} = snmp_pdus:dec_value(Enc0),
Val1 = 0,
- io:format("try encode and decode value 1: ~w (0x~.16b)~n", [Val1, Val1]),
+ ?IPRINT("try encode and decode value 1: ~w (0x~.16b)", [Val1, Val1]),
Enc1 = snmp_pdus:enc_value('Counter32', Val1),
- io:format(" => ~w~n", [Enc1]),
+ ?IPRINT(" => ~w", [Enc1]),
{{'Counter32', Val1}, []} = snmp_pdus:dec_value(Enc1),
Val2 = Val1 + 1,
- io:format("try encode and decode value 2: ~w (0x~.16b)~n", [Val2, Val2]),
+ ?IPRINT("try encode and decode value 2: ~w (0x~.16b)", [Val2, Val2]),
Enc2 = snmp_pdus:enc_value('Counter32', Val2),
- io:format(" => ~w~n", [Enc2]),
+ ?IPRINT(" => ~w", [Enc2]),
{{'Counter32', Val2}, []} = snmp_pdus:dec_value(Enc2),
Val3 = 16#7ffffffe,
- io:format("try encode and decode value 3: ~w (0x~.16b)~n", [Val3, Val3]),
+ ?IPRINT("try encode and decode value 3: ~w (0x~.16b)", [Val3, Val3]),
Enc3 = snmp_pdus:enc_value('Counter32', Val3),
- io:format(" => ~w~n", [Enc3]),
+ ?IPRINT(" => ~w", [Enc3]),
{{'Counter32', Val3}, []} = snmp_pdus:dec_value(Enc3),
Val4 = Val3 + 1,
- io:format("try encode and decode value 4: ~w (0x~.16b)~n", [Val4, Val4]),
+ ?IPRINT("try encode and decode value 4: ~w (0x~.16b)", [Val4, Val4]),
Enc4 = snmp_pdus:enc_value('Counter32', Val4),
- io:format(" => ~w~n", [Enc4]),
+ ?IPRINT(" => ~w", [Enc4]),
{{'Counter32', Val4}, []} = snmp_pdus:dec_value(Enc4),
Val5 = Val4 + 1,
- io:format("try encode and decode value 5: ~w (0x~.16b)~n", [Val5, Val5]),
+ ?IPRINT("try encode and decode value 5: ~w (0x~.16b)", [Val5, Val5]),
Enc5 = snmp_pdus:enc_value('Counter32', Val5),
- io:format(" => ~w~n", [Enc5]),
+ ?IPRINT(" => ~w", [Enc5]),
{{'Counter32', Val5}, []} = snmp_pdus:dec_value(Enc5),
Val6 = 16#fffffffe,
- io:format("try encode and decode value 6: ~w (0x~.16b)~n", [Val6, Val6]),
+ ?IPRINT("try encode and decode value 6: ~w (0x~.16b)", [Val6, Val6]),
Enc6 = snmp_pdus:enc_value('Counter32', Val6),
- io:format(" => ~w~n", [Enc6]),
+ ?IPRINT(" => ~w", [Enc6]),
{{'Counter32', Val6}, []} = snmp_pdus:dec_value(Enc6),
Val7 = Val6 + 1,
- io:format("try encode and decode value 7: ~w (0x~.16b)~n", [Val7, Val7]),
+ ?IPRINT("try encode and decode value 7: ~w (0x~.16b)", [Val7, Val7]),
Enc7 = snmp_pdus:enc_value('Counter32', Val7),
- io:format(" => ~w~n", [Enc7]),
+ ?IPRINT(" => ~w", [Enc7]),
{{'Counter32', Val7}, []} = snmp_pdus:dec_value(Enc7),
Val8 = 16#ffffffff + 1,
- io:format("try and fail to encode value 8: ~w (0x~.16b)~n", [Val8, Val8]),
+ ?IPRINT("try and fail to encode value 8: ~w (0x~.16b)", [Val8, Val8]),
case (catch snmp_pdus:enc_value('Counter32', Val8)) of
{'EXIT', {error, {bad_counter32, Val8}}} ->
ok;
Unexpected8 ->
- io:format(" => ~w~n", [Unexpected8]),
+ ?IPRINT(" => ~w", [Unexpected8]),
exit({unexpected_encode_result, Unexpected8, Val8})
end,
Val9 = -1,
- io:format("try and fail to encode value 9: ~w~n", [Val9]),
+ ?IPRINT("try and fail to encode value 9: ~w", [Val9]),
case (catch snmp_pdus:enc_value('Counter32', Val9)) of
{'EXIT', {error, {bad_counter32, Val9}}} ->
ok;
Unexpected9 ->
- io:format(" => ~w~n", [Unexpected9]),
+ ?IPRINT(" => ~w", [Unexpected9]),
exit({unexpected_encode_result, Unexpected9, Val9})
end,
@@ -278,74 +316,74 @@ otp10132(suite) -> [];
otp10132(doc) -> ["OTP-10132 - TimeTicks"];
otp10132(Config) when is_list(Config) ->
Val0 = 2159001034,
- io:format("try encode and decode value 0: ~w (0x~.16b)~n", [Val0, Val0]),
+ ?IPRINT("try encode and decode value 0: ~w (0x~.16b)", [Val0, Val0]),
Enc0 = snmp_pdus:enc_value('TimeTicks', Val0),
- io:format(" => ~w~n", [Enc0]),
+ ?IPRINT(" => ~w", [Enc0]),
{{'TimeTicks', Val0}, []} = snmp_pdus:dec_value(Enc0),
Val1 = 0,
- io:format("try encode and decode value 1: ~w (0x~.16b)~n", [Val1, Val1]),
+ ?IPRINT("try encode and decode value 1: ~w (0x~.16b)", [Val1, Val1]),
Enc1 = snmp_pdus:enc_value('TimeTicks', Val1),
- io:format(" => ~w~n", [Enc1]),
+ ?IPRINT(" => ~w", [Enc1]),
{{'TimeTicks', Val1}, []} = snmp_pdus:dec_value(Enc1),
Val2 = Val1 + 1,
- io:format("try encode and decode value 2: ~w (0x~.16b)~n", [Val2, Val2]),
+ ?IPRINT("try encode and decode value 2: ~w (0x~.16b)", [Val2, Val2]),
Enc2 = snmp_pdus:enc_value('TimeTicks', Val2),
- io:format(" => ~w~n", [Enc2]),
+ ?IPRINT(" => ~w", [Enc2]),
{{'TimeTicks', Val2}, []} = snmp_pdus:dec_value(Enc2),
Val3 = 16#7ffffffe,
- io:format("try encode and decode value 3: ~w (0x~.16b)~n", [Val3, Val3]),
+ ?IPRINT("try encode and decode value 3: ~w (0x~.16b)", [Val3, Val3]),
Enc3 = snmp_pdus:enc_value('TimeTicks', Val3),
- io:format(" => ~w~n", [Enc3]),
+ ?IPRINT(" => ~w", [Enc3]),
{{'TimeTicks', Val3}, []} = snmp_pdus:dec_value(Enc3),
Val4 = Val3 + 1,
- io:format("try encode and decode value 4: ~w (0x~.16b)~n", [Val4, Val4]),
+ ?IPRINT("try encode and decode value 4: ~w (0x~.16b)", [Val4, Val4]),
Enc4 = snmp_pdus:enc_value('TimeTicks', Val4),
- io:format(" => ~w~n", [Enc4]),
+ ?IPRINT(" => ~w", [Enc4]),
{{'TimeTicks', Val4}, []} = snmp_pdus:dec_value(Enc4),
Val5 = Val4 + 1,
- io:format("try encode and decode value 5: ~w (0x~.16b)~n", [Val5, Val5]),
+ ?IPRINT("try encode and decode value 5: ~w (0x~.16b)", [Val5, Val5]),
Enc5 = snmp_pdus:enc_value('TimeTicks', Val5),
- io:format(" => ~w~n", [Enc5]),
+ ?IPRINT(" => ~w", [Enc5]),
{{'TimeTicks', Val5}, []} = snmp_pdus:dec_value(Enc5),
Val6 = 16#fffffffe,
- io:format("try encode and decode value 6: ~w (0x~.16b)~n", [Val6, Val6]),
+ ?IPRINT("try encode and decode value 6: ~w (0x~.16b)", [Val6, Val6]),
Enc6 = snmp_pdus:enc_value('TimeTicks', Val6),
- io:format(" => ~w~n", [Enc6]),
+ ?IPRINT(" => ~w", [Enc6]),
{{'TimeTicks', Val6}, []} = snmp_pdus:dec_value(Enc6),
Val7 = Val6 + 1,
- io:format("try encode and decode value 7: ~w (0x~.16b)~n", [Val7, Val7]),
+ ?IPRINT("try encode and decode value 7: ~w (0x~.16b)", [Val7, Val7]),
Enc7 = snmp_pdus:enc_value('TimeTicks', Val7),
- io:format(" => ~w~n", [Enc7]),
+ ?IPRINT(" => ~w", [Enc7]),
{{'TimeTicks', Val7}, []} = snmp_pdus:dec_value(Enc7),
Val8 = Val7 + 1,
- io:format("try and fail to encode value 8: ~w (0x~.16b)~n", [Val8, Val8]),
+ ?IPRINT("try and fail to encode value 8: ~w (0x~.16b)", [Val8, Val8]),
case (catch snmp_pdus:enc_value('TimeTicks', Val8)) of
{'EXIT', {error, {bad_timeticks, Val8}}} ->
ok;
Unexpected8 ->
- io:format(" => ~w~n", [Unexpected8]),
+ ?IPRINT(" => ~w", [Unexpected8]),
exit({unexpected_encode_result, Unexpected8, Val8})
end,
Val9 = -1,
- io:format("try and fail to encode value 9: ~w~n", [Val9]),
+ ?IPRINT("try and fail to encode value 9: ~w", [Val9]),
case (catch snmp_pdus:enc_value('TimeTicks', Val9)) of
{'EXIT', {error, {bad_timeticks, Val9}}} ->
ok;
Unexpected9 ->
- io:format(" => ~w~n", [Unexpected9]),
+ ?IPRINT(" => ~w", [Unexpected9]),
exit({unexpected_encode_result, Unexpected9, Val9})
end,
- io:format("done~n", []),
+ ?IPRINT("done"),
ok.
diff --git a/lib/snmp/test/snmp_test_lib.erl b/lib/snmp/test/snmp_test_lib.erl
index 5d1b87ad04..3e445174ba 100644
--- a/lib/snmp/test/snmp_test_lib.erl
+++ b/lib/snmp/test/snmp_test_lib.erl
@@ -42,12 +42,14 @@
-export([ping/1, local_nodes/0, nodes_on/1]).
-export([start_node/2, stop_node/1]).
-export([is_app_running/1,
- is_crypto_running/0, is_mnesia_running/0, is_snmp_running/0]).
+ is_crypto_running/0, is_mnesia_running/0, is_snmp_running/0,
+ ensure_not_running/3]).
-export([crypto_start/0, crypto_support/0]).
-export([watchdog/3, watchdog_start/1, watchdog_start/2, watchdog_stop/1]).
-export([del_dir/1]).
--export([cover/1]).
--export([f/2, p/2, print1/2, print2/2, print/5, formated_timestamp/0]).
+-export([f/2, formated_timestamp/0]).
+-export([p/2, print1/2, print2/2, print/5]).
+-export([eprint/2, wprint/2, nprint/2, iprint/2]).
-define(SKIP(R), skip(R, ?MODULE, ?LINE)).
@@ -97,20 +99,24 @@ tc_try(Case, TCCond, Pre, TC, Post)
tc_begin(Case),
try TCCond() of
ok ->
+ tc_print("starting: try pre"),
try Pre() of
State ->
+ tc_print("pre done: try test case"),
try
begin
TC(State),
sleep(seconds(1)),
+ tc_print("test case done: try post"),
(catch Post(State)),
tc_end("ok")
end
catch
C:{skip, _} = SKIP when (C =:= throw) orelse
(C =:= exit) ->
+ tc_print("test case (~w) skip: try post", [C]),
(catch Post(State)),
- tc_end( f("skipping(catched,~w,tc)", [C]) ),
+ tc_end( f("skipping(catched,~w,tc)", [C]) ),
SKIP;
C:E:S ->
%% We always check the system events
@@ -119,17 +125,18 @@ tc_try(Case, TCCond, Pre, TC, Post)
%% generate sys events itself...
case snmp_test_global_sys_monitor:events() of
[] ->
+ tc_print("test case failed: try post"),
(catch Post(State)),
tc_end( f("failed(catched,~w,tc)", [C]) ),
erlang:raise(C, E, S);
SysEvs ->
- tc_print("System Events received: "
+ tc_print("System Events received during tc: "
"~n ~p"
"~nwhen tc failed:"
"~n C: ~p"
"~n E: ~p"
"~n S: ~p",
- [SysEvs, C, E, S], "", ""),
+ [SysEvs, C, E, S]),
(catch Post(State)),
tc_end( f("skipping(catched-sysevs,~w,tc)",
[C]) ),
@@ -147,16 +154,22 @@ tc_try(Case, TCCond, Pre, TC, Post)
%% before we accept a failure
case snmp_test_global_sys_monitor:events() of
[] ->
- tc_end( f("failed(catched,~w,tc-pre)", [C]) ),
- erlang:raise(C, E, S);
- SysEvs ->
- tc_print("System Events received: "
- "~n ~p"
- "~nwhen tc-pre failed:"
+ tc_print("tc-pre failed: auto-skip"
"~n C: ~p"
"~n E: ~p"
"~n S: ~p",
- [SysEvs, C, E, S], "", ""),
+ [C, E, S]),
+ tc_end( f("auto-skip(catched,~w,tc-pre)", [C]) ),
+ SKIP = {skip, f("TC-Pre failure (~w)", [C])},
+ SKIP;
+ SysEvs ->
+ tc_print("System Events received: "
+ "~n ~p"
+ "~nwhen tc-pre failed:"
+ "~n C: ~p"
+ "~n E: ~p"
+ "~n S: ~p",
+ [SysEvs, C, E, S], "", ""),
tc_end( f("skipping(catched-sysevs,~w,tc-pre)", [C]) ),
SKIP = {skip, "TC-Pre failure with system events"},
SKIP
@@ -210,13 +223,19 @@ tc_end(Result) when is_list(Result) ->
"", "----------------------------------------------------~n~n"),
ok.
+tc_print(F) ->
+ tc_print(F, [], "", "").
+
+tc_print(F, A) ->
+ tc_print(F, A, "", "").
+
tc_print(F, Before, After) ->
tc_print(F, [], Before, After).
tc_print(F, A, Before, After) ->
Name = tc_which_name(),
FStr = f("*** [~s][~s][~p] " ++ F ++ "~n",
- [formated_timestamp(),Name,self()|A]),
+ [formated_timestamp(), Name, self() | A]),
io:format(user, Before ++ FStr ++ After, []),
io:format(standard_io, Before ++ FStr ++ After, []).
@@ -800,6 +819,8 @@ analyze_and_print_host_info() ->
analyze_and_print_freebsd_host_info(Version);
{unix, sunos} ->
analyze_and_print_solaris_host_info(Version);
+ {win32, nt} ->
+ analyze_and_print_win_host_info(Version);
_ ->
io:format("OS Family: ~p"
"~n OS Type: ~p"
@@ -1318,6 +1339,135 @@ analyze_and_print_solaris_host_info(Version) ->
+analyze_and_print_win_host_info(Version) ->
+ SysInfo = which_win_system_info(),
+ OsName = win_sys_info_lookup(os_name, SysInfo),
+ OsVersion = win_sys_info_lookup(os_version, SysInfo),
+ SysMan = win_sys_info_lookup(system_manufacturer, SysInfo),
+ SysMod = win_sys_info_lookup(system_model, SysInfo),
+ NumProcs = win_sys_info_lookup(num_processors, SysInfo),
+ TotPhysMem = win_sys_info_lookup(total_phys_memory, SysInfo),
+ io:format("Windows: ~s"
+ "~n OS Version: ~s (~p)"
+ "~n System Manufacturer: ~s"
+ "~n System Model: ~s"
+ "~n Number of Processor(s): ~s"
+ "~n Total Physical Memory: ~s"
+ "~n Num Schedulers: ~s"
+ "~n~n", [OsName, OsVersion, Version,
+ SysMan, SysMod, NumProcs, TotPhysMem,
+ str_num_schedulers()]),
+ io:format("TS Scale Factor: ~w~n", [timetrap_scale_factor()]),
+ MemFactor =
+ try
+ begin
+ [MStr, MUnit|_] =
+ string:tokens(lists:delete($,, TotPhysMem), [$\ ]),
+ case string:to_lower(MUnit) of
+ "gb" ->
+ try list_to_integer(MStr) of
+ M when M > 8 ->
+ 0;
+ M when M > 4 ->
+ 1;
+ M when M > 2 ->
+ 2;
+ _ ->
+ 5
+ catch
+ _:_:_ ->
+ 10
+ end;
+ "mb" ->
+ try list_to_integer(MStr) of
+ M when M > 8192 ->
+ 0;
+ M when M > 4096 ->
+ 1;
+ M when M > 2048 ->
+ 2;
+ _ ->
+ 5
+ catch
+ _:_:_ ->
+ 10
+ end;
+ _ ->
+ 10
+ end
+ end
+ catch
+ _:_:_ ->
+ 10
+ end,
+ CPUFactor =
+ case erlang:system_info(schedulers) of
+ 1 ->
+ 10;
+ 2 ->
+ 5;
+ _ ->
+ 2
+ end,
+ CPUFactor + MemFactor.
+
+win_sys_info_lookup(Key, SysInfo) ->
+ win_sys_info_lookup(Key, SysInfo, "-").
+
+win_sys_info_lookup(Key, SysInfo, Def) ->
+ case lists:keysearch(Key, 1, SysInfo) of
+ {value, {Key, Value}} ->
+ Value;
+ false ->
+ Def
+ end.
+
+%% This function only extracts the prop we actually care about!
+which_win_system_info() ->
+ SysInfo = os:cmd("systeminfo"),
+ try process_win_system_info(string:tokens(SysInfo, [$\r, $\n]), [])
+ catch
+ _:_:_ ->
+ io:format("Failed process System info: "
+ "~s~n", [SysInfo]),
+ []
+ end.
+
+process_win_system_info([], Acc) ->
+ Acc;
+process_win_system_info([H|T], Acc) ->
+ case string:tokens(H, [$:]) of
+ [Key, Value] ->
+ case string:to_lower(Key) of
+ "os name" ->
+ process_win_system_info(T,
+ [{os_name, string:trim(Value)}|Acc]);
+ "os version" ->
+ process_win_system_info(T,
+ [{os_version, string:trim(Value)}|Acc]);
+ "system manufacturer" ->
+ process_win_system_info(T,
+ [{system_manufacturer, string:trim(Value)}|Acc]);
+ "system model" ->
+ process_win_system_info(T,
+ [{system_model, string:trim(Value)}|Acc]);
+ "processor(s)" ->
+ [NumProcStr|_] = string:tokens(Value, [$\ ]),
+ T2 = lists:nthtail(list_to_integer(NumProcStr), T),
+ process_win_system_info(T2,
+ [{num_processors, NumProcStr}|Acc]);
+ "total physical memory" ->
+ process_win_system_info(T,
+ [{total_phys_memory, string:trim(Value)}|Acc]);
+ _ ->
+ process_win_system_info(T, Acc)
+ end;
+ _ ->
+ process_win_system_info(T, Acc)
+ end.
+
+
+
str_num_schedulers() ->
try erlang:system_info(schedulers) of
N -> f("~w", [N])
@@ -1448,8 +1598,74 @@ crypto_support([Func|Funcs], Acc) ->
is_crypto_supported(Func) ->
snmp_misc:is_crypto_supported(Func).
-
-
+
+
+%% This function ensures that a *named* process on the local node is not running.
+%% It does so by:
+%% 1) Wait for 'Timeout' msec
+%% 2) If 1 did not work, issue 'stop' and then wait 'Timeout' msec
+%% 3) And finally, if 2 did not work, issue exit(kill).
+ensure_not_running(Name, Stopper, Timeout)
+ when is_atom(Name) andalso
+ is_function(Stopper, 0) andalso
+ is_integer(Timeout) ->
+ ensure_not_running(whereis(Name), Name, Stopper, Timeout).
+
+ensure_not_running(Pid, Name, Stopper, Timeout) when is_pid(Pid) ->
+ MRef = erlang:monitor(process, Pid),
+ try
+ begin
+ ensure_not_running_wait(Pid, MRef, Timeout),
+ ensure_not_running_stop(Pid, MRef, Stopper, Timeout),
+ ensure_not_running_kill(Pid, MRef, Timeout),
+ exit({failed_ensure_not_running, Name})
+ end
+ catch
+ throw:ok ->
+ sleep(1000),
+ ok
+ end;
+ensure_not_running(_, _, _, _) ->
+ iprint("ensure_not_running -> not running", []),
+ sleep(1000), % This should not actually be necessary!
+ ok.
+
+
+ensure_not_running_wait(Pid, MRef, Timeout) ->
+ receive
+ {'DOWN', MRef, process, Pid, _Info} ->
+ iprint("ensure_not_running_wait -> died peacefully", []),
+ throw(ok)
+ after Timeout ->
+ wprint("ensure_not_running_wait -> giving up", []),
+ ok
+ end.
+
+ensure_not_running_stop(Pid, MRef, Stopper, Timeout) ->
+ %% Spawn a stop'er process
+ StopPid = spawn(Stopper),
+ receive
+ {'DOWN', MRef, process, Pid, _Info} ->
+ nprint("ensure_not_running_stop -> dead (stopped)", []),
+ throw(ok)
+ after Timeout ->
+ wprint("ensure_not_running_stop -> giving up", []),
+ exit(StopPid, kill),
+ ok
+ end.
+
+ensure_not_running_kill(Pid, MRef, Timeout) ->
+ exit(Pid, kill),
+ receive
+ {'DOWN', MRef, process, Pid, _Info} ->
+ nprint("ensure_not_running_kill -> dead (killed)", []),
+ throw(ok)
+ after Timeout ->
+ wprint("ensure_not_running_kill -> giving up", []),
+ ok
+ end.
+
+
%% ----------------------------------------------------------------
%% Watchdog functions
%%
@@ -1578,19 +1794,6 @@ del_file_or_dir(FileOrDir) ->
%% ----------------------------------------------------------------------
-%% cover functions
-%%
-
-cover([Suite, Case] = Args) when is_atom(Suite) andalso is_atom(Case) ->
- Mods0 = cover:compile_directory("../src"),
- Mods1 = [Mod || {ok, Mod} <- Mods0],
- snmp_test_server:t(Args),
- Files0 = [cover:analyse_to_file(Mod) || Mod <- Mods1],
- [io:format("Cover output: ~s~n", [File]) || {ok, File} <- Files0],
- ok.
-
-
-%% ----------------------------------------------------------------------
%% (debug) Print functions
%%
@@ -1636,3 +1839,49 @@ print(Prefix, Module, Line, Format, Args) ->
formated_timestamp() ->
snmp_misc:formated_timestamp().
+
+%% ----------------------------------------------------------------------
+%%
+%% General purpose print functions
+%% ERROR, WARNING and NOTICE are written both to 'user' and 'standard_io'.
+%% INFO only to 'standard_io'.
+%%
+%% Should we also allow for (optional) a "short name" (sname)?
+%%
+
+%% ERROR print (both to user and standard_io)
+eprint(F, A) ->
+ Str = format_print("ERROR", F, A),
+ io:format(user, "~s~n", [Str]),
+ io:format(standard_io, "~s~n", [Str]).
+
+%% WARNING print (both to user and standard_io)
+wprint(F, A) ->
+ Str = format_print("WARNING", F, A),
+ io:format(user, "~s~n", [Str]),
+ io:format(standard_io, "~s~n", [Str]).
+
+%% NOTICE print (both to user and standard_io)
+nprint(F, A) ->
+ Str = format_print("NOTICE", F, A),
+ io:format(user, "~s~n", [Str]),
+ io:format(standard_io, "~s~n", [Str]).
+
+%% INFO print (only to user)
+iprint(F, A) ->
+ Str = format_print("INFO", F, A),
+ io:format(standard_io, "~s~n", [Str]).
+
+format_print(Prefix, F, A) ->
+ format_print(get(tname), Prefix, F, A).
+
+format_print(undefined, Prefix, F, A) ->
+ f("*** [~s] ~s ~p ~p *** ~n" ++ F ++ "~n",
+ [formated_timestamp(), Prefix, node(), self() | A]);
+format_print(TName, Prefix, F, A) when is_atom(TName) ->
+ format_print(atom_to_list(TName), Prefix, F, A);
+format_print(TName, Prefix, F, A) when is_list(TName) ->
+ f("*** [~s] ~s ~s ~p ~p *** ~n" ++ F ++ "~n",
+ [formated_timestamp(), Prefix, TName, node(), self() | A]).
+
+
diff --git a/lib/snmp/test/snmp_test_lib.hrl b/lib/snmp/test/snmp_test_lib.hrl
index c84b05c5ba..f4863c9a1e 100644
--- a/lib/snmp/test/snmp_test_lib.hrl
+++ b/lib/snmp/test/snmp_test_lib.hrl
@@ -109,6 +109,9 @@
-define(CRYPTO_SUPPORT(), ?LIB:crypto_support()).
+-define(ENSURE_NOT_RUNNING(N, S, T), ?LIB:ensure_not_running(N, S, T)).
+
+
%% - Dir macros -
-define(DEL_DIR(D), ?LIB:del_dir(D)).
@@ -116,56 +119,33 @@
%% - Print macros
+%% Used for indicating the start of a test case
-define(P(C), ?LIB:p(?MODULE, C)).
--define(P1(F), ?LIB:p(F, [])).
--define(P2(F, A), ?LIB:p(F, A)).
--define(F(F, A), ?LIB:f(F, A)).
--ifdef(snmp_debug).
--ifndef(snmp_log).
--define(snmp_log,true).
--endif.
--ifndef(snmp_error).
--define(snmp_error,true).
--endif.
--else.
--ifdef(snmp_log).
--ifndef(snmp_error).
--define(snmp_error,true).
--endif.
--endif.
--endif.
+%% Takes a format call (such as io:format) and produces a printable string
+-define(F(F, A), ?LIB:f(F, A)).
-ifdef(snmp_debug).
--define(DBG(F,A), ?PRINT("DEBUG", F, A)).
+-define(DBG(F,A), ?IPRINT(F, A)).
-else.
-define(DBG(F,A), ok).
-endif.
--ifdef(snmp_log).
--define(LOG(F,A), ?PRINT("LOG", F, A)).
--else.
--define(LOG(F,A), ok).
--endif.
-
--ifdef(snmp_error).
--define(ERR(F,A), ?PRINT("ERROR", F, A)).
--else.
--define(ERR(F,A), ok).
--endif.
-
--define(INF(F), ?INF(F, [])).
--define(INF(F,A), ?PRINT("INFO", F, A)).
+%% ERROR print
+-define(EPRINT(F), ?LIB:eprint(F, [])).
+-define(EPRINT(F, A), ?LIB:eprint(F, A)).
--define(PRINT(P,F,A), ?LIB:print(P, ?MODULE, ?LINE, F, A)).
+%% WARNING print
+-define(WPRINT(F), ?LIB:wprint(F, [])).
+-define(WPRINT(F, A), ?LIB:wprint(F, A)).
--define(PRINT1(F, A), ?LIB:print1(F, A)).
--define(PRINT1(F), ?PRINT1(F, [])).
--define(EPRINT1(F, A), ?PRINT1("<ERROR> " ++ F, A)).
+%% NOTICE print
+-define(NPRINT(F), ?LIB:nprint(F, [])).
+-define(NPRINT(F, A), ?LIB:nprint(F, A)).
--define(PRINT2(F, A), ?LIB:print2(F, A)).
--define(PRINT2(F), ?PRINT2(F, [])).
--define(EPRINT2(F, A), ?PRINT2("<ERROR> " ++ F, A)).
+%% INFO print
+-define(IPRINT(F), ?LIB:iprint(F, [])).
+-define(IPRINT(F, A), ?LIB:iprint(F, A)).
-define(FTS(), snmp_misc:formated_timestamp()).
-define(FTS(TS), snmp_misc:format_timestamp(TS)).
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).
-
diff --git a/lib/snmp/test/snmp_to_snmpnet_SUITE.erl b/lib/snmp/test/snmp_to_snmpnet_SUITE.erl
index 0863cf0000..76a1967513 100644
--- a/lib/snmp/test/snmp_to_snmpnet_SUITE.erl
+++ b/lib/snmp/test/snmp_to_snmpnet_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2014-2018. All Rights Reserved.
+%% Copyright Ericsson AB 2014-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.
@@ -130,8 +130,11 @@ snmpd_cases() ->
%% -----
%%
-init_per_suite(Config) ->
- case netsnmp_init(Config) of
+init_per_suite(Config0) ->
+ ?IPRINT("init_per_suite -> entry with"
+ "~n Config: ~p", [Config0]),
+
+ case netsnmp_init(Config0) of
{skip, _} = SKIP ->
SKIP;
@@ -142,6 +145,10 @@ init_per_suite(Config) ->
Config2 when is_list(Config2) ->
snmp_test_sys_monitor:start(),
+
+ ?IPRINT("init_per_suite -> end when"
+ "~n Config: ~p", [Config2]),
+
Config2
end
end.
@@ -176,9 +183,15 @@ netsnmp_check(RE) ->
end_per_suite(Config) ->
+ ?IPRINT("end_per_suite -> entry with"
+ "~n Config: ~p", [Config]),
+
snmp_test_sys_monitor:stop(),
- ?LIB:end_per_suite(Config).
+ ?LIB:end_per_suite(Config),
+ ?IPRINT("end_per_suite -> end"),
+
+ Config.
%%
%% -----
@@ -260,17 +273,27 @@ end_per_group(_GroupName, Config) ->
%%
init_per_testcase(_Case, Config) ->
+ ?IPRINT("init_per_testcase -> entry with"
+ "~n Config: ~p", [Config]),
snmp_test_global_sys_monitor:reset_events(),
- Dog = ct:timetrap(20000),
+ Dog = ct:timetrap(?SECS(20)),
application:stop(snmp),
application:unload(snmp),
- [{watchdog, Dog} | Config].
+ Config1 = [{watchdog, Dog} | Config],
+
+ ?IPRINT("init_per_testcase -> done when"
+ "~n Config: ~p", [Config1]),
+
+ Config1.
end_per_testcase(_, Config) ->
- ?PRINT2("system events during test: "
+ ?IPRINT("end_per_testcase -> entry with"
+ "~n Config: ~p", [Config]),
+
+ ?IPRINT("system events during test: "
"~n ~p", [snmp_test_global_sys_monitor:events()]),
case application:stop(snmp) of
@@ -285,6 +308,10 @@ end_per_testcase(_, Config) ->
E2 ->
ct:pal("application:unload(snmp) -> ~p", [E2])
end,
+
+ ?IPRINT("end_per_testcase -> done with"
+ "~n Config: ~p", [Config]),
+
Config.
find_executable(Exec, Config) ->