1#!/bin/bash 2# Copyright (c) 2012 The LibYuv Project Authors. All rights reserved. 3# 4# Use of this source code is governed by a BSD-style license 5# that can be found in the LICENSE file in the root of the source 6# tree. An additional intellectual property rights grant can be found 7# in the file PATENTS. All contributing project authors may 8# be found in the AUTHORS file in the root of the source tree. 9 10# Set up some paths and re-direct the arguments to libyuv_tests.py 11 12# This script is a copy of the chrome_tests.sh wrapper script with the following 13# changes: 14# - The locate_valgrind.sh of Chromium's Valgrind scripts dir is used to locate 15# the Valgrind framework install. If it fails a fallback path is used instead 16# (../../chromium/src/third_party/valgrind/linux_x64) and a warning message 17# is showed by |show_locate_valgrind_failed_warning|. 18# - libyuv_tests.py is invoked instead of chrome_tests.py. 19# - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it 20# possible to execute the Python scripts properly. 21 22export THISDIR=`dirname $0` 23ARGV_COPY="$@" 24 25# We need to set CHROME_VALGRIND iff using Memcheck: 26# tools_libyuv/valgrind/libyuv_tests.sh --tool memcheck 27# or 28# tools_libyuv/valgrind/libyuv_tests.sh --tool=memcheck 29tool="memcheck" # Default to memcheck. 30while (( "$#" )) 31do 32 if [[ "$1" == "--tool" ]] 33 then 34 tool="$2" 35 shift 36 elif [[ "$1" =~ --tool=(.*) ]] 37 then 38 tool="${BASH_REMATCH[1]}" 39 fi 40 shift 41done 42 43NEEDS_VALGRIND=0 44 45case "$tool" in 46 "memcheck") 47 NEEDS_VALGRIND=1 48 ;; 49esac 50 51# For libyuv, we'll use the locate_valgrind.sh script in Chromium's Valgrind 52# scripts dir to locate the Valgrind framework install 53CHROME_VALGRIND_SCRIPTS=$THISDIR/../../tools/valgrind 54 55if [ "$NEEDS_VALGRIND" == "1" ] 56then 57 CHROME_VALGRIND=`sh $CHROME_VALGRIND_SCRIPTS/locate_valgrind.sh` 58 if [ "$CHROME_VALGRIND" = "" ] 59 then 60 CHROME_VALGRIND=../../src/third_party/valgrind/linux_x64 61 echo 62 echo "-------------------- WARNING ------------------------" 63 echo "locate_valgrind.sh failed." 64 echo "Using $CHROME_VALGRIND as a fallback location." 65 echo "This might be because:" 66 echo "1) This is a swarming bot" 67 echo "2) You haven't set up the valgrind binaries correctly." 68 echo "In this case, please make sure you have followed the instructions at" 69 echo "http://www.chromium.org/developers/how-tos/using-valgrind/get-valgrind" 70 echo "Notice: In the .gclient file, you need to add this for the 'libyuv'" 71 echo "solution since our directory structure is different from Chromium's:" 72 echo "\"custom_deps\": {" 73 echo " \"libyuv/third_party/valgrind\":" 74 echo " \"https://chromium.googlesource.com/chromium/deps/valgrind/binaries\"," 75 echo "}," 76 echo "-----------------------------------------------------" 77 echo 78 fi 79 echo "Using valgrind binaries from ${CHROME_VALGRIND}" 80 81 PATH="${CHROME_VALGRIND}/bin:$PATH" 82 # We need to set these variables to override default lib paths hard-coded into 83 # Valgrind binary. 84 export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind" 85 export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" 86 87 # Clean up some /tmp directories that might be stale due to interrupted 88 # chrome_tests.py execution. 89 # FYI: 90 # -mtime +1 <- only print files modified more than 24h ago, 91 # -print0/-0 are needed to handle possible newlines in the filenames. 92 echo "Cleanup /tmp from Valgrind stuff" 93 find /tmp -maxdepth 1 \(\ 94 -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \ 95 \) -mtime +1 -print0 | xargs -0 rm -rf 96fi 97 98# Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains 99# the scripts that are needed for this script to run 100PYTHONPATH=$THISDIR/../../tools/python/google:$CHROME_VALGRIND_SCRIPTS python \ 101 "$THISDIR/libyuv_tests.py" $ARGV_COPY 102