| Index: build/android/pylib/valgrind_tools.py
|
| diff --git a/build/android/pylib/valgrind_tools.py b/build/android/pylib/valgrind_tools.py
|
| index c92ee1740942a1721bae74c111d1d263e28760af..65e1cf8ad1befff1b9491ae380bde46baaaa2b78 100644
|
| --- a/build/android/pylib/valgrind_tools.py
|
| +++ b/build/android/pylib/valgrind_tools.py
|
| @@ -29,14 +29,14 @@ import sys
|
| from pylib.constants import DIR_SOURCE_ROOT
|
|
|
|
|
| -def SetChromeTimeoutScale(adb, scale):
|
| +def SetChromeTimeoutScale(device, scale):
|
| """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale."""
|
| path = '/data/local/tmp/chrome_timeout_scale'
|
| if not scale or scale == 1.0:
|
| # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0
|
| - adb.RunShellCommand('rm %s' % path)
|
| + device.old_interface.RunShellCommand('rm %s' % path)
|
| else:
|
| - adb.SetProtectedFileContents(path, '%f' % scale)
|
| + device.old_interface.SetProtectedFileContents(path, '%f' % scale)
|
|
|
|
|
| class BaseTool(object):
|
| @@ -96,21 +96,21 @@ class AddressSanitizerTool(BaseTool):
|
| # nothing we can do about that.
|
| EXTRA_OPTIONS = 'strict_memcmp=0,use_sigaltstack=1'
|
|
|
| - def __init__(self, adb):
|
| + def __init__(self, device):
|
| super(AddressSanitizerTool, self).__init__()
|
| - self._adb = adb
|
| + self._device = device
|
| # Configure AndroidCommands to run utils (such as md5sum_bin) under ASan.
|
| # This is required because ASan is a compiler-based tool, and md5sum
|
| # includes instrumented code from base.
|
| - adb.SetUtilWrapper(self.GetUtilWrapper())
|
| + device.old_interface.SetUtilWrapper(self.GetUtilWrapper())
|
|
|
| def CopyFiles(self):
|
| """Copies ASan tools to the device."""
|
| subprocess.call([os.path.join(DIR_SOURCE_ROOT,
|
| 'tools/android/asan/asan_device_setup.sh'),
|
| - '--device', self._adb.GetDevice(),
|
| + '--device', self._device.old_interface.GetDevice(),
|
| '--extra-options', AddressSanitizerTool.EXTRA_OPTIONS])
|
| - self._adb.WaitForDevicePm()
|
| + self._device.old_interface.WaitForDevicePm()
|
|
|
| def GetTestWrapper(self):
|
| return AddressSanitizerTool.WRAPPER_NAME
|
| @@ -124,11 +124,11 @@ class AddressSanitizerTool(BaseTool):
|
| return self.GetTestWrapper()
|
|
|
| def SetupEnvironment(self):
|
| - self._adb.EnableAdbRoot()
|
| - SetChromeTimeoutScale(self._adb, self.GetTimeoutScale())
|
| + self._device.old_interface.EnableAdbRoot()
|
| + SetChromeTimeoutScale(self._device, self.GetTimeoutScale())
|
|
|
| def CleanUpEnvironment(self):
|
| - SetChromeTimeoutScale(self._adb, None)
|
| + SetChromeTimeoutScale(self._device, None)
|
|
|
| def GetTimeoutScale(self):
|
| # Very slow startup.
|
| @@ -141,40 +141,40 @@ class ValgrindTool(BaseTool):
|
| VG_DIR = '/data/local/tmp/valgrind'
|
| VGLOGS_DIR = '/data/local/tmp/vglogs'
|
|
|
| - def __init__(self, adb):
|
| + def __init__(self, device):
|
| super(ValgrindTool, self).__init__()
|
| - self._adb = adb
|
| + self._device = device
|
| # exactly 31 chars, SystemProperties::PROP_NAME_MAX
|
| self._wrap_properties = ['wrap.com.google.android.apps.ch',
|
| 'wrap.org.chromium.native_test']
|
|
|
| def CopyFiles(self):
|
| """Copies Valgrind tools to the device."""
|
| - self._adb.RunShellCommand('rm -r %s; mkdir %s' %
|
| - (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR))
|
| - self._adb.RunShellCommand('rm -r %s; mkdir %s' %
|
| - (ValgrindTool.VGLOGS_DIR,
|
| - ValgrindTool.VGLOGS_DIR))
|
| + self._device.old_interface.RunShellCommand(
|
| + 'rm -r %s; mkdir %s' % (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR))
|
| + self._device.old_interface.RunShellCommand(
|
| + 'rm -r %s; mkdir %s' % (ValgrindTool.VGLOGS_DIR,
|
| + ValgrindTool.VGLOGS_DIR))
|
| files = self.GetFilesForTool()
|
| for f in files:
|
| - self._adb.PushIfNeeded(os.path.join(DIR_SOURCE_ROOT, f),
|
| - os.path.join(ValgrindTool.VG_DIR,
|
| - os.path.basename(f)))
|
| + self._device.old_interface.PushIfNeeded(
|
| + os.path.join(DIR_SOURCE_ROOT, f),
|
| + os.path.join(ValgrindTool.VG_DIR, os.path.basename(f)))
|
|
|
| def SetupEnvironment(self):
|
| """Sets up device environment."""
|
| - self._adb.RunShellCommand('chmod 777 /data/local/tmp')
|
| - self._adb.RunShellCommand('setenforce 0')
|
| + self._device.old_interface.RunShellCommand('chmod 777 /data/local/tmp')
|
| + self._device.old_interface.RunShellCommand('setenforce 0')
|
| for prop in self._wrap_properties:
|
| - self._adb.RunShellCommand('setprop %s "logwrapper %s"' % (
|
| - prop, self.GetTestWrapper()))
|
| - SetChromeTimeoutScale(self._adb, self.GetTimeoutScale())
|
| + self._device.old_interface.RunShellCommand(
|
| + 'setprop %s "logwrapper %s"' % (prop, self.GetTestWrapper()))
|
| + SetChromeTimeoutScale(self._device, self.GetTimeoutScale())
|
|
|
| def CleanUpEnvironment(self):
|
| """Cleans up device environment."""
|
| for prop in self._wrap_properties:
|
| - self._adb.RunShellCommand('setprop %s ""' % (prop,))
|
| - SetChromeTimeoutScale(self._adb, None)
|
| + self._device.RunShellCommand('setprop %s ""' % (prop,))
|
| + SetChromeTimeoutScale(self._device, None)
|
|
|
| def GetFilesForTool(self):
|
| """Returns a list of file names for the tool."""
|
| @@ -192,8 +192,8 @@ class ValgrindTool(BaseTool):
|
| class MemcheckTool(ValgrindTool):
|
| """Memcheck tool."""
|
|
|
| - def __init__(self, adb):
|
| - super(MemcheckTool, self).__init__(adb)
|
| + def __init__(self, device):
|
| + super(MemcheckTool, self).__init__(device)
|
|
|
| def GetFilesForTool(self):
|
| """Returns a list of file names for the tool."""
|
| @@ -213,8 +213,8 @@ class MemcheckTool(ValgrindTool):
|
| class TSanTool(ValgrindTool):
|
| """ThreadSanitizer tool. See http://code.google.com/p/data-race-test ."""
|
|
|
| - def __init__(self, adb):
|
| - super(TSanTool, self).__init__(adb)
|
| + def __init__(self, device):
|
| + super(TSanTool, self).__init__(device)
|
|
|
| def GetFilesForTool(self):
|
| """Returns a list of file names for the tool."""
|
| @@ -241,12 +241,12 @@ TOOL_REGISTRY = {
|
| }
|
|
|
|
|
| -def CreateTool(tool_name, adb):
|
| +def CreateTool(tool_name, device):
|
| """Creates a tool with the specified tool name.
|
|
|
| Args:
|
| tool_name: Name of the tool to create.
|
| - adb: ADB interface the tool will use.
|
| + device: A DeviceUtils instance.
|
| Returns:
|
| A tool for the specified tool_name.
|
| """
|
| @@ -255,7 +255,7 @@ def CreateTool(tool_name, adb):
|
|
|
| ctor = TOOL_REGISTRY.get(tool_name)
|
| if ctor:
|
| - return ctor(adb)
|
| + return ctor(device)
|
| else:
|
| print 'Unknown tool %s, available tools: %s' % (
|
| tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
|
|
|