Difference between revisions of "Test Scripts"
 (start documenting test script variables)  | 
				 (→fulltests/support/simple_TESTCONF.sh)  | 
				||
| Line 2: | Line 2: | ||
== Environment variables ==  | == Environment variables ==  | ||
| − | == fulltests/support/simple_TESTCONF.sh ==  | + | === fulltests/support/simple_TESTCONF.sh ===  | 
* SNMP_LIMIT_VMEM N ; shell limit on memory used (bytes)  | * SNMP_LIMIT_VMEM N ; shell limit on memory used (bytes)  | ||
* SNMP_LIMIT_CPU N ; shell limit on cpu used (seconds)  | * SNMP_LIMIT_CPU N ; shell limit on cpu used (seconds)  | ||
| Line 26: | Line 26: | ||
* SNMP_TRANSPORT_SPEC X ; use transport x (udp)  | * SNMP_TRANSPORT_SPEC X ; use transport x (udp)  | ||
* SNMP_TEST_DEST addr ; use address (127.0.0.1)  | * SNMP_TEST_DEST addr ; use address (127.0.0.1)  | ||
| + | |||
| + | === fulltests/support/simple_eval_tools.sh ===  | ||
| + | * OK_TO_SAVE_RESULT [0|1] ; save results (1)  | ||
| + | |||
| + | == Functions ==  | ||
| + | === fulltests/support/simple_eval_tools.sh ===  | ||
| + |  HEADER "TEXT"  | ||
| + | saves text to $SNMP_TMPDIR/invoked  | ||
| + | |||
| + |  OUTPUT "TEXT"  | ||
| + | output test to console  | ||
| + | |||
| + |  SUCCESS "TEXT"  | ||
| + | output "SUCCESS: TEXT"  | ||
| + | |||
| + |  FAILED  | ||
| + | output "FAILED: TEXT"  | ||
| + | |||
| + |  SKIP "TEXT"  | ||
| + | Calls REMOVETESTDATA, output "1..0 # SKIP TEXT" and exits  | ||
| + | |||
| + |  ISDEFINED X  | ||
| + | checks (using grep) net-snmp-config.h, mib_module_config.h and agent_module_config.h for "^#define X"  | ||
| + | |||
| + |  SKIPIFNOT X  | ||
| + | skips test if X is not defined  | ||
| + | |||
| + |  SKIPIF  | ||
| + | skips test if X is defined  | ||
| + | |||
| + |  VERIFY X [Y] [Z] ...  | ||
| + | checks for files X, Y, and Z and exits if any are missing  | ||
| + | |||
| + |  NEWOUTPUTFILE  | ||
| + | bumps count in ''junkoutputfile''  | ||
| + | |||
| + |  STARTTEST  | ||
| + | creates new ''junkoutputfile'' or exits if it already exists  | ||
| + | |||
| + |  STOPTEST  | ||
| + | removes ''junkoutputfile''  | ||
| + | |||
| + |  REMOVETESTDATA  | ||
| + | calls "rm -rf $SNMP_TMPDIR"  | ||
| + | |||
| + |  CAPTURE COMMAND [ARGS]  | ||
| + | runs COMMAND (with optional ARGS) and captures output to file. Will output file contents if ''SNMP_VERBOSE'' is greater than 1.  | ||
| + | |||
| + |  DELAY  | ||
| + | calls "sleep $SNMP_SLEEP"  | ||
| + | |||
| + |  SAVE_RESULTS  | ||
| + | saves ''return_value'' to ''real_return_value''  | ||
| + | |||
| + |  EXPECTRESULTS X  | ||
| + | checks ''snmp_last_test_result'' against X and sets ''return_value'' to 0 if the match, and 1 otherwise.  | ||
| + | |||
| + |  CHECKCOUNT X  | ||
| + | calls ''CHECKFILECOUNT $junkoutputfile X''  | ||
| + | |||
| + |  CHECKVALUEIS A B C  | ||
| + | call ''GOOD C'' or ''BAD C'', depending on whether or not A = B  | ||
| + | |||
| + |  CHECKVALUEISNT  | ||
| + | inverse of ''CHECKVALUEIS''  | ||
| + | |||
| + |  CHECKFILECOUNT FILE N PAT  | ||
| + | check FILE for N instances of PAT. N can also be ''noerror'' or ''atleastone''.  | ||
| + | |||
| + |  CHECK X  | ||
| + | calls ''CHECKCOUNT 1 X''  | ||
| + | |||
| + | .. many more ... to be continued  | ||
Latest revision as of 04:31, 16 August 2010
Hints and tips on working with test scripts.
Contents
Environment variables
fulltests/support/simple_TESTCONF.sh
- SNMP_LIMIT_VMEM N ; shell limit on memory used (bytes)
 - SNMP_LIMIT_CPU N ; shell limit on cpu used (seconds)
 - SNMP_VERBOSE [0|1]
 - SNMP_PREFER_NEAR_MIBS [0|1] ; if set, set MIBDIRS=${srcdir}/mibs
 - SNMP_TMPDIR dir ; use dir for output/config (default /tmp/snmp-test-$testnum-$$)
 - SNMP_TMP_PERSISTENTDIR dir ; use dir for persistent dir
 - SNMP_SAVE_TMPDIR [yes|no] ; save SNMP_TMPDIR even for successful tests (no)
 - SNMP_TESTDIR dir ; where to look for tests
 - SNMP_CONFIG_FILE path/xxx.conf ; config file to use
 - SNMPTRAPD_CONFIG_FILE path/xxx.conf ; config file to use
 - SNMPAPP_CONFIG_FILE path/xxx.conf ; config file to use
 - SNMP_SNMPD_PID_FILE path/xxx ; pid file for app
 - SNMP_SNMPD_LOG_FILE path/xxx ; log file for app
 - SNMP_SNMPTRAPD_PID_FILE path/xxx ; pid file for app
 - SNMP_SNMPTRAPD_LOG_FILE path/xxx ; log file for app
 - SNMP_AGENTX_PID_FILE path/xxx ; pid file for app
 - SNMP_AGENTX_LOG_FILE path/xxx ; log file for app
 - SNMP_FLAGS flags ; use flags for all snmp commands (-d)
 - SNMP_SNMPD_PORT N ; use port N (default: probe for available high port)
 - SNMP_SNMPTRAPD_PORT N ; use port N (default: probe for available high port)
 - SNMP_AGENTX_PORT N ; use port N (default: probe for available high port)
 - SNMP_TRANSPORT_SPEC X ; use transport x (udp)
 - SNMP_TEST_DEST addr ; use address (127.0.0.1)
 
fulltests/support/simple_eval_tools.sh
- OK_TO_SAVE_RESULT [0|1] ; save results (1)
 
Functions
fulltests/support/simple_eval_tools.sh
HEADER "TEXT"
saves text to $SNMP_TMPDIR/invoked
OUTPUT "TEXT"
output test to console
SUCCESS "TEXT"
output "SUCCESS: TEXT"
FAILED
output "FAILED: TEXT"
SKIP "TEXT"
Calls REMOVETESTDATA, output "1..0 # SKIP TEXT" and exits
ISDEFINED X
checks (using grep) net-snmp-config.h, mib_module_config.h and agent_module_config.h for "^#define X"
SKIPIFNOT X
skips test if X is not defined
SKIPIF
skips test if X is defined
VERIFY X [Y] [Z] ...
checks for files X, Y, and Z and exits if any are missing
NEWOUTPUTFILE
bumps count in junkoutputfile
STARTTEST
creates new junkoutputfile or exits if it already exists
STOPTEST
removes junkoutputfile
REMOVETESTDATA
calls "rm -rf $SNMP_TMPDIR"
CAPTURE COMMAND [ARGS]
runs COMMAND (with optional ARGS) and captures output to file. Will output file contents if SNMP_VERBOSE is greater than 1.
DELAY
calls "sleep $SNMP_SLEEP"
SAVE_RESULTS
saves return_value to real_return_value
EXPECTRESULTS X
checks snmp_last_test_result against X and sets return_value to 0 if the match, and 1 otherwise.
CHECKCOUNT X
calls CHECKFILECOUNT $junkoutputfile X
CHECKVALUEIS A B C
call GOOD C or BAD C, depending on whether or not A = B
CHECKVALUEISNT
inverse of CHECKVALUEIS
CHECKFILECOUNT FILE N PAT
check FILE for N instances of PAT. N can also be noerror or atleastone.
CHECK X
calls CHECKCOUNT 1 X
.. many more ... to be continued