More shellcheck checks and fixes.
Remove a libtool check while we're here. Change-Id: I813add2031480f34ce89f268b541f8939016c2c7 Reviewed-on: https://code.wireshark.org/review/28066 Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
0882e94cff
commit
4905983845
|
@ -3013,6 +3013,11 @@ if(SHELLCHECK_EXECUTABLE)
|
|||
# --external-sources requires 0.4.0 or later.
|
||||
add_custom_command(TARGET shellcheck POST_BUILD
|
||||
COMMAND shellcheck --external-sources
|
||||
image/stock_icons/svg-to-png.sh
|
||||
packaging/macosx/osx-app.sh.in
|
||||
packaging/macosx/osx-dmg.sh.in
|
||||
tools/compress-pngs.sh
|
||||
tools/git-export-release.sh
|
||||
tools/fuzz-test.sh
|
||||
tools/randpkt-test.sh
|
||||
tools/release-update-debian-soversions.sh
|
||||
|
|
|
@ -80,8 +80,8 @@ for SIZE in 14x14 16x16 24x14 24x14 ; do
|
|||
HEIGHT=${SIZE/*x/}
|
||||
SIZE_DIR=${SIZE}
|
||||
|
||||
TWO_X_WIDTH=`expr $WIDTH \* 2`
|
||||
TWO_X_HEIGHT=`expr $HEIGHT \* 2`
|
||||
TWO_X_WIDTH=$(( WIDTH * 2 ))
|
||||
TWO_X_HEIGHT=$(( HEIGHT * 2 ))
|
||||
ONE_X_ARGS="--export-width=${WIDTH} --export-height=${HEIGHT}"
|
||||
TWO_X_ARGS="--export-width=${TWO_X_WIDTH} --export-height=${TWO_X_HEIGHT}"
|
||||
|
||||
|
@ -89,7 +89,7 @@ for SIZE in 14x14 16x16 24x14 24x14 ; do
|
|||
cd $SIZE_DIR || exit 1
|
||||
|
||||
for ICON in $ICONS ; do
|
||||
set_source_svgs $ICON
|
||||
set_source_svgs "$ICON"
|
||||
|
||||
if [ ! -f ${ONE_X_SVG} ] ; then
|
||||
>&2 echo "Skipping ${ONE_X_SVG}"
|
||||
|
@ -99,12 +99,14 @@ for SIZE in 14x14 16x16 24x14 24x14 ; do
|
|||
ONE_X_PNG=${ICON}.png
|
||||
TWO_X_PNG=${ICON}@2x.png
|
||||
|
||||
if [ $ONE_X_SVG -nt $ONE_X_PNG ] ; then
|
||||
if [ $ONE_X_SVG -nt "$ONE_X_PNG" ] ; then
|
||||
# shellcheck disable=SC2086
|
||||
inkscape $COMMON_ARGS $ONE_X_ARGS \
|
||||
--file="$PWD/$ONE_X_SVG" --export-png="$PWD/$ONE_X_PNG" || exit 1
|
||||
fi
|
||||
|
||||
if [ $TWO_X_SVG -nt $TWO_X_PNG ] ; then
|
||||
if [ $TWO_X_SVG -nt "$TWO_X_PNG" ] ; then
|
||||
# shellcheck disable=SC2086
|
||||
inkscape $COMMON_ARGS $TWO_X_ARGS \
|
||||
--file="$PWD/$TWO_X_SVG" --export-png="$PWD/$TWO_X_PNG" || exit 1
|
||||
fi
|
||||
|
|
|
@ -44,7 +44,7 @@ bundle="Wireshark.app"
|
|||
# Location for libraries (tools/macos-setup.sh defaults to whatever the
|
||||
# various support libraries use as their standard installation location,
|
||||
# which is /usr/local)
|
||||
if [ -z $LIBPREFIX ]; then
|
||||
if [ -z "$LIBPREFIX" ]; then
|
||||
LIBPREFIX="/usr/local"
|
||||
fi
|
||||
|
||||
|
@ -119,21 +119,21 @@ exclude_prefixes="$exclude_prefixes|$qt_frameworks_dir"
|
|||
|
||||
# Package paths
|
||||
pkgexec="$bundle/Contents/MacOS"
|
||||
pkgres="$bundle/Contents/Resources"
|
||||
#pkgres="$bundle/Contents/Resources"
|
||||
pkglib="$bundle/Contents/Frameworks"
|
||||
pkgplugin="$bundle/Contents/PlugIns/wireshark/@VERSION_MAJOR@.@VERSION_MINOR@"
|
||||
|
||||
# Set the 'macosx' directory, usually the current directory.
|
||||
resdir=`pwd`
|
||||
#resdir=$( pwd )
|
||||
|
||||
#
|
||||
# Get a list of all binaries in the bundle.
|
||||
# Treat all plain files with read and execute permissions for all as
|
||||
# binaries.
|
||||
#
|
||||
bundle_binary_list=`find $pkgexec -type f -perm -0555 -print`
|
||||
bundle_binary_list=$( find $pkgexec -type f -perm -0555 -print )
|
||||
|
||||
echo -e "\nFixing up $bundle...\n"
|
||||
echo -e "\\nFixing up $bundle...\\n"
|
||||
|
||||
# Find out libs we need from Fink, MacPorts, or from a custom install
|
||||
# (i.e. $LIBPREFIX), then loop until no changes.
|
||||
|
@ -169,19 +169,22 @@ while $endl; do
|
|||
#
|
||||
# eliminate duplicates.
|
||||
#
|
||||
libs="`\
|
||||
libs="$(
|
||||
# shellcheck disable=SC2086
|
||||
otool -L $bundle_binary_list "$pkglib"/*.dylib 2>/dev/null \
|
||||
| fgrep compatibility \
|
||||
| grep -F compatibility \
|
||||
| cut -d\( -f1 \
|
||||
| sed '1,$s;^ libssh; /usr/local/lib/libssh;' \
|
||||
| egrep -v "$exclude_prefixes" \
|
||||
| grep -E -v "$exclude_prefixes" \
|
||||
| sort \
|
||||
| uniq \
|
||||
`"
|
||||
)"
|
||||
# shellcheck disable=SC2086
|
||||
cp -vn $libs "$pkglib"
|
||||
let "a+=1"
|
||||
nnfiles=`ls "$pkglib" | wc -l`
|
||||
if [ $nnfiles = $nfiles ]; then
|
||||
(( a += 1 ))
|
||||
# shellcheck disable=SC2012
|
||||
nnfiles=$( ls "$pkglib" | wc -l )
|
||||
if [ "$nnfiles" = $nfiles ]; then
|
||||
endl=false
|
||||
else
|
||||
nfiles=$nnfiles
|
||||
|
@ -193,7 +196,7 @@ chmod 755 "$pkglib"/*.dylib
|
|||
# Strip libraries and executables if requested
|
||||
#----------------------------------------------------------
|
||||
if [ "$strip" = "true" ]; then
|
||||
echo -e "\nStripping debugging symbols...\n"
|
||||
echo -e "\\nStripping debugging symbols...\\n"
|
||||
strip -x "$pkglib"/*.dylib
|
||||
strip -ur "$bundle_binary_list"
|
||||
fi
|
||||
|
@ -222,8 +225,9 @@ rpathify_file () {
|
|||
#
|
||||
# OK, what type of file is this?
|
||||
#
|
||||
filetype=$( otool -hv "$1" | egrep MH_MAGIC | awk '{print $5}' ; exit ${PIPESTATUS[0]} )
|
||||
if [ $? -ne 0 ] ; then
|
||||
filetype=$( otool -hv "$1" | grep -E MH_MAGIC | awk '{print $5}' ; exit "${PIPESTATUS[0]}" )
|
||||
RETVAL=$0
|
||||
if [ "$RETVAL" -ne 0 ] ; then
|
||||
echo "Unable to rpathify $1 in $( pwd ): file type failed."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -241,38 +245,38 @@ rpathify_file () {
|
|||
#
|
||||
if [[ "$filetype" = "DYLIB" || "$filetype" = "BUNDLE" ]]; then
|
||||
echo "Changing shared library identification of $1"
|
||||
base=`echo $1 | awk -F/ '{print $NF}'`
|
||||
base=$( echo "$1" | awk -F/ '{print $NF}' )
|
||||
#
|
||||
# The library will end up in a directory in
|
||||
# the rpath; this is what we should change its
|
||||
# ID to.
|
||||
#
|
||||
to=@rpath/$base
|
||||
/usr/bin/install_name_tool -id $to $1
|
||||
/usr/bin/install_name_tool -id "$to" "$1"
|
||||
|
||||
#
|
||||
# If we're a library and we depend on something in
|
||||
# @executable_path/../Frameworks, replace that with
|
||||
# @rpath.
|
||||
#
|
||||
otool -L $1 | grep @executable_path/../Frameworks | awk '{print $1}' | \
|
||||
while read dep_lib ; do
|
||||
base=`echo $dep_lib | awk -F/ '{print $NF}'`
|
||||
otool -L "$1" | grep @executable_path/../Frameworks | awk '{print $1}' | \
|
||||
while read -r dep_lib ; do
|
||||
base=$( echo "$dep_lib" | awk -F/ '{print $NF}' )
|
||||
to="@rpath/$base"
|
||||
echo "Changing reference to $dep_lib to $to in $1"
|
||||
/usr/bin/install_name_tool -change $dep_lib $to $1
|
||||
/usr/bin/install_name_tool -change "$dep_lib" "$to" "$1"
|
||||
done
|
||||
fi
|
||||
|
||||
#
|
||||
# Find our local rpaths and remove them.
|
||||
#
|
||||
otool -l $1 | grep -A2 LC_RPATH \
|
||||
otool -l "$1" | grep -A2 LC_RPATH \
|
||||
| awk '$1=="path" && $2 !~ /^@/ {print $2}' \
|
||||
| egrep -v "$exclude_prefixes" | \
|
||||
while read lc_rpath ; do
|
||||
| grep -E -v "$exclude_prefixes" | \
|
||||
while read -r lc_rpath ; do
|
||||
echo "Stripping LC_RPATH $lc_rpath from $1"
|
||||
install_name_tool -delete_rpath $lc_rpath $1
|
||||
install_name_tool -delete_rpath "$lc_rpath" "$1"
|
||||
done
|
||||
|
||||
#
|
||||
|
@ -293,7 +297,7 @@ rpathify_file () {
|
|||
fi
|
||||
|
||||
echo "Adding @executable_path/$framework_path to rpath of $1"
|
||||
/usr/bin/install_name_tool -add_rpath @executable_path/$framework_path $1
|
||||
/usr/bin/install_name_tool -add_rpath @executable_path/$framework_path "$1"
|
||||
fi
|
||||
|
||||
#
|
||||
|
@ -302,7 +306,7 @@ rpathify_file () {
|
|||
#
|
||||
if [[ "$filetype" = "EXECUTE" || "$filetype" = "DYLIB" ]] && [[ "$VERSION" -ge "7" ]] ; then
|
||||
echo "Minimum macOS version for $1:"
|
||||
otool -l $1 | grep -A3 LC_VERSION_MIN_MACOSX
|
||||
otool -l "$1" | grep -A3 LC_VERSION_MIN_MACOSX
|
||||
fi
|
||||
|
||||
#
|
||||
|
@ -315,20 +319,20 @@ rpathify_file () {
|
|||
# system on which the bundle will be installed,
|
||||
# and should be referred to by their full pathnames.
|
||||
#
|
||||
libs="`\
|
||||
otool -L $1 \
|
||||
| fgrep compatibility \
|
||||
libs="$(
|
||||
otool -L "$1" \
|
||||
| grep -F compatibility \
|
||||
| cut -d\( -f1 \
|
||||
| egrep -v "$exclude_prefixes" \
|
||||
| grep -E -v "$exclude_prefixes" \
|
||||
| sort \
|
||||
| uniq \
|
||||
`"
|
||||
)"
|
||||
|
||||
for lib in $libs; do
|
||||
#
|
||||
# Get the file name of the library.
|
||||
#
|
||||
base=`echo $lib | awk -F/ '{print $NF}'`
|
||||
base=$( echo "$lib" | awk -F/ '{print $NF}' )
|
||||
#
|
||||
# The library will end up in a directory in
|
||||
# the rpath; this is what we should change its
|
||||
|
@ -339,7 +343,7 @@ rpathify_file () {
|
|||
# Change the reference to that library.
|
||||
#
|
||||
echo "Changing reference to $lib to $to in $1"
|
||||
/usr/bin/install_name_tool -change $lib $to $1
|
||||
/usr/bin/install_name_tool -change "$lib" "$to" "$1"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
@ -350,15 +354,15 @@ rpathify_dir () {
|
|||
# Make sure we *have* that directory
|
||||
#
|
||||
if [ -d "$1" ]; then
|
||||
(cd "$1"
|
||||
(cd "$1" || exit 1
|
||||
echo "rpathifying $1"
|
||||
#
|
||||
# Make sure we *have* files to fix
|
||||
#
|
||||
files=`ls $2 2>/dev/null`
|
||||
files=$( ls "$2" 2>/dev/null )
|
||||
if [ ! -z "$files" ]; then
|
||||
for file in $files; do
|
||||
rpathify_file "$file" "`pwd`"
|
||||
rpathify_file "$file" "$( pwd )"
|
||||
done
|
||||
fi
|
||||
)
|
||||
|
@ -381,8 +385,7 @@ rpathify_files () {
|
|||
rpathify_dir "$pkgexec/extcap" "*"
|
||||
}
|
||||
|
||||
PATHLENGTH=`echo $LIBPREFIX | wc -c`
|
||||
if [ "$PATHLENGTH" -ge "6" ]; then
|
||||
if [ ${#LIBPREFIX} -ge "6" ]; then
|
||||
# If the LIBPREFIX path is long enough to allow
|
||||
# path rewriting, then do this.
|
||||
# 6 is the length of @rpath, which replaces LIBPREFIX.
|
||||
|
@ -407,23 +410,23 @@ for binary in $bundle_binary_list ; do
|
|||
done
|
||||
|
||||
echo "Dsymifying frameworks"
|
||||
for framework in $pkglib/*.framework/Versions/*/* ; do
|
||||
for framework in "$pkglib"/*.framework/Versions/*/* ; do
|
||||
if [ -f "$framework" ];then
|
||||
dsymutil "$framework"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Dsymifying libraries"
|
||||
for library in $pkglib/*.dylib ; do
|
||||
for library in "$pkglib"/*.dylib ; do
|
||||
#
|
||||
# Squelch warnings, in case the .o files from building
|
||||
# support libraries aren't around any more.
|
||||
#
|
||||
dsymutil "$library" | egrep -v 'unable to open object file'
|
||||
dsymutil "$library" | grep -E -v 'unable to open object file'
|
||||
done
|
||||
|
||||
echo "Dsymifying plugins"
|
||||
for plugin in $pkgplugin/*/*.so ; do
|
||||
for plugin in "$pkgplugin"/*/*.so ; do
|
||||
dsymutil "$plugin"
|
||||
done
|
||||
|
||||
|
@ -448,17 +451,17 @@ if [ -n "$CODE_SIGN_IDENTITY" ] ; then
|
|||
done
|
||||
|
||||
echo "Signing frameworks"
|
||||
for framework in $pkglib/*.framework/Versions/*/* ; do
|
||||
for framework in "$pkglib"/*.framework/Versions/*/* ; do
|
||||
codesign_file "$framework"
|
||||
done
|
||||
|
||||
echo "Signing libraries"
|
||||
for library in $pkglib/*.dylib ; do
|
||||
for library in "$pkglib"/*.dylib ; do
|
||||
codesign_file "$library"
|
||||
done
|
||||
|
||||
echo "Signing plugins"
|
||||
for plugin in $pkgplugin/*/*.so ; do
|
||||
for plugin in "$pkgplugin"/*/*.so ; do
|
||||
codesign_file "$plugin"
|
||||
done
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ fi
|
|||
|
||||
# Get the architecture
|
||||
ws_bin="$app_bundle/Contents/MacOS/Wireshark"
|
||||
case `file $ws_bin` in
|
||||
case $( file "$ws_bin" ) in
|
||||
*Mach-O*64-bit*x86_64*)
|
||||
architecture="Intel 64"
|
||||
;;
|
||||
|
@ -143,7 +143,7 @@ case `file $ws_bin` in
|
|||
;;
|
||||
*)
|
||||
echo "Cannot determine architecture of $ws_bin; file reports:"
|
||||
file $ws_bin
|
||||
file "$ws_bin"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -155,7 +155,7 @@ if [ -z "$version" ] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\nCREATE WIRESHARK PACKAGE\n"
|
||||
echo -e "\\nCREATE WIRESHARK PACKAGE\\n"
|
||||
pkg_title="$volume_name $version $architecture"
|
||||
pkg_file="$pkg_title.pkg"
|
||||
rm -rf "$pkg_file"
|
||||
|
@ -175,12 +175,12 @@ if [ -n "$CODE_SIGN_IDENTITY" ] ; then
|
|||
spctl --assess --type install "$pkg_file" || exit 1
|
||||
pkgutil --check-signature "$pkg_file" || exit 1
|
||||
shasum "$pkg_file"
|
||||
rm -rf "$pkg_dir_unsigned" "$pkg_file_unsigned" "$pkg_file_flattened"
|
||||
rm -rf "$pkg_file_unsigned"
|
||||
else
|
||||
echo "Code signing not performed (no identity)"
|
||||
fi
|
||||
|
||||
echo -e "\nCREATE WIRESHARK DISK IMAGE\n"
|
||||
echo -e "\\nCREATE WIRESHARK DISK IMAGE\\n"
|
||||
img_name="$pkg_title.dmg"
|
||||
|
||||
# Create temp directory with desired contents of the release volume.
|
||||
|
@ -191,7 +191,7 @@ echo -e "Copying files to temp directory"
|
|||
# Copy the installer package
|
||||
cp "$pkg_file" "$tmp_dir"/ || exit 1
|
||||
# Copy the readme
|
||||
cp "$src_dir/Read_me_first.rtf" "$tmp_dir"/"Read me first.rtf" || exit 1
|
||||
cp "$src_dir/Read_me_first.rtf" "$tmp_dir/Read me first.rtf" || exit 1
|
||||
|
||||
# If the appearance settings are not to be modified we just copy them
|
||||
if [ ${set_ds_store} = "false" ]; then
|
||||
|
@ -199,7 +199,7 @@ if [ ${set_ds_store} = "false" ]; then
|
|||
# window size, appearance, etc. Most of this can be set
|
||||
# with Apple script but involves user intervention so we
|
||||
# just keep a copy of the correct settings and use that instead.
|
||||
cp $src_dir/$ds_store_root "$tmp_dir/.DS_Store" || exit 1
|
||||
cp "$src_dir/$ds_store_root" "$tmp_dir/.DS_Store" || exit 1
|
||||
auto_open_opt=-noautoopen
|
||||
fi
|
||||
|
||||
|
@ -212,8 +212,8 @@ rm -f "$rw_name"
|
|||
rm -rf "$tmp_dir"
|
||||
|
||||
# Mount the created image.
|
||||
MOUNT_DIR="/Volumes/$volume_name"
|
||||
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify $auto_open_opt "$rw_name" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
|
||||
#MOUNT_DIR="/Volumes/$volume_name"
|
||||
DEV_NAME=$( /usr/bin/hdiutil attach -readwrite -noverify $auto_open_opt "$rw_name" | grep -E '^/dev/' | sed 1q | awk '{print $1}' )
|
||||
|
||||
# Have the disk image window open automatically when mounted.
|
||||
bless -openfolder /Volumes/$volume_name
|
||||
|
@ -232,12 +232,12 @@ if [ ${set_ds_store} = "true" ]; then
|
|||
* then close it and press enter *
|
||||
**************************************
|
||||
"
|
||||
read -e DUMB
|
||||
read -r -e _
|
||||
|
||||
# .DS_Store files aren't written till the disk is unmounted, or finder is restarted.
|
||||
hdiutil detach "$DEV_NAME"
|
||||
auto_open_opt=-noautoopen
|
||||
DEV_NAME=`/usr/bin/hdiutil attach -readwrite -noverify $auto_open_opt "$rw_name" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
|
||||
DEV_NAME=$( /usr/bin/hdiutil attach -readwrite -noverify $auto_open_opt "$rw_name" | grep -E '^/dev/' | sed 1q | awk '{print $1}' )
|
||||
echo
|
||||
cp /Volumes/$volume_name/.DS_Store ./$ds_store_root
|
||||
SetFile -a v ./$ds_store_root
|
||||
|
|
|
@ -24,14 +24,13 @@ JOBS=8
|
|||
export FILE_LIST_CMD
|
||||
(
|
||||
echo -n "PNG_FILES ="
|
||||
bash -c "$FILE_LIST_CMD" | while read PNG_FILE ; do
|
||||
bash -c "$FILE_LIST_CMD" | while read -r PNG_FILE ; do
|
||||
echo -e " \\"
|
||||
echo -e -n "\t${PNG_FILE}"
|
||||
echo -e -n "\\t${PNG_FILE}"
|
||||
|
||||
done
|
||||
cat <<"FIN"
|
||||
|
||||
|
||||
all: $(PNG_FILES)
|
||||
|
||||
$(PNG_FILES): FORCE
|
||||
|
|
|
@ -17,9 +17,10 @@ DESTDIR=.
|
|||
while getopts "d:" OPTCHAR ; do
|
||||
case $OPTCHAR in
|
||||
d) DESTDIR=$OPTARG ;;
|
||||
*) printf "Unknown option %s" "$OPTCHAR"
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
# The remaining parameter, if set, is a git commit, like v1.12.0-rc1 or 54819e5699f
|
||||
# By default HEAD is used.
|
||||
|
@ -37,7 +38,7 @@ if [ ! -e "${GIT_DIR:-.git}" ] ; then
|
|||
fi
|
||||
|
||||
# --abbrev=<n> and --match should match make-version.pl.
|
||||
DESCRIPTION=$(git describe --abbrev=8 --match "v[1-9]*" ${COMMIT})
|
||||
DESCRIPTION=$(git describe --abbrev=8 --match "v[1-9]*" "${COMMIT}")
|
||||
VERSION=${DESCRIPTION#v}
|
||||
STASH_POP=False
|
||||
|
||||
|
@ -74,7 +75,7 @@ fi
|
|||
|
||||
echo "Creating wireshark-$VERSION.tar.xz"
|
||||
|
||||
git archive --prefix=wireshark-${VERSION}/ ${COMMIT} | xz > ${DESTDIR}/wireshark-${VERSION}.tar.xz
|
||||
git archive --prefix="wireshark-${VERSION}/" ${COMMIT} | xz > "${DESTDIR}/wireshark-${VERSION}.tar.xz"
|
||||
|
||||
if [ "$STASH_POP" == "True" ] ; then
|
||||
git stash pop
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
TEST_TYPE="randpkt"
|
||||
# shellcheck source=tools/test-common.sh
|
||||
. `dirname $0`/test-common.sh || exit 1
|
||||
. "$( dirname "$0" )"/test-common.sh || exit 1
|
||||
|
||||
# Run under valgrind ?
|
||||
VALGRIND=0
|
||||
|
@ -18,12 +18,12 @@ ASAN=$CONFIGURED_WITH_ASAN
|
|||
|
||||
# Trigger an abort if a dissector finds a bug.
|
||||
# Uncomment to disable
|
||||
WIRESHARK_ABORT_ON_DISSECTOR_BUG="True"
|
||||
export WIRESHARK_ABORT_ON_DISSECTOR_BUG="True"
|
||||
|
||||
# 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.
|
||||
MAX_LEAK=`expr 1024 \* 100`
|
||||
MAX_LEAK=$(( 1024 * 100 ))
|
||||
|
||||
# To do: add options for file names and limits
|
||||
while getopts "ab:d:gp:t:" OPTCHAR ; do
|
||||
|
@ -34,9 +34,10 @@ while getopts "ab:d:gp:t:" OPTCHAR ; do
|
|||
g) VALGRIND=1 ;;
|
||||
p) MAX_PASSES=$OPTARG ;;
|
||||
t) PKT_TYPES=$OPTARG ;;
|
||||
*) printf "Unknown option: %s\\n" "$OPTARG"
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
### usually you won't have to change anything below this line ###
|
||||
|
||||
|
@ -46,13 +47,13 @@ ws_check_exec "$TSHARK" "$RANDPKT" "$DATE" "$TMP_DIR"
|
|||
[[ -z "$PKT_TYPES" ]] && PKT_TYPES=$($RANDPKT -h | awk '/^\t/ {print $1}')
|
||||
|
||||
if [ $VALGRIND -eq 1 ]; then
|
||||
RUNNER="`dirname $0`/valgrind-wireshark.sh"
|
||||
RUNNER="$( dirname "$0" )/valgrind-wireshark.sh"
|
||||
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)
|
||||
MAX_CPU_TIME=`expr 3 \* $MAX_CPU_TIME`
|
||||
MAX_VMEM=`expr 3 \* $MAX_VMEM / 2`
|
||||
MAX_CPU_TIME=$(( 3 * "$MAX_CPU_TIME" ))
|
||||
MAX_VMEM=$(( 3 * "$MAX_VMEM" / 2 ))
|
||||
else
|
||||
# Not using valgrind, use regular tshark.
|
||||
# TShark arguments (you won't have to change these)
|
||||
|
@ -73,7 +74,7 @@ else
|
|||
fi
|
||||
|
||||
HOWMANY="forever"
|
||||
if [ $MAX_PASSES -gt 0 ]; then
|
||||
if [ "$MAX_PASSES" -gt 0 ]; then
|
||||
HOWMANY="$MAX_PASSES passes"
|
||||
fi
|
||||
echo -n "Running $RUNNER with args: "
|
||||
|
@ -87,12 +88,12 @@ trap "MAX_PASSES=1; echo 'Caught signal'" HUP INT TERM
|
|||
|
||||
# Iterate over our capture files.
|
||||
PASS=0
|
||||
while [ $PASS -lt $MAX_PASSES -o $MAX_PASSES -lt 1 ] ; do
|
||||
let PASS=$PASS+1
|
||||
while [ $PASS -lt "$MAX_PASSES" ] || [ "$MAX_PASSES" -lt 1 ] ; do
|
||||
PASS=$(( PASS + 1 ))
|
||||
echo "Pass $PASS:"
|
||||
|
||||
for PKT_TYPE in $PKT_TYPES ; do
|
||||
if [ $PASS -gt $MAX_PASSES -a $MAX_PASSES -ge 1 ] ; then
|
||||
if [ $PASS -gt "$MAX_PASSES" ] && [ "$MAX_PASSES" -ge 1 ] ; then
|
||||
break # We caught a signal
|
||||
fi
|
||||
echo -n " $PKT_TYPE: "
|
||||
|
@ -100,12 +101,13 @@ while [ $PASS -lt $MAX_PASSES -o $MAX_PASSES -lt 1 ] ; do
|
|||
DISSECTOR_BUG=0
|
||||
VG_ERR_CNT=0
|
||||
|
||||
"$RANDPKT" $RANDPKT_ARGS -t $PKT_TYPE $TMP_DIR/$TMP_FILE \
|
||||
# shellcheck disable=SC2086
|
||||
"$RANDPKT" $RANDPKT_ARGS -t "$PKT_TYPE" "$TMP_DIR/$TMP_FILE" \
|
||||
> /dev/null 2>&1
|
||||
|
||||
for ARGS in "${RUNNER_ARGS[@]}" ; do
|
||||
for ARGS in "${RUNNER_ARGS[@]}" ; do
|
||||
echo -n "($ARGS) "
|
||||
echo -e "Command and args: $RUNNER $ARGS\n" > $TMP_DIR/$ERR_FILE
|
||||
echo -e "Command and args: $RUNNER $ARGS\\n" > "$TMP_DIR/$ERR_FILE"
|
||||
|
||||
# Run in a child process with limits.
|
||||
(
|
||||
|
@ -125,38 +127,39 @@ while [ $PASS -lt $MAX_PASSES -o $MAX_PASSES -lt 1 ] ; do
|
|||
ulimit -S -v $MAX_VMEM
|
||||
fi
|
||||
|
||||
"$RUNNER" $ARGS $TMP_DIR/$TMP_FILE \
|
||||
> /dev/null 2>> $TMP_DIR/$ERR_FILE
|
||||
# shellcheck disable=SC2086
|
||||
"$RUNNER" $ARGS "$TMP_DIR/$TMP_FILE" \
|
||||
> /dev/null 2>> "$TMP_DIR/$ERR_FILE"
|
||||
)
|
||||
RETVAL=$?
|
||||
|
||||
if [ $VALGRIND -eq 1 ]; then
|
||||
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=`expr $VG_DEF_LEAKED + $VG_IND_LEAKED`
|
||||
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" ))
|
||||
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)."
|
||||
echo "Definitely + indirectly ($VG_DEF_LEAKED + $VG_IND_LEAKED) exceeds max ($MAX_LEAK)." >> $TMP_DIR/$ERR_FILE
|
||||
echo "Definitely + indirectly ($VG_DEF_LEAKED + $VG_IND_LEAKED) exceeds max ($MAX_LEAK)." >> "$TMP_DIR/$ERR_FILE"
|
||||
VG_ERR_CNT=1
|
||||
fi
|
||||
if grep -q "Valgrind cannot continue" $TMP_DIR/$ERR_FILE; then
|
||||
if grep -q "Valgrind cannot continue" "$TMP_DIR/$ERR_FILE" ; then
|
||||
echo "Valgrind unable to continue."
|
||||
VG_ERR_CNT=-1
|
||||
fi
|
||||
fi
|
||||
if [ $RETVAL -ne 0 ] ; then break ; fi
|
||||
done
|
||||
grep -i "dissector bug" $TMP_DIR/$ERR_FILE \
|
||||
grep -i "dissector bug" "$TMP_DIR/$ERR_FILE" \
|
||||
> /dev/null 2>&1 && DISSECTOR_BUG=1
|
||||
|
||||
if [ $RETVAL -ne 0 -o $DISSECTOR_BUG -ne 0 -o $VG_ERR_CNT -ne 0 ] ; then
|
||||
if [ $RETVAL -ne 0 ] || [ $DISSECTOR_BUG -ne 0 ] || [ $VG_ERR_CNT -ne 0 ] ; then
|
||||
ws_exit_error
|
||||
fi
|
||||
echo " OK"
|
||||
rm -f $TMP_DIR/$TMP_FILE $TMP_DIR/$ERR_FILE
|
||||
rm -f "$TMP_DIR/$TMP_FILE" "$TMP_DIR/$ERR_FILE"
|
||||
done
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
TEST_TYPE="manual"
|
||||
# shellcheck source=tools/test-common.sh
|
||||
. `dirname $0`/test-common.sh || exit 1
|
||||
. "$( dirname "$0" )"/test-common.sh || exit 1
|
||||
|
||||
# Run under AddressSanitizer ?
|
||||
ASAN=$CONFIGURED_WITH_ASAN
|
||||
|
@ -26,13 +26,14 @@ while getopts "ab:" OPTCHAR ; do
|
|||
case $OPTCHAR in
|
||||
a) ASAN=1 ;;
|
||||
b) WIRESHARK_BIN_DIR=$OPTARG ;;
|
||||
*) printf "Unknown option: %s\\n" "$OPTARG"
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
printf "Usage: $(basename $0) [-b bin_dir] /path/to/file[s].pcap\n"
|
||||
printf "Usage: %s [-b bin_dir] /path/to/file[s].pcap\\n" "$( basename "$0" )"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -58,15 +59,15 @@ for file in "$@"
|
|||
do
|
||||
echo "Testing file $file..."
|
||||
echo -n " - with tree... "
|
||||
if $TSHARK -nVxr $file > /dev/null
|
||||
if $TSHARK -nVxr "$file" > /dev/null
|
||||
then
|
||||
echo "OK"
|
||||
echo -n " - without tree... "
|
||||
if $WIRESHARK_BIN_DIR/tshark -nr $file > /dev/null
|
||||
if "$WIRESHARK_BIN_DIR/tshark" -nr "$file" > /dev/null
|
||||
then
|
||||
echo "OK"
|
||||
echo -n " - without tree but with a read filter... "
|
||||
if $WIRESHARK_BIN_DIR/tshark -Yframe -nr $file > /dev/null
|
||||
if "$WIRESHARK_BIN_DIR/tshark" -Yframe -nr "$file" > /dev/null
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
|
|
|
@ -57,16 +57,16 @@ while getopts ":2a:b:C:lmnpP:rstTYwcevWdG" OPTCHAR ; do
|
|||
d) COMMAND=dumpcap
|
||||
COMMAND_ARGS="-i eth1 -c 3000"
|
||||
VALID=1 ;;
|
||||
*) printf "Unknown option -$OPTARG!\n"
|
||||
*) printf "Unknown option: %s\\n" "$OPTARG"
|
||||
exit ;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
# Sanitize parameters
|
||||
if [ "$COMMAND" != "tshark" ] && [[ $COMMAND_ARGS =~ Vx ]]
|
||||
then
|
||||
printf "\nYou can't use -T if you're not using tshark\n\n" >&2
|
||||
printf "\\nYou can't use -T if you're not using tshark\\n\\n" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -78,25 +78,25 @@ fi
|
|||
|
||||
if [ $VALID -eq 0 ]
|
||||
then
|
||||
printf "\nUsage: $(basename $0) [-2] [-a file] [-b bin_dir] [-c] [-e] [-C config_profile] "
|
||||
printf "[-l] [-m] [-n] [-p] [-r] [-s] [-t] [-T] [-w] [-v] /path/to/file.pcap\n"
|
||||
printf "\n"
|
||||
printf "[-2]: run tshark with 2-pass analysis\n"
|
||||
printf "[-a]: additional valgrind suppression file\n"
|
||||
printf "[-b]: tshark binary dir\n"
|
||||
printf "[-e]: use 'editcap -E 0.02' instead of tshark\n"
|
||||
printf "[-c]: use capinfos instead of tshark\n"
|
||||
printf "[-C]: binary profile file\n"
|
||||
printf "[-l]: add valgrind option --leak-check=full\n"
|
||||
printf "[-m]: use valgrind massif tool\n"
|
||||
printf "[-n]: print binary version\n"
|
||||
printf "[-p]: use callgrind massif tool\n"
|
||||
printf "[-r]: add valgrind option --show-reachable=yes\n"
|
||||
printf "[-s]: add valgrind option --gen-suppressions=yes\n"
|
||||
printf "[-t]: add valgrind option --track-origins=yes\n"
|
||||
printf "[-T]: build the tshark tree (-Vx)\n"
|
||||
printf "[-w]: use wireshark instead of tshark\n"
|
||||
printf "[-v]: run in verbose mode (--num-callers=256)\n"
|
||||
printf "\\nUsage: %s [-2] [-a file] [-b bin_dir] [-c] [-e] [-C config_profile] " "$(basename "$0")"
|
||||
printf "[-l] [-m] [-n] [-p] [-r] [-s] [-t] [-T] [-w] [-v] /path/to/file.pcap\\n"
|
||||
printf "\\n"
|
||||
printf "[-2]: run tshark with 2-pass analysis\\n"
|
||||
printf "[-a]: additional valgrind suppression file\\n"
|
||||
printf "[-b]: tshark binary dir\\n"
|
||||
printf "[-e]: use 'editcap -E 0.02' instead of tshark\\n"
|
||||
printf "[-c]: use capinfos instead of tshark\\n"
|
||||
printf "[-C]: binary profile file\\n"
|
||||
printf "[-l]: add valgrind option --leak-check=full\\n"
|
||||
printf "[-m]: use valgrind massif tool\\n"
|
||||
printf "[-n]: print binary version\\n"
|
||||
printf "[-p]: use callgrind massif tool\\n"
|
||||
printf "[-r]: add valgrind option --show-reachable=yes\\n"
|
||||
printf "[-s]: add valgrind option --gen-suppressions=yes\\n"
|
||||
printf "[-t]: add valgrind option --track-origins=yes\\n"
|
||||
printf "[-T]: build the tshark tree (-Vx)\\n"
|
||||
printf "[-w]: use wireshark instead of tshark\\n"
|
||||
printf "[-v]: run in verbose mode (--num-callers=256)\\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -111,23 +111,13 @@ fi
|
|||
|
||||
COMMAND="$WIRESHARK_BIN_DIR/$COMMAND"
|
||||
|
||||
if file $COMMAND | grep -q "ASCII text"; then
|
||||
if [ -x "`dirname $0`/../libtool" ]; then
|
||||
LIBTOOL="`dirname $0`/../libtool"
|
||||
else
|
||||
LIBTOOL="libtool"
|
||||
fi
|
||||
LIBTOOL="$LIBTOOL --mode=execute"
|
||||
else
|
||||
LIBTOOL=""
|
||||
fi
|
||||
|
||||
cmdline="$LIBTOOL valgrind --suppressions=`dirname $0`/vg-suppressions $ADDITIONAL_SUPPRESSION_FILE \
|
||||
cmdline="valgrind --suppressions=$( dirname "$0" )/vg-suppressions $ADDITIONAL_SUPPRESSION_FILE \
|
||||
--tool=$TOOL $CALLGRIND_OUT_FILE $VERBOSE $LEAK_CHECK $REACHABLE $GEN_SUPPRESSIONS $TRACK_ORIGINS \
|
||||
$COMMAND $COMMAND_ARGS $PCAP $COMMAND_ARGS2"
|
||||
|
||||
if [ "$VERBOSE" != "" ];then
|
||||
echo -e "\n$cmdline\n"
|
||||
echo -e "\\n$cmdline\\n"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
exec $cmdline > /dev/null
|
||||
|
|
Loading…
Reference in New Issue