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
10 # Wireshark - Network traffic analyzer
11 # By Gerald Combs <gerald@wireshark.org>
12 # Copyright 2005 Ulf Lamping
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 # an existing capture file
34 while getopts "chs:" OPTION
; do
38 s
) RUN_SUITE
="$OPTARG" ;;
39 *) echo "Unknown option: " $OPTION $OPTARG
43 shift $
(( $OPTIND - 1 ))
45 if [ $PRINT_USAGE -ne 0 ] ; then
48 Usage: $THIS [-c] [-h] [-s <suite>]
49 -c: Disable color output
50 -h: Print this message and exit
51 -s: Run a suite. Must be one of:
65 source test-backend.sh
69 # needed by some tests
70 TEST_OUTDIR
=$
(mktemp
-d)
71 TEST_OUTDIR_CLEAN
=${TEST_OUTDIR_CLEAN:-1}
72 if [ -z "$TEST_OUTDIR" ] ||
! cd "$TEST_OUTDIR"; then
73 # If for any reason the temporary tests output directory cannot be created...
80 HOME_PATH
="$TEST_OUTDIR/home"
81 CONF_PATH
="$HOME_PATH/.wireshark"
83 if [ "$WS_SYSTEM" == "Windows" ] ; then
85 HOME_PATH
="`cygpath -w $HOME_PATH`"
86 CONF_PATH
="$HOME_PATH/Wireshark"
87 CAPTURE_DIR
="`cygpath -w $CAPTURE_DIR`"
92 source $TESTS_DIR/suite-clopts.sh
93 source $TESTS_DIR/suite-io.sh
94 source $TESTS_DIR/suite-capture.sh
95 source $TESTS_DIR/suite-unittests.sh
96 source $TESTS_DIR/suite-fileformats.sh
97 source $TESTS_DIR/suite-decryption.sh
98 source $TESTS_DIR/suite-nameres.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" "$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
161 #test_set_output OFF # doesn't work
162 #test_set_output DOTTED
163 test_set_output VERBOSE
166 #test_suite_run "TShark command line options" clopt_suite
167 #test_suite_run "TShark capture" capture_suite
171 #test_suite_run "All" test_suite
172 #test_suite_show "All" test_suite
174 if [ -n "$RUN_SUITE" ] ; then
177 test_suite_run
"All" test_suite
180 test_suite_run
"Capture" capture_suite
183 test_suite_run
"Command line options" clopt_suite
186 test_suite_run
"Decryption" decryption_suite
189 test_suite_run
"File formats" fileformats_suite
192 test_suite_run
"File I/O" io_suite
195 test_suite_run
"Name Resolution" name_resolution_suite
198 test_suite_run
"Prerequisites" prerequisites_suite
201 test_suite_run
"Unit tests" unittests_suite
209 menu_function
[0]=test_suite
211 echo "----------------------------------------------------------------------"
213 for ((a
=0; a
<= 100000000000 ; a
++))
215 TEST_STEPS
[0]=0 # number of steps of a specific nesting level
217 #echo $current_title $current_function
218 test_suite_show
"${menu_title[MENU_LEVEL]}" "${menu_function[MENU_LEVEL]}"
219 echo "1-$TEST_STEPS : Select item"
220 echo "Enter: Test All"
221 if [[ ! $MENU_LEVEL -eq 0 ]]; then
228 echo "$newl----------------------------------------------------------------------"
230 TEST_STEPS
[0]=0 # number of steps of a specific nesting level
239 for ((a_runs
=1; a_runs
<= LIMIT_RUNS
; a_runs
++)) # Double parentheses, and "LIMIT" with no "$".
241 test_suite_run
"${menu_title[MENU_LEVEL]}" "${menu_function[MENU_LEVEL]}"
243 echo "----------------------------------------------------------------------"
246 if [[ ! $MENU_LEVEL -eq 0 ]]; then
247 let "MENU_LEVEL -= 1"
248 #echo "----------------------------------------------------------------------"
252 let "MENU_LEVEL += 1"
253 menu_title
[MENU_LEVEL
]=${test_title[1]}
254 menu_function
[MENU_LEVEL
]=${test_function[1]}
257 let "MENU_LEVEL += 1"
258 menu_title
[MENU_LEVEL
]=${test_title[2]}
259 menu_function
[MENU_LEVEL
]=${test_function[2]}
262 let "MENU_LEVEL += 1"
263 menu_title
[MENU_LEVEL
]=${test_title[3]}
264 menu_function
[MENU_LEVEL
]=${test_function[3]}
267 let "MENU_LEVEL += 1"
268 menu_title
[MENU_LEVEL
]=${test_title[4]}
269 menu_function
[MENU_LEVEL
]=${test_function[4]}
272 let "MENU_LEVEL += 1"
273 menu_title
[MENU_LEVEL
]=${test_title[5]}
274 menu_function
[MENU_LEVEL
]=${test_function[5]}
277 let "MENU_LEVEL += 1"
278 menu_title
[MENU_LEVEL
]=${test_title[6]}
279 menu_function
[MENU_LEVEL
]=${test_function[6]}
282 let "MENU_LEVEL += 1"
283 menu_title
[MENU_LEVEL
]=${test_title[7]}
284 menu_function
[MENU_LEVEL
]=${test_function[7]}
287 let "MENU_LEVEL += 1"
288 menu_title
[MENU_LEVEL
]=${test_title[8]}
289 menu_function
[MENU_LEVEL
]=${test_function[8]}
292 let "MENU_LEVEL += 1"
293 menu_title
[MENU_LEVEL
]=${test_title[9]}
294 menu_function
[MENU_LEVEL
]=${test_function[9]}