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