blob: 7d752dfec446e08f0924dabd96e727d05d07e248 [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.
Henrik Kjellander057b8d92016-10-20 13:17:14 +020018# - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it
kjellander@webrtc.orgb5b155b2011-12-20 08:53:41 +000019# possible to execute the Python scripts properly.
20
21export THISDIR=`dirname $0`
22ARGV_COPY="$@"
23
kjellander@webrtc.orgafede832014-10-10 09:18:34 +000024# We need to set CHROME_VALGRIND iff using Memcheck:
kjellander@webrtc.orgd1e7a9a2012-09-28 15:34:18 +000025# tools/valgrind-webrtc/webrtc_tests.sh --tool memcheck
kjellander@webrtc.orgb5b155b2011-12-20 08:53:41 +000026# or
kjellander@webrtc.orgd1e7a9a2012-09-28 15:34:18 +000027# tools/valgrind-webrtc/webrtc_tests.sh --tool=memcheck
kjellander@webrtc.orgb5b155b2011-12-20 08:53:41 +000028tool="memcheck" # Default to memcheck.
29while (( "$#" ))
30do
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
40done
41
42NEEDS_VALGRIND=0
kjellander@webrtc.orgb5b155b2011-12-20 08:53:41 +000043
44case "$tool" in
45 "memcheck")
46 NEEDS_VALGRIND=1
47 ;;
kjellander@webrtc.orgb5b155b2011-12-20 08:53:41 +000048esac
49
Henrik Kjellander057b8d92016-10-20 13:17:14 +020050# For WebRTC, we'll use the locate_valgrind.sh script in Chromium's Valgrind
kjellander@webrtc.orgb5b155b2011-12-20 08:53:41 +000051# scripts dir to locate the Valgrind framework install
52CHROME_VALGRIND_SCRIPTS=$THISDIR/../valgrind
53
54if [ "$NEEDS_VALGRIND" == "1" ]
55then
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.orgd1e7a9a2012-09-28 15:34:18 +000069
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.orgb5b155b2011-12-20 08:53:41 +000079fi
80
Henrik Kjellander057b8d92016-10-20 13:17:14 +020081# Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains
kjellander@webrtc.orgb5b155b2011-12-20 08:53:41 +000082# the scripts that are needed for this script to run
83PYTHONPATH=$THISDIR/../python/google:$CHROME_VALGRIND_SCRIPTS python \
84 "$THISDIR/webrtc_tests.py" $ARGV_COPY