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 |
ehmaldonado | 0fa164a | 2016-11-25 05:48:51 -0800 | [diff] [blame] | 16 | # the Valgrind framework install. If it fails a fallback path is used instead |
| 17 | # (../../chromium/src/third_party/valgrind/linux_x64) and a warning message |
| 18 | # is showed by |show_locate_valgrind_failed_warning|. |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 19 | # - webrtc_tests.py is invoked instead of chrome_tests.py. |
Henrik Kjellander | 057b8d9 | 2016-10-20 13:17:14 +0200 | [diff] [blame] | 20 | # - 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] | 21 | # possible to execute the Python scripts properly. |
| 22 | |
| 23 | export THISDIR=`dirname $0` |
| 24 | ARGV_COPY="$@" |
| 25 | |
kjellander@webrtc.org | afede83 | 2014-10-10 09:18:34 +0000 | [diff] [blame] | 26 | # We need to set CHROME_VALGRIND iff using Memcheck: |
Henrik Kjellander | 90fd7d8 | 2017-05-09 08:30:10 +0200 | [diff] [blame] | 27 | # tools_webrtc/valgrind/webrtc_tests.sh --tool memcheck |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 28 | # or |
Henrik Kjellander | 90fd7d8 | 2017-05-09 08:30:10 +0200 | [diff] [blame] | 29 | # tools_webrtc/valgrind/webrtc_tests.sh --tool=memcheck |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 30 | tool="memcheck" # Default to memcheck. |
| 31 | while (( "$#" )) |
| 32 | do |
| 33 | if [[ "$1" == "--tool" ]] |
| 34 | then |
| 35 | tool="$2" |
| 36 | shift |
| 37 | elif [[ "$1" =~ --tool=(.*) ]] |
| 38 | then |
| 39 | tool="${BASH_REMATCH[1]}" |
| 40 | fi |
| 41 | shift |
| 42 | done |
| 43 | |
| 44 | NEEDS_VALGRIND=0 |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 45 | |
| 46 | case "$tool" in |
| 47 | "memcheck") |
| 48 | NEEDS_VALGRIND=1 |
| 49 | ;; |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 50 | esac |
| 51 | |
Henrik Kjellander | 057b8d9 | 2016-10-20 13:17:14 +0200 | [diff] [blame] | 52 | # 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] | 53 | # scripts dir to locate the Valgrind framework install |
kjellander | afd5494 | 2016-12-17 12:21:39 -0800 | [diff] [blame] | 54 | CHROME_VALGRIND_SCRIPTS=$THISDIR/../../tools/valgrind |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 55 | |
| 56 | if [ "$NEEDS_VALGRIND" == "1" ] |
| 57 | then |
kjellander | 0393de4 | 2017-06-18 13:21:21 -0700 | [diff] [blame] | 58 | CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh` |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 59 | if [ "$CHROME_VALGRIND" = "" ] |
| 60 | then |
Henrik Kjellander | 49d2f26 | 2016-12-22 11:30:01 +0100 | [diff] [blame] | 61 | CHROME_VALGRIND=../../src/third_party/valgrind/linux_x64 |
ehmaldonado | 0fa164a | 2016-11-25 05:48:51 -0800 | [diff] [blame] | 62 | echo |
| 63 | echo "-------------------- WARNING ------------------------" |
| 64 | echo "locate_valgrind.sh failed." |
| 65 | echo "Using $CHROME_VALGRIND as a fallback location." |
| 66 | echo "This might be because:" |
| 67 | echo "1) This is a swarming bot" |
| 68 | echo "2) You haven't set up the valgrind binaries correctly." |
| 69 | echo "In this case, please make sure you have followed the instructions at" |
| 70 | echo "http://www.chromium.org/developers/how-tos/using-valgrind/get-valgrind" |
| 71 | echo "Notice: In the .gclient file, you need to add this for the 'src'" |
| 72 | echo "solution since our directory structure is different from Chromium's:" |
| 73 | echo "\"custom_deps\": {" |
Henrik Kjellander | 49d2f26 | 2016-12-22 11:30:01 +0100 | [diff] [blame] | 74 | echo " \"src/third_party/valgrind\":" |
ehmaldonado | 0fa164a | 2016-11-25 05:48:51 -0800 | [diff] [blame] | 75 | echo " \"https://chromium.googlesource.com/chromium/deps/valgrind/binaries\"," |
| 76 | echo "}," |
| 77 | echo "-----------------------------------------------------" |
| 78 | echo |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 79 | fi |
| 80 | echo "Using valgrind binaries from ${CHROME_VALGRIND}" |
| 81 | |
| 82 | PATH="${CHROME_VALGRIND}/bin:$PATH" |
| 83 | # We need to set these variables to override default lib paths hard-coded into |
| 84 | # Valgrind binary. |
| 85 | export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind" |
| 86 | export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" |
kjellander@webrtc.org | d1e7a9a | 2012-09-28 15:34:18 +0000 | [diff] [blame] | 87 | |
| 88 | # Clean up some /tmp directories that might be stale due to interrupted |
| 89 | # chrome_tests.py execution. |
| 90 | # FYI: |
| 91 | # -mtime +1 <- only print files modified more than 24h ago, |
| 92 | # -print0/-0 are needed to handle possible newlines in the filenames. |
| 93 | echo "Cleanup /tmp from Valgrind stuff" |
| 94 | find /tmp -maxdepth 1 \(\ |
| 95 | -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \ |
| 96 | \) -mtime +1 -print0 | xargs -0 rm -rf |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 97 | fi |
| 98 | |
Henrik Kjellander | 057b8d9 | 2016-10-20 13:17:14 +0200 | [diff] [blame] | 99 | # 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] | 100 | # the scripts that are needed for this script to run |
kjellander | afd5494 | 2016-12-17 12:21:39 -0800 | [diff] [blame] | 101 | PYTHONPATH=$THISDIR/../../tools/python/google:$CHROME_VALGRIND_SCRIPTS python \ |
kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame] | 102 | "$THISDIR/webrtc_tests.py" $ARGV_COPY |