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