Add command-line options: -c disables color, -h prints help, -s runs
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 10 Oct 2006 20:55:38 +0000 (20:55 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 10 Oct 2006 20:55:38 +0000 (20:55 +0000)
a suite.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@19479 f5534014-38df-0310-8fa8-9805f1628bb7

test/test-backend.sh
test/test.sh

index d7da592dd4f358c6be0ce13c19151fd74122fe09..49762a724d91cc0e9bd4d53c2be7945e73986b10 100644 (file)
 
 
 # coloring the output
-color_reset="tput sgr0"
-color_green='\E[32;40m'
-color_red='\E[31;40m'
-color_yellow='\E[33;40m'
-color_blue='\E[36;40m'
+if [ $USE_COLOR -eq 1 ] ; then
+        color_reset="tput sgr0"
+        color_green='\E[32;40m'
+        color_red='\E[31;40m'
+        color_yellow='\E[33;40m'
+        color_blue='\E[36;40m'
+else
+        color_reset="/bin/true"
+        color_green=''
+        color_red=''
+        color_yellow=''
+        color_blue=''
+fi
 
 # runtime flags
 TEST_RUN="OFF"
index 491e489a26f042d6018d4f943083d39e3ac03549..2088725a0f314943a4df6f5e95bfcfdd962beca4 100644 (file)
 
 # an existing capture file
 CAPFILE=./dhcp.pcap
+USE_COLOR=1
+RUN_SUITE=""
+PRINT_USAGE=0
+
+while getopts "chs:" OPTION ; do
+        case $OPTION in
+          c) USE_COLOR=0 ;;
+          h) PRINT_USAGE=1 ;;
+          s) RUN_SUITE="$OPTARG" ;;
+          *) echo "Unknown option: " $OPTION $OPTARG
+        esac
+done
 
+shift $(( $OPTIND - 1 ))
+
+if [ $PRINT_USAGE -ne 0 ] ; then
+        THIS=`basename $0`
+        cat <<FIN
+Usage: $THIS [-c] [-h] [-s <suite>]
+  -c: Disable color output
+  -h: Print this message and exit
+  -s: Run a suite.  Must be one of: all, capture, clopts, io, or
+      prerequisites
+FIN
+        exit 0
+fi
 
 source test-backend.sh
 
@@ -79,9 +104,24 @@ 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 $?
+if [ -n "$RUN_SUITE" ] ; then
+        case $RUN_SUITE in
+          "all")
+            test_suite_run "All" test_suite
+            exit $? ;;
+         "capture")
+            test_suite_run "Capture" capture_suite
+            exit $? ;;
+         "clopts")
+           test_suite_run "Command line options" clopt_suite
+            exit $? ;;
+         "io")
+           test_suite_run "File I/O" io_suite
+            exit $? ;;
+         "prerequisites")
+            test_suite_run "Prerequisites" prerequisites_suite
+            exit $? ;;
+        esac
 fi
 
 MENU_LEVEL=0