mojo: Strongly bind WebUI handler to pipe.
[chromium-blink-merge.git] / tools / valgrind / chrome_tests.sh
blobdf5e8e745f2bef9b1da5d094b95dfe6a6f2e3839
1 #!/bin/bash
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Set up some paths and re-direct the arguments to chrome_tests.py
9 export THISDIR=`dirname $0`
10 ARGV_COPY="$@"
12 # We need to set CHROME_VALGRIND iff using Memcheck or TSan-Valgrind:
13 # tools/valgrind/chrome_tests.sh --tool memcheck
14 # or
15 # tools/valgrind/chrome_tests.sh --tool=memcheck
16 # (same for "--tool=tsan")
17 tool="memcheck" # Default to memcheck.
18 while (( "$#" ))
20 if [[ "$1" == "--tool" ]]
21 then
22 tool="$2"
23 shift
24 elif [[ "$1" =~ --tool=(.*) ]]
25 then
26 tool="${BASH_REMATCH[1]}"
28 shift
29 done
31 NEEDS_VALGRIND=0
32 NEEDS_DRMEMORY=0
34 case "$tool" in
35 "memcheck")
36 NEEDS_VALGRIND=1
38 "tsan" | "tsan_rv")
39 if [ "`uname -s`" == CYGWIN* ]
40 then
41 NEEDS_PIN=1
42 else
43 NEEDS_VALGRIND=1
46 "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern")
47 NEEDS_DRMEMORY=1
49 esac
51 if [ "$NEEDS_VALGRIND" == "1" ]
52 then
53 export CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh`
54 if [ "$CHROME_VALGRIND" = "" ]
55 then
56 # locate_valgrind.sh failed
57 exit 1
59 echo "Using valgrind binaries from ${CHROME_VALGRIND}"
61 PATH="${CHROME_VALGRIND}/bin:$PATH"
62 # We need to set these variables to override default lib paths hard-coded into
63 # Valgrind binary.
64 export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind"
65 export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind"
67 # Clean up some /tmp directories that might be stale due to interrupted
68 # chrome_tests.py execution.
69 # FYI:
70 # -mtime +1 <- only print files modified more than 24h ago,
71 # -print0/-0 are needed to handle possible newlines in the filenames.
72 echo "Cleanup /tmp from Valgrind stuff"
73 find /tmp -maxdepth 1 \(\
74 -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \
75 \) -mtime +1 -print0 | xargs -0 rm -rf
78 if [ "$NEEDS_DRMEMORY" == "1" ]
79 then
80 if [ -z "$DRMEMORY_COMMAND" ]
81 then
82 DRMEMORY_PATH="$THISDIR/../../third_party/drmemory"
83 DRMEMORY_SFX="$DRMEMORY_PATH/drmemory-windows-sfx.exe"
84 if [ ! -f "$DRMEMORY_SFX" ]
85 then
86 echo "Can't find Dr. Memory executables."
87 echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory"
88 echo "for the instructions on how to get them."
89 exit 1
92 chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x.
93 "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y
94 export DRMEMORY_COMMAND="$DRMEMORY_PATH/unpacked/bin/drmemory.exe"
98 if [ "$NEEDS_PIN" == "1" ]
99 then
100 if [ -z "$PIN_COMMAND" ]
101 then
102 # Set up PIN_COMMAND to invoke TSan.
103 TSAN_PATH="$THISDIR/../../third_party/tsan"
104 TSAN_SFX="$TSAN_PATH/tsan-x86-windows-sfx.exe"
105 echo "$TSAN_SFX"
106 if [ ! -f $TSAN_SFX ]
107 then
108 echo "Can't find ThreadSanitizer executables."
109 echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows"
110 echo "for the instructions on how to get them."
111 exit 1
114 chmod +x "$TSAN_SFX" # Cygwin won't run it without +x.
115 "$TSAN_SFX" -o"$TSAN_PATH"/unpacked -y
116 export PIN_COMMAND="$TSAN_PATH/unpacked/tsan-x86-windows/tsan.bat"
121 PYTHONPATH=$THISDIR/../python/google python \
122 "$THISDIR/chrome_tests.py" $ARGV_COPY