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

Side by Side Diff: testing/android/generate_native_test.py

Issue 11066094: Nuke unused test code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nuke more test code. Created 8 years, 2 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
« no previous file with comments | « build/apk_test.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # On Android we build unit test bundles as shared libraries. To run 7 # On Android we build unit test bundles as shared libraries. To run
8 # tests, we launch a special "test runner" apk which loads the library 8 # tests, we launch a special "test runner" apk which loads the library
9 # then jumps into it. Since java is required for many tests 9 # then jumps into it. Since java is required for many tests
10 # (e.g. PathUtils.java), a "pure native" test bundle is inadequate. 10 # (e.g. PathUtils.java), a "pure native" test bundle is inadequate.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 dest]) 123 dest])
124 if self._jars: 124 if self._jars:
125 destdir = os.path.join(self._output_directory, 'java/libs') 125 destdir = os.path.join(self._output_directory, 'java/libs')
126 if not os.path.exists(destdir): 126 if not os.path.exists(destdir):
127 os.makedirs(destdir) 127 os.makedirs(destdir)
128 for jar in self._jars: 128 for jar in self._jars:
129 dest = os.path.join(destdir, os.path.basename(jar)) 129 dest = os.path.join(destdir, os.path.basename(jar))
130 logging.warn('%s --> %s', jar, dest) 130 logging.warn('%s --> %s', jar, dest)
131 shutil.copyfile(jar, dest) 131 shutil.copyfile(jar, dest)
132 132
133 def CreateBundle(self, sdk_build): 133 def CreateBundle(self):
134 """Create the apk bundle source and assemble components.""" 134 """Create the apk bundle source and assemble components."""
135 if not sdk_build:
136 self._SOURCE_FILES.append('Android.mk')
137 self._REPLACEME_FILES.append('Android.mk')
138 self._CopyTemplateFilesAndClearDir() 135 self._CopyTemplateFilesAndClearDir()
139 self._ReplaceStrings() 136 self._ReplaceStrings()
140 self._CopyLibraryAndJars() 137 self._CopyLibraryAndJars()
141 138
142 def Compile(self, ant_args): 139 def Compile(self, ant_args):
143 """Build the generated apk with ant. 140 """Build the generated apk with ant.
144 141
145 Args: 142 Args:
146 ant_args: extra args to pass to ant 143 ant_args: extra args to pass to ant
147 """ 144 """
148 cmd = ['ant'] 145 cmd = ['ant']
149 if ant_args: 146 if ant_args:
150 cmd.extend(ant_args) 147 cmd.extend(ant_args)
151 cmd.append("-DAPP_ABI=" + self._target_abi) 148 cmd.append("-DAPP_ABI=" + self._target_abi)
152 cmd.extend(['-buildfile', 149 cmd.extend(['-buildfile',
153 os.path.join(self._output_directory, 'native_test_apk.xml')]) 150 os.path.join(self._output_directory, 'native_test_apk.xml')])
154 logging.warn(cmd) 151 logging.warn(cmd)
155 p = subprocess.Popen(cmd, stderr=subprocess.STDOUT) 152 p = subprocess.Popen(cmd, stderr=subprocess.STDOUT)
156 (stdout, _) = p.communicate() 153 (stdout, _) = p.communicate()
157 logging.warn(stdout) 154 logging.warn(stdout)
158 if p.returncode != 0: 155 if p.returncode != 0:
159 logging.error('Ant return code %d', p.returncode) 156 logging.error('Ant return code %d', p.returncode)
160 sys.exit(p.returncode) 157 sys.exit(p.returncode)
161 158
162 def CompileAndroidMk(self):
163 """Build the generated apk within Android source tree using Android.mk."""
164 try:
165 import compile_android_mk # pylint: disable=F0401
166 except:
167 raise AssertionError('Not in Android source tree. '
168 'Please use --sdk-build.')
169 compile_android_mk.CompileAndroidMk(self._native_library,
170 self._output_directory)
171
172
173 def main(argv): 159 def main(argv):
174 parser = optparse.OptionParser() 160 parser = optparse.OptionParser()
175 parser.add_option('--verbose', 161 parser.add_option('--verbose',
176 help='Be verbose') 162 help='Be verbose')
177 parser.add_option('--native_library', 163 parser.add_option('--native_library',
178 help='Full name of native shared library test bundle') 164 help='Full name of native shared library test bundle')
179 parser.add_option('--jars', 165 parser.add_option('--jars',
180 help='Space separated list of jars to be included') 166 help='Space separated list of jars to be included')
181 parser.add_option('--output', 167 parser.add_option('--output',
182 help='Output directory for generated files.') 168 help='Output directory for generated files.')
(...skipping 27 matching lines...) Expand all
210 # Remove all quotes from the jars string 196 # Remove all quotes from the jars string
211 jar_list = [] 197 jar_list = []
212 if options.jars: 198 if options.jars:
213 jar_list = options.jars.replace('"', '').split() 199 jar_list = options.jars.replace('"', '').split()
214 200
215 ntag = NativeTestApkGenerator(native_library=options.native_library, 201 ntag = NativeTestApkGenerator(native_library=options.native_library,
216 jars=jar_list, 202 jars=jar_list,
217 strip_binary=options.strip_binary, 203 strip_binary=options.strip_binary,
218 output_directory=options.output, 204 output_directory=options.output,
219 target_abi=options.app_abi) 205 target_abi=options.app_abi)
220 ntag.CreateBundle(options.sdk_build) 206 ntag.CreateBundle()
221 207 ntag.Compile(options.ant_args)
222 if options.sdk_build:
223 ntag.Compile(options.ant_args)
224 else:
225 ntag.CompileAndroidMk()
226
227 logging.warn('COMPLETE.') 208 logging.warn('COMPLETE.')
228 209
229 if __name__ == '__main__': 210 if __name__ == '__main__':
230 sys.exit(main(sys.argv)) 211 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/apk_test.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698