Commit 6da38095 authored by timurrrr@chromium.org's avatar timurrrr@chromium.org

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
parent 361d37f6
...@@ -7,63 +7,41 @@ ...@@ -7,63 +7,41 @@
# Set up some paths and re-direct the arguments to chrome_tests.py # Set up some paths and re-direct the arguments to chrome_tests.py
export THISDIR=`dirname $0` export THISDIR=`dirname $0`
ARGV_COPY="$@"
TOOL_OPTION=0
# If --tool is omitted, default to --tool=memcheck
NEEDS_VALGRIND=1
# We need to set CHROME_VALGRIND iff using Memcheck or TSan-Valgrind: # We need to set CHROME_VALGRIND iff using Memcheck or TSan-Valgrind:
# tools/valgrind/chrome_tests.sh --tool memcheck # tools/valgrind/chrome_tests.sh --tool memcheck
# or # or
# tools/valgrind/chrome_tests.sh --tool=memcheck # tools/valgrind/chrome_tests.sh --tool=memcheck
# (same for "--tool=tsan") # (same for "--tool=tsan")
# TODO(glider): can this be made more compact? tool="memcheck" # Default to memcheck.
for flag in $@ while (( "$#" ))
do do
if [ "$flag" == "--tool" ] if [[ "$1" == "--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 then
NEEDS_VALGRIND=1 tool="$2"
break shift
elif [ "$flag" == "--tool=memcheck" ] elif [[ "$1" =~ --tool=(.*) ]]
then
NEEDS_VALGRIND=1
break
elif [ $(echo $flag | sed "s/=.*//") == "--tool" ]
then then
# This is a non-Valgrind tool. tool="${BASH_REMATCH[1]}"
NEEDS_VALGRIND=0
break
fi fi
if [ "$TOOL_OPTION" == "1" ] shift
then done
if [ "$flag" == "memcheck" ]
then NEEDS_VALGRIND=0
NEEDS_VALGRIND=1 NEEDS_DRMEMORY=0
break
elif [ "$flag" == "tsan" ] case "$tool" in
then "memcheck")
NEEDS_VALGRIND=1 NEEDS_VALGRIND=1
break ;;
elif [ "$flag" == "tsan_rv" ] "tsan" | "tsan_rv")
then
NEEDS_VALGRIND=1 NEEDS_VALGRIND=1
break ;;
else "drmemory" | "drmemory_light" | "drmemory_full")
TOOL_OPTION=0 NEEDS_DRMEMORY=1
fi ;;
fi esac
done
if [ "$NEEDS_VALGRIND" == "1" ] if [ "$NEEDS_VALGRIND" == "1" ]
then then
...@@ -82,4 +60,22 @@ then ...@@ -82,4 +60,22 @@ then
export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind"
fi 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
...@@ -191,3 +191,24 @@ def BoringCallers(mangled, use_re_wildcards): ...@@ -191,3 +191,24 @@ def BoringCallers(mangled, use_re_wildcards):
ret[i] = ret[i].replace('*', '.*').replace('?', '.') ret[i] = ret[i].replace('*', '.*').replace('?', '.')
return ret 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
...@@ -834,7 +834,7 @@ class DrMemory(BaseTool): ...@@ -834,7 +834,7 @@ class DrMemory(BaseTool):
for suppression_file in self._options.suppressions: for suppression_file in self._options.suppressions:
if os.path.exists(suppression_file): if os.path.exists(suppression_file):
suppression_count += 1 suppression_count += 1
proc += ["-suppress", suppression_file] proc += ["-suppress", common.NormalizeWindowsPath(suppression_file)]
if not suppression_count: if not suppression_count:
logging.warning("WARNING: NOT USING SUPPRESSIONS!") logging.warning("WARNING: NOT USING SUPPRESSIONS!")
...@@ -848,7 +848,7 @@ class DrMemory(BaseTool): ...@@ -848,7 +848,7 @@ class DrMemory(BaseTool):
if self._options.use_debug: if self._options.use_debug:
proc += ["-debug"] proc += ["-debug"]
proc += ["-logdir", self.log_dir] proc += ["-logdir", common.NormalizeWindowsPath(self.log_dir)]
proc += ["-batch", "-quiet", "-no_results_to_stderr"] proc += ["-batch", "-quiet", "-no_results_to_stderr"]
proc += ["-callstack_max_frames", "40"] proc += ["-callstack_max_frames", "40"]
...@@ -876,6 +876,7 @@ class DrMemory(BaseTool): ...@@ -876,6 +876,7 @@ class DrMemory(BaseTool):
proc = [] proc = []
# Note that self._args begins with the name of the exe to be run. # 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 proc += self._args
return proc return proc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment