| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """ | 5 """ |
| 6 Classes in this file define additional actions that need to be taken to run a | 6 Classes in this file define additional actions that need to be taken to run a |
| 7 test under some kind of runtime error detection tool. | 7 test under some kind of runtime error detection tool. |
| 8 | 8 |
| 9 The interface is intended to be used as follows. | 9 The interface is intended to be used as follows. |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 from pylib.constants import DIR_SOURCE_ROOT | 31 from pylib.constants import DIR_SOURCE_ROOT |
| 32 from pylib.device import device_errors | 32 from pylib.device import device_errors |
| 33 | 33 |
| 34 | 34 |
| 35 def SetChromeTimeoutScale(device, scale): | 35 def SetChromeTimeoutScale(device, scale): |
| 36 """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale.""" | 36 """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale.""" |
| 37 path = '/data/local/tmp/chrome_timeout_scale' | 37 path = '/data/local/tmp/chrome_timeout_scale' |
| 38 if not scale or scale == 1.0: | 38 if not scale or scale == 1.0: |
| 39 # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0 | 39 # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0 |
| 40 device.old_interface.RunShellCommand('rm %s' % path) | 40 device.RunShellCommand('rm %s' % path) |
| 41 else: | 41 else: |
| 42 device.old_interface.SetProtectedFileContents(path, '%f' % scale) | 42 device.old_interface.SetProtectedFileContents(path, '%f' % scale) |
| 43 | 43 |
| 44 | 44 |
| 45 class BaseTool(object): | 45 class BaseTool(object): |
| 46 """A tool that does nothing.""" | 46 """A tool that does nothing.""" |
| 47 | 47 |
| 48 def __init__(self): | 48 def __init__(self): |
| 49 """Does nothing.""" | 49 """Does nothing.""" |
| 50 pass | 50 pass |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 def __init__(self, device): | 160 def __init__(self, device): |
| 161 super(ValgrindTool, self).__init__() | 161 super(ValgrindTool, self).__init__() |
| 162 self._device = device | 162 self._device = device |
| 163 # exactly 31 chars, SystemProperties::PROP_NAME_MAX | 163 # exactly 31 chars, SystemProperties::PROP_NAME_MAX |
| 164 self._wrap_properties = ['wrap.com.google.android.apps.ch', | 164 self._wrap_properties = ['wrap.com.google.android.apps.ch', |
| 165 'wrap.org.chromium.native_test'] | 165 'wrap.org.chromium.native_test'] |
| 166 | 166 |
| 167 def CopyFiles(self): | 167 def CopyFiles(self): |
| 168 """Copies Valgrind tools to the device.""" | 168 """Copies Valgrind tools to the device.""" |
| 169 self._device.old_interface.RunShellCommand( | 169 self._device.RunShellCommand( |
| 170 'rm -r %s; mkdir %s' % (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR)) | 170 'rm -r %s; mkdir %s' % (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR)) |
| 171 self._device.old_interface.RunShellCommand( | 171 self._device.RunShellCommand( |
| 172 'rm -r %s; mkdir %s' % (ValgrindTool.VGLOGS_DIR, | 172 'rm -r %s; mkdir %s' % (ValgrindTool.VGLOGS_DIR, |
| 173 ValgrindTool.VGLOGS_DIR)) | 173 ValgrindTool.VGLOGS_DIR)) |
| 174 files = self.GetFilesForTool() | 174 files = self.GetFilesForTool() |
| 175 for f in files: | 175 for f in files: |
| 176 self._device.old_interface.PushIfNeeded( | 176 self._device.old_interface.PushIfNeeded( |
| 177 os.path.join(DIR_SOURCE_ROOT, f), | 177 os.path.join(DIR_SOURCE_ROOT, f), |
| 178 os.path.join(ValgrindTool.VG_DIR, os.path.basename(f))) | 178 os.path.join(ValgrindTool.VG_DIR, os.path.basename(f))) |
| 179 | 179 |
| 180 def SetupEnvironment(self): | 180 def SetupEnvironment(self): |
| 181 """Sets up device environment.""" | 181 """Sets up device environment.""" |
| 182 self._device.old_interface.RunShellCommand('chmod 777 /data/local/tmp') | 182 self._device.RunShellCommand('chmod 777 /data/local/tmp') |
| 183 self._device.old_interface.RunShellCommand('setenforce 0') | 183 self._device.RunShellCommand('setenforce 0') |
| 184 for prop in self._wrap_properties: | 184 for prop in self._wrap_properties: |
| 185 self._device.old_interface.RunShellCommand( | 185 self._device.RunShellCommand( |
| 186 'setprop %s "logwrapper %s"' % (prop, self.GetTestWrapper())) | 186 'setprop %s "logwrapper %s"' % (prop, self.GetTestWrapper())) |
| 187 SetChromeTimeoutScale(self._device, self.GetTimeoutScale()) | 187 SetChromeTimeoutScale(self._device, self.GetTimeoutScale()) |
| 188 | 188 |
| 189 def CleanUpEnvironment(self): | 189 def CleanUpEnvironment(self): |
| 190 """Cleans up device environment.""" | 190 """Cleans up device environment.""" |
| 191 for prop in self._wrap_properties: | 191 for prop in self._wrap_properties: |
| 192 self._device.old_interface.RunShellCommand('setprop %s ""' % (prop,)) | 192 self._device.RunShellCommand('setprop %s ""' % (prop,)) |
| 193 SetChromeTimeoutScale(self._device, None) | 193 SetChromeTimeoutScale(self._device, None) |
| 194 | 194 |
| 195 def GetFilesForTool(self): | 195 def GetFilesForTool(self): |
| 196 """Returns a list of file names for the tool.""" | 196 """Returns a list of file names for the tool.""" |
| 197 raise NotImplementedError() | 197 raise NotImplementedError() |
| 198 | 198 |
| 199 def NeedsDebugInfo(self): | 199 def NeedsDebugInfo(self): |
| 200 """Whether this tool requires debug info. | 200 """Whether this tool requires debug info. |
| 201 | 201 |
| 202 Returns: | 202 Returns: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if not tool_name: | 269 if not tool_name: |
| 270 return BaseTool() | 270 return BaseTool() |
| 271 | 271 |
| 272 ctor = TOOL_REGISTRY.get(tool_name) | 272 ctor = TOOL_REGISTRY.get(tool_name) |
| 273 if ctor: | 273 if ctor: |
| 274 return ctor(device) | 274 return ctor(device) |
| 275 else: | 275 else: |
| 276 print 'Unknown tool %s, available tools: %s' % ( | 276 print 'Unknown tool %s, available tools: %s' % ( |
| 277 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) | 277 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) |
| 278 sys.exit(1) | 278 sys.exit(1) |
| OLD | NEW |