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

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

Issue 11361125: Support running Android apk-based tests under ASan. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « build/android/pylib/test_package_apk.py ('k') | tools/android/asan/asanwrapper.sh » ('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
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 Returns: 78 Returns:
79 True if this tool can not work with stripped binaries. 79 True if this tool can not work with stripped binaries.
80 """ 80 """
81 return False 81 return False
82 82
83 83
84 class AddressSanitizerTool(BaseTool): 84 class AddressSanitizerTool(BaseTool):
85 """AddressSanitizer tool.""" 85 """AddressSanitizer tool."""
86 86
87 WRAPPER_PATH = '/system/bin/asanwrapper' 87 TMP_DIR = '/data/local/tmp/asan'
88 WRAPPER_NAME = 'asanwrapper.sh'
88 89
89 def __init__(self, adb): 90 def __init__(self, adb):
90 self._adb = adb 91 self._adb = adb
91 self._wrap_properties = ['wrap.com.google.android.apps.ch', 92 self._wrap_properties = ['wrap.com.google.android.apps.ch',
92 'wrap.org.chromium.native_test'] 93 'wrap.org.chromium.native_test']
93 94
94 def CopyFiles(self): 95 def CopyFiles(self):
95 """Copies ASan tools to the device.""" 96 """Copies ASan tools to the device."""
96 files = ['system/lib/libasan_preload.so', 97 files = ['tools/android/asan/asanwrapper.sh',
97 'system/bin/asanwrapper', 98 'third_party/llvm-build/Release+Asserts/lib/clang/3.2/lib/linux/' +
98 'system/bin/asan/app_process', 99 'libclang_rt.asan-arm-android.so']
99 'system/bin/linker']
100 android_product_out = os.environ['ANDROID_PRODUCT_OUT']
101 self._adb.MakeSystemFolderWritable()
102 for f in files: 100 for f in files:
103 self._adb.PushIfNeeded(os.path.join(android_product_out, f), 101 self._adb.PushIfNeeded(os.path.join(CHROME_DIR, f),
104 os.path.join('/', f)) 102 os.path.join(AddressSanitizerTool.TMP_DIR,
103 os.path.basename(f)))
105 104
106 def GetTestWrapper(self): 105 def GetTestWrapper(self):
107 return AddressSanitizerTool.WRAPPER_PATH 106 return os.path.join(AddressSanitizerTool.TMP_DIR,
107 AddressSanitizerTool.WRAPPER_NAME)
108 108
109 def GetUtilWrapper(self): 109 def GetUtilWrapper(self):
110 """Returns the wrapper for utilities, such as forwarder. 110 """Returns the wrapper for utilities, such as forwarder.
111 111
112 AddressSanitizer wrapper must be added to all instrumented binaries, 112 AddressSanitizer wrapper must be added to all instrumented binaries,
113 including forwarder and the like. This can be removed if such binaries 113 including forwarder and the like. This can be removed if such binaries
114 were built without instrumentation. """ 114 were built without instrumentation. """
115 return AddressSanitizerTool.WRAPPER_PATH 115 return self.GetTestWrapper()
116 116
117 def SetupEnvironment(self): 117 def SetupEnvironment(self):
118 self._adb.EnableAdbRoot()
118 for prop in self._wrap_properties: 119 for prop in self._wrap_properties:
119 self._adb.RunShellCommand('setprop %s "logwrapper %s"' % ( 120 self._adb.RunShellCommand('setprop %s "logwrapper %s"' % (
120 prop, self.GetTestWrapper())) 121 prop, self.GetTestWrapper()))
121 SetChromeTimeoutScale(self._adb, self.GetTimeoutScale()) 122 SetChromeTimeoutScale(self._adb, self.GetTimeoutScale())
122 123
123 def CleanUpEnvironment(self): 124 def CleanUpEnvironment(self):
124 for prop in self._wrap_properties: 125 for prop in self._wrap_properties:
125 self._adb.RunShellCommand('setprop %s ""' % (prop,)) 126 self._adb.RunShellCommand('setprop %s ""' % (prop,))
126 SetChromeTimeoutScale(self._adb, None) 127 SetChromeTimeoutScale(self._adb, None)
127 128
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if not tool_name: 247 if not tool_name:
247 return BaseTool() 248 return BaseTool()
248 249
249 ctor = TOOL_REGISTRY.get(tool_name) 250 ctor = TOOL_REGISTRY.get(tool_name)
250 if ctor: 251 if ctor:
251 return ctor(adb) 252 return ctor(adb)
252 else: 253 else:
253 print 'Unknown tool %s, available tools: %s' % ( 254 print 'Unknown tool %s, available tools: %s' % (
254 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) 255 tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
255 sys.exit(1) 256 sys.exit(1)
OLDNEW
« no previous file with comments | « build/android/pylib/test_package_apk.py ('k') | tools/android/asan/asanwrapper.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698