1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libyuv/tools/valgrind-libyuv/libyuv_tests.sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,138 @@ 1.4 +#!/bin/bash 1.5 +# Copyright (c) 2012 The LibYuv Project Authors. All rights reserved. 1.6 +# 1.7 +# Use of this source code is governed by a BSD-style license 1.8 +# that can be found in the LICENSE file in the root of the source 1.9 +# tree. An additional intellectual property rights grant can be found 1.10 +# in the file PATENTS. All contributing project authors may 1.11 +# be found in the AUTHORS file in the root of the source tree. 1.12 + 1.13 +# Set up some paths and re-direct the arguments to libyuv_tests.py 1.14 + 1.15 +# This script is a copy of the chrome_tests.sh wrapper script with the following 1.16 +# changes: 1.17 +# - The locate_valgrind.sh of Chromium's Valgrind scripts dir is used to locate 1.18 +# the Valgrind framework install. 1.19 +# - libyuv_tests.py is invoked instead of chrome_tests.py. 1.20 +# - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it 1.21 +# possible to execute the Python scripts properly. 1.22 + 1.23 +export THISDIR=`dirname $0` 1.24 +ARGV_COPY="$@" 1.25 + 1.26 +# We need to set CHROME_VALGRIND iff using Memcheck or TSan-Valgrind: 1.27 +# tools/valgrind-libyuv/libyuv_tests.sh --tool memcheck 1.28 +# or 1.29 +# tools/valgrind-libyuv/libyuv_tests.sh --tool=memcheck 1.30 +# (same for "--tool=tsan") 1.31 +tool="memcheck" # Default to memcheck. 1.32 +while (( "$#" )) 1.33 +do 1.34 + if [[ "$1" == "--tool" ]] 1.35 + then 1.36 + tool="$2" 1.37 + shift 1.38 + elif [[ "$1" =~ --tool=(.*) ]] 1.39 + then 1.40 + tool="${BASH_REMATCH[1]}" 1.41 + fi 1.42 + shift 1.43 +done 1.44 + 1.45 +NEEDS_VALGRIND=0 1.46 +NEEDS_DRMEMORY=0 1.47 + 1.48 +case "$tool" in 1.49 + "memcheck") 1.50 + NEEDS_VALGRIND=1 1.51 + ;; 1.52 + "tsan" | "tsan_rv") 1.53 + if [ "`uname -s`" == CYGWIN* ] 1.54 + then 1.55 + NEEDS_PIN=1 1.56 + else 1.57 + NEEDS_VALGRIND=1 1.58 + fi 1.59 + ;; 1.60 + "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern") 1.61 + NEEDS_DRMEMORY=1 1.62 + ;; 1.63 +esac 1.64 + 1.65 +# For Libyuv, we'll use the locate_valgrind.sh script in Chromium's Valgrind 1.66 +# scripts dir to locate the Valgrind framework install 1.67 +CHROME_VALGRIND_SCRIPTS=$THISDIR/../valgrind 1.68 + 1.69 +if [ "$NEEDS_VALGRIND" == "1" ] 1.70 +then 1.71 + CHROME_VALGRIND=`sh $CHROME_VALGRIND_SCRIPTS/locate_valgrind.sh` 1.72 + if [ "$CHROME_VALGRIND" = "" ] 1.73 + then 1.74 + # locate_valgrind.sh failed 1.75 + exit 1 1.76 + fi 1.77 + echo "Using valgrind binaries from ${CHROME_VALGRIND}" 1.78 + 1.79 + PATH="${CHROME_VALGRIND}/bin:$PATH" 1.80 + # We need to set these variables to override default lib paths hard-coded into 1.81 + # Valgrind binary. 1.82 + export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind" 1.83 + export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" 1.84 + 1.85 + # Clean up some /tmp directories that might be stale due to interrupted 1.86 + # chrome_tests.py execution. 1.87 + # FYI: 1.88 + # -mtime +1 <- only print files modified more than 24h ago, 1.89 + # -print0/-0 are needed to handle possible newlines in the filenames. 1.90 + echo "Cleanup /tmp from Valgrind stuff" 1.91 + find /tmp -maxdepth 1 \(\ 1.92 + -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \ 1.93 + \) -mtime +1 -print0 | xargs -0 rm -rf 1.94 +fi 1.95 + 1.96 +if [ "$NEEDS_DRMEMORY" == "1" ] 1.97 +then 1.98 + if [ -z "$DRMEMORY_COMMAND" ] 1.99 + then 1.100 + DRMEMORY_PATH="$THISDIR/../../third_party/drmemory" 1.101 + DRMEMORY_SFX="$DRMEMORY_PATH/drmemory-windows-sfx.exe" 1.102 + if [ ! -f "$DRMEMORY_SFX" ] 1.103 + then 1.104 + echo "Can't find Dr. Memory executables." 1.105 + echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory" 1.106 + echo "for the instructions on how to get them." 1.107 + exit 1 1.108 + fi 1.109 + 1.110 + chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x. 1.111 + "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y 1.112 + export DRMEMORY_COMMAND="$DRMEMORY_PATH/unpacked/bin/drmemory.exe" 1.113 + fi 1.114 +fi 1.115 + 1.116 +if [ "$NEEDS_PIN" == "1" ] 1.117 +then 1.118 + if [ -z "$PIN_COMMAND" ] 1.119 + then 1.120 + # Set up PIN_COMMAND to invoke TSan. 1.121 + TSAN_PATH="$THISDIR/../../third_party/tsan" 1.122 + TSAN_SFX="$TSAN_PATH/tsan-x86-windows-sfx.exe" 1.123 + echo "$TSAN_SFX" 1.124 + if [ ! -f $TSAN_SFX ] 1.125 + then 1.126 + echo "Can't find ThreadSanitizer executables." 1.127 + echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows" 1.128 + echo "for the instructions on how to get them." 1.129 + exit 1 1.130 + fi 1.131 + 1.132 + chmod +x "$TSAN_SFX" # Cygwin won't run it without +x. 1.133 + "$TSAN_SFX" -o"$TSAN_PATH"/unpacked -y 1.134 + export PIN_COMMAND="$TSAN_PATH/unpacked/tsan-x86-windows/tsan.bat" 1.135 + fi 1.136 +fi 1.137 + 1.138 +# Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains 1.139 +# the scripts that are needed for this script to run 1.140 +PYTHONPATH=$THISDIR/../python/google:$CHROME_VALGRIND_SCRIPTS python \ 1.141 + "$THISDIR/libyuv_tests.py" $ARGV_COPY