Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: build/android/pylib/valgrind_tools.py

Issue 132463007: Enable presubmit pylint in build/android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 1. For tests that simply run a native process (i.e. no activity is spawned): 11 1. For tests that simply run a native process (i.e. no activity is spawned):
12 12
13 Call tool.CopyFiles(). 13 Call tool.CopyFiles().
14 Prepend test command line with tool.GetTestWrapper(). 14 Prepend test command line with tool.GetTestWrapper().
15 15
16 2. For tests that spawn an activity: 16 2. For tests that spawn an activity:
17 17
18 Call tool.CopyFiles(). 18 Call tool.CopyFiles().
19 Call tool.SetupEnvironment(). 19 Call tool.SetupEnvironment().
20 Run the test as usual. 20 Run the test as usual.
21 Call tool.CleanUpEnvironment(). 21 Call tool.CleanUpEnvironment().
22 """ 22 """
23 23
24 import os.path 24 import os.path
25 import sys 25 import sys
26 from glob import glob 26 from glob import glob
27 27
28 from constants import DIR_SOURCE_ROOT 28 from .constants import DIR_SOURCE_ROOT
29 29
30 30
31 def SetChromeTimeoutScale(adb, scale): 31 def SetChromeTimeoutScale(adb, scale):
32 """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale.""" 32 """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale."""
33 path = '/data/local/tmp/chrome_timeout_scale' 33 path = '/data/local/tmp/chrome_timeout_scale'
34 if not scale or scale == 1.0: 34 if not scale or scale == 1.0:
35 # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0 35 # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0
36 adb.RunShellCommand('rm %s' % path) 36 adb.RunShellCommand('rm %s' % path)
37 else: 37 else:
38 adb.SetProtectedFileContents(path, '%f' % scale) 38 adb.SetProtectedFileContents(path, '%f' % scale)
39 39
40 40
41 class BaseTool(object): 41 class BaseTool(object):
42 """A tool that does nothing.""" 42 """A tool that does nothing."""
43 43
44 def __init__(self):
frankf 2014/02/03 18:58:51 why do we need this?
jbudorick 2014/02/03 19:33:57 W0231: 91,2:AddressSanitizerTool.__init__: __init_
45 """Does nothing."""
46 pass
47
44 def GetTestWrapper(self): 48 def GetTestWrapper(self):
45 """Returns a string that is to be prepended to the test command line.""" 49 """Returns a string that is to be prepended to the test command line."""
46 return '' 50 return ''
47 51
48 def GetUtilWrapper(self): 52 def GetUtilWrapper(self):
49 """Returns the wrapper name for the utilities. 53 """Returns the wrapper name for the utilities.
50 54
51 Returns: 55 Returns:
52 A string that is to be prepended to the command line of utility 56 A string that is to be prepended to the command line of utility
53 processes (forwarder, etc.). 57 processes (forwarder, etc.).
(...skipping 28 matching lines...) Expand all
82 return False 86 return False
83 87
84 88
85 class AddressSanitizerTool(BaseTool): 89 class AddressSanitizerTool(BaseTool):
86 """AddressSanitizer tool.""" 90 """AddressSanitizer tool."""
87 91
88 TMP_DIR = '/data/local/tmp/asan' 92 TMP_DIR = '/data/local/tmp/asan'
89 WRAPPER_NAME = 'asanwrapper.sh' 93 WRAPPER_NAME = 'asanwrapper.sh'
90 94
91 def __init__(self, adb): 95 def __init__(self, adb):
96 super(AddressSanitizerTool, self).__init__()
92 self._adb = adb 97 self._adb = adb
93 self._wrap_properties = ['wrap.com.google.android.apps.ch', 98 self._wrap_properties = ['wrap.com.google.android.apps.ch',
94 'wrap.org.chromium.native_test', 99 'wrap.org.chromium.native_test',
95 'wrap.org.chromium.content_shell', 100 'wrap.org.chromium.content_shell',
96 'wrap.org.chromium.chrome.testsh', 101 'wrap.org.chromium.chrome.testsh',
97 'wrap.org.chromium.android_webvi'] 102 'wrap.org.chromium.android_webvi']
98 # Configure AndroidCommands to run utils (such as md5sum_bin) under ASan. 103 # Configure AndroidCommands to run utils (such as md5sum_bin) under ASan.
99 # This is required because ASan is a compiler-based tool, and md5sum 104 # This is required because ASan is a compiler-based tool, and md5sum
100 # includes instrumented code from base. 105 # includes instrumented code from base.
101 adb.SetUtilWrapper(self.GetUtilWrapper()) 106 adb.SetUtilWrapper(self.GetUtilWrapper())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return 20.0 145 return 20.0
141 146
142 147
143 class ValgrindTool(BaseTool): 148 class ValgrindTool(BaseTool):
144 """Base abstract class for Valgrind tools.""" 149 """Base abstract class for Valgrind tools."""
145 150
146 VG_DIR = '/data/local/tmp/valgrind' 151 VG_DIR = '/data/local/tmp/valgrind'
147 VGLOGS_DIR = '/data/local/tmp/vglogs' 152 VGLOGS_DIR = '/data/local/tmp/vglogs'
148 153
149 def __init__(self, adb): 154 def __init__(self, adb):
155 super(ValgrindTool, self).__init__()
150 self._adb = adb 156 self._adb = adb
151 # exactly 31 chars, SystemProperties::PROP_NAME_MAX 157 # exactly 31 chars, SystemProperties::PROP_NAME_MAX
152 self._wrap_properties = ['wrap.com.google.android.apps.ch', 158 self._wrap_properties = ['wrap.com.google.android.apps.ch',
153 'wrap.org.chromium.native_test'] 159 'wrap.org.chromium.native_test']
154 160
155 def CopyFiles(self): 161 def CopyFiles(self):
156 """Copies Valgrind tools to the device.""" 162 """Copies Valgrind tools to the device."""
157 self._adb.RunShellCommand('rm -r %s; mkdir %s' % 163 self._adb.RunShellCommand('rm -r %s; mkdir %s' %
158 (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR)) 164 (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR))
159 self._adb.RunShellCommand('rm -r %s; mkdir %s' % 165 self._adb.RunShellCommand('rm -r %s; mkdir %s' %
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 def GetTestWrapper(self): 236 def GetTestWrapper(self):
231 """Returns a string that is to be prepended to the test command line.""" 237 """Returns a string that is to be prepended to the test command line."""
232 return ValgrindTool.VG_DIR + '/' + 'vg-chrome-wrapper-tsan.sh' 238 return ValgrindTool.VG_DIR + '/' + 'vg-chrome-wrapper-tsan.sh'
233 239
234 def GetTimeoutScale(self): 240 def GetTimeoutScale(self):
235 """Returns a multiplier that should be applied to timeout values.""" 241 """Returns a multiplier that should be applied to timeout values."""
236 return 30.0 242 return 30.0
237 243
238 244
239 TOOL_REGISTRY = { 245 TOOL_REGISTRY = {
240 'memcheck': lambda x: MemcheckTool(x), 246 'memcheck': MemcheckTool,
241 'memcheck-renderer': lambda x: MemcheckTool(x), 247 'memcheck-renderer': MemcheckTool,
242 'tsan': lambda x: TSanTool(x), 248 'tsan': TSanTool,
243 'tsan-renderer': lambda x: TSanTool(x), 249 'tsan-renderer': TSanTool,
244 'asan': lambda x: AddressSanitizerTool(x), 250 'asan': AddressSanitizerTool,
245 } 251 }
246 252
247 253
248 def CreateTool(tool_name, adb): 254 def CreateTool(tool_name, adb):
249 """Creates a tool with the specified tool name. 255 """Creates a tool with the specified tool name.
250 256
251 Args: 257 Args:
252 tool_name: Name of the tool to create. 258 tool_name: Name of the tool to create.
253 adb: ADB interface the tool will use. 259 adb: ADB interface the tool will use.
254 Returns: 260 Returns:
255 A tool for the specified tool_name. 261 A tool for the specified tool_name.
256 """ 262 """
257 if not tool_name: 263 if not tool_name:
258 return BaseTool() 264 return BaseTool()
259 265
260 ctor = TOOL_REGISTRY.get(tool_name) 266 ctor = TOOL_REGISTRY.get(tool_name)
261 if ctor: 267 if ctor:
262 return ctor(adb) 268 return ctor(adb)
263 else: 269 else:
264 print 'Unknown tool %s, available tools: %s' % ( 270 print 'Unknown tool %s, available tools: %s' % (
265 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) 271 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
266 sys.exit(1) 272 sys.exit(1)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698