[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 | |
glider | d6b3c7e0 | 2014-12-30 09:57:20 | [diff] [blame] | 12 | # We need to set CHROME_VALGRIND iff using Memcheck: |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 13 | # tools/valgrind/chrome_tests.sh --tool memcheck |
14 | # or | ||||
15 | # tools/valgrind/chrome_tests.sh --tool=memcheck | ||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 16 | tool="memcheck" # Default to memcheck. |
17 | while (( "$#" )) | ||||
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 18 | do |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 19 | if [[ "$1" == "--tool" ]] |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 20 | then |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 21 | tool="$2" |
22 | shift | ||||
23 | elif [[ "$1" =~ --tool=(.*) ]] | ||||
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 24 | then |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 25 | tool="${BASH_REMATCH[1]}" |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 26 | fi |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 27 | shift |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 28 | done |
29 | |||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 30 | NEEDS_VALGRIND=0 |
31 | NEEDS_DRMEMORY=0 | ||||
32 | |||||
33 | case "$tool" in | ||||
34 | "memcheck") | ||||
35 | NEEDS_VALGRIND=1 | ||||
36 | ;; | ||||
[email protected] | 2b03757 | 2012-06-21 22:20:33 | [diff] [blame] | 37 | "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern") |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 38 | NEEDS_DRMEMORY=1 |
39 | ;; | ||||
40 | esac | ||||
41 | |||||
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 42 | if [ "$NEEDS_VALGRIND" == "1" ] |
43 | then | ||||
[email protected] | 19f66f2 | 2013-08-22 02:25:44 | [diff] [blame] | 44 | export CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh` |
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 45 | if [ "$CHROME_VALGRIND" = "" ] |
46 | then | ||||
47 | # locate_valgrind.sh failed | ||||
48 | exit 1 | ||||
49 | fi | ||||
50 | echo "Using valgrind binaries from ${CHROME_VALGRIND}" | ||||
51 | |||||
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" | ||||
[email protected] | d53faa3d | 2012-02-28 15:30:29 | [diff] [blame] | 57 | |
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 | ||||
[email protected] | 3d7e2c5 | 2011-09-12 08:27:00 | [diff] [blame] | 67 | fi |
[email protected] | b9056e9d | 2010-01-20 19:41:15 | [diff] [blame] | 68 | |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 69 | if [ "$NEEDS_DRMEMORY" == "1" ] |
70 | then | ||||
[email protected] | 6a58bba | 2011-12-06 17:50:45 | [diff] [blame] | 71 | if [ -z "$DRMEMORY_COMMAND" ] |
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 72 | then |
[email protected] | 6a58bba | 2011-12-06 17:50:45 | [diff] [blame] | 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 | ||||
81 | fi | ||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 82 | |
[email protected] | 6a58bba | 2011-12-06 17:50:45 | [diff] [blame] | 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" | ||||
86 | fi | ||||
[email protected] | 6da3809 | 2011-11-22 10:37:09 | [diff] [blame] | 87 | fi |
88 | |||||
89 | PYTHONPATH=$THISDIR/../python/google python \ | ||||
90 | "$THISDIR/chrome_tests.py" $ARGV_COPY |