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. |
Henrik Kjellander | 057b8d9 | 2016-10-20 13:17:14 +0200 | [diff] [blame] | 18 | # - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 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 |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 43 | |
| 44 | case "$tool" in |
| 45 | "memcheck") |
| 46 | NEEDS_VALGRIND=1 |
| 47 | ;; |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 48 | esac |
| 49 | |
Henrik Kjellander | 057b8d9 | 2016-10-20 13:17:14 +0200 | [diff] [blame] | 50 | # For WebRTC, we'll use the locate_valgrind.sh script in Chromium's Valgrind |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 51 | # scripts dir to locate the Valgrind framework install |
| 52 | CHROME_VALGRIND_SCRIPTS=$THISDIR/../valgrind |
| 53 | |
| 54 | if [ "$NEEDS_VALGRIND" == "1" ] |
| 55 | then |
| 56 | CHROME_VALGRIND=`sh $CHROME_VALGRIND_SCRIPTS/locate_valgrind.sh` |
| 57 | if [ "$CHROME_VALGRIND" = "" ] |
| 58 | then |
| 59 | # locate_valgrind.sh failed |
| 60 | exit 1 |
| 61 | fi |
| 62 | echo "Using valgrind binaries from ${CHROME_VALGRIND}" |
| 63 | |
| 64 | PATH="${CHROME_VALGRIND}/bin:$PATH" |
| 65 | # We need to set these variables to override default lib paths hard-coded into |
| 66 | # Valgrind binary. |
| 67 | export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind" |
| 68 | export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" |
kjellander@webrtc.org | d1e7a9a | 2012-09-28 15:34:18 +0000 | [diff] [blame] | 69 | |
| 70 | # Clean up some /tmp directories that might be stale due to interrupted |
| 71 | # chrome_tests.py execution. |
| 72 | # FYI: |
| 73 | # -mtime +1 <- only print files modified more than 24h ago, |
| 74 | # -print0/-0 are needed to handle possible newlines in the filenames. |
| 75 | echo "Cleanup /tmp from Valgrind stuff" |
| 76 | find /tmp -maxdepth 1 \(\ |
| 77 | -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \ |
| 78 | \) -mtime +1 -print0 | xargs -0 rm -rf |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 79 | fi |
| 80 | |
Henrik Kjellander | 057b8d9 | 2016-10-20 13:17:14 +0200 | [diff] [blame] | 81 | # Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 82 | # the scripts that are needed for this script to run |
| 83 | PYTHONPATH=$THISDIR/../python/google:$CHROME_VALGRIND_SCRIPTS python \ |
| 84 | "$THISDIR/webrtc_tests.py" $ARGV_COPY |