[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 1 | #!/bin/bash |
[email protected] | f14a91b0 | 2009-01-09 01:08:37 | [diff] [blame] | 2 | |
[email protected] | ecff4ad | 2012-02-22 19:52:36 | [diff] [blame] | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | e46cdae | 2009-08-25 20:59:27 | [diff] [blame] | 4 | # Use of this source code is governed by a BSD-style license that can be |
5 | # found in the LICENSE file. | ||||
6 | |||||
[email protected] | a057041 | 2010-01-26 22:40:06 | [diff] [blame] | 7 | # Set up some paths and re-direct the arguments to chrome_tests.py |
[email protected] | e568619 | 2009-08-12 20:19:07 | [diff] [blame] | 8 | |
[email protected] | b9056e9d | 2010-01-20 19:41:15 | [diff] [blame] | 9 | export THISDIR=`dirname $0` |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 10 | ARGV_COPY="$@" |
[email protected] | 81e0a0d3 | 2011-09-09 13:00:17 | [diff] [blame] | 11 | |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 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") | ||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 17 | tool="memcheck" # Default to memcheck. |
18 | while (( "$#" )) | ||||
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 19 | do |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 20 | if [[ "$1" == "--tool" ]] |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 21 | then |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 22 | tool="$2" |
23 | shift | ||||
24 | elif [[ "$1" =~ --tool=(.*) ]] | ||||
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 25 | then |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 26 | tool="${BASH_REMATCH[1]}" |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 27 | fi |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 28 | shift |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 29 | done |
30 | |||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 31 | NEEDS_VALGRIND=0 |
32 | NEEDS_DRMEMORY=0 | ||||
33 | |||||
34 | case "$tool" in | ||||
35 | "memcheck") | ||||
36 | NEEDS_VALGRIND=1 | ||||
37 | ;; | ||||
38 | "tsan" | "tsan_rv") | ||||
[email protected] | ecff4ad | 2012-02-22 19:52:36 | [diff] [blame] | 39 | if [ "`uname -s`" == CYGWIN* ] |
40 | then | ||||
41 | NEEDS_PIN=1 | ||||
42 | else | ||||
43 | NEEDS_VALGRIND=1 | ||||
44 | fi | ||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 45 | ;; |
[email protected] | 2b03757 | 2012-06-21 22:20:33 | [diff] [blame] | 46 | "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern") |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 47 | NEEDS_DRMEMORY=1 |
48 | ;; | ||||
49 | esac | ||||
50 | |||||
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 51 | if [ "$NEEDS_VALGRIND" == "1" ] |
52 | then | ||||
[email protected] | 19f66f2 | 2013-08-22 02:25:44 | [diff] [blame] | 53 | export CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh` |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 54 | if [ "$CHROME_VALGRIND" = "" ] |
55 | then | ||||
56 | # locate_valgrind.sh failed | ||||
57 | exit 1 | ||||
58 | fi | ||||
59 | echo "Using valgrind binaries from ${CHROME_VALGRIND}" | ||||
60 | |||||
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" | ||||
[email protected] | d53faa3d | 2012-02-28 15:30:29 | [diff] [blame] | 66 | |
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 | ||||
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 76 | fi |
[email protected] | b9056e9d | 2010-01-20 19:41:15 | [diff] [blame] | 77 | |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 78 | if [ "$NEEDS_DRMEMORY" == "1" ] |
79 | then | ||||
[email protected] | 6a58bba | 2011-12-06 17:50:45 | [diff] [blame] | 80 | if [ -z "$DRMEMORY_COMMAND" ] |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 81 | then |
[email protected] | 6a58bba | 2011-12-06 17:50:45 | [diff] [blame] | 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 | ||||
90 | fi | ||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 91 | |
[email protected] | 6a58bba | 2011-12-06 17:50:45 | [diff] [blame] | 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" | ||||
95 | fi | ||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 96 | fi |
97 | |||||
[email protected] | ecff4ad | 2012-02-22 19:52:36 | [diff] [blame] | 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 | ||||
112 | fi | ||||
113 | |||||
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" | ||||
117 | fi | ||||
118 | fi | ||||
119 | |||||
120 | |||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 121 | PYTHONPATH=$THISDIR/../python/google python \ |
122 | "$THISDIR/chrome_tests.py" $ARGV_COPY |