OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Script for a testing an existing SDK. | 6 """Script for a testing an existing SDK. |
7 | 7 |
8 This script is normally run immediately after build_sdk.py. | 8 This script is normally run immediately after build_sdk.py. |
9 """ | 9 """ |
10 | 10 |
11 import optparse | 11 import argparse |
12 import os | 12 import os |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 | 15 |
16 import buildbot_common | 16 import buildbot_common |
17 import build_projects | 17 import build_projects |
18 import build_sdk | 18 import build_sdk |
19 import build_version | 19 import build_version |
20 import parse_dsc | 20 import parse_dsc |
21 | 21 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 for toolchain in toolchains: | 152 for toolchain in toolchains: |
153 args.extend(['-t', toolchain]) | 153 args.extend(['-t', toolchain]) |
154 | 154 |
155 try: | 155 try: |
156 subprocess.check_call(args) | 156 subprocess.check_call(args) |
157 except subprocess.CalledProcessError: | 157 except subprocess.CalledProcessError: |
158 buildbot_common.ErrorExit('Error running tests.') | 158 buildbot_common.ErrorExit('Error running tests.') |
159 | 159 |
160 | 160 |
161 def main(args): | 161 def main(args): |
162 usage = '%prog [<options>] [<phase...>]' | 162 parser = argparse.ArgumentParser(description=__doc__) |
163 parser = optparse.OptionParser(description=__doc__, usage=usage) | 163 parser.add_argument('--experimental', help='build experimental tests', |
164 parser.add_option('--experimental', help='build experimental tests', | 164 action='store_true') |
165 action='store_true') | 165 parser.add_argument('--sanitizer', |
166 parser.add_option('--sanitizer', | 166 help='Run sanitizer (asan/tsan/valgrind) tests', |
167 help='Run sanitizer (asan/tsan/valgrind) tests', | 167 action='store_true') |
168 action='store_true') | 168 parser.add_argument('--verbose', '-v', help='Verbose output', |
169 parser.add_option('--verbose', '-v', help='Verbose output', | 169 action='store_true') |
170 action='store_true') | 170 parser.add_argument('phases', nargs="*") |
171 | 171 |
172 if 'NACL_SDK_ROOT' in os.environ: | 172 if 'NACL_SDK_ROOT' in os.environ: |
173 # We don't want the currently configured NACL_SDK_ROOT to have any effect | 173 # We don't want the currently configured NACL_SDK_ROOT to have any effect |
174 # of the build. | 174 # of the build. |
175 del os.environ['NACL_SDK_ROOT'] | 175 del os.environ['NACL_SDK_ROOT'] |
176 | 176 |
177 # To setup bash completion for this command first install optcomplete | 177 # To setup bash completion for this command first install optcomplete |
178 # and then add this line to your .bashrc: | 178 # and then add this line to your .bashrc: |
179 # complete -F _optcomplete test_sdk.py | 179 # complete -F _optcomplete test_sdk.py |
180 try: | 180 try: |
181 import optcomplete | 181 import optcomplete |
182 optcomplete.autocomplete(parser) | 182 optcomplete.autocomplete(parser) |
183 except ImportError: | 183 except ImportError: |
184 pass | 184 pass |
185 | 185 |
186 options, args = parser.parse_args(args) | 186 options = parser.parse_args(args) |
187 | 187 |
188 pepper_ver = str(int(build_version.ChromeMajorVersion())) | 188 pepper_ver = str(int(build_version.ChromeMajorVersion())) |
189 pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) | 189 pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) |
190 toolchains = ['newlib', 'glibc', 'pnacl'] | 190 toolchains = ['newlib', 'glibc', 'pnacl'] |
191 toolchains.append(getos.GetPlatform()) | 191 toolchains.append(getos.GetPlatform()) |
192 | 192 |
193 if options.verbose: | 193 if options.verbose: |
194 build_projects.verbose = True | 194 build_projects.verbose = True |
195 | 195 |
196 phases = [ | 196 phases = [ |
197 ('build_examples', StepBuildExamples, pepperdir), | 197 ('build_examples', StepBuildExamples, pepperdir), |
198 ('copy_tests', StepCopyTests, pepperdir, toolchains, options.experimental), | 198 ('copy_tests', StepCopyTests, pepperdir, toolchains, options.experimental), |
199 ('build_tests', StepBuildTests, pepperdir), | 199 ('build_tests', StepBuildTests, pepperdir), |
200 ('sel_ldr_tests', StepRunSelLdrTests, pepperdir, None), | 200 ('sel_ldr_tests', StepRunSelLdrTests, pepperdir, None), |
201 ('browser_tests', StepRunBrowserTests, toolchains, options.experimental), | 201 ('browser_tests', StepRunBrowserTests, toolchains, options.experimental), |
202 ] | 202 ] |
203 | 203 |
204 if options.sanitizer: | 204 if options.sanitizer: |
205 if getos.GetPlatform() != 'linux': | 205 if getos.GetPlatform() != 'linux': |
206 buildbot_common.ErrorExit('sanitizer tests only run on linux.') | 206 buildbot_common.ErrorExit('sanitizer tests only run on linux.') |
207 phases += [ | 207 phases += [ |
208 ('sel_ldr_tests_asan', StepRunSelLdrTests, pepperdir, 'address'), | 208 ('sel_ldr_tests_asan', StepRunSelLdrTests, pepperdir, 'address'), |
209 ('sel_ldr_tests_tsan', StepRunSelLdrTests, pepperdir, 'thread'), | 209 ('sel_ldr_tests_tsan', StepRunSelLdrTests, pepperdir, 'thread'), |
210 ('sel_ldr_tests_valgrind', StepRunSelLdrTests, pepperdir, 'valgrind') | 210 ('sel_ldr_tests_valgrind', StepRunSelLdrTests, pepperdir, 'valgrind') |
211 ] | 211 ] |
212 | 212 |
213 if args: | 213 if options.phases: |
214 phase_names = [p[0] for p in phases] | 214 phase_names = [p[0] for p in phases] |
215 for arg in args: | 215 for arg in options.phases: |
216 if arg not in phase_names: | 216 if arg not in phase_names: |
217 msg = 'Invalid argument: %s\n' % arg | 217 msg = 'Invalid argument: %s\n' % arg |
218 msg += 'Possible arguments:\n' | 218 msg += 'Possible arguments:\n' |
219 for name in phase_names: | 219 for name in phase_names: |
220 msg += ' %s\n' % name | 220 msg += ' %s\n' % name |
221 parser.error(msg.strip()) | 221 parser.error(msg.strip()) |
222 | 222 |
223 for phase in phases: | 223 for phase in phases: |
224 phase_name = phase[0] | 224 phase_name = phase[0] |
225 if args and phase_name not in args: | 225 if options.phases and phase_name not in options.phases: |
226 continue | 226 continue |
227 phase_func = phase[1] | 227 phase_func = phase[1] |
228 phase_args = phase[2:] | 228 phase_args = phase[2:] |
229 phase_func(*phase_args) | 229 phase_func(*phase_args) |
230 | 230 |
231 return 0 | 231 return 0 |
232 | 232 |
233 | 233 |
234 if __name__ == '__main__': | 234 if __name__ == '__main__': |
235 try: | 235 try: |
236 sys.exit(main(sys.argv[1:])) | 236 sys.exit(main(sys.argv[1:])) |
237 except KeyboardInterrupt: | 237 except KeyboardInterrupt: |
238 buildbot_common.ErrorExit('test_sdk: interrupted') | 238 buildbot_common.ErrorExit('test_sdk: interrupted') |
OLD | NEW |