2 (shopt -s igncr) 2>/dev/null && shopt -s 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 while getopts "chs:" OPTION ; do
36 s) RUN_SUITE="$OPTARG" ;;
37 *) echo "Unknown option: " $OPTION $OPTARG
41 shift $(( $OPTIND - 1 ))
43 if [ $PRINT_USAGE -ne 0 ] ; then
46 Usage: $THIS [-c] [-h] [-s <suite>]
47 -c: Disable color output
48 -h: Print this message and exit
49 -s: Run a suite. Must be one of:
64 source test-backend.sh
68 # needed by some tests
69 TEST_OUTDIR=$(mktemp -d)
70 TEST_OUTDIR_CLEAN=${TEST_OUTDIR_CLEAN:-1}
71 if [ -z "$TEST_OUTDIR" ] || ! cd "$TEST_OUTDIR"; then
72 # If for any reason the temporary tests output directory cannot be created...
79 HOME_PATH="$TEST_OUTDIR/home"
80 CONF_PATH="$HOME_PATH/.wireshark"
82 if [ "$WS_SYSTEM" == "Windows" ] ; then
84 HOME_PATH="`cygpath -w $HOME_PATH`"
85 CONF_PATH="$HOME_PATH/Wireshark"
86 CAPTURE_DIR="`cygpath -w $CAPTURE_DIR`"
91 source $TESTS_DIR/suite-clopts.sh
92 source $TESTS_DIR/suite-io.sh
93 source $TESTS_DIR/suite-capture.sh
94 source $TESTS_DIR/suite-unittests.sh
95 source $TESTS_DIR/suite-fileformats.sh
96 source $TESTS_DIR/suite-decryption.sh
97 source $TESTS_DIR/suite-nameres.sh
98 source $TESTS_DIR/suite-wslua.sh
101 if [ $TEST_OUTDIR_CLEAN = 1 ]; then
102 # display contents of test outputs, ignore directory:
103 # home (decryption suite)
104 grep -r . --exclude-dir=home .
105 rm -rf "$TEST_OUTDIR"
106 elif ! rmdir "$TEST_OUTDIR" 2>/dev/null; then
107 # if directory is non-empty, print directory
108 echo "Test results are available in $TEST_OUTDIR"
111 trap test_cleanup EXIT
114 test_step_prerequisites() {
117 for i in "$WIRESHARK_GTK" "$TSHARK" "$CAPINFOS" "$DUMPCAP" ; do
119 echo "Couldn't find $i"
123 if [ $NOTFOUND -eq 1 ]; then
124 test_step_failed "Tool not found"
131 # Dump version information
132 test_step_tshark_version() {
133 test_remark_add "Printing TShark version"
136 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
137 test_step_failed "Failed to print version information"
144 prerequisites_suite() {
145 test_step_add "Prerequisites settings" test_step_prerequisites
146 test_step_add "Version information" test_step_tshark_version
150 test_suite_add "Prerequisites" prerequisites_suite
151 test_suite_add "Command line options" clopt_suite
152 test_suite_add "File I/O" io_suite
153 test_suite_add "Capture" capture_suite
154 test_suite_add "Unit tests" unittests_suite
155 test_suite_add "File formats" fileformats_suite
156 test_suite_add "Decryption" decryption_suite
157 test_suite_add "Name Resolution" name_resolution_suite
158 test_suite_add "Lua API" wslua_suite
162 #test_set_output OFF # doesn't work
163 #test_set_output DOTTED
164 test_set_output VERBOSE
167 #test_suite_run "TShark command line options" clopt_suite
168 #test_suite_run "TShark capture" capture_suite
172 #test_suite_run "All" test_suite
173 #test_suite_show "All" test_suite
175 if [ -n "$RUN_SUITE" ] ; then
178 test_suite_run "All" test_suite
181 test_suite_run "Capture" capture_suite
184 test_suite_run "Command line options" clopt_suite
187 test_suite_run "Decryption" decryption_suite
190 test_suite_run "File formats" fileformats_suite
193 test_suite_run "File I/O" io_suite
196 test_suite_run "Name Resolution" name_resolution_suite
199 test_suite_run "Prerequisites" prerequisites_suite
202 test_suite_run "Unit tests" unittests_suite
205 test_suite_run "Lua API" wslua_suite
213 menu_function[0]=test_suite
215 echo "----------------------------------------------------------------------"
217 for ((a=0; a <= 100000000000 ; a++))
219 TEST_STEPS[0]=0 # number of steps of a specific nesting level
221 #echo $current_title $current_function
222 test_suite_show "${menu_title[MENU_LEVEL]}" "${menu_function[MENU_LEVEL]}"
223 echo "1-$TEST_STEPS : Select item"
224 echo "Enter: Test All"
225 if [[ ! $MENU_LEVEL -eq 0 ]]; then
232 echo "$newl----------------------------------------------------------------------"
234 TEST_STEPS[0]=0 # number of steps of a specific nesting level
243 for ((a_runs=1; a_runs <= LIMIT_RUNS ; a_runs++)) # Double parentheses, and "LIMIT" with no "$".
245 test_suite_run "${menu_title[MENU_LEVEL]}" "${menu_function[MENU_LEVEL]}"
247 echo "----------------------------------------------------------------------"
250 if [[ ! $MENU_LEVEL -eq 0 ]]; then
251 let "MENU_LEVEL -= 1"
252 #echo "----------------------------------------------------------------------"
256 let "MENU_LEVEL += 1"
257 menu_title[MENU_LEVEL]=${test_title[1]}
258 menu_function[MENU_LEVEL]=${test_function[1]}
261 let "MENU_LEVEL += 1"
262 menu_title[MENU_LEVEL]=${test_title[2]}
263 menu_function[MENU_LEVEL]=${test_function[2]}
266 let "MENU_LEVEL += 1"
267 menu_title[MENU_LEVEL]=${test_title[3]}
268 menu_function[MENU_LEVEL]=${test_function[3]}
271 let "MENU_LEVEL += 1"
272 menu_title[MENU_LEVEL]=${test_title[4]}
273 menu_function[MENU_LEVEL]=${test_function[4]}
276 let "MENU_LEVEL += 1"
277 menu_title[MENU_LEVEL]=${test_title[5]}
278 menu_function[MENU_LEVEL]=${test_function[5]}
281 let "MENU_LEVEL += 1"
282 menu_title[MENU_LEVEL]=${test_title[6]}
283 menu_function[MENU_LEVEL]=${test_function[6]}
286 let "MENU_LEVEL += 1"
287 menu_title[MENU_LEVEL]=${test_title[7]}
288 menu_function[MENU_LEVEL]=${test_function[7]}
291 let "MENU_LEVEL += 1"
292 menu_title[MENU_LEVEL]=${test_title[8]}
293 menu_function[MENU_LEVEL]=${test_function[8]}
296 let "MENU_LEVEL += 1"
297 menu_title[MENU_LEVEL]=${test_title[9]}
298 menu_function[MENU_LEVEL]=${test_function[9]}