blob: e33b78c6f7c8128e8de0dbfd0b7fe7342a64f5dc [file] [log] [blame]
kjellander@webrtc.orgb5b155b2011-12-20 08:53:41 +00001#!/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.
18# - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it
19# possible to execute the Python scripts properly.
20
21export THISDIR=`dirname $0`
22ARGV_COPY="$@"
23
24# We need to set CHROME_VALGRIND iff using Memcheck or TSan-Valgrind:
25# tools/valgrind/chrome_tests.sh --tool memcheck
26# or
27# tools/valgrind/chrome_tests.sh --tool=memcheck
28# (same for "--tool=tsan")
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
44NEEDS_DRMEMORY=0
45
46case "$tool" in
47 "memcheck")
48 NEEDS_VALGRIND=1
49 ;;
50 "tsan" | "tsan_rv")
51 NEEDS_VALGRIND=1
52 ;;
53 "drmemory" | "drmemory_light" | "drmemory_full")
54 NEEDS_DRMEMORY=1
55 ;;
56esac
57
58# For WebRTC, we'll use the locate_valgrind.sh script in Chromium's Valgrind
59# scripts dir to locate the Valgrind framework install
60CHROME_VALGRIND_SCRIPTS=$THISDIR/../valgrind
61
62if [ "$NEEDS_VALGRIND" == "1" ]
63then
64 CHROME_VALGRIND=`sh $CHROME_VALGRIND_SCRIPTS/locate_valgrind.sh`
65 if [ "$CHROME_VALGRIND" = "" ]
66 then
67 # locate_valgrind.sh failed
68 exit 1
69 fi
70 echo "Using valgrind binaries from ${CHROME_VALGRIND}"
71
72 PATH="${CHROME_VALGRIND}/bin:$PATH"
73 # We need to set these variables to override default lib paths hard-coded into
74 # Valgrind binary.
75 export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind"
76 export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind"
77fi
78
79if [ "$NEEDS_DRMEMORY" == "1" ]
80then
81 if [ -z "$DRMEMORY_COMMAND" ]
82 then
83 DRMEMORY_PATH="$THISDIR/../../third_party/drmemory"
84 DRMEMORY_SFX="$DRMEMORY_PATH/drmemory-windows-sfx.exe"
85 if [ ! -f "$DRMEMORY_SFX" ]
86 then
87 echo "Can't find Dr. Memory executables."
88 echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory"
89 echo "for the instructions on how to get them."
90 exit 1
91 fi
92
93 chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x.
94 "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y
95 export DRMEMORY_COMMAND="$DRMEMORY_PATH/unpacked/bin/drmemory.exe"
96 fi
97fi
98
99# Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains
100# the scripts that are needed for this script to run
101PYTHONPATH=$THISDIR/../python/google:$CHROME_VALGRIND_SCRIPTS python \
102 "$THISDIR/webrtc_tests.py" $ARGV_COPY