kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license |
| 6 | # that can be found in the LICENSE file in the root of the source |
| 7 | # tree. An additional intellectual property rights grant can be found |
| 8 | # in the file PATENTS. All contributing project authors may |
| 9 | # be found in the AUTHORS file in the root of the source tree. |
| 10 | |
| 11 | # Set up some paths and re-direct the arguments to webrtc_tests.py |
| 12 | |
| 13 | # This script is a copy of the chrome_tests.sh wrapper script with the following |
| 14 | # changes: |
| 15 | # - The locate_valgrind.sh of Chromium's Valgrind scripts dir is used to locate |
| 16 | # the Valgrind framework install. |
| 17 | # - webrtc_tests.py is invoked instead of chrome_tests.py. |
| 18 | # - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it |
| 19 | # possible to execute the Python scripts properly. |
| 20 | |
| 21 | export THISDIR=`dirname $0` |
| 22 | ARGV_COPY="$@" |
| 23 | |
kjellander@webrtc.org | afede83 | 2014-10-10 09:18:34 +0000 | [diff] [blame] | 24 | # We need to set CHROME_VALGRIND iff using Memcheck: |
kjellander@webrtc.org | d1e7a9a | 2012-09-28 15:34:18 +0000 | [diff] [blame] | 25 | # tools/valgrind-webrtc/webrtc_tests.sh --tool memcheck |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 26 | # or |
kjellander@webrtc.org | d1e7a9a | 2012-09-28 15:34:18 +0000 | [diff] [blame] | 27 | # tools/valgrind-webrtc/webrtc_tests.sh --tool=memcheck |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 28 | tool="memcheck" # Default to memcheck. |
| 29 | while (( "$#" )) |
| 30 | do |
| 31 | if [[ "$1" == "--tool" ]] |
| 32 | then |
| 33 | tool="$2" |
| 34 | shift |
| 35 | elif [[ "$1" =~ --tool=(.*) ]] |
| 36 | then |
| 37 | tool="${BASH_REMATCH[1]}" |
| 38 | fi |
| 39 | shift |
| 40 | done |
| 41 | |
| 42 | NEEDS_VALGRIND=0 |
| 43 | NEEDS_DRMEMORY=0 |
| 44 | |
| 45 | case "$tool" in |
| 46 | "memcheck") |
| 47 | NEEDS_VALGRIND=1 |
| 48 | ;; |
kjellander@webrtc.org | d1e7a9a | 2012-09-28 15:34:18 +0000 | [diff] [blame] | 49 | "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern") |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 50 | NEEDS_DRMEMORY=1 |
| 51 | ;; |
| 52 | esac |
| 53 | |
| 54 | # For WebRTC, we'll use the locate_valgrind.sh script in Chromium's Valgrind |
| 55 | # scripts dir to locate the Valgrind framework install |
| 56 | CHROME_VALGRIND_SCRIPTS=$THISDIR/../valgrind |
| 57 | |
| 58 | if [ "$NEEDS_VALGRIND" == "1" ] |
| 59 | then |
| 60 | CHROME_VALGRIND=`sh $CHROME_VALGRIND_SCRIPTS/locate_valgrind.sh` |
| 61 | if [ "$CHROME_VALGRIND" = "" ] |
| 62 | then |
| 63 | # locate_valgrind.sh failed |
| 64 | exit 1 |
| 65 | fi |
| 66 | echo "Using valgrind binaries from ${CHROME_VALGRIND}" |
| 67 | |
| 68 | PATH="${CHROME_VALGRIND}/bin:$PATH" |
| 69 | # We need to set these variables to override default lib paths hard-coded into |
| 70 | # Valgrind binary. |
| 71 | export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind" |
| 72 | export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" |
kjellander@webrtc.org | d1e7a9a | 2012-09-28 15:34:18 +0000 | [diff] [blame] | 73 | |
| 74 | # Clean up some /tmp directories that might be stale due to interrupted |
| 75 | # chrome_tests.py execution. |
| 76 | # FYI: |
| 77 | # -mtime +1 <- only print files modified more than 24h ago, |
| 78 | # -print0/-0 are needed to handle possible newlines in the filenames. |
| 79 | echo "Cleanup /tmp from Valgrind stuff" |
| 80 | find /tmp -maxdepth 1 \(\ |
| 81 | -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \ |
| 82 | \) -mtime +1 -print0 | xargs -0 rm -rf |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 83 | fi |
| 84 | |
| 85 | if [ "$NEEDS_DRMEMORY" == "1" ] |
| 86 | then |
| 87 | if [ -z "$DRMEMORY_COMMAND" ] |
| 88 | then |
| 89 | DRMEMORY_PATH="$THISDIR/../../third_party/drmemory" |
| 90 | DRMEMORY_SFX="$DRMEMORY_PATH/drmemory-windows-sfx.exe" |
| 91 | if [ ! -f "$DRMEMORY_SFX" ] |
| 92 | then |
| 93 | echo "Can't find Dr. Memory executables." |
| 94 | echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory" |
| 95 | echo "for the instructions on how to get them." |
| 96 | exit 1 |
| 97 | fi |
| 98 | |
| 99 | chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x. |
| 100 | "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y |
| 101 | export DRMEMORY_COMMAND="$DRMEMORY_PATH/unpacked/bin/drmemory.exe" |
| 102 | fi |
| 103 | fi |
| 104 | |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 105 | # Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains |
| 106 | # the scripts that are needed for this script to run |
| 107 | PYTHONPATH=$THISDIR/../python/google:$CHROME_VALGRIND_SCRIPTS python \ |
| 108 | "$THISDIR/webrtc_tests.py" $ARGV_COPY |