2006-08-02 18:59:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Randpkt testing script for TShark
|
|
|
|
#
|
|
|
|
# This script uses Randpkt to generate capture files with randomized
|
|
|
|
# content. It runs TShark on each generated file and checks for errors.
|
|
|
|
# The files are processed repeatedly until an error is found.
|
|
|
|
|
2012-12-07 17:57:09 +00:00
|
|
|
TEST_TYPE="randpkt"
|
2016-09-26 17:34:04 +00:00
|
|
|
# shellcheck source=tools/test-common.sh
|
2018-06-06 17:10:07 +00:00
|
|
|
. "$( dirname "$0" )"/test-common.sh || exit 1
|
2006-08-02 18:59:29 +00:00
|
|
|
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
# Run under valgrind ?
|
|
|
|
VALGRIND=0
|
|
|
|
|
2016-09-11 19:08:45 +00:00
|
|
|
# Run under AddressSanitizer ?
|
2016-09-21 22:38:16 +00:00
|
|
|
ASAN=$CONFIGURED_WITH_ASAN
|
2016-09-11 19:08:45 +00:00
|
|
|
|
2006-08-02 18:59:29 +00:00
|
|
|
# Trigger an abort if a dissector finds a bug.
|
|
|
|
# Uncomment to disable
|
2018-06-06 17:10:07 +00:00
|
|
|
export WIRESHARK_ABORT_ON_DISSECTOR_BUG="True"
|
2006-08-02 18:59:29 +00:00
|
|
|
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
# The maximum permitted amount of memory leaked. Eventually this should be
|
|
|
|
# worked down to zero, but right now that would fail on every single capture.
|
|
|
|
# Only has effect when running under valgrind.
|
2018-06-06 17:10:07 +00:00
|
|
|
MAX_LEAK=$(( 1024 * 100 ))
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
|
2006-08-02 18:59:29 +00:00
|
|
|
# To do: add options for file names and limits
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
while getopts "ab:d:gp:t:" OPTCHAR ; do
|
2006-08-02 18:59:29 +00:00
|
|
|
case $OPTCHAR in
|
2016-09-11 19:08:45 +00:00
|
|
|
a) ASAN=1 ;;
|
2015-06-26 06:48:48 +00:00
|
|
|
b) WIRESHARK_BIN_DIR=$OPTARG ;;
|
2006-08-02 18:59:29 +00:00
|
|
|
d) TMP_DIR=$OPTARG ;;
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
g) VALGRIND=1 ;;
|
2006-08-02 18:59:29 +00:00
|
|
|
p) MAX_PASSES=$OPTARG ;;
|
|
|
|
t) PKT_TYPES=$OPTARG ;;
|
2018-06-06 17:10:07 +00:00
|
|
|
*) printf "Unknown option: %s\\n" "$OPTARG"
|
2006-08-02 18:59:29 +00:00
|
|
|
esac
|
|
|
|
done
|
2018-06-06 17:10:07 +00:00
|
|
|
shift $(( OPTIND - 1 ))
|
2006-08-02 18:59:29 +00:00
|
|
|
|
|
|
|
### usually you won't have to change anything below this line ###
|
|
|
|
|
2014-03-30 20:55:08 +00:00
|
|
|
ws_bind_exec_paths
|
|
|
|
ws_check_exec "$TSHARK" "$RANDPKT" "$DATE" "$TMP_DIR"
|
|
|
|
|
|
|
|
[[ -z "$PKT_TYPES" ]] && PKT_TYPES=$($RANDPKT -h | awk '/^\t/ {print $1}')
|
|
|
|
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
if [ $VALGRIND -eq 1 ]; then
|
2018-06-06 17:10:07 +00:00
|
|
|
RUNNER="$( dirname "$0" )/valgrind-wireshark.sh"
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
COMMON_ARGS="-b $WIRESHARK_BIN_DIR $COMMON_ARGS"
|
|
|
|
declare -a RUNNER_ARGS=("" "-T")
|
|
|
|
# Valgrind requires more resources, so permit 1.5x memory and 3x time
|
|
|
|
# (1.5x time is too small for a few large captures in the menagerie)
|
2018-06-06 17:10:07 +00:00
|
|
|
MAX_CPU_TIME=$(( 3 * "$MAX_CPU_TIME" ))
|
|
|
|
MAX_VMEM=$(( 3 * "$MAX_VMEM" / 2 ))
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
else
|
|
|
|
# Not using valgrind, use regular tshark.
|
|
|
|
# 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
|
|
|
|
# x Cause TShark to print a hex and ASCII dump of the packet data after printing the summary or details
|
|
|
|
# r Read packet data from the following infile
|
|
|
|
RUNNER="$TSHARK"
|
|
|
|
declare -a RUNNER_ARGS=("-nVxr" "-nr")
|
|
|
|
fi
|
2006-08-02 18:59:29 +00:00
|
|
|
RANDPKT_ARGS="-b 2000 -c 5000"
|
|
|
|
|
2016-09-11 19:08:45 +00:00
|
|
|
if [ $ASAN -ne 0 ]; then
|
|
|
|
echo -n "ASan enabled. Virtual memory limit is "
|
|
|
|
ulimit -v
|
|
|
|
else
|
|
|
|
echo "ASan disabled. Virtual memory limit is $MAX_VMEM"
|
|
|
|
fi
|
|
|
|
|
2006-08-02 18:59:29 +00:00
|
|
|
HOWMANY="forever"
|
2018-06-06 17:10:07 +00:00
|
|
|
if [ "$MAX_PASSES" -gt 0 ]; then
|
2006-08-02 18:59:29 +00:00
|
|
|
HOWMANY="$MAX_PASSES passes"
|
|
|
|
fi
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
echo -n "Running $RUNNER with args: "
|
|
|
|
printf "\"%s\" " "${RUNNER_ARGS[@]}"
|
2012-10-02 17:58:00 +00:00
|
|
|
echo "($HOWMANY)"
|
2006-08-02 18:59:29 +00:00
|
|
|
echo "Running $RANDPKT with args: $RANDPKT_ARGS"
|
|
|
|
echo ""
|
|
|
|
|
2021-05-11 17:56:10 +00:00
|
|
|
# Clean up on <ctrl>C, etc
|
|
|
|
trap_all() {
|
|
|
|
printf '\n\nCaught signal. Exiting.\n'
|
|
|
|
rm -f "$TMP_DIR/$TMP_FILE" "$TMP_DIR/$ERR_FILE"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
trap trap_all HUP INT TERM ABRT
|
2012-08-17 16:28:28 +00:00
|
|
|
|
2006-08-02 18:59:29 +00:00
|
|
|
# Iterate over our capture files.
|
|
|
|
PASS=0
|
2018-06-06 17:10:07 +00:00
|
|
|
while [ $PASS -lt "$MAX_PASSES" ] || [ "$MAX_PASSES" -lt 1 ] ; do
|
|
|
|
PASS=$(( PASS + 1 ))
|
2006-08-02 18:59:29 +00:00
|
|
|
echo "Pass $PASS:"
|
|
|
|
|
|
|
|
for PKT_TYPE in $PKT_TYPES ; do
|
2018-06-06 17:10:07 +00:00
|
|
|
if [ $PASS -gt "$MAX_PASSES" ] && [ "$MAX_PASSES" -ge 1 ] ; then
|
2012-08-19 13:50:22 +00:00
|
|
|
break # We caught a signal
|
|
|
|
fi
|
|
|
|
echo -n " $PKT_TYPE: "
|
2006-08-02 18:59:29 +00:00
|
|
|
|
2012-08-19 13:50:22 +00:00
|
|
|
DISSECTOR_BUG=0
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
VG_ERR_CNT=0
|
2006-08-02 18:59:29 +00:00
|
|
|
|
2018-06-06 17:10:07 +00:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
"$RANDPKT" $RANDPKT_ARGS -t "$PKT_TYPE" "$TMP_DIR/$TMP_FILE" \
|
2006-08-02 18:59:29 +00:00
|
|
|
> /dev/null 2>&1
|
|
|
|
|
2018-06-06 17:10:07 +00:00
|
|
|
for ARGS in "${RUNNER_ARGS[@]}" ; do
|
2012-10-02 17:58:00 +00:00
|
|
|
echo -n "($ARGS) "
|
2018-06-06 17:10:07 +00:00
|
|
|
echo -e "Command and args: $RUNNER $ARGS\\n" > "$TMP_DIR/$ERR_FILE"
|
2013-01-26 20:36:57 +00:00
|
|
|
|
2016-09-21 21:41:04 +00:00
|
|
|
# Run in a child process with limits.
|
2013-01-26 20:36:57 +00:00
|
|
|
(
|
2016-09-21 21:41:04 +00:00
|
|
|
# Set some limits to the child processes, e.g. stop it if
|
|
|
|
# it's running longer than MAX_CPU_TIME seconds. (ulimit
|
|
|
|
# is not supported well on cygwin - it shows some warnings -
|
|
|
|
# and the features we use may not all be supported on some
|
|
|
|
# UN*X platforms.)
|
2016-09-11 19:08:45 +00:00
|
|
|
ulimit -S -t $MAX_CPU_TIME -s $MAX_STACK
|
2016-09-21 21:41:04 +00:00
|
|
|
|
|
|
|
# Allow core files to be generated
|
2013-01-26 20:36:57 +00:00
|
|
|
ulimit -c unlimited
|
2016-09-11 19:08:45 +00:00
|
|
|
|
|
|
|
# Don't enable ulimit -v when using ASAN. See
|
|
|
|
# https://github.com/google/sanitizers/wiki/AddressSanitizer#ulimit--v
|
|
|
|
if [ $ASAN -eq 0 ]; then
|
2016-09-21 21:41:04 +00:00
|
|
|
ulimit -S -v $MAX_VMEM
|
2016-09-11 19:08:45 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-06 17:10:07 +00:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
"$RUNNER" $ARGS "$TMP_DIR/$TMP_FILE" \
|
|
|
|
> /dev/null 2>> "$TMP_DIR/$ERR_FILE"
|
2013-01-26 20:36:57 +00:00
|
|
|
)
|
2012-10-02 17:58:00 +00:00
|
|
|
RETVAL=$?
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
|
|
|
|
if [ $VALGRIND -eq 1 ]; then
|
2018-06-06 17:10:07 +00:00
|
|
|
VG_ERR_CNT=$( grep "ERROR SUMMARY:" "$TMP_DIR/$ERR_FILE" | cut -f4 -d' ' )
|
|
|
|
VG_DEF_LEAKED=$( grep "definitely lost:" "$TMP_DIR/$ERR_FILE" | cut -f7 -d' ' | tr -d , )
|
|
|
|
VG_IND_LEAKED=$( grep "indirectly lost:" "$TMP_DIR/$ERR_FILE" | cut -f7 -d' ' | tr -d , )
|
|
|
|
VG_TOTAL_LEAKED=$(( "$VG_DEF_LEAKED" + "$VG_IND_LEAKED" ))
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
if [ $RETVAL -ne 0 ] ; then
|
|
|
|
echo "General Valgrind failure."
|
|
|
|
VG_ERR_CNT=1
|
|
|
|
elif [ "$VG_TOTAL_LEAKED" -gt "$MAX_LEAK" ] ; then
|
|
|
|
echo "Definitely + indirectly ($VG_DEF_LEAKED + $VG_IND_LEAKED) exceeds max ($MAX_LEAK)."
|
2018-06-06 17:10:07 +00:00
|
|
|
echo "Definitely + indirectly ($VG_DEF_LEAKED + $VG_IND_LEAKED) exceeds max ($MAX_LEAK)." >> "$TMP_DIR/$ERR_FILE"
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
VG_ERR_CNT=1
|
|
|
|
fi
|
2018-06-06 17:10:07 +00:00
|
|
|
if grep -q "Valgrind cannot continue" "$TMP_DIR/$ERR_FILE" ; then
|
Add valgrind support to randpkt-test.sh.
There's already valgrind support in fuzz-test.sh; This change simply clones the
relevant fragments of script into randpkt-test.sh, making very minor tweaks as
needed. Valgrind support in randpkt-test.sh is enabled through the "-g"
command-line option, just like with fuzz-test.sh.
In my testing here, it seems MAX_LEAK could be reduced somewhat, but I don't
think that that belongs as part of this change; I've simply kept the MAX_LEAK
value from fuzz-test.sh.
While we're here, the last line of valgrind-wireshark.sh launches a subprocess,
and that shell then simply returns its exit code, so there is no need for the
shell to stick around. So, let's use "exec" here to replace the shell with the
new process.
Testing Done: On Linux amd64, ran several iterations of randpkt-test.sh and
fuzz-test.sh, both with and without the "-g" option.
Change-Id: I87cc63559dc2e66c42c905f46657ce40cabf0104
Reviewed-on: https://code.wireshark.org/review/27741
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 08:53:59 +00:00
|
|
|
echo "Valgrind unable to continue."
|
|
|
|
VG_ERR_CNT=-1
|
|
|
|
fi
|
|
|
|
fi
|
2012-10-03 16:39:35 +00:00
|
|
|
if [ $RETVAL -ne 0 ] ; then break ; fi
|
2012-10-02 17:58:00 +00:00
|
|
|
done
|
2018-06-06 17:10:07 +00:00
|
|
|
grep -i "dissector bug" "$TMP_DIR/$ERR_FILE" \
|
2012-08-19 13:50:22 +00:00
|
|
|
> /dev/null 2>&1 && DISSECTOR_BUG=1
|
2012-10-03 18:03:12 +00:00
|
|
|
|
2018-06-06 17:10:07 +00:00
|
|
|
if [ $RETVAL -ne 0 ] || [ $DISSECTOR_BUG -ne 0 ] || [ $VG_ERR_CNT -ne 0 ] ; then
|
2014-03-30 20:55:08 +00:00
|
|
|
ws_exit_error
|
2012-08-19 13:50:22 +00:00
|
|
|
fi
|
|
|
|
echo " OK"
|
2018-06-06 17:10:07 +00:00
|
|
|
rm -f "$TMP_DIR/$TMP_FILE" "$TMP_DIR/$ERR_FILE"
|
2006-08-02 18:59:29 +00:00
|
|
|
done
|
|
|
|
done
|