| OLD | NEW |
| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 Args: | 316 Args: |
| 317 options: options for running the tests. | 317 options: options for running the tests. |
| 318 | 318 |
| 319 Returns: | 319 Returns: |
| 320 0 if successful, number of failing tests otherwise. | 320 0 if successful, number of failing tests otherwise. |
| 321 """ | 321 """ |
| 322 attached_devices = [] | 322 attached_devices = [] |
| 323 buildbot_emulators = [] | 323 buildbot_emulators = [] |
| 324 | 324 |
| 325 if options.use_emulator: | 325 if options.use_emulator: |
| 326 for n in range(options.use_emulator): | 326 for n in range(options.emulator_count): |
| 327 t = TimeProfile('Emulator launch %d' % n) | 327 t = TimeProfile('Emulator launch %d' % n) |
| 328 buildbot_emulator = emulator.Emulator(options.fast_and_loose) | 328 buildbot_emulator = emulator.Emulator(options.fast_and_loose) |
| 329 buildbot_emulator.Launch(kill_all_emulators=n == 0) | 329 buildbot_emulator.Launch(kill_all_emulators=n == 0) |
| 330 t.Stop() | 330 t.Stop() |
| 331 buildbot_emulators.append(buildbot_emulator) | 331 buildbot_emulators.append(buildbot_emulator) |
| 332 attached_devices.append(buildbot_emulator.device) | 332 attached_devices.append(buildbot_emulator.device) |
| 333 # Wait for all emulators to boot completed. | 333 # Wait for all emulators to boot completed. |
| 334 map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True), | 334 map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True), |
| 335 buildbot_emulators) | 335 buildbot_emulators) |
| 336 elif options.test_device: | 336 elif options.test_device: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 options.fast_and_loose = True | 377 options.fast_and_loose = True |
| 378 options.repeat -= 1 | 378 options.repeat -= 1 |
| 379 logging.critical('Repeats left: ' + str(options.repeat)) | 379 logging.critical('Repeats left: ' + str(options.repeat)) |
| 380 return _RunATestSuite(options) | 380 return _RunATestSuite(options) |
| 381 return len(test_results.failed) | 381 return len(test_results.failed) |
| 382 | 382 |
| 383 | 383 |
| 384 def Dispatch(options): | 384 def Dispatch(options): |
| 385 """Dispatches the tests, sharding if possible. | 385 """Dispatches the tests, sharding if possible. |
| 386 | 386 |
| 387 If options.use_emulator is True, all tests will be run in a new emulator | 387 If options.use_emulator is True, all tests will be run in new emulator |
| 388 instance. | 388 instance. |
| 389 | 389 |
| 390 Args: | 390 Args: |
| 391 options: options for running the tests. | 391 options: options for running the tests. |
| 392 | 392 |
| 393 Returns: | 393 Returns: |
| 394 0 if successful, number of failing tests otherwise. | 394 0 if successful, number of failing tests otherwise. |
| 395 """ | 395 """ |
| 396 if options.test_suite == 'help': | 396 if options.test_suite == 'help': |
| 397 ListTestSuites() | 397 ListTestSuites() |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 option_parser.add_option('-a', '--test_arguments', dest='test_arguments', | 440 option_parser.add_option('-a', '--test_arguments', dest='test_arguments', |
| 441 help='Additional arguments to pass to the test') | 441 help='Additional arguments to pass to the test') |
| 442 option_parser.add_option('-p', dest='performance_test', | 442 option_parser.add_option('-p', dest='performance_test', |
| 443 help='Indicator of performance test', | 443 help='Indicator of performance test', |
| 444 action='store_true') | 444 action='store_true') |
| 445 option_parser.add_option('-L', dest='log_dump', | 445 option_parser.add_option('-L', dest='log_dump', |
| 446 help='file name of log dump, which will be put in' | 446 help='file name of log dump, which will be put in' |
| 447 'subfolder debug_info_dumps under the same directory' | 447 'subfolder debug_info_dumps under the same directory' |
| 448 'in where the test_suite exists.') | 448 'in where the test_suite exists.') |
| 449 option_parser.add_option('-e', '--emulator', dest='use_emulator', | 449 option_parser.add_option('-e', '--emulator', dest='use_emulator', |
| 450 help='Run tests in a new instance of emulator', | 450 action='store_true', |
| 451 type='int', | 451 help='Run tests in a new instance of emulator') |
| 452 default=0) | 452 option_parser.add_option('-n', '--emulator_count', |
| 453 type='int', default=1, |
| 454 help='Number of emulators to launch for running the ' |
| 455 'tests.') |
| 453 option_parser.add_option('-x', '--xvfb', dest='use_xvfb', | 456 option_parser.add_option('-x', '--xvfb', dest='use_xvfb', |
| 454 action='store_true', | 457 action='store_true', |
| 455 help='Use Xvfb around tests (ignored if not Linux)') | 458 help='Use Xvfb around tests (ignored if not Linux)') |
| 456 option_parser.add_option('--fast', '--fast_and_loose', dest='fast_and_loose', | 459 option_parser.add_option('--fast', '--fast_and_loose', dest='fast_and_loose', |
| 457 action='store_true', | 460 action='store_true', |
| 458 help='Go faster (but be less stable), ' | 461 help='Go faster (but be less stable), ' |
| 459 'for quick testing. Example: when tracking down ' | 462 'for quick testing. Example: when tracking down ' |
| 460 'tests that hang to add to the disabled list, ' | 463 'tests that hang to add to the disabled list, ' |
| 461 'there is no need to redeploy the test binary ' | 464 'there is no need to redeploy the test binary ' |
| 462 'or data to the device again. ' | 465 'or data to the device again. ' |
| (...skipping 22 matching lines...) Expand all Loading... |
| 485 # the batch (this happens because the exit status is a sum of all failures | 488 # the batch (this happens because the exit status is a sum of all failures |
| 486 # from all suites, but the buildbot associates the exit status only with the | 489 # from all suites, but the buildbot associates the exit status only with the |
| 487 # most recent step). | 490 # most recent step). |
| 488 if options.exit_code: | 491 if options.exit_code: |
| 489 return failed_tests_count | 492 return failed_tests_count |
| 490 return 0 | 493 return 0 |
| 491 | 494 |
| 492 | 495 |
| 493 if __name__ == '__main__': | 496 if __name__ == '__main__': |
| 494 sys.exit(main(sys.argv)) | 497 sys.exit(main(sys.argv)) |
| OLD | NEW |