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

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: rebase vs tot and only disabling F0401 in specific spots 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
« no previous file with comments | « build/android/pylib/utils/xvfb.py ('k') | build/android/surface_stats.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # pylint: disable=R0201
23 24
24 import os.path 25 import os.path
25 import subprocess 26 import subprocess
26 import sys 27 import sys
27 from glob import glob
28 28
29 from constants import DIR_SOURCE_ROOT 29 from pylib.constants import DIR_SOURCE_ROOT
30 30
31 31
32 def SetChromeTimeoutScale(adb, scale): 32 def SetChromeTimeoutScale(adb, scale):
33 """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale.""" 33 """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale."""
34 path = '/data/local/tmp/chrome_timeout_scale' 34 path = '/data/local/tmp/chrome_timeout_scale'
35 if not scale or scale == 1.0: 35 if not scale or scale == 1.0:
36 # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0 36 # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0
37 adb.RunShellCommand('rm %s' % path) 37 adb.RunShellCommand('rm %s' % path)
38 else: 38 else:
39 adb.SetProtectedFileContents(path, '%f' % scale) 39 adb.SetProtectedFileContents(path, '%f' % scale)
40 40
41 41
42 class BaseTool(object): 42 class BaseTool(object):
43 """A tool that does nothing.""" 43 """A tool that does nothing."""
44 44
45 def __init__(self):
46 """Does nothing."""
47 pass
48
45 def GetTestWrapper(self): 49 def GetTestWrapper(self):
46 """Returns a string that is to be prepended to the test command line.""" 50 """Returns a string that is to be prepended to the test command line."""
47 return '' 51 return ''
48 52
49 def GetUtilWrapper(self): 53 def GetUtilWrapper(self):
50 """Returns the wrapper name for the utilities. 54 """Returns the wrapper name for the utilities.
51 55
52 Returns: 56 Returns:
53 A string that is to be prepended to the command line of utility 57 A string that is to be prepended to the command line of utility
54 processes (forwarder, etc.). 58 processes (forwarder, etc.).
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 class AddressSanitizerTool(BaseTool): 90 class AddressSanitizerTool(BaseTool):
87 """AddressSanitizer tool.""" 91 """AddressSanitizer tool."""
88 92
89 WRAPPER_NAME = '/system/bin/asanwrapper' 93 WRAPPER_NAME = '/system/bin/asanwrapper'
90 # Disable memcmp overlap check.There are blobs (gl drivers) 94 # Disable memcmp overlap check.There are blobs (gl drivers)
91 # on some android devices that use memcmp on overlapping regions, 95 # on some android devices that use memcmp on overlapping regions,
92 # nothing we can do about that. 96 # nothing we can do about that.
93 EXTRA_OPTIONS = 'strict_memcmp=0' 97 EXTRA_OPTIONS = 'strict_memcmp=0'
94 98
95 def __init__(self, adb): 99 def __init__(self, adb):
100 super(AddressSanitizerTool, self).__init__()
96 self._adb = adb 101 self._adb = adb
97 # Configure AndroidCommands to run utils (such as md5sum_bin) under ASan. 102 # Configure AndroidCommands to run utils (such as md5sum_bin) under ASan.
98 # This is required because ASan is a compiler-based tool, and md5sum 103 # This is required because ASan is a compiler-based tool, and md5sum
99 # includes instrumented code from base. 104 # includes instrumented code from base.
100 adb.SetUtilWrapper(self.GetUtilWrapper()) 105 adb.SetUtilWrapper(self.GetUtilWrapper())
101 106
102 def CopyFiles(self): 107 def CopyFiles(self):
103 """Copies ASan tools to the device.""" 108 """Copies ASan tools to the device."""
104 subprocess.call([os.path.join(DIR_SOURCE_ROOT, 109 subprocess.call([os.path.join(DIR_SOURCE_ROOT,
105 'tools/android/asan/asan_device_setup.sh'), 110 'tools/android/asan/asan_device_setup.sh'),
(...skipping 24 matching lines...) Expand all
130 return 20.0 135 return 20.0
131 136
132 137
133 class ValgrindTool(BaseTool): 138 class ValgrindTool(BaseTool):
134 """Base abstract class for Valgrind tools.""" 139 """Base abstract class for Valgrind tools."""
135 140
136 VG_DIR = '/data/local/tmp/valgrind' 141 VG_DIR = '/data/local/tmp/valgrind'
137 VGLOGS_DIR = '/data/local/tmp/vglogs' 142 VGLOGS_DIR = '/data/local/tmp/vglogs'
138 143
139 def __init__(self, adb): 144 def __init__(self, adb):
145 super(ValgrindTool, self).__init__()
140 self._adb = adb 146 self._adb = adb
141 # exactly 31 chars, SystemProperties::PROP_NAME_MAX 147 # exactly 31 chars, SystemProperties::PROP_NAME_MAX
142 self._wrap_properties = ['wrap.com.google.android.apps.ch', 148 self._wrap_properties = ['wrap.com.google.android.apps.ch',
143 'wrap.org.chromium.native_test'] 149 'wrap.org.chromium.native_test']
144 150
145 def CopyFiles(self): 151 def CopyFiles(self):
146 """Copies Valgrind tools to the device.""" 152 """Copies Valgrind tools to the device."""
147 self._adb.RunShellCommand('rm -r %s; mkdir %s' % 153 self._adb.RunShellCommand('rm -r %s; mkdir %s' %
148 (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR)) 154 (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR))
149 self._adb.RunShellCommand('rm -r %s; mkdir %s' % 155 self._adb.RunShellCommand('rm -r %s; mkdir %s' %
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 def GetTestWrapper(self): 226 def GetTestWrapper(self):
221 """Returns a string that is to be prepended to the test command line.""" 227 """Returns a string that is to be prepended to the test command line."""
222 return ValgrindTool.VG_DIR + '/' + 'vg-chrome-wrapper-tsan.sh' 228 return ValgrindTool.VG_DIR + '/' + 'vg-chrome-wrapper-tsan.sh'
223 229
224 def GetTimeoutScale(self): 230 def GetTimeoutScale(self):
225 """Returns a multiplier that should be applied to timeout values.""" 231 """Returns a multiplier that should be applied to timeout values."""
226 return 30.0 232 return 30.0
227 233
228 234
229 TOOL_REGISTRY = { 235 TOOL_REGISTRY = {
230 'memcheck': lambda x: MemcheckTool(x), 236 'memcheck': MemcheckTool,
231 'memcheck-renderer': lambda x: MemcheckTool(x), 237 'memcheck-renderer': MemcheckTool,
232 'tsan': lambda x: TSanTool(x), 238 'tsan': TSanTool,
233 'tsan-renderer': lambda x: TSanTool(x), 239 'tsan-renderer': TSanTool,
234 'asan': lambda x: AddressSanitizerTool(x), 240 'asan': AddressSanitizerTool,
235 } 241 }
236 242
237 243
238 def CreateTool(tool_name, adb): 244 def CreateTool(tool_name, adb):
239 """Creates a tool with the specified tool name. 245 """Creates a tool with the specified tool name.
240 246
241 Args: 247 Args:
242 tool_name: Name of the tool to create. 248 tool_name: Name of the tool to create.
243 adb: ADB interface the tool will use. 249 adb: ADB interface the tool will use.
244 Returns: 250 Returns:
245 A tool for the specified tool_name. 251 A tool for the specified tool_name.
246 """ 252 """
247 if not tool_name: 253 if not tool_name:
248 return BaseTool() 254 return BaseTool()
249 255
250 ctor = TOOL_REGISTRY.get(tool_name) 256 ctor = TOOL_REGISTRY.get(tool_name)
251 if ctor: 257 if ctor:
252 return ctor(adb) 258 return ctor(adb)
253 else: 259 else:
254 print 'Unknown tool %s, available tools: %s' % ( 260 print 'Unknown tool %s, available tools: %s' % (
255 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) 261 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
256 sys.exit(1) 262 sys.exit(1)
OLDNEW
« no previous file with comments | « build/android/pylib/utils/xvfb.py ('k') | build/android/surface_stats.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698