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

Side by Side Diff: build/android/run_tests.py

Issue 11817033: Move android buildbot steps into buildbot dir (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 #!/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 """Runs all the native unit tests. 7 """Runs all the native unit tests.
8 8
9 1. Copy over test binary to /data/local on device. 9 1. Copy over test binary to /data/local on device.
10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak) 10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 from pylib import ports 52 from pylib import ports
53 from pylib.base_test_sharder import BaseTestSharder 53 from pylib.base_test_sharder import BaseTestSharder
54 from pylib.gtest import debug_info 54 from pylib.gtest import debug_info
55 from pylib.gtest.single_test_runner import SingleTestRunner 55 from pylib.gtest.single_test_runner import SingleTestRunner
56 from pylib.utils import run_tests_helper 56 from pylib.utils import run_tests_helper
57 from pylib.utils import test_options_parser 57 from pylib.utils import test_options_parser
58 from pylib.utils import time_profile 58 from pylib.utils import time_profile
59 from pylib.utils import xvfb 59 from pylib.utils import xvfb
60 60
61 61
62 _TEST_SUITES = ['base_unittests',
63 'cc_unittests',
64 'content_unittests',
65 'gpu_unittests',
66 'ipc_tests',
67 'media_unittests',
68 'net_unittests',
69 'sql_unittests',
70 'sync_unit_tests',
71 'ui_unittests',
72 'unit_tests',
73 'webkit_compositor_bindings_unittests',
74 'android_webview_unittests',
75 ]
76
77
78 def FullyQualifiedTestSuites(exe, option_test_suite, build_type): 62 def FullyQualifiedTestSuites(exe, option_test_suite, build_type):
79 """Get a list of absolute paths to test suite targets. 63 """Get a list of absolute paths to test suite targets.
80 64
81 Args: 65 Args:
82 exe: if True, use the executable-based test runner. 66 exe: if True, use the executable-based test runner.
83 option_test_suite: the test_suite specified as an option. 67 option_test_suite: the test_suite specified as an option.
84 build_type: 'Release' or 'Debug'. 68 build_type: 'Release' or 'Debug'.
85 """ 69 """
86 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) 70 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type)
87 if option_test_suite: 71 if option_test_suite:
88 all_test_suites = [option_test_suite] 72 all_test_suites = [option_test_suite]
89 else: 73 else:
90 all_test_suites = _TEST_SUITES 74 all_test_suites = constants.DEFAULT_UNIT_TEST_SUITES
91 75
92 if exe: 76 if exe:
93 qualified_test_suites = [os.path.join(test_suite_dir, t) 77 qualified_test_suites = [os.path.join(test_suite_dir, t)
94 for t in all_test_suites] 78 for t in all_test_suites]
95 else: 79 else:
96 # out/(Debug|Release)/$SUITE_apk/$SUITE-debug.apk 80 # out/(Debug|Release)/$SUITE_apk/$SUITE-debug.apk
97 qualified_test_suites = [os.path.join(test_suite_dir, 81 qualified_test_suites = [os.path.join(test_suite_dir,
98 t + '_apk', 82 t + '_apk',
99 t + '-debug.apk') 83 t + '-debug.apk')
100 for t in all_test_suites] 84 for t in all_test_suites]
101 for t, q in zip(all_test_suites, qualified_test_suites): 85 for t, q in zip(all_test_suites, qualified_test_suites):
102 if not os.path.exists(q): 86 if not os.path.exists(q):
103 raise Exception('Test suite %s not found in %s.\n' 87 raise Exception('Test suite %s not found in %s.\n'
104 'Supported test suites:\n %s\n' 88 'Supported test suites:\n %s\n'
105 'Ensure it has been built.\n' % 89 'Ensure it has been built.\n' %
106 (t, q, _TEST_SUITES)) 90 (t, q, constants.DEFAULT_UNIT_TEST_SUITES))
107 return qualified_test_suites 91 return qualified_test_suites
108 92
109 93
110 class TestSharder(BaseTestSharder): 94 class TestSharder(BaseTestSharder):
111 """Responsible for sharding the tests on the connected devices.""" 95 """Responsible for sharding the tests on the connected devices."""
112 96
113 def __init__(self, attached_devices, test_suite, gtest_filter, 97 def __init__(self, attached_devices, test_suite, gtest_filter,
114 test_arguments, timeout, cleanup_test_files, tool, 98 test_arguments, timeout, cleanup_test_files, tool,
115 log_dump_name, build_type, in_webkit_checkout, 99 log_dump_name, build_type, in_webkit_checkout,
116 flakiness_server=None): 100 flakiness_server=None):
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 test bundles. If using the emulator, we start it on entry and stop 216 test bundles. If using the emulator, we start it on entry and stop
233 it on exit. 217 it on exit.
234 218
235 Args: 219 Args:
236 options: options for running the tests. 220 options: options for running the tests.
237 221
238 Returns: 222 Returns:
239 0 if successful, number of failing tests otherwise. 223 0 if successful, number of failing tests otherwise.
240 """ 224 """
241 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') 225 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '')
242 buildbot_report.PrintNamedStep(step_name)
243 attached_devices = [] 226 attached_devices = []
244 buildbot_emulators = [] 227 buildbot_emulators = []
245 228
246 if options.use_emulator: 229 if options.use_emulator:
247 for n in range(options.emulator_count): 230 for n in range(options.emulator_count):
248 t = time_profile.TimeProfile('Emulator launch %d' % n) 231 t = time_profile.TimeProfile('Emulator launch %d' % n)
249 avd_name = None 232 avd_name = None
250 if n > 0: 233 if n > 0:
251 # Creates a temporary AVD for the extra emulators. 234 # Creates a temporary AVD for the extra emulators.
252 avd_name = 'run_tests_avd_%d' % n 235 avd_name = 'run_tests_avd_%d' % n
253 buildbot_emulator = emulator.Emulator(avd_name) 236 buildbot_emulator = emulator.Emulator(avd_name)
254 buildbot_emulator.Launch(kill_all_emulators=n == 0) 237 buildbot_emulator.Launch(kill_all_emulators=n == 0)
255 t.Stop() 238 t.Stop()
256 buildbot_emulators.append(buildbot_emulator) 239 buildbot_emulators.append(buildbot_emulator)
257 attached_devices.append(buildbot_emulator.device) 240 attached_devices.append(buildbot_emulator.device)
258 # Wait for all emulators to boot completed. 241 # Wait for all emulators to boot completed.
259 map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True), 242 map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True),
260 buildbot_emulators) 243 buildbot_emulators)
261 elif options.test_device: 244 elif options.test_device:
262 attached_devices = [options.test_device] 245 attached_devices = [options.test_device]
263 else: 246 else:
264 attached_devices = android_commands.GetAttachedDevices() 247 attached_devices = android_commands.GetAttachedDevices()
265 248
266 if not attached_devices: 249 if not attached_devices:
267 logging.critical('A device must be attached and online.') 250 logging.critical('A device must be attached and online.')
268 buildbot_report.PrintError() 251 buildbot_report.PrintError()
frankf 2013/01/09 21:53:02 This can be removed.
Isaac (away) 2013/01/09 21:59:58 Will do.
269 return 1 252 return 1
270 253
271 # Reset the test port allocation. It's important to do it before starting 254 # Reset the test port allocation. It's important to do it before starting
272 # to dispatch any tests. 255 # to dispatch any tests.
273 if not ports.ResetTestServerPortAllocation(): 256 if not ports.ResetTestServerPortAllocation():
274 raise Exception('Failed to reset test server port.') 257 raise Exception('Failed to reset test server port.')
275 258
276 if options.gtest_filter: 259 if options.gtest_filter:
277 logging.warning('Sharding is not possible with these configurations.') 260 logging.warning('Sharding is not possible with these configurations.')
278 attached_devices = [attached_devices[0]] 261 attached_devices = [attached_devices[0]]
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 failures += _RunATestSuite(test_options) 310 failures += _RunATestSuite(test_options)
328 311
329 if options.use_xvfb: 312 if options.use_xvfb:
330 framebuffer.Stop() 313 framebuffer.Stop()
331 return failures 314 return failures
332 315
333 316
334 def ListTestSuites(): 317 def ListTestSuites():
335 """Display a list of available test suites.""" 318 """Display a list of available test suites."""
336 print 'Available test suites are:' 319 print 'Available test suites are:'
337 for test_suite in _TEST_SUITES: 320 for test_suite in constants.DEFAULT_UNIT_TEST_SUITES:
338 print test_suite 321 print test_suite
339 322
340 323
341 def main(argv): 324 def main(argv):
342 option_parser = optparse.OptionParser() 325 option_parser = optparse.OptionParser()
343 test_options_parser.AddGTestOptions(option_parser) 326 test_options_parser.AddGTestOptions(option_parser)
344 options, args = option_parser.parse_args(argv) 327 options, args = option_parser.parse_args(argv)
345 328
346 if len(args) > 1: 329 if len(args) > 1:
347 option_parser.error('Unknown argument: %s' % args[1:]) 330 option_parser.error('Unknown argument: %s' % args[1:])
348 331
349 run_tests_helper.SetLogLevel(options.verbose_count) 332 run_tests_helper.SetLogLevel(options.verbose_count)
350 333
351 if options.out_directory: 334 if options.out_directory:
352 cmd_helper.OutDirectory.set(options.out_directory) 335 cmd_helper.OutDirectory.set(options.out_directory)
353 336
354 if options.use_emulator: 337 if options.use_emulator:
355 emulator.DeleteAllTempAVDs() 338 emulator.DeleteAllTempAVDs()
356 339
357 failed_tests_count = Dispatch(options) 340 failed_tests_count = Dispatch(options)
358 341
359 # Failures of individual test suites are communicated by printing a 342 # Failures of individual test suites are communicated by printing a
360 # STEP_FAILURE message. 343 # STEP_FAILURE message.
361 # Returning a success exit status also prevents the buildbot from incorrectly 344 # Returning a success exit status also prevents the buildbot from incorrectly
362 # marking the last suite as failed if there were failures in other suites in 345 # marking the last suite as failed if there were failures in other suites in
363 # the batch (this happens because the exit status is a sum of all failures 346 # the batch (this happens because the exit status is a sum of all failures
364 # from all suites, but the buildbot associates the exit status only with the 347 # from all suites, but the buildbot associates the exit status only with the
365 # most recent step). 348 # most recent step).
366 if options.exit_code: 349 if options.exit_code:
367 return failed_tests_count 350 return failed_tests_count
frankf 2013/01/09 21:53:02 Why don't we always return failed_test_count? When
Isaac (away) 2013/01/09 21:59:58 I'm not sure, sorry. It wouldn't surprise me if t
368 return 0 351 return 0
369 352
370 353
371 if __name__ == '__main__': 354 if __name__ == '__main__':
372 sys.exit(main(sys.argv)) 355 sys.exit(main(sys.argv))
OLDNEW
« build/android/pylib/constants.py ('K') | « build/android/pylib/constants.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698