3 # Copyright (c) 2009, 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
37 if [ "x$1" = "x-h" -o "x$1" = "x--help" ]; then
38 echo "USAGE: $0 [unittest dir]"
39 echo " By default, unittest_dir=$BINDIR"
43 DEBUGALLOCATION_TEST
="${1:-$BINDIR/debugallocation_test}"
47 # Run the i-th death test and make sure the test has the expected
48 # regexp. We can depend on the first line of the output being
49 # Expected regex:<regex>
50 # Evaluates to "done" if we are not actually a death-test (so $1 is
51 # too big a number, and we can stop). Evaluates to "" otherwise.
52 # Increments num_failures if the death test does not succeed.
54 "$DEBUGALLOCATION_TEST" "$1" 2>&1 |
{
56 # Normally the regex_line is the first line of output, but not
57 # always (if tcmalloc itself does any logging to stderr).
58 while test -n "$regex_line"; do
60 regex
=`expr "$regex_line" : "Expected regex:\(.*\)"`
61 test -n "$regex" && break # found the regex line
63 test -z "$regex" && echo "done" ||
grep "$regex" 2>&1
67 death_test_num
=0 # which death test to run
68 while :; do # same as 'while true', but more portable
69 echo -n "Running death test $death_test_num..."
70 output
="`OneDeathTest $death_test_num`"
72 # Empty string means grep didn't find anything.
73 "") echo "FAILED"; num_failures
=`expr $num_failures + 1`;;
74 "done"*) echo "done with death tests"; break;;
75 # Any other string means grep found something, like it ought to.
78 death_test_num
=`expr $death_test_num + 1`
81 # Test the non-death parts of the test too
82 echo -n "Running non-death tests..."
83 if "$DEBUGALLOCATION_TEST"; then
87 num_failures
=`expr $num_failures + 1`
90 if [ "$num_failures" = 0 ]; then
93 echo "Failed with $num_failures failures"