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

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

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