Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 Call tool.CleanUpEnvironment(). | 21 Call tool.CleanUpEnvironment(). |
| 22 """ | 22 """ |
| 23 # pylint: disable=R0201 | 23 # pylint: disable=R0201 |
| 24 | 24 |
| 25 import glob | 25 import glob |
| 26 import os.path | 26 import os.path |
| 27 import subprocess | 27 import subprocess |
| 28 import sys | 28 import sys |
| 29 | 29 |
| 30 from pylib.constants import DIR_SOURCE_ROOT | 30 from pylib.constants import DIR_SOURCE_ROOT |
| 31 from pylib.device import device_errors | |
| 31 | 32 |
| 32 | 33 |
| 33 def SetChromeTimeoutScale(device, scale): | 34 def SetChromeTimeoutScale(device, scale): |
| 34 """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale.""" | 35 """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale.""" |
| 35 path = '/data/local/tmp/chrome_timeout_scale' | 36 path = '/data/local/tmp/chrome_timeout_scale' |
| 36 if not scale or scale == 1.0: | 37 if not scale or scale == 1.0: |
| 37 # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0 | 38 # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0 |
| 38 device.old_interface.RunShellCommand('rm %s' % path) | 39 device.old_interface.RunShellCommand('rm %s' % path) |
| 39 else: | 40 else: |
| 40 device.old_interface.SetProtectedFileContents(path, '%f' % scale) | 41 device.old_interface.SetProtectedFileContents(path, '%f' % scale) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 | 126 |
| 126 def GetUtilWrapper(self): | 127 def GetUtilWrapper(self): |
| 127 """Returns the wrapper for utilities, such as forwarder. | 128 """Returns the wrapper for utilities, such as forwarder. |
| 128 | 129 |
| 129 AddressSanitizer wrapper must be added to all instrumented binaries, | 130 AddressSanitizer wrapper must be added to all instrumented binaries, |
| 130 including forwarder and the like. This can be removed if such binaries | 131 including forwarder and the like. This can be removed if such binaries |
| 131 were built without instrumentation. """ | 132 were built without instrumentation. """ |
| 132 return self.GetTestWrapper() | 133 return self.GetTestWrapper() |
| 133 | 134 |
| 134 def SetupEnvironment(self): | 135 def SetupEnvironment(self): |
| 135 self._device.old_interface.EnableAdbRoot() | 136 try: |
| 137 self._device.EnableRoot() | |
| 138 except device_errors.CommandFailedError: | |
| 139 # Try to set the timeout scale anyway. | |
| 140 pass | |
|
craigdh
2014/05/14 20:33:08
I really dislike this. Why are exceptions so often
jbudorick
2014/05/14 21:02:01
My default stance for this series of interface swi
craigdh
2014/05/14 21:21:11
At the very very very least log the exception so i
| |
| 136 SetChromeTimeoutScale(self._device, self.GetTimeoutScale()) | 141 SetChromeTimeoutScale(self._device, self.GetTimeoutScale()) |
| 137 | 142 |
| 138 def CleanUpEnvironment(self): | 143 def CleanUpEnvironment(self): |
| 139 SetChromeTimeoutScale(self._device, None) | 144 SetChromeTimeoutScale(self._device, None) |
| 140 | 145 |
| 141 def GetTimeoutScale(self): | 146 def GetTimeoutScale(self): |
| 142 # Very slow startup. | 147 # Very slow startup. |
| 143 return 20.0 | 148 return 20.0 |
| 144 | 149 |
| 145 | 150 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 if not tool_name: | 266 if not tool_name: |
| 262 return BaseTool() | 267 return BaseTool() |
| 263 | 268 |
| 264 ctor = TOOL_REGISTRY.get(tool_name) | 269 ctor = TOOL_REGISTRY.get(tool_name) |
| 265 if ctor: | 270 if ctor: |
| 266 return ctor(device) | 271 return ctor(device) |
| 267 else: | 272 else: |
| 268 print 'Unknown tool %s, available tools: %s' % ( | 273 print 'Unknown tool %s, available tools: %s' % ( |
| 269 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) | 274 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) |
| 270 sys.exit(1) | 275 sys.exit(1) |
| OLD | NEW |