2 (set -o igncr) 2>/dev/null && set -o igncr; # comment is needed
3 # # hack for cygwin bash
6 # Test various command line testable aspects of the Wireshark tools
8 # Wireshark - Network traffic analyzer
9 # By Gerald Combs <gerald@wireshark.org>
10 # Copyright 2005 Ulf Lamping
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 # an existing capture file
32 # Ensure cygwin bin dir is on the path if running under it
33 if [[ $OSTYPE == "cygwin" ]]; then
37 while getopts "chs:" OPTION ; do
41 s) RUN_SUITE="$OPTARG" ;;
42 *) echo "Unknown option: " $OPTION $OPTARG
46 shift $(( $OPTIND - 1 ))
48 if [ $PRINT_USAGE -ne 0 ] ; then
51 Usage: $THIS [-c] [-h] [-s <suite>]
52 -c: Disable color output
53 -h: Print this message and exit
54 -s: Run a suite. Must be one of:
71 if [ -e run/tshark -o -e run/dumpcap -o -e run/rawshark ]; then
72 WS_BIN_PATH=${WS_BIN_PATH:-$(cd run && pwd)}
73 WS_QT_BIN_PATH=${WS_QT_BIN_PATH:-$WS_BIN_PATH}
76 source $MYDIR/test-backend.sh
77 source $MYDIR/config.sh
79 # needed by some tests
80 TEST_OUTDIR=$(mktemp -d)
81 TEST_OUTDIR_CLEAN=${TEST_OUTDIR_CLEAN:-1}
82 if [ -z "$TEST_OUTDIR" ] || ! cd "$TEST_OUTDIR"; then
83 # If for any reason the temporary tests output directory cannot be created...
90 HOME_PATH="$TEST_OUTDIR/home"
91 CONF_PATH="$HOME_PATH/.wireshark"
93 if [ "$WS_SYSTEM" == "Windows" ] ; then
95 HOME_PATH="`cygpath -w $HOME_PATH`"
96 CONF_PATH="$HOME_PATH/Wireshark"
97 CAPTURE_DIR="`cygpath -w $CAPTURE_DIR`"
98 TESTS_DIR="`cygpath -w $TESTS_DIR`"
103 source $TESTS_DIR/suite-clopts.sh
104 source $TESTS_DIR/suite-io.sh
105 source $TESTS_DIR/suite-capture.sh
106 source $TESTS_DIR/suite-unittests.sh
107 source $TESTS_DIR/suite-fileformats.sh
108 source $TESTS_DIR/suite-decryption.sh
109 source $TESTS_DIR/suite-nameres.sh
110 source $TESTS_DIR/suite-wslua.sh
113 if [ $TEST_OUTDIR_CLEAN = 1 ]; then
114 # display contents of test outputs, ignore directory:
115 # home (decryption suite)
116 grep -r . --exclude-dir=home .
117 rm -rf "$TEST_OUTDIR"
118 elif ! rmdir "$TEST_OUTDIR" 2>/dev/null; then
119 # if directory is non-empty, print directory
120 echo "Test results are available in $TEST_OUTDIR"
123 trap test_cleanup EXIT
126 test_step_prerequisites() {
129 for i in "$WIRESHARK" "$WIRESHARK_GTK" "$TSHARK" "$CAPINFOS" "$DUMPCAP" ; do
131 echo "Couldn't find $i"
135 if [ $NOTFOUND -eq 1 ]; then
136 test_step_failed "Tool not found"
143 # Dump version information
144 test_step_tshark_version() {
145 test_remark_add "Printing TShark version"
148 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
149 test_step_failed "Failed to print version information"
156 prerequisites_suite() {
157 test_step_add "Prerequisites settings" test_step_prerequisites
158 test_step_add "Version information" test_step_tshark_version
162 test_suite_add "Prerequisites" prerequisites_suite
163 test_suite_add "Command line options" clopt_suite
164 test_suite_add "File I/O" io_suite
165 test_suite_add "Capture" capture_suite
166 test_suite_add "Unit tests" unittests_suite
167 test_suite_add "File formats" fileformats_suite
168 test_suite_add "Decryption" decryption_suite
169 test_suite_add "Name Resolution" name_resolution_suite
170 test_suite_add "Lua API" wslua_suite
174 #test_set_output OFF # doesn't work
175 #test_set_output DOTTED
176 test_set_output VERBOSE
179 #test_suite_run "TShark command line options" clopt_suite
180 #test_suite_run "TShark capture" capture_suite
184 #test_suite_run "All" test_suite
185 #test_suite_show "All" test_suite
187 if [ -n "$RUN_SUITE" ] ; then
190 test_suite_run "All" test_suite
193 test_suite_run "Capture" capture_suite
196 test_suite_run "Command line options" clopt_suite
199 test_suite_run "Decryption" decryption_suite
202 test_suite_run "File formats" fileformats_suite
205 test_suite_run "File I/O" io_suite
208 test_suite_run "Name Resolution" name_resolution_suite
211 test_suite_run "Prerequisites" prerequisites_suite
214 test_suite_run "Unit tests" unittests_suite
217 test_suite_run "Lua API" wslua_suite
225 menu_function[0]=test_suite
227 echo "----------------------------------------------------------------------"
229 for ((a=0; a <= 100000000000 ; a++))
231 TEST_STEPS[0]=0 # number of steps of a specific nesting level
233 #echo $current_title $current_function
234 test_suite_show "${menu_title[MENU_LEVEL]}" "${menu_function[MENU_LEVEL]}"
235 echo "1-$TEST_STEPS : Select item"
236 echo "Enter: Test All"
237 if [[ ! $MENU_LEVEL -eq 0 ]]; then
244 echo "$newl----------------------------------------------------------------------"
246 TEST_STEPS[0]=0 # number of steps of a specific nesting level
255 for ((a_runs=1; a_runs <= LIMIT_RUNS ; a_runs++)) # Double parentheses, and "LIMIT" with no "$".
257 test_suite_run "${menu_title[MENU_LEVEL]}" "${menu_function[MENU_LEVEL]}"
259 echo "----------------------------------------------------------------------"
262 if [[ ! $MENU_LEVEL -eq 0 ]]; then
263 let "MENU_LEVEL -= 1"
264 #echo "----------------------------------------------------------------------"
268 let "MENU_LEVEL += 1"
269 menu_title[MENU_LEVEL]=${test_title[1]}
270 menu_function[MENU_LEVEL]=${test_function[1]}
273 let "MENU_LEVEL += 1"
274 menu_title[MENU_LEVEL]=${test_title[2]}
275 menu_function[MENU_LEVEL]=${test_function[2]}
278 let "MENU_LEVEL += 1"
279 menu_title[MENU_LEVEL]=${test_title[3]}
280 menu_function[MENU_LEVEL]=${test_function[3]}
283 let "MENU_LEVEL += 1"
284 menu_title[MENU_LEVEL]=${test_title[4]}
285 menu_function[MENU_LEVEL]=${test_function[4]}
288 let "MENU_LEVEL += 1"
289 menu_title[MENU_LEVEL]=${test_title[5]}
290 menu_function[MENU_LEVEL]=${test_function[5]}
293 let "MENU_LEVEL += 1"
294 menu_title[MENU_LEVEL]=${test_title[6]}
295 menu_function[MENU_LEVEL]=${test_function[6]}
298 let "MENU_LEVEL += 1"
299 menu_title[MENU_LEVEL]=${test_title[7]}
300 menu_function[MENU_LEVEL]=${test_function[7]}
303 let "MENU_LEVEL += 1"
304 menu_title[MENU_LEVEL]=${test_title[8]}
305 menu_function[MENU_LEVEL]=${test_function[8]}
308 let "MENU_LEVEL += 1"
309 menu_title[MENU_LEVEL]=${test_title[9]}
310 menu_function[MENU_LEVEL]=${test_function[9]}
321 # indent-tabs-mode: t
324 # ex: set shiftwidth=8 tabstop=8 noexpandtab:
325 # :indentSize=8:tabSize=8:noTabs=false: