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

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

Issue 138153003: Switch to the "new" way of ASan deployment on Android devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 subprocess
25 import sys 26 import sys
26 from glob import glob 27 from glob import glob
27 28
28 from constants import DIR_SOURCE_ROOT 29 from constants import DIR_SOURCE_ROOT
29 30
30 31
31 def SetChromeTimeoutScale(adb, scale): 32 def SetChromeTimeoutScale(adb, scale):
32 """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."""
33 path = '/data/local/tmp/chrome_timeout_scale' 34 path = '/data/local/tmp/chrome_timeout_scale'
34 if not scale or scale == 1.0: 35 if not scale or scale == 1.0:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 79
79 Returns: 80 Returns:
80 True if this tool can not work with stripped binaries. 81 True if this tool can not work with stripped binaries.
81 """ 82 """
82 return False 83 return False
83 84
84 85
85 class AddressSanitizerTool(BaseTool): 86 class AddressSanitizerTool(BaseTool):
86 """AddressSanitizer tool.""" 87 """AddressSanitizer tool."""
87 88
88 TMP_DIR = '/data/local/tmp/asan' 89 WRAPPER_NAME = '/system/bin/asanwrapper'
89 WRAPPER_NAME = 'asanwrapper.sh'
90 90
91 def __init__(self, adb): 91 def __init__(self, adb):
92 self._adb = adb 92 self._adb = adb
93 self._wrap_properties = ['wrap.com.google.android.apps.ch',
94 'wrap.org.chromium.native_test',
95 'wrap.org.chromium.content_shell',
96 'wrap.org.chromium.chrome.testsh',
97 'wrap.org.chromium.android_webvi']
98 # Configure AndroidCommands to run utils (such as md5sum_bin) under ASan. 93 # Configure AndroidCommands to run utils (such as md5sum_bin) under ASan.
99 # This is required because ASan is a compiler-based tool, and md5sum 94 # This is required because ASan is a compiler-based tool, and md5sum
100 # includes instrumented code from base. 95 # includes instrumented code from base.
101 adb.SetUtilWrapper(self.GetUtilWrapper()) 96 adb.SetUtilWrapper(self.GetUtilWrapper())
102 97
103 def CopyFiles(self): 98 def CopyFiles(self):
104 """Copies ASan tools to the device.""" 99 """Copies ASan tools to the device."""
105 files = (['tools/android/asan/asanwrapper.sh'] + 100 subprocess.call(os.path.join(DIR_SOURCE_ROOT,
106 glob('third_party/llvm-build/Release+Asserts/lib/clang/*/lib/' 101 "tools/android/asan/asan_device_setup.sh"))
Alexander Potapenko 2014/01/17 12:43:50 Looks like this script uses single quotes for stri
eugenis 2014/01/17 12:48:08 Done.
107 'linux/libclang_rt.asan-arm-android.so')) 102 self._adb.Reboot()
eugenis 2014/01/17 12:32:10 Reboot is required after asan_device_setup.sh. Unf
Alexander Potapenko 2014/01/17 12:43:50 Please put this into a comment.
eugenis 2014/01/17 12:48:08 Done.
108 for f in files:
109 self._adb.PushIfNeeded(os.path.join(DIR_SOURCE_ROOT, f),
110 os.path.join(AddressSanitizerTool.TMP_DIR,
111 os.path.basename(f)))
112 103
113 def GetTestWrapper(self): 104 def GetTestWrapper(self):
114 return os.path.join(AddressSanitizerTool.TMP_DIR, 105 return AddressSanitizerTool.WRAPPER_NAME
115 AddressSanitizerTool.WRAPPER_NAME)
116 106
117 def GetUtilWrapper(self): 107 def GetUtilWrapper(self):
118 """Returns the wrapper for utilities, such as forwarder. 108 """Returns the wrapper for utilities, such as forwarder.
119 109
120 AddressSanitizer wrapper must be added to all instrumented binaries, 110 AddressSanitizer wrapper must be added to all instrumented binaries,
121 including forwarder and the like. This can be removed if such binaries 111 including forwarder and the like. This can be removed if such binaries
122 were built without instrumentation. """ 112 were built without instrumentation. """
123 return self.GetTestWrapper() 113 return self.GetTestWrapper()
124 114
125 def SetupEnvironment(self): 115 def SetupEnvironment(self):
126 self._adb.EnableAdbRoot() 116 self._adb.EnableAdbRoot()
127 self._adb.RunShellCommand('setenforce 0')
128 for prop in self._wrap_properties:
129 self._adb.RunShellCommand('setprop %s "logwrapper %s"' % (
130 prop, self.GetTestWrapper()))
131 SetChromeTimeoutScale(self._adb, self.GetTimeoutScale()) 117 SetChromeTimeoutScale(self._adb, self.GetTimeoutScale())
132 118
133 def CleanUpEnvironment(self): 119 def CleanUpEnvironment(self):
134 for prop in self._wrap_properties:
135 self._adb.RunShellCommand('setprop %s ""' % (prop,))
136 SetChromeTimeoutScale(self._adb, None) 120 SetChromeTimeoutScale(self._adb, None)
137 121
138 def GetTimeoutScale(self): 122 def GetTimeoutScale(self):
139 # Very slow startup. 123 # Very slow startup.
140 return 20.0 124 return 20.0
141 125
142 126
143 class ValgrindTool(BaseTool): 127 class ValgrindTool(BaseTool):
144 """Base abstract class for Valgrind tools.""" 128 """Base abstract class for Valgrind tools."""
145 129
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 if not tool_name: 241 if not tool_name:
258 return BaseTool() 242 return BaseTool()
259 243
260 ctor = TOOL_REGISTRY.get(tool_name) 244 ctor = TOOL_REGISTRY.get(tool_name)
261 if ctor: 245 if ctor:
262 return ctor(adb) 246 return ctor(adb)
263 else: 247 else:
264 print 'Unknown tool %s, available tools: %s' % ( 248 print 'Unknown tool %s, available tools: %s' % (
265 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) 249 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
266 sys.exit(1) 250 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | tools/android/asan/asan_device_setup.sh » ('j') | tools/android/asan/asan_device_setup.sh » ('J')

Powered by Google App Engine
This is Rietveld 408576698