aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2014-03-30 16:55:08 -0400
committerBill Meier <wmeier@newsguy.com>2014-03-30 21:03:15 +0000
commit550e3153bf0f37a9297057c3c5024aa8809fd428 (patch)
tree21518c30159a6e3052d5e3d5153d62adc20ed856 /tools
parentb63b5034569f861d6cca0354aaa5c25eda18558e (diff)
Fix fuzz-test.sh '-b' option so it works again; Do some other tools/*test*.sh changes
- Add -b option to randpkt-test.sh and test-captures.sh; - Create/ue a common function to do '-x' tests on files/dirs; - Rename exit_error function to ws_exit_error Change-Id: I032c9d784bec1fb6b0717aaad08a061e4d935476 Reviewed-on: https://code.wireshark.org/review/872 Reviewed-by: Bill Meier <wmeier@newsguy.com> Tested-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/fuzz-test.sh21
-rwxr-xr-xtools/randpkt-test.sh23
-rwxr-xr-xtools/test-captures.sh18
-rw-r--r--tools/test-common.sh18
4 files changed, 44 insertions, 36 deletions
diff --git a/tools/fuzz-test.sh b/tools/fuzz-test.sh
index 082c96e3c4..4d18a94d7f 100755
--- a/tools/fuzz-test.sh
+++ b/tools/fuzz-test.sh
@@ -30,9 +30,6 @@
TEST_TYPE="fuzz"
. `dirname $0`/test-common.sh || exit 1
-# Directory containing binaries. Default current directory.
-BIN_DIR=.
-
# Sanity check to make sure we can find our plugins. Zero or less disables.
MIN_PLUGINS=0
@@ -70,6 +67,9 @@ shift $(($OPTIND - 1))
### usually you won't have to change anything below this line ###
+ws_bind_exec_paths
+ws_check_exec "$TSHARK" "$EDITCAP" "$CAPINFOS" "$DATE" "$TMP_DIR"
+
COMMON_ARGS="${CONFIG_PROFILE}${TWO_PASS}"
if [ $VALGRIND -eq 1 ]; then
RUNNER="`dirname $0`/valgrind-wireshark.sh"
@@ -95,17 +95,6 @@ else
fi
-NOTFOUND=0
-for i in "$TSHARK" "$EDITCAP" "$CAPINFOS" "$DATE" "$TMP_DIR" ; do
- if [ ! -x $i ]; then
- echo "Couldn't find $i"
- NOTFOUND=1
- fi
-done
-if [ $NOTFOUND -eq 1 ]; then
- exit 1
-fi
-
# Make sure we have a valid test set
FOUND=0
for CF in "$@" ; do
@@ -172,7 +161,7 @@ while [ \( $PASS -lt $MAX_PASSES -o $MAX_PASSES -lt 1 \) -a $DONE -ne 1 ] ; do
continue
elif [ $RETVAL -ne 0 -a $DONE -ne 1 ] ; then
# Some other error
- exit_error
+ ws_exit_error
fi
DISSECTOR_BUG=0
@@ -228,7 +217,7 @@ while [ \( $PASS -lt $MAX_PASSES -o $MAX_PASSES -lt 1 \) -a $DONE -ne 1 ] ; do
fi
if [ $DONE -ne 1 -a \( $RETVAL -ne 0 -o $DISSECTOR_BUG -ne 0 -o $VG_ERR_CNT -ne 0 \) ] ; then
- exit_error
+ ws_exit_error
fi
done
diff --git a/tools/randpkt-test.sh b/tools/randpkt-test.sh
index 4d00c307a3..c1b3016153 100755
--- a/tools/randpkt-test.sh
+++ b/tools/randpkt-test.sh
@@ -13,11 +13,10 @@ TEST_TYPE="randpkt"
# Uncomment to disable
WIRESHARK_ABORT_ON_DISSECTOR_BUG="True"
-PKT_TYPES=`$RANDPKT -h | awk '/^\t/ {print $1}'`
-
# To do: add options for file names and limits
-while getopts ":d:p:t:" OPTCHAR ; do
+while getopts ":b:d:p:t:" OPTCHAR ; do
case $OPTCHAR in
+ b) BIN_DIR=$OPTARG ;;
d) TMP_DIR=$OPTARG ;;
p) MAX_PASSES=$OPTARG ;;
t) PKT_TYPES=$OPTARG ;;
@@ -27,6 +26,11 @@ shift $(($OPTIND - 1))
### usually you won't have to change anything below this line ###
+ws_bind_exec_paths
+ws_check_exec "$TSHARK" "$RANDPKT" "$DATE" "$TMP_DIR"
+
+[[ -z "$PKT_TYPES" ]] && PKT_TYPES=$($RANDPKT -h | awk '/^\t/ {print $1}')
+
# TShark arguments (you won't have to change these)
# n Disable network object name resolution
# V Print a view of the details of the packet rather than a one-line summary of the packet
@@ -35,17 +39,6 @@ shift $(($OPTIND - 1))
declare -a TSHARK_ARGS=("-nVxr" "-nr")
RANDPKT_ARGS="-b 2000 -c 5000"
-NOTFOUND=0
-for i in "$TSHARK" "$RANDPKT" "$DATE" "$TMP_DIR" ; do
- if [ ! -x $i ]; then
- echo "Couldn't find $i"
- NOTFOUND=1
- fi
-done
-if [ $NOTFOUND -eq 1 ]; then
- exit 1
-fi
-
HOWMANY="forever"
if [ $MAX_PASSES -gt 0 ]; then
HOWMANY="$MAX_PASSES passes"
@@ -97,7 +90,7 @@ while [ $PASS -lt $MAX_PASSES -o $MAX_PASSES -lt 1 ] ; do
if [ $RETVAL -ne 0 -o $DISSECTOR_BUG -ne 0 ] ; then
- exit_error
+ ws_exit_error
fi
echo " OK"
rm -f $TMP_DIR/$TMP_FILE $TMP_DIR/$ERR_FILE
diff --git a/tools/test-captures.sh b/tools/test-captures.sh
index 16df859e45..f4693e8b02 100755
--- a/tools/test-captures.sh
+++ b/tools/test-captures.sh
@@ -27,14 +27,24 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+TEST_TYPE="manual"
+. `dirname $0`/test-common.sh || exit 1
+
+while getopts ":b:" OPTCHAR ; do
+ case $OPTCHAR in
+ b) BIN_DIR=$OPTARG ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
if [ $# -lt 1 ]
then
- printf "Usage: $0 /path/to/file[s].pcap\n"
+ printf "Usage: $(basename $0) [-b bin_dir] /path/to/file[s].pcap\n"
exit 1
fi
-TEST_TYPE="manual"
-. `dirname $0`/test-common.sh || exit 1
+ws_bind_exec_paths
+ws_check_exec "$TSHARK"
# set some limits to the child processes, e.g. stop it if it's running longer then MAX_CPU_TIME seconds
# (ulimit is not supported well on cygwin and probably other platforms, e.g. cygwin shows some warnings)
@@ -46,7 +56,7 @@ for file in "$@"
do
echo "Testing file $file..."
echo -n " - with tree... "
- if $BIN_DIR/tshark -nVxr $file > /dev/null
+ if $TSHARK -nVxr $file > /dev/null
then
echo "OK"
echo -n " - without tree... "
diff --git a/tools/test-common.sh b/tools/test-common.sh
index e5e1e8cc69..1accdc0442 100644
--- a/tools/test-common.sh
+++ b/tools/test-common.sh
@@ -61,6 +61,8 @@ MAX_STACK=2033
# Insert z times an error into the capture file (0.02 seems to be a good value to find errors)
ERR_PROB=0.02
+# Call *after* any changes to BIN_DIR (e.g., via command-line options)
+function ws_bind_exec_paths() {
# Tweak the following to your liking. Editcap must support "-E".
TSHARK="$BIN_DIR/tshark"
EDITCAP="$BIN_DIR/editcap"
@@ -70,6 +72,20 @@ RANDPKT="$BIN_DIR/randpkt"
if [ "$BIN_DIR" = "." ]; then
export WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1
fi
+}
+
+function ws_check_exec() {
+NOTFOUND=0
+for i in "$@" ; do
+ if [ ! -x "$i" ]; then
+ echo "Couldn't find \"$i\""
+ NOTFOUND=1
+ fi
+done
+if [ $NOTFOUND -eq 1 ]; then
+ exit 1
+fi
+}
##############################################################################
### Set up environment variables for fuzz testing ###
@@ -112,7 +128,7 @@ export MallocCheckHeapAbort=1
export MallocBadFreeAbort=1
# Create an error report
-function exit_error() {
+function ws_exit_error() {
echo -e "\n ERROR"
echo -e "Processing failed. Capture info follows:\n"
echo " Input file: $CF"