diff options
author | Gerald Combs <gerald@wireshark.org> | 2006-10-09 18:47:42 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2006-10-09 18:47:42 +0000 |
commit | e2335073089af7372aa333d06ff73ca3cfdd67d7 (patch) | |
tree | d0ecf4d62e754a6cf6aa80fbe80d0011cc23e087 | |
parent | dfc0a650028470b1084f9f061ff0bdf60b4cbe37 (diff) |
Make preparations for running under Buildbot:
- Check for an "all" argument at startup. If it's present,
then proceed with testing.
- Add a platform check. Use it to handle cases where we can't run
as a normal user, e.g. trying to capture under Linux.
- Add a "Skipped" result.
svn path=/trunk/; revision=19461
-rw-r--r-- | test/config.sh | 24 | ||||
-rw-r--r-- | test/suite-capture.sh | 37 | ||||
-rw-r--r-- | test/suite-clopts.sh | 29 | ||||
-rw-r--r-- | test/test-backend.sh | 67 | ||||
-rw-r--r-- | test/test.sh | 13 |
5 files changed, 128 insertions, 42 deletions
diff --git a/test/config.sh b/test/config.sh index 3ee935c07b..e3fd1003f5 100644 --- a/test/config.sh +++ b/test/config.sh @@ -21,16 +21,28 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# +# + +# Set WS_SYSTEM to our system type, e.g. Windows, Linux, Darwin +# http://support.microsoft.com/kb/100843 +if [ -n "${OS#Windows}" ] ; then + WS_SYSTEM="Windows" +else + WS_SYSTEM=`uname -s` +fi # path to the Wireshark binaries, only used for the settings below -ETH_BIN_PATH=../wireshark-gtk2 +if [ "$WS_SYSTEM" = "Windows" ] ; then + WS_BIN_PATH=../wireshark-gtk2 +else + WS_BIN_PATH=.. +fi # Tweak the following to your liking. -WIRESHARK=$ETH_BIN_PATH/wireshark -TSHARK=$ETH_BIN_PATH/tshark -CAPINFOS=$ETH_BIN_PATH/capinfos -DUMPCAP=$ETH_BIN_PATH/dumpcap +WIRESHARK=$WS_BIN_PATH/wireshark +TSHARK=$WS_BIN_PATH/tshark +CAPINFOS=$WS_BIN_PATH/capinfos +DUMPCAP=$WS_BIN_PATH/dumpcap # interface with at least a few packets/sec traffic on it # (e.g. start a web radio to generate some traffic :-) diff --git a/test/suite-capture.sh b/test/suite-capture.sh index 2850760015..454e62055c 100644 --- a/test/suite-capture.sh +++ b/test/suite-capture.sh @@ -21,7 +21,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# +# # common exit status values @@ -32,6 +32,11 @@ EXIT_ERROR=2 # capture exactly 10 packets capture_step_10packets() { + if [ "$WS_SYSTEM" != "Windows" ] ; then + test_step_skipped + return + fi + $DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC -w ./testout.pcap -c 10 -a duration:$TRAFFIC_CAPTURE_DURATION > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then @@ -47,7 +52,7 @@ capture_step_10packets() { test_step_failed "No output file!" return fi - + # ok, we got a capture file, does it contain exactly 10 packets? $CAPINFOS ./testout.pcap > ./testout.txt grep -i 'Number of packets: 10' ./testout.txt > /dev/null @@ -65,6 +70,11 @@ capture_step_10packets() { # capture exactly 10 packets using "-w -" (piping to stdout) capture_step_10packets_stdout() { + if [ "$WS_SYSTEM" != "Windows" ] ; then + test_step_skipped + return + fi + $DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC -c 10 -a duration:$TRAFFIC_CAPTURE_DURATION -w - > ./testout.pcap 2>./testout.txt RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then @@ -78,7 +88,7 @@ capture_step_10packets_stdout() { test_step_failed "No output file!" return fi - + # ok, we got a capture file, does it contain exactly 10 packets? $CAPINFOS ./testout.pcap > ./testout2.txt 2>&1 grep -i 'Number of packets: 10' ./testout2.txt > /dev/null @@ -110,7 +120,7 @@ capture_step_fifo() { test_step_failed "No output file!" return fi - + # ok, we got a capture file, does it contain exactly 8 packets? $CAPINFOS ./testout.pcap > ./testout.txt grep -i 'Number of packets: 8' ./testout.txt > /dev/null @@ -121,10 +131,15 @@ capture_step_fifo() { cat ./testout.txt test_step_failed "No or not enough traffic captured." fi -} +} # capture exactly 2 times 10 packets (multiple files) capture_step_2multi_10packets() { + if [ "$WS_SYSTEM" != "Windows" ] ; then + test_step_skipped + return + fi + $DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC -w ./testout.pcap -c 10 -a duration:$TRAFFIC_CAPTURE_DURATION > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then @@ -140,7 +155,7 @@ capture_step_2multi_10packets() { test_step_failed "No output file!" return fi - + # ok, we got a capture file, does it contain exactly 10 packets? $CAPINFOS ./testout.pcap > ./testout.txt grep -i 'Number of packets: 10' ./testout.txt > /dev/null @@ -155,6 +170,11 @@ capture_step_2multi_10packets() { # capture with a very unlikely read filter, packets must be zero afterwards capture_step_read_filter() { + if [ "$WS_SYSTEM" != "Windows" ] ; then + test_step_skipped + return + fi + # valid, but very unlikely filter $DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC -w ./testout.pcap -a duration:$TRAFFIC_CAPTURE_DURATION -R 'dcerpc.cn_call_id==123456' -c 10 > ./testout.txt 2>&1 RETURNVALUE=$? @@ -184,6 +204,11 @@ capture_step_read_filter() { # capture with a snapshot length capture_step_snapshot() { + if [ "$WS_SYSTEM" != "Windows" ] ; then + test_step_skipped + return + fi + # capture with a snapshot length of 68 bytes for $TRAFFIC_CAPTURE_DURATION seconds # this should result in no packets $DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC -w ./testout.pcap -s 68 -a duration:$TRAFFIC_CAPTURE_DURATION > ./testout.txt 2>&1 diff --git a/test/suite-clopts.sh b/test/suite-clopts.sh index 97554541ab..d1b37dfc0a 100644 --- a/test/suite-clopts.sh +++ b/test/suite-clopts.sh @@ -21,8 +21,8 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - +# + # common exit status values EXIT_OK=0 EXIT_COMMAND_LINE=1 @@ -84,17 +84,34 @@ clopts_suite_tshark_invalid_chars() { # check exit status of all single char option being valid clopts_suite_valid_chars() { - for index in D G L h v + for index in G h v do test_step_add "Valid TShark parameter -$index, exit status must be $EXIT_OK" "test_single_char_options $TSHARK $index $EXIT_OK" done } +# special case: interface-specific opts should work under Windows and fail as +# a regular user on other systems. +clopts_suite_interface_chars() { + for index in D L + do + if [ "$WS_SYSTEM" = "Windows" ] ; then + test_step_add "Valid TShark parameter -$index, exit status must be $EXIT_OK" "test_single_char_options $TSHARK $index $EXIT_OK" + else + test_step_add "Invalid permissions for TShark parameter -$index, exit status must be $EXIT_ERROR" "test_single_char_options $TSHARK $index $EXIT_ERROR" + fi + done +} # S V l n p q x # check exit status and grep output string of an invalid capture filter clopts_step_invalid_capfilter() { + if [ "$WS_SYSTEM" != "Windows" ] ; then + test_step_skipped + return + fi + $TSHARK -f 'jkghg' -w './testout.pcap' > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then @@ -148,6 +165,11 @@ clopts_step_invalid_interface_index() { # check exit status and grep output string of an invalid capture filter # XXX - how to efficiently test the *invalid* flags? clopts_step_valid_name_resolving() { + if [ "$WS_SYSTEM" != "Windows" ] ; then + test_step_skipped + return + fi + $TSHARK -N mntC -a duration:1 > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then @@ -173,6 +195,7 @@ clopt_suite() { test_suite_add "Basic tests" clopts_suite_basic test_suite_add "Invalid TShark single char options" clopts_suite_tshark_invalid_chars test_suite_add "Valid TShark single char options" clopts_suite_valid_chars + test_suite_add "Interface-specific TShark single char options" clopts_suite_interface_chars test_step_add "Invalid capture filter -f" clopts_step_invalid_capfilter test_step_add "Invalid capture interface -i" clopts_step_invalid_interface test_step_add "Invalid capture interface index 0" clopts_step_invalid_interface_index diff --git a/test/test-backend.sh b/test/test-backend.sh index e70511de10..384d4f42ad 100644 --- a/test/test-backend.sh +++ b/test/test-backend.sh @@ -21,7 +21,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# +# # References: @@ -39,6 +39,7 @@ color_reset="tput sgr0" color_green='\E[32;40m' color_red='\E[31;40m' +color_yellow='\E[33;40m' color_blue='\E[36;40m' # runtime flags @@ -52,6 +53,7 @@ TEST_STEPS[0]=0 # number of steps of a specific nesting level # output counters TEST_OK=0 # global count of succeeded steps TEST_FAILED=0 # global count of failed steps +TEST_SKIPPED=0 # global count of failed steps TEST_STEP_PRE_CB= TEST_STEP_POST_CB= @@ -59,8 +61,8 @@ TEST_STEP_POST_CB= # level number of this test item (suite or step) test_level() { LIMIT_LEVEL=100 - - for ((a=0; a <= LIMIT_LEVEL ; a++)) + + for ((a=0; a <= LIMIT_LEVEL ; a++)) do if [ ! $a -eq 0 ]; then echo -n "." @@ -70,7 +72,7 @@ test_level() { #echo "end" return fi - done + done } # set output format @@ -93,7 +95,7 @@ test_suite_run() { # run the actual test suite $2 - + # results if [ $TEST_RUN = "ON" ]; then echo "" @@ -107,6 +109,8 @@ test_suite_run() { echo "Ok : $TEST_OK" echo -n -e $color_red echo "Failed: $TEST_FAILED" + echo -n -e $color_yellow + echo "Skipped: $TEST_SKIPPED" $color_reset fi @@ -137,7 +141,7 @@ test_suite_show() { # show this test suite subitems $2 - + echo "" } @@ -148,12 +152,12 @@ test_suite_show() { test_suite_add() { # increase step counter of this nesting level let "TEST_STEPS[$TEST_NESTING_LEVEL] += 1" - + if [ $TEST_RUN = "ON" ]; then echo "" fi - - # title output if we'll list the subitems + + # title output if we'll list the subitems if [[ $TEST_RUN = "ON" ]]; then echo -n -e $color_blue test_level @@ -172,7 +176,7 @@ test_suite_add() { # reset test step counter back to zero TEST_STEP=0 - + # call the suites function let "TEST_NESTING_LEVEL += 1" TEST_STEPS[$TEST_NESTING_LEVEL]=0 @@ -185,7 +189,7 @@ test_suite_add() { test_level echo " Suite: $1 (${TEST_STEPS[TEST_NESTING_LEVEL+1]} subitems)" $color_reset - fi + fi } @@ -200,7 +204,7 @@ test_step_add() { if [[ ($TEST_RUN = "ON" && $TEST_OUTPUT = "DOTTED") && $TEST_NESTING_LEVEL -eq 0 ]]; then echo "" fi - + if [[ ( $TEST_RUN = "ON" && $TEST_OUTPUT = "VERBOSE" ) || $TEST_NESTING_LEVEL -eq 0 ]]; then echo -n -e $color_blue test_level @@ -208,13 +212,13 @@ test_step_add() { $color_reset fi - if [ $TEST_RUN = "ON" ]; then + if [ $TEST_RUN = "ON" ]; then # preprecessing step $TEST_STEP_PRE_CB #echo "command: "$2" opt1: "$3" opt2: "$4" opt3: "$5" opt4: "$6" opt5: "$7 TEST_STEP_NAME=$1 # actually run the command to test now - $2 + $2 #"$3" "$4" "$5" "$6" "$7" # post precessing step $TEST_STEP_POST_CB @@ -248,7 +252,7 @@ test_remark_add() { if [[ $TEST_RUN = "ON" && $TEST_OUTPUT = "DOTTED" ]]; then echo "" fi - + # remark echo -n -e $color_blue echo " Remark: $1" @@ -261,16 +265,16 @@ test_remark_add() { test_step_ok() { # count appearance let "TEST_OK += 1" - + # output in green echo -n -e $color_green - + if [ $TEST_OUTPUT = "VERBOSE" ]; then echo " Ok" else echo -n . fi - + $color_reset } @@ -278,18 +282,35 @@ test_step_ok() { # $1 output text test_step_failed() { let "TEST_FAILED += 1" - + # output in red echo -n -e "$color_red" - + echo "" echo "\"$TEST_STEP_NAME\" Failed!" echo $1 - + $color_reset - + exit 1 - + # XXX - add a mechanism to optionally stop here } +# the test step succeeded +test_step_skipped() { + # count appearance + let "TEST_SKIPPED += 1" + + # output in green + echo -n -e $color_yellow + + if [ $TEST_OUTPUT = "VERBOSE" ]; then + echo " Skipped" + else + echo -n . + fi + + $color_reset +} + diff --git a/test/test.sh b/test/test.sh index c31dba8662..c69b59cf22 100644 --- a/test/test.sh +++ b/test/test.sh @@ -21,7 +21,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# +# # an existing capture file CAPFILE=./dhcp.pcap @@ -44,7 +44,7 @@ test_step_prerequisites() { echo "Couldn't find $i" NOTFOUND=1 fi - done + done if [ $NOTFOUND -eq 1 ]; then test_step_failed "Tool not found" exit 1 @@ -79,6 +79,11 @@ test_set_output VERBOSE #test_suite_run "All" test_suite #test_suite_show "All" test_suite +if [ "$1" == "all" ] ; then + test_suite_run "All" test_suite + exit +fi + MENU_LEVEL=0 menu_title[0]="All" @@ -86,10 +91,10 @@ menu_function[0]=test_suite echo "----------------------------------------------------------------------" -for ((a=0; a <= 100000000000 ; a++)) +for ((a=0; a <= 100000000000 ; a++)) do TEST_STEPS[0]=0 # number of steps of a specific nesting level - + #echo $current_title $current_function test_suite_show "${menu_title[MENU_LEVEL]}" "${menu_function[MENU_LEVEL]}" echo "1-$TEST_STEPS : Select item" |