1@echo off
2:: Copyright (c) 2011 The Chromium Authors. All rights reserved.
3:: Use of this source code is governed by a BSD-style license that can be
4:: found in the LICENSE file.
5
6setlocal
7
8set THISDIR=%~dp0
9set TOOL_NAME="unknown"
10
11:: Get the tool name and put it into TOOL_NAME {{{1
12:: NB: SHIFT command doesn't modify %*
13:PARSE_ARGS_LOOP
14  if %1 == () GOTO:TOOLNAME_NOT_FOUND
15  if %1 == --tool GOTO:TOOLNAME_FOUND
16  SHIFT
17  goto :PARSE_ARGS_LOOP
18
19:TOOLNAME_NOT_FOUND
20echo "Please specify a tool (e.g. drmemory) by using --tool flag"
21exit /B 1
22
23:TOOLNAME_FOUND
24SHIFT
25set TOOL_NAME=%1
26:: }}}
27if "%TOOL_NAME%" == "drmemory"          GOTO :SETUP_DRMEMORY
28if "%TOOL_NAME%" == "drmemory_light"    GOTO :SETUP_DRMEMORY
29if "%TOOL_NAME%" == "drmemory_full"     GOTO :SETUP_DRMEMORY
30if "%TOOL_NAME%" == "drmemory_pattern"  GOTO :SETUP_DRMEMORY
31echo "Unknown tool: `%TOOL_NAME%`! Only drmemory is supported right now"
32exit /B 1
33
34:SETUP_DRMEMORY
35:: Set up DRMEMORY_COMMAND to invoke Dr. Memory {{{1
36set DRMEMORY_PATH=%THISDIR%..\..\third_party\drmemory
37set DRMEMORY_SFX=%DRMEMORY_PATH%\drmemory-windows-sfx.exe
38if EXIST %DRMEMORY_SFX% GOTO DRMEMORY_BINARY_OK
39echo "Can't find Dr. Memory executables."
40echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory"
41echo "for the instructions on how to get them."
42exit /B 1
43
44:DRMEMORY_BINARY_OK
45%DRMEMORY_SFX% -o%DRMEMORY_PATH%\unpacked -y
46set DRMEMORY_COMMAND=%DRMEMORY_PATH%\unpacked\bin\drmemory.exe
47:: }}}
48goto :RUN_TESTS
49
50:RUN_TESTS
51set PYTHONPATH=%THISDIR%../python/google
52set RUNNING_ON_VALGRIND=yes
53python %THISDIR%/chrome_tests.py %*
54