Minor Python style clean-up
[chromium-blink-merge.git] / tools / valgrind / chrome_tests.sh
blob479138e7ab4941cbd98c178093ad013eb0e36e34
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:
13 # tools/valgrind/chrome_tests.sh --tool memcheck
14 # or
15 # tools/valgrind/chrome_tests.sh --tool=memcheck
16 tool="memcheck" # Default to memcheck.
17 while (( "$#" ))
19 if [[ "$1" == "--tool" ]]
20 then
21 tool="$2"
22 shift
23 elif [[ "$1" =~ --tool=(.*) ]]
24 then
25 tool="${BASH_REMATCH[1]}"
27 shift
28 done
30 NEEDS_VALGRIND=0
31 NEEDS_DRMEMORY=0
33 case "$tool" in
34 "memcheck")
35 NEEDS_VALGRIND=1
37 "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern")
38 NEEDS_DRMEMORY=1
40 esac
42 if [ "$NEEDS_VALGRIND" == "1" ]
43 then
44 export CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh`
45 if [ "$CHROME_VALGRIND" = "" ]
46 then
47 # locate_valgrind.sh failed
48 exit 1
50 echo "Using valgrind binaries from ${CHROME_VALGRIND}"
52 PATH="${CHROME_VALGRIND}/bin:$PATH"
53 # We need to set these variables to override default lib paths hard-coded into
54 # Valgrind binary.
55 export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind"
56 export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind"
58 # Clean up some /tmp directories that might be stale due to interrupted
59 # chrome_tests.py execution.
60 # FYI:
61 # -mtime +1 <- only print files modified more than 24h ago,
62 # -print0/-0 are needed to handle possible newlines in the filenames.
63 echo "Cleanup /tmp from Valgrind stuff"
64 find /tmp -maxdepth 1 \(\
65 -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \
66 \) -mtime +1 -print0 | xargs -0 rm -rf
69 if [ "$NEEDS_DRMEMORY" == "1" ]
70 then
71 if [ -z "$DRMEMORY_COMMAND" ]
72 then
73 DRMEMORY_PATH="$THISDIR/../../third_party/drmemory"
74 DRMEMORY_SFX="$DRMEMORY_PATH/drmemory-windows-sfx.exe"
75 if [ ! -f "$DRMEMORY_SFX" ]
76 then
77 echo "Can't find Dr. Memory executables."
78 echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory"
79 echo "for the instructions on how to get them."
80 exit 1
83 chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x.
84 "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y
85 export DRMEMORY_COMMAND="$DRMEMORY_PATH/unpacked/bin/drmemory.exe"
89 PYTHONPATH=$THISDIR/../python/google python \
90 "$THISDIR/chrome_tests.py" $ARGV_COPY