aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/test/snmp_test_lib.hrl
blob: f077f15d3e5a0cabd3503f5013bace7ea48dcbd1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2002-2019. 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.
%% You may obtain a copy of the License at
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% The Initial Developer of the Original Code is Ericsson AB.
%% %CopyrightEnd%
%%

%%----------------------------------------------------------------------
%% Purpose: Define common macros for (the snmp) testing
%%----------------------------------------------------------------------

%% - Misc macros -

-ifndef(APPLICATION).
-define(APPLICATION,    snmp).
-endif.

-define(SCONF(K,D,C),               snmp_test_lib:set_config(K,D,C)).
-define(GCONF(K,C),                 snmp_test_lib:get_config(K,C)).
-define(RCONF(K,C,V),               snmp_test_lib:replace_config(K,C,V)).
-define(HOSTNAME(N),                snmp_test_lib:hostname(N)).
-define(LOCALHOST(),                snmp_test_lib:localhost()).
-define(LOCALHOST(Family),          snmp_test_lib:localhost(Family)).
-define(SZ(X),                      snmp_test_lib:sz(X)).
-define(OSTYPE(),                   snmp_test_lib:os_type()).
-define(DISPLAY_SUITE_INFO(),       snmp_test_lib:display_suite_info(?MODULE)).


%% - Test case macros - 
-define(TC_TRY(C, TC),         snmp_test_lib:tc_try(C, TC)).
-define(TC_TRY(C, TCCond, TC), snmp_test_lib:tc_try(C, TCCond, TC)).
-define(OS_BASED_SKIP(Skippable),
        snmp_test_lib:os_based_skip(Skippable)).
-define(NON_PC_TC_MAYBE_SKIP(Config, Condition),
        snmp_test_lib:non_pc_tc_maybe_skip(Config, Condition, ?MODULE, ?LINE)).
-define(SKIP(Reason),        snmp_test_lib:skip(Reason, ?MODULE, ?LINE)).
-define(FAIL(Reason),        snmp_test_lib:fail(Reason, ?MODULE, ?LINE)).
-define(IS_IPV6_HOST(),      snmp_test_lib:is_ipv6_host()).
-define(IS_IPV6_HOST(H),     snmp_test_lib:is_ipv6_host(H)).
-define(HAS_SUPPORT_IPV6(),  snmp_test_lib:has_support_ipv6()).
-define(HAS_SUPPORT_IPV6(H), snmp_test_lib:has_support_ipv6(H)).


%% - Time macros -

-ifdef(DONT_USE_TEST_SERVER).
-define(HOURS(N),       snmp_test_lib:hours(N)).
-define(MINS(N),        snmp_test_lib:minutes(N)).
-define(SECS(N),        snmp_test_lib:seconds(N)).
-else.
-define(HOURS(N),       test_server:hours(N)).
-define(MINS(N),        test_server:minutes(N)).
-define(SECS(N),        test_server:seconds(N)).
-endif.

-ifdef(DONT_USE_TEST_SERVER).
-define(WD_START(T),    snmp_test_lib:watchdog_start(T)).
-define(WD_STOP(P),     snmp_test_lib:watchdog_stop(P)).
-else.
-define(WD_START(T),    test_server:timetrap(T)).
-define(WD_STOP(P),     test_server:timetrap_cancel(P)).
-endif.

-define(SLEEP(MSEC),    snmp_test_lib:sleep(MSEC)).

%% - Process utility macros - 

-define(FLUSH(),        snmp_test_lib:flush_mqueue()).
-define(ETRAP_GET(),    snmp_test_lib:trap_exit()).
-define(ETRAP_SET(O),   snmp_test_lib:trap_exit(O)).


%% - Node utility macros - 

-define(PING(N),            snmp_test_lib:ping(N)).
-define(LNODES(),           snmp_test_lib:local_nodes()).
-define(NODES(H),           snmp_test_lib:nodes_on(H)).
-define(START_NODE(N,A),    snmp_test_lib:start_node(N,A)).
-define(STOP_NODE(N),       snmp_test_lib:stop_node(N)).


%% - Application and Crypto utility macros - 

-define(IS_APP_RUNNING(A),   snmp_test_lib:is_app_running(A)).
-define(IS_SNMP_RUNNING(),   snmp_test_lib:is_snmp_running()).
-define(IS_MNESIA_RUNNING(), snmp_test_lib:is_mnesia_running()).
-define(IS_CRYPTO_RUNNING(), snmp_test_lib:is_crypto_running()).
-define(CRYPTO_START(),      snmp_test_lib:crypto_start()).
-define(CRYPTO_SUPPORT(),    snmp_test_lib:crypto_support()).


%% - Dir macros -

-define(DEL_DIR(D),         snmp_test_lib:del_dir(D)).


%% - Print macros

-define(P(C),               snmp_test_lib:p(?MODULE, C)).
-define(P1(F),              snmp_test_lib:p(F, [])).
-define(P2(F, A),           snmp_test_lib:p(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.

-ifdef(snmp_debug).
-define(DBG(F,A), ?PRINT("DBG", 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("ERR", F, A)).
-else.
-define(ERR(F,A), ok).
-endif.

-define(INF(F,A), ?PRINT("INF", F, A)).

-define(PRINT(P,F,A),
	snmp_test_lib:print(P, ?MODULE, ?LINE, F, A)).

-define(PRINT1(F, A),  snmp_test_lib:print1(F, A)).
-define(PRINT1(F),     ?PRINT1(F, [])).
-define(EPRINT1(F, A), ?PRINT1("<ERROR> " ++ F, A)).

-define(PRINT2(F, A),  snmp_test_lib:print2(F, A)).
-define(PRINT2(F),     ?PRINT2(F, [])).
-define(EPRINT2(F, A), ?PRINT2("<ERROR> " ++ F, A)).