1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 2002-2015. All Rights Reserved.
5%%
6%% Licensed under the Apache License, Version 2.0 (the "License");
7%% you may not use this file except in compliance with the License.
8%% You may obtain a copy of the License at
9%%
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17%%
18%% The Initial Developer of the Original Code is Ericsson AB.
19%% %CopyrightEnd%
20%%
21%%----------------------------------------------------------------------
22%% Purpose: Define common macros for testing
23%%----------------------------------------------------------------------
24
25%% - (some of the) Macros stolen from the test server -
26
27%% -define(line,put(test_server_loc,{?MODULE,?LINE}),).
28
29
30%% - Misc macros -
31
32-ifndef(APPLICATION).
33-define(APPLICATION,    snmp).
34-endif.
35
36-define(SCONF(K,D,C),               snmp_test_lib:set_config(K,D,C)).
37-define(GCONF(K,C),                 snmp_test_lib:get_config(K,C)).
38-define(RCONF(K,C,V),               snmp_test_lib:replace_config(K,C,V)).
39-define(HOSTNAME(N),                snmp_test_lib:hostname(N)).
40-define(LOCALHOST(),                snmp_test_lib:localhost()).
41-define(LOCALHOST(Family),          snmp_test_lib:localhost(Family)).
42-define(SZ(X),                      snmp_test_lib:sz(X)).
43-define(OSTYPE(),                   snmp_test_lib:os_type()).
44-define(DISPLAY_SUITE_INFO(),       snmp_test_lib:display_suite_info(?MODULE)).
45
46
47%% - Test case macros -
48-define(OS_BASED_SKIP(Skippable),
49        snmp_test_lib:os_based_skip(Skippable)).
50-define(NON_PC_TC_MAYBE_SKIP(Config, Condition),
51        snmp_test_lib:non_pc_tc_maybe_skip(Config, Condition, ?MODULE, ?LINE)).
52-define(SKIP(Reason),   snmp_test_lib:skip(Reason, ?MODULE, ?LINE)).
53-define(FAIL(Reason),   snmp_test_lib:fail(Reason, ?MODULE, ?LINE)).
54
55
56%% - Time macros -
57
58-ifdef(DONT_USE_TEST_SERVER).
59-define(HOURS(N),       snmp_test_lib:hours(N)).
60-define(MINS(N),        snmp_test_lib:minutes(N)).
61-define(SECS(N),        snmp_test_lib:seconds(N)).
62-else.
63-define(HOURS(N),       test_server:hours(N)).
64-define(MINS(N),        test_server:minutes(N)).
65-define(SECS(N),        test_server:seconds(N)).
66-endif.
67
68-ifdef(DONT_USE_TEST_SERVER).
69-define(WD_START(T),    snmp_test_lib:watchdog_start(T)).
70-define(WD_STOP(P),     snmp_test_lib:watchdog_stop(P)).
71-else.
72-define(WD_START(T),    test_server:timetrap(T)).
73-define(WD_STOP(P),     test_server:timetrap_cancel(P)).
74-endif.
75
76-define(SLEEP(MSEC),    snmp_test_lib:sleep(MSEC)).
77
78%% - Process utility macros -
79
80-define(FLUSH(),        snmp_test_lib:flush_mqueue()).
81-define(ETRAP_GET(),    snmp_test_lib:trap_exit()).
82-define(ETRAP_SET(O),   snmp_test_lib:trap_exit(O)).
83
84
85%% - Node utility macros -
86
87-define(PING(N),            snmp_test_lib:ping(N)).
88-define(LNODES(),           snmp_test_lib:local_nodes()).
89-define(NODES(H),           snmp_test_lib:nodes_on(H)).
90-define(START_NODE(N,A),    snmp_test_lib:start_node(N,A)).
91
92
93%% - Application and Crypto utility macros -
94
95-define(IS_APP_RUNNING(A),   snmp_test_lib:is_app_running(A)).
96-define(IS_SNMP_RUNNING(),   snmp_test_lib:is_snmp_running()).
97-define(IS_MNESIA_RUNNING(), snmp_test_lib:is_mnesia_running()).
98-define(IS_CRYPTO_RUNNING(), snmp_test_lib:is_crypto_running()).
99-define(CRYPTO_START(),      snmp_test_lib:crypto_start()).
100-define(CRYPTO_SUPPORT(),    snmp_test_lib:crypto_support()).
101
102
103%% - Dir macros -
104
105-define(DEL_DIR(D),         snmp_test_lib:del_dir(D)).
106
107
108%% - Print macros
109
110-define(P(C),               snmp_test_lib:p(?MODULE, C)).
111-define(P1(F),              snmp_test_lib:p(F, [])).
112-define(P2(F, A),           snmp_test_lib:p(F, A)).
113
114-ifdef(snmp_debug).
115-ifndef(snmp_log).
116-define(snmp_log,true).
117-endif.
118-ifndef(snmp_error).
119-define(snmp_error,true).
120-endif.
121-else.
122-ifdef(snmp_log).
123-ifndef(snmp_error).
124-define(snmp_error,true).
125-endif.
126-endif.
127-endif.
128
129-ifdef(snmp_debug).
130-define(DBG(F,A),?PRINT("DBG",F,A)).
131-else.
132-define(DBG(F,A),ok).
133-endif.
134
135-ifdef(snmp_log).
136-define(LOG(F,A),?PRINT("LOG",F,A)).
137-else.
138-define(LOG(F,A),ok).
139-endif.
140
141-ifdef(snmp_error).
142-define(ERR(F,A),?PRINT("ERR",F,A)).
143-else.
144-define(ERR(F,A),ok).
145-endif.
146
147-define(INF(F,A),?PRINT("INF",F,A)).
148
149-define(PRINT(P,F,A),
150	snmp_test_lib:print(P,?MODULE,?LINE,F,A)).
151