summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authortimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 10:37:09 +0000
committertimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 10:37:09 +0000
commit6da380958eefd027cade926b4794ff1d4e771ccb (patch)
tree8727c2bce2fcc76288ce0c8a9cc1900b9961aadc /tools
parent361d37f6574d61171dbf3f9441959e788e74ec56 (diff)
downloadchromium_src-6da380958eefd027cade926b4794ff1d4e771ccb.zip
chromium_src-6da380958eefd027cade926b4794ff1d4e771ccb.tar.gz
chromium_src-6da380958eefd027cade926b4794ff1d4e771ccb.tar.bz2
Update chrome_tests.sh to run DrMemory from Cygwin
Also change valgrind_tests.py to use cygpath to give DrMemory Windows paths when running with Cygwin Python. The original change was made by Reid Kleckner and reviewed at http://codereview.chromium.org/8505028/ TBR=glider Review URL: http://codereview.chromium.org/8636008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-xtools/valgrind/chrome_tests.sh90
-rwxr-xr-xtools/valgrind/common.py21
-rwxr-xr-xtools/valgrind/valgrind_test.py5
3 files changed, 67 insertions, 49 deletions
diff --git a/tools/valgrind/chrome_tests.sh b/tools/valgrind/chrome_tests.sh
index d30253a..ec2545d 100755
--- a/tools/valgrind/chrome_tests.sh
+++ b/tools/valgrind/chrome_tests.sh
@@ -7,64 +7,42 @@
# Set up some paths and re-direct the arguments to chrome_tests.py
export THISDIR=`dirname $0`
-
-TOOL_OPTION=0
-# If --tool is omitted, default to --tool=memcheck
-NEEDS_VALGRIND=1
+ARGV_COPY="$@"
# We need to set CHROME_VALGRIND iff using Memcheck or TSan-Valgrind:
# tools/valgrind/chrome_tests.sh --tool memcheck
# or
# tools/valgrind/chrome_tests.sh --tool=memcheck
# (same for "--tool=tsan")
-# TODO(glider): can this be made more compact?
-for flag in $@
+tool="memcheck" # Default to memcheck.
+while (( "$#" ))
do
- if [ "$flag" == "--tool" ]
- then
- # Need to check that the next argument is either "memcheck", "tsan"
- # or "tsan_rv".
- TOOL_OPTION=1
- NEEDS_VALGRIND=0
- continue
- elif [ "$flag" == "--tool=tsan" ]
- then
- NEEDS_VALGRIND=1
- break
- elif [ "$flag" == "--tool=tsan_rv" ]
- then
- NEEDS_VALGRIND=1
- break
- elif [ "$flag" == "--tool=memcheck" ]
+ if [[ "$1" == "--tool" ]]
then
- NEEDS_VALGRIND=1
- break
- elif [ $(echo $flag | sed "s/=.*//") == "--tool" ]
+ tool="$2"
+ shift
+ elif [[ "$1" =~ --tool=(.*) ]]
then
- # This is a non-Valgrind tool.
- NEEDS_VALGRIND=0
- break
- fi
- if [ "$TOOL_OPTION" == "1" ]
- then
- if [ "$flag" == "memcheck" ]
- then
- NEEDS_VALGRIND=1
- break
- elif [ "$flag" == "tsan" ]
- then
- NEEDS_VALGRIND=1
- break
- elif [ "$flag" == "tsan_rv" ]
- then
- NEEDS_VALGRIND=1
- break
- else
- TOOL_OPTION=0
- fi
+ tool="${BASH_REMATCH[1]}"
fi
+ shift
done
+NEEDS_VALGRIND=0
+NEEDS_DRMEMORY=0
+
+case "$tool" in
+ "memcheck")
+ NEEDS_VALGRIND=1
+ ;;
+ "tsan" | "tsan_rv")
+ NEEDS_VALGRIND=1
+ ;;
+ "drmemory" | "drmemory_light" | "drmemory_full")
+ NEEDS_DRMEMORY=1
+ ;;
+esac
+
if [ "$NEEDS_VALGRIND" == "1" ]
then
CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh`
@@ -82,4 +60,22 @@ then
export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind"
fi
-PYTHONPATH=$THISDIR/../python/google "$THISDIR/chrome_tests.py" "$@"
+if [ "$NEEDS_DRMEMORY" == "1" ]
+then
+ export DRMEMORY_PATH=$THISDIR/../../third_party/drmemory
+ export DRMEMORY_SFX=$DRMEMORY_PATH/drmemory-windows-sfx.exe
+ if [ ! -f "$DRMEMORY_SFX" ]
+ then
+ echo "Can't find Dr. Memory executables."
+ echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory"
+ echo "for the instructions on how to get them."
+ exit 1
+ fi
+
+ chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x.
+ "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y
+ export DRMEMORY_COMMAND=$DRMEMORY_PATH/unpacked/bin/drmemory.exe
+fi
+
+PYTHONPATH=$THISDIR/../python/google python \
+ "$THISDIR/chrome_tests.py" $ARGV_COPY
diff --git a/tools/valgrind/common.py b/tools/valgrind/common.py
index 4804213..c7a5c92 100755
--- a/tools/valgrind/common.py
+++ b/tools/valgrind/common.py
@@ -191,3 +191,24 @@ def BoringCallers(mangled, use_re_wildcards):
ret[i] = ret[i].replace('*', '.*').replace('?', '.')
return ret
+
+def NormalizeWindowsPath(path):
+ """If we're using Cygwin Python, turn the path into a Windows path.
+
+ Don't turn forward slashes into backslashes for easier copy-pasting and
+ escaping.
+
+ TODO(rnk): If we ever want to cut out the subprocess invocation, we can use
+ _winreg to get the root Cygwin directory from the registry key:
+ HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\setup\rootdir.
+ """
+ if sys.platform.startswith("cygwin"):
+ p = subprocess.Popen(["cygpath", "-m", path],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ (out, err) = p.communicate()
+ if err:
+ logging.warning("WARNING: cygpath error: %s", err)
+ return out.strip()
+ else:
+ return path
diff --git a/tools/valgrind/valgrind_test.py b/tools/valgrind/valgrind_test.py
index fd727c7..1f68bb0 100755
--- a/tools/valgrind/valgrind_test.py
+++ b/tools/valgrind/valgrind_test.py
@@ -834,7 +834,7 @@ class DrMemory(BaseTool):
for suppression_file in self._options.suppressions:
if os.path.exists(suppression_file):
suppression_count += 1
- proc += ["-suppress", suppression_file]
+ proc += ["-suppress", common.NormalizeWindowsPath(suppression_file)]
if not suppression_count:
logging.warning("WARNING: NOT USING SUPPRESSIONS!")
@@ -848,7 +848,7 @@ class DrMemory(BaseTool):
if self._options.use_debug:
proc += ["-debug"]
- proc += ["-logdir", self.log_dir]
+ proc += ["-logdir", common.NormalizeWindowsPath(self.log_dir)]
proc += ["-batch", "-quiet", "-no_results_to_stderr"]
proc += ["-callstack_max_frames", "40"]
@@ -876,6 +876,7 @@ class DrMemory(BaseTool):
proc = []
# Note that self._args begins with the name of the exe to be run.
+ self._args[0] = common.NormalizeWindowsPath(self._args[0])
proc += self._args
return proc