Convert the quick setup chapter to AsciiDoc and start converting its
[metze/wireshark/wip.git] / tools / test-captures.sh
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 # $Id$
13 #
14 # Wireshark - Network traffic analyzer
15 # By Gerald Combs <gerald@wireshark.org>
16 # Copyright 1998 Gerald Combs
17 #
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License
20 # as published by the Free Software Foundation; either version 2
21 # of the License, or (at your option) any later version.
22 #
23 # This program is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26 # GNU General Public License for more details.
27 #
28 # You should have received a copy of the GNU General Public License
29 # along with this program; if not, write to the Free Software
30 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31
32 if [ $# -lt 1 ]
33 then
34         printf "Usage: $0 /path/to/file[s].pcap\n"
35         exit 1
36 fi
37
38 TEST_TYPE="manual"
39 . `dirname $0`/test-common.sh || exit 1
40
41 # set some limits to the child processes, e.g. stop it if it's running longer then MAX_CPU_TIME seconds
42 # (ulimit is not supported well on cygwin and probably other platforms, e.g. cygwin shows some warnings)
43 ulimit -S -t $MAX_CPU_TIME -v $MAX_VMEM
44 # Allow core files to be generated
45 ulimit -c unlimited
46
47 for file in "$@"
48 do
49         echo "Testing file $file..."
50         echo -n " - with tree... "
51         if $BIN_DIR/tshark -nVxr $file > /dev/null
52         then
53                 echo "OK"
54                 echo -n " - without tree... "
55                 if $BIN_DIR/tshark -nr $file > /dev/null
56                 then
57                         echo "OK"
58                         echo -n " - without tree but with a read filter... "
59                         if $BIN_DIR/tshark -Yframe -nr $file > /dev/null
60                         then
61                                 echo "OK"
62                         else
63                                 echo "Failed"
64                                 exit 1
65                         fi
66                 else
67                         echo "Failed"
68                         exit 1
69                 fi
70         else
71                 echo "Failed"
72                 exit 1
73         fi
74 done