aboutsummaryrefslogtreecommitdiffstats
path: root/tools/fuzz-test.sh
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2005-04-14 04:32:27 +0000
committerGerald Combs <gerald@wireshark.org>2005-04-14 04:32:27 +0000
commit210225e22d56401ece1a217183a986c2df302c3b (patch)
tree520251b5e17d8887bf807eb874b4dee88cdf6938 /tools/fuzz-test.sh
parent2f3a3716131816e735a451d706fe617db0f917e6 (diff)
Add a script based on the "menagerie-fuzz" buildbot test. Running
"./tools/fuzz-test.sh /path/to/capture/files/*" will iterate over the specified capture files, using editcap to introduce errors and tethereal to check for bugs. It will do this until tethereal exits abnormally or a dissector bug is encountered. svn path=/trunk/; revision=14073
Diffstat (limited to 'tools/fuzz-test.sh')
-rwxr-xr-xtools/fuzz-test.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/fuzz-test.sh b/tools/fuzz-test.sh
new file mode 100755
index 0000000000..76e9664fed
--- /dev/null
+++ b/tools/fuzz-test.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# $Id$
+
+# This needs to point to a 'date' that supports %s.
+DATE=/bin/date
+
+# Where our temp files are saved (editcap.out and stderr.out)
+TMP_DIR=/tmp
+
+TETHEREAL_ARGS="-nVxr"
+
+# These may be set to your liking
+MAX_CPU_TIME=900
+ERR_PROB=0.02
+
+ulimit -S -t $MAX_CPU_TIME
+
+echo "Running tethereal with args:" $TETHEREAL_ARGS
+echo ""
+
+# Iterate over our capture files.
+PASS=0
+while [ 1 ] ; do
+ PASS=`expr $PASS + 1`
+ echo "Pass $PASS:"
+
+ for CF in "$@" ; do
+ echo -n " $CF: "
+ DISSECTOR_BUG=0
+ ./editcap -E $ERR_PROB "$CF" $TMP_DIR/editcap.out
+ ./tethereal -nxVr $TMP_DIR/editcap.out \
+ > /dev/null 2> $TMP_DIR/stderr.out
+ RETVAL=$?
+ grep -i "dissector bug" $TMP_DIR/stderr.out \
+ > /dev/null 2>&1 && DISSECTOR_BUG=1
+ if [ $RETVAL -ne 0 -o $DISSECTOR_BUG -ne 0 ] ; then
+ SUF=`$DATE +%s`
+ echo " ERROR"
+ echo -e "Processing failed. Capture info follows:\n"
+ mv $TMP_DIR/editcap.out $TMP_DIR/editcap.out.$SUF
+ echo " Output file: $TMP_DIR/editcap.out.$SUF"
+ if [ $DISSECTOR_BUG -ne 0 ] ; then
+ echo -e "stderr follows:\n"
+ cat $TMP_DIR/stderr.out
+ fi
+ exit 1
+ fi
+ echo " OK"
+ done
+done
+