From f22c7139e06f46685384d7ac22f4c0279cc13195 Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Mon, 20 Feb 2017 16:35:32 +0100 Subject: [PATCH] tools: add options validation. This prevents to call the apps with incongruent options. Change-Id: I76919a2da141bd277c06e708548c971c19dd7af7 Reviewed-on: https://code.wireshark.org/review/20211 Reviewed-by: Dario Lombardo --- tools/valgrind-wireshark.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/valgrind-wireshark.sh b/tools/valgrind-wireshark.sh index 8328370183..1ffdc7530e 100755 --- a/tools/valgrind-wireshark.sh +++ b/tools/valgrind-wireshark.sh @@ -62,7 +62,7 @@ while getopts ":2a:b:C:lmnpP:rstTYwcevWdG" OPTCHAR ; do COMMAND_ARGS="-E 0.02" # We don't care about the output of editcap COMMAND_ARGS2="/dev/null" ;; - v) VERBOSE="--num-callers=256" ;; + v) VERBOSE="--num-callers=256 -v" ;; W) COMMAND=wireshark COMMAND_ARGS="" VALID=1 ;; @@ -78,6 +78,13 @@ while getopts ":2a:b:C:lmnpP:rstTYwcevWdG" OPTCHAR ; do done 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 + exit 1 +fi + if [ $# -ge 1 ] then PCAP=$1 @@ -135,7 +142,7 @@ cmdline="$LIBTOOL valgrind --suppressions=`dirname $0`/vg-suppressions $ADDITION --tool=$TOOL $CALLGRIND_OUT_FILE $VERBOSE $LEAK_CHECK $REACHABLE $GEN_SUPPRESSIONS $TRACK_ORIGINS \ $COMMAND $COMMAND_ARGS $PCAP $COMMAND_ARGS2" -if [ $VERBOSE ];then +if [ "$VERBOSE" != "" ];then echo -e "\n$cmdline\n" fi