nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #!/bin/bash
2  
3 # A little script to run tshark on capture file[s] (potentially ones that
4 # failed fuzz testing). Useful because it sets up ulimits and other environment
5 # variables for you to ensure things like misused ephemeral memory are caught.
6 # (I'm writing this after having my machine hang up for like 15 minutes because
7 # I wasn't paying attention while tshark was running on a fuzzed capture and
8 # it used all my RAM + swap--which was pretty painful.)
9 #
10 # Copyright 2012 Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
11 #
12 # Wireshark - Network traffic analyzer
13 # By Gerald Combs <gerald@wireshark.org>
14 # Copyright 1998 Gerald Combs
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation; either version 2
19 # of the License, or (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29  
30 TEST_TYPE="manual"
31 . `dirname $0`/test-common.sh || exit 1
32  
33 # Run under AddressSanitizer ?
34 ASAN=$CONFIGURED_WITH_ASAN
35  
36 while getopts "ab:" OPTCHAR ; do
37 case $OPTCHAR in
38 a) ASAN=1 ;;
39 b) WIRESHARK_BIN_DIR=$OPTARG ;;
40 esac
41 done
42 shift $(($OPTIND - 1))
43  
44 if [ $# -lt 1 ]
45 then
46 printf "Usage: $(basename $0) [-b bin_dir] /path/to/file[s].pcap\n"
47 exit 1
48 fi
49  
50 ws_bind_exec_paths
51 ws_check_exec "$TSHARK"
52  
53 # Set some limits to the child processes, e.g. stop it if it's running
54 # longer than MAX_CPU_TIME seconds. (ulimit is not supported well on
55 # cygwin - it shows some warnings - and the features we use may not all
56 # be supported on some UN*X platforms.)
57 ulimit -S -t $MAX_CPU_TIME
58  
59 # Allow core files to be generated
60 ulimit -c unlimited
61  
62 # Don't enable ulimit -v when using ASAN. See
63 # https://github.com/google/sanitizers/wiki/AddressSanitizer#ulimit--v
64 if [ $ASAN -eq 0 ]; then
65 ulimit -S -v $MAX_VMEM
66 fi
67  
68 for file in "$@"
69 do
70 echo "Testing file $file..."
71 echo -n " - with tree... "
72 if $TSHARK -nVxr $file > /dev/null
73 then
74 echo "OK"
75 echo -n " - without tree... "
76 if $WIRESHARK_BIN_DIR/tshark -nr $file > /dev/null
77 then
78 echo "OK"
79 echo -n " - without tree but with a read filter... "
80 if $WIRESHARK_BIN_DIR/tshark -Yframe -nr $file > /dev/null
81 then
82 echo "OK"
83 else
84 echo "Failed"
85 exit 1
86 fi
87 else
88 echo "Failed"
89 exit 1
90 fi
91 else
92 echo "Failed"
93 exit 1
94 fi
95 done