1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2002-2020. 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%%---------------------------------------------------------------------- 23%% Purpose: Define common macros for (the snmp) testing 24%%---------------------------------------------------------------------- 25 26%% - Misc macros - 27 28-ifndef(APPLICATION). 29-define(APPLICATION, snmp). 30-endif. 31 32-define(LIB, snmp_test_lib). 33 34-define(SCONF(K,D,C), ?LIB:set_config(K,D,C)). 35-define(GCONF(K,C), ?LIB:get_config(K,C)). 36-define(RCONF(K,C,V), ?LIB:replace_config(K,C,V)). 37-define(HOSTNAME(N), ?LIB:hostname(N)). 38-define(LOCALHOST(), ?LIB:localhost()). 39-define(LOCALHOST(Family), ?LIB:localhost(Family)). 40-define(SZ(X), ?LIB:sz(X)). 41-define(OSTYPE(), ?LIB:os_type()). 42-define(DISPLAY_SUITE_INFO(), ?LIB:display_suite_info(?MODULE)). 43 44 45%% - Test case macros - 46 47-define(TC_TRY(C, TC), ?LIB:tc_try(C, TC)). 48-define(TC_TRY(C, TCCond, TC), ?LIB:tc_try(C, TCCond, TC)). 49-define(TC_TRY(C, Pre, TC, Post), ?LIB:tc_try(C, Pre, TC, Post)). 50-define(TC_TRY(C, TCCond, Pre, TC, Post), ?LIB:tc_try(C, TCCond, Pre, TC, Post)). 51 52-define(OS_BASED_SKIP(Skippable), ?LIB:os_based_skip(Skippable)). 53-define(NON_PC_TC_MAYBE_SKIP(Config, Condition), 54 ?LIB:non_pc_tc_maybe_skip(Config, Condition, ?MODULE, ?LINE)). 55 56-define(SKIP(Reason), ?LIB:skip(Reason, ?MODULE, ?LINE)). 57-define(FAIL(Reason), ?LIB:fail(Reason, ?MODULE, ?LINE)). 58-define(HAS_SUPPORT_IPV6(), ?LIB:has_support_ipv6()). 59 60-define(PCALL(F, T, D), ?LIB:proxy_call(F, T, D)). 61 62 63%% - Time macros - 64 65-ifdef(DONT_USE_TEST_SERVER). 66-define(HOURS(N), ?LIB:hours(N)). 67-define(MINS(N), ?LIB:minutes(N)). 68-define(SECS(N), ?LIB:seconds(N)). 69-else. 70-define(HOURS(N), test_server:hours(N)). 71-define(MINS(N), test_server:minutes(N)). 72-define(SECS(N), test_server:seconds(N)). 73-endif. 74 75-ifdef(DONT_USE_TEST_SERVER). 76-define(WD_START(T), ?LIB:watchdog_start(T)). 77-define(WD_STOP(P), ?LIB:watchdog_stop(P)). 78-else. 79-define(WD_START(T), test_server:timetrap(T)). 80-define(WD_STOP(P), test_server:timetrap_cancel(P)). 81-endif. 82 83-define(SLEEP(MSEC), ?LIB:sleep(MSEC)). 84 85%% - Process utility macros - 86 87-define(FLUSH(), ?LIB:flush_mqueue()). 88-define(MQUEUE(), ?LIB:mqueue()). 89-define(MQUEUE(P), ?LIB:mqueue(P)). 90-define(ETRAP_GET(), ?LIB:trap_exit()). 91-define(ETRAP_SET(O), ?LIB:trap_exit(O)). 92-define(PINFO(__P__), try process_info(__P__) 93 catch _:_:_ -> 94 {not_running, __P__} 95 end). 96 97 98%% - Node utility macros - 99 100-define(PING(N), ?LIB:ping(N)). 101-define(LNODES(), ?LIB:local_nodes()). 102-define(NODES(H), ?LIB:nodes_on(H)). 103-define(START_NODE(N,A), ?LIB:start_node(N,A)). 104-define(STOP_NODE(N), ?LIB:stop_node(N)). 105 106 107%% - Application and Crypto utility macros - 108 109-define(IS_APP_RUNNING(A), ?LIB:is_app_running(A)). 110-define(IS_SNMP_RUNNING(), ?LIB:is_snmp_running()). 111-define(IS_MNESIA_RUNNING(), ?LIB:is_mnesia_running()). 112-define(IS_CRYPTO_RUNNING(), ?LIB:is_crypto_running()). 113-define(CRYPTO_START(), ?LIB:crypto_start()). 114-define(CRYPTO_SUPPORT(), ?LIB:crypto_support()). 115 116 117-define(ENSURE_NOT_RUNNING(N, S, T), ?LIB:ensure_not_running(N, S, T)). 118 119 120%% - Dir macros - 121 122-define(DEL_DIR(D), ?LIB:del_dir(D)). 123 124 125%% - Print macros 126 127%% Used for indicating the start of a test case 128-define(P(C), ?LIB:p(?MODULE, C)). 129 130%% Takes a format call (such as io:format) and produces a printable string 131-define(F(F, A), ?LIB:f(F, A)). 132 133-ifdef(snmp_debug). 134-define(DBG(F,A), ?IPRINT(F, A)). 135-else. 136-define(DBG(F,A), ok). 137-endif. 138 139%% ERROR print 140-define(EPRINT(F), ?LIB:eprint(F, [])). 141-define(EPRINT(F, A), ?LIB:eprint(F, A)). 142 143%% WARNING print 144-define(WPRINT(F), ?LIB:wprint(F, [])). 145-define(WPRINT(F, A), ?LIB:wprint(F, A)). 146 147%% NOTICE print 148-define(NPRINT(F), ?LIB:nprint(F, [])). 149-define(NPRINT(F, A), ?LIB:nprint(F, A)). 150 151%% INFO print 152-define(IPRINT(F), ?LIB:iprint(F, [])). 153-define(IPRINT(F, A), ?LIB:iprint(F, A)). 154 155-define(FTS(), snmp_misc:formated_timestamp()). 156-define(FTS(TS), snmp_misc:format_timestamp(TS)). 157 158