michael@0: #!/bin/bash michael@0: # Copyright (c) 2012 The LibYuv Project Authors. All rights reserved. michael@0: # michael@0: # Use of this source code is governed by a BSD-style license michael@0: # that can be found in the LICENSE file in the root of the source michael@0: # tree. An additional intellectual property rights grant can be found michael@0: # in the file PATENTS. All contributing project authors may michael@0: # be found in the AUTHORS file in the root of the source tree. michael@0: michael@0: # Set up some paths and re-direct the arguments to libyuv_tests.py michael@0: michael@0: # This script is a copy of the chrome_tests.sh wrapper script with the following michael@0: # changes: michael@0: # - The locate_valgrind.sh of Chromium's Valgrind scripts dir is used to locate michael@0: # the Valgrind framework install. michael@0: # - libyuv_tests.py is invoked instead of chrome_tests.py. michael@0: # - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it michael@0: # possible to execute the Python scripts properly. michael@0: michael@0: export THISDIR=`dirname $0` michael@0: ARGV_COPY="$@" michael@0: michael@0: # We need to set CHROME_VALGRIND iff using Memcheck or TSan-Valgrind: michael@0: # tools/valgrind-libyuv/libyuv_tests.sh --tool memcheck michael@0: # or michael@0: # tools/valgrind-libyuv/libyuv_tests.sh --tool=memcheck michael@0: # (same for "--tool=tsan") michael@0: tool="memcheck" # Default to memcheck. michael@0: while (( "$#" )) michael@0: do michael@0: if [[ "$1" == "--tool" ]] michael@0: then michael@0: tool="$2" michael@0: shift michael@0: elif [[ "$1" =~ --tool=(.*) ]] michael@0: then michael@0: tool="${BASH_REMATCH[1]}" michael@0: fi michael@0: shift michael@0: done michael@0: michael@0: NEEDS_VALGRIND=0 michael@0: NEEDS_DRMEMORY=0 michael@0: michael@0: case "$tool" in michael@0: "memcheck") michael@0: NEEDS_VALGRIND=1 michael@0: ;; michael@0: "tsan" | "tsan_rv") michael@0: if [ "`uname -s`" == CYGWIN* ] michael@0: then michael@0: NEEDS_PIN=1 michael@0: else michael@0: NEEDS_VALGRIND=1 michael@0: fi michael@0: ;; michael@0: "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern") michael@0: NEEDS_DRMEMORY=1 michael@0: ;; michael@0: esac michael@0: michael@0: # For Libyuv, we'll use the locate_valgrind.sh script in Chromium's Valgrind michael@0: # scripts dir to locate the Valgrind framework install michael@0: CHROME_VALGRIND_SCRIPTS=$THISDIR/../valgrind michael@0: michael@0: if [ "$NEEDS_VALGRIND" == "1" ] michael@0: then michael@0: CHROME_VALGRIND=`sh $CHROME_VALGRIND_SCRIPTS/locate_valgrind.sh` michael@0: if [ "$CHROME_VALGRIND" = "" ] michael@0: then michael@0: # locate_valgrind.sh failed michael@0: exit 1 michael@0: fi michael@0: echo "Using valgrind binaries from ${CHROME_VALGRIND}" michael@0: michael@0: PATH="${CHROME_VALGRIND}/bin:$PATH" michael@0: # We need to set these variables to override default lib paths hard-coded into michael@0: # Valgrind binary. michael@0: export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind" michael@0: export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" michael@0: michael@0: # Clean up some /tmp directories that might be stale due to interrupted michael@0: # chrome_tests.py execution. michael@0: # FYI: michael@0: # -mtime +1 <- only print files modified more than 24h ago, michael@0: # -print0/-0 are needed to handle possible newlines in the filenames. michael@0: echo "Cleanup /tmp from Valgrind stuff" michael@0: find /tmp -maxdepth 1 \(\ michael@0: -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \ michael@0: \) -mtime +1 -print0 | xargs -0 rm -rf michael@0: fi michael@0: michael@0: if [ "$NEEDS_DRMEMORY" == "1" ] michael@0: then michael@0: if [ -z "$DRMEMORY_COMMAND" ] michael@0: then michael@0: DRMEMORY_PATH="$THISDIR/../../third_party/drmemory" michael@0: DRMEMORY_SFX="$DRMEMORY_PATH/drmemory-windows-sfx.exe" michael@0: if [ ! -f "$DRMEMORY_SFX" ] michael@0: then michael@0: echo "Can't find Dr. Memory executables." michael@0: echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory" michael@0: echo "for the instructions on how to get them." michael@0: exit 1 michael@0: fi michael@0: michael@0: chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x. michael@0: "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y michael@0: export DRMEMORY_COMMAND="$DRMEMORY_PATH/unpacked/bin/drmemory.exe" michael@0: fi michael@0: fi michael@0: michael@0: if [ "$NEEDS_PIN" == "1" ] michael@0: then michael@0: if [ -z "$PIN_COMMAND" ] michael@0: then michael@0: # Set up PIN_COMMAND to invoke TSan. michael@0: TSAN_PATH="$THISDIR/../../third_party/tsan" michael@0: TSAN_SFX="$TSAN_PATH/tsan-x86-windows-sfx.exe" michael@0: echo "$TSAN_SFX" michael@0: if [ ! -f $TSAN_SFX ] michael@0: then michael@0: echo "Can't find ThreadSanitizer executables." michael@0: echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows" michael@0: echo "for the instructions on how to get them." michael@0: exit 1 michael@0: fi michael@0: michael@0: chmod +x "$TSAN_SFX" # Cygwin won't run it without +x. michael@0: "$TSAN_SFX" -o"$TSAN_PATH"/unpacked -y michael@0: export PIN_COMMAND="$TSAN_PATH/unpacked/tsan-x86-windows/tsan.bat" michael@0: fi michael@0: fi michael@0: michael@0: # Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains michael@0: # the scripts that are needed for this script to run michael@0: PYTHONPATH=$THISDIR/../python/google:$CHROME_VALGRIND_SCRIPTS python \ michael@0: "$THISDIR/libyuv_tests.py" $ARGV_COPY