3 # Copyright (c) 2005, Google Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following disclaimer
14 # in the documentation and/or other materials provided with the
16 # * Neither the name of Google Inc. nor the names of its
17 # contributors may be used to endorse or promote products derived from
18 # this software without specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 # Author: Craig Silverstein
35 # Runs the heap-checker unittest with various environment variables.
36 # This is necessary because we turn on features like the heap profiler
37 # and heap checker via environment variables. This test makes sure
38 # they all play well together.
40 # We expect BINDIR and PPROF_PATH to be set in the environment.
41 # If not, we set them to some reasonable values
43 PPROF_PATH
="${PPROF_PATH:-$BINDIR/src/pprof}"
45 if [ "x$1" = "x-h" -o "$1" = "x--help" ]; then
46 echo "USAGE: $0 [unittest dir] [path to pprof]"
47 echo " By default, unittest_dir=$BINDIR, pprof_path=$PPROF_PATH"
51 HEAP_CHECKER
="${1:-$BINDIR}/heap-checker_unittest"
52 PPROF_PATH
="${2:-$PPROF_PATH}"
54 TMPDIR
=/tmp
/heap_check_info
55 rm -rf $TMPDIR ||
exit 2
56 mkdir
$TMPDIR ||
exit 3
58 # $1: value of heap-check env. var.
60 export PPROF_PATH
="$PPROF_PATH"
61 [ -n "$1" ] && export HEAPCHECK
="$1" ||
unset HEAPPROFILE
63 echo -n "Testing $HEAP_CHECKER with HEAPCHECK=$1 ... "
64 if $HEAP_CHECKER > $TMPDIR/output
2>&1; then
68 echo "Output from the failed run:"
75 # If we set HEAPPROFILE, then we expect it to actually have emitted
76 # a profile. Check that it did.
77 if [ -n "$HEAPPROFILE" ]; then
78 [ -e "$HEAPPROFILE.0001.heap" ] ||
exit 5
87 rm -rf $TMPDIR # clean up