Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright (c) 2013, Google Inc. |
| 4 | # All rights reserved. |
| 5 | # |
| 6 | # Redistribution and use in source and binary forms, with or without |
| 7 | # modification, are permitted provided that the following conditions are |
| 8 | # met: |
| 9 | # |
| 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 |
| 15 | # distribution. |
| 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. |
| 19 | # |
| 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. |
| 31 | |
| 32 | # --- |
| 33 | # Author: Adhemerval Zanella |
| 34 | # |
| 35 | # Runs the tcmalloc_unittest with various environment variables. |
| 36 | # This is necessary because tuning some environment variables |
| 37 | # (TCMALLOC_TRANSFER_NUM_OBJ for instance) should not change program |
| 38 | # behavior, just performance. |
| 39 | |
| 40 | BINDIR="${BINDIR:-.}" |
| 41 | TCMALLOC_UNITTEST="${1:-$BINDIR/tcmalloc_unittest}" |
| 42 | |
| 43 | TMPDIR=/tmp/tcmalloc_unittest |
| 44 | rm -rf $TMPDIR || exit 2 |
| 45 | mkdir $TMPDIR || exit 3 |
| 46 | |
| 47 | run_unittest() { |
| 48 | if $TCMALLOC_UNITTEST > $TMPDIR/output 2>&1; then |
| 49 | echo "OK" |
| 50 | else |
| 51 | echo "FAILED" |
| 52 | echo "Output from the failed run:" |
| 53 | echo "----" |
| 54 | cat $TMPDIR/output |
| 55 | echo "----" |
| 56 | exit 4 |
| 57 | fi |
| 58 | } |
| 59 | |
| 60 | # $1: value of tcmalloc_unittest env. var. |
| 61 | run_check_transfer_num_obj() { |
| 62 | [ -n "$1" ] && export TCMALLOC_TRANSFER_NUM_OBJ="$1" |
| 63 | |
| 64 | echo -n "Testing $TCMALLOC_UNITTEST with TCMALLOC_TRANSFER_NUM_OBJ=$1 ... " |
| 65 | run_unittest |
| 66 | } |
| 67 | |
| 68 | run_check_transfer_num_obj "" |
| 69 | run_check_transfer_num_obj "40" |
| 70 | run_check_transfer_num_obj "4096" |
| 71 | |
| 72 | echo -n "Testing $TCMALLOC_UNITTEST with TCMALLOC_AGGRESSIVE_DECOMMIT=f ... " |
| 73 | |
| 74 | TCMALLOC_AGGRESSIVE_DECOMMIT=f run_unittest |
| 75 | |
| 76 | echo -n "Testing $TCMALLOC_UNITTEST with TCMALLOC_HEAP_LIMIT_MB=512 ... " |
| 77 | |
| 78 | TCMALLOC_HEAP_LIMIT_MB=512 run_unittest |
| 79 | |
| 80 | echo "PASS" |