Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / third_party / tcmalloc / chromium / src / tests / maybe_threads_unittest.sh
blob77b3b7885c2ca2c98a83879efab5a8c39580274b
1 #!/bin/sh
3 # Copyright (c) 2007, 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.
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.
32 # ---
33 # Author: Craig Silverstein
35 # maybe_threads.cc was written to allow LD_PRELOAD=libtcmalloc.so to
36 # work even on binaries that were not linked with pthreads. This
37 # unittest tests that, by running low_level_alloc_unittest with an
38 # LD_PRELOAD. (low_level_alloc_unittest was chosen because it doesn't
39 # link in tcmalloc.)
41 # We assume all the .so files are in the same directory as both
42 # addressmap_unittest and profiler1_unittest. The reason we need
43 # profiler1_unittest is because it's instrumented to show the directory
44 # it's "really" in when run without any args. In practice this will either
45 # be BINDIR, or, when using libtool, BINDIR/.lib.
47 # We expect BINDIR to be set in the environment.
48 # If not, we set them to some reasonable values.
49 BINDIR="${BINDIR:-.}"
51 if [ "x$1" = "x-h" -o "x$1" = "x--help" ]; then
52 echo "USAGE: $0 [unittest dir]"
53 echo " By default, unittest_dir=$BINDIR"
54 exit 1
57 UNITTEST_DIR=${1:-$BINDIR}
59 # Figure out the "real" unittest directory. Also holds the .so files.
60 UNITTEST_DIR=`$UNITTEST_DIR/low_level_alloc_unittest --help 2>&1 \
61 | awk '{print $2; exit;}' \
62 | xargs dirname`
64 # Figure out where libtcmalloc lives. It should be in UNITTEST_DIR,
65 # but with libtool it might be in a subdir.
66 if [ -r "$UNITTEST_DIR/libtcmalloc_minimal.so" ]; then
67 LIB_PATH="$UNITTEST_DIR/libtcmalloc_minimal.so"
68 elif [ -r "$UNITTEST_DIR/.libs/libtcmalloc_minimal.so" ]; then
69 LIB_PATH="$UNITTEST_DIR/.libs/libtcmalloc_minimal.so"
70 elif [ -r "$UNITTEST_DIR/libtcmalloc_minimal.dylib" ]; then # for os x
71 LIB_PATH="$UNITTEST_DIR/libtcmalloc_minimal.dylib"
72 elif [ -r "$UNITTEST_DIR/.libs/libtcmalloc_minimal.dylib" ]; then
73 LIB_PATH="$UNITTEST_DIR/.libs/libtcmalloc_minimal.dylib"
74 else
75 echo "Cannot run $0: cannot find libtcmalloc_minimal.so"
76 exit 2
79 LD_PRELOAD="$LIB_PATH" $UNITTEST_DIR/low_level_alloc_unittest