| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 import subprocess | 44 import subprocess |
| 45 import sys | 45 import sys |
| 46 import time | 46 import time |
| 47 | 47 |
| 48 import emulator | 48 import emulator |
| 49 from pylib import android_commands | 49 from pylib import android_commands |
| 50 from pylib import buildbot_report | 50 from pylib import buildbot_report |
| 51 from pylib import cmd_helper | 51 from pylib import cmd_helper |
| 52 from pylib import debug_info | 52 from pylib import debug_info |
| 53 from pylib import ports | 53 from pylib import ports |
| 54 from pylib import run_tests_helper | |
| 55 from pylib import test_options_parser | |
| 56 from pylib.base_test_sharder import BaseTestSharder | 54 from pylib.base_test_sharder import BaseTestSharder |
| 57 from pylib.single_test_runner import SingleTestRunner | 55 from pylib.single_test_runner import SingleTestRunner |
| 56 from pylib.utils import run_tests_helper |
| 57 from pylib.utils import test_options_parser |
| 58 | 58 |
| 59 | 59 |
| 60 _TEST_SUITES = ['base_unittests', | 60 _TEST_SUITES = ['base_unittests', |
| 61 'cc_unittests', | 61 'cc_unittests', |
| 62 'content_unittests', | 62 'content_unittests', |
| 63 'gpu_unittests', | 63 'gpu_unittests', |
| 64 'ipc_tests', | 64 'ipc_tests', |
| 65 'media_unittests', | 65 'media_unittests', |
| 66 'net_unittests', | 66 'net_unittests', |
| 67 'sql_unittests', | 67 'sql_unittests', |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 | 400 |
| 401 def ListTestSuites(): | 401 def ListTestSuites(): |
| 402 """Display a list of available test suites.""" | 402 """Display a list of available test suites.""" |
| 403 print 'Available test suites are:' | 403 print 'Available test suites are:' |
| 404 for test_suite in _TEST_SUITES: | 404 for test_suite in _TEST_SUITES: |
| 405 print test_suite | 405 print test_suite |
| 406 | 406 |
| 407 | 407 |
| 408 def main(argv): | 408 def main(argv): |
| 409 option_parser = optparse.OptionParser() | 409 option_parser = optparse.OptionParser() |
| 410 test_options_parser.AddTestRunnerOptions(option_parser, default_timeout=0) | 410 test_options_parser.AddGTestOptions(option_parser) |
| 411 option_parser.add_option('-s', '--suite', dest='test_suite', | |
| 412 help='Executable name of the test suite to run ' | |
| 413 '(use -s help to list them)') | |
| 414 option_parser.add_option('--out-directory', dest='out_directory', | |
| 415 help='Path to the out/ directory, irrespective of ' | |
| 416 'the build type. Only for non-Chromium uses.') | |
| 417 option_parser.add_option('-d', '--device', dest='test_device', | |
| 418 help='Target device the test suite to run ') | |
| 419 option_parser.add_option('-f', '--gtest_filter', dest='gtest_filter', | |
| 420 help='gtest filter') | |
| 421 option_parser.add_option('-a', '--test_arguments', dest='test_arguments', | |
| 422 help='Additional arguments to pass to the test') | |
| 423 option_parser.add_option('-L', dest='log_dump', | |
| 424 help='file name of log dump, which will be put in ' | |
| 425 'subfolder debug_info_dumps under the same ' | |
| 426 'directory in where the test_suite exists.') | |
| 427 option_parser.add_option('-e', '--emulator', dest='use_emulator', | |
| 428 action='store_true', | |
| 429 help='Run tests in a new instance of emulator') | |
| 430 option_parser.add_option('-n', '--emulator_count', | |
| 431 type='int', default=1, | |
| 432 help='Number of emulators to launch for running the ' | |
| 433 'tests.') | |
| 434 option_parser.add_option('-x', '--xvfb', dest='use_xvfb', | |
| 435 action='store_true', | |
| 436 help='Use Xvfb around tests (ignored if not Linux)') | |
| 437 option_parser.add_option('--webkit', action='store_true', | |
| 438 help='Run the tests from a WebKit checkout.') | |
| 439 option_parser.add_option('--fast', '--fast_and_loose', dest='fast_and_loose', | |
| 440 action='store_true', | |
| 441 help='Go faster (but be less stable), ' | |
| 442 'for quick testing. Example: when tracking down ' | |
| 443 'tests that hang to add to the disabled list, ' | |
| 444 'there is no need to redeploy the test binary ' | |
| 445 'or data to the device again. ' | |
| 446 'Don\'t use on bots by default!') | |
| 447 option_parser.add_option('--repeat', dest='repeat', type='int', | |
| 448 default=2, | |
| 449 help='Repeat count on test timeout') | |
| 450 option_parser.add_option('--exit_code', action='store_true', | |
| 451 help='If set, the exit code will be total number ' | |
| 452 'of failures.') | |
| 453 option_parser.add_option('--exe', action='store_true', | |
| 454 help='If set, use the exe test runner instead of ' | |
| 455 'the APK.') | |
| 456 | |
| 457 options, args = option_parser.parse_args(argv) | 411 options, args = option_parser.parse_args(argv) |
| 458 | 412 |
| 459 if len(args) > 1: | 413 if len(args) > 1: |
| 460 print 'Unknown argument:', args[1:] | 414 option_parser.error('Unknown argument: %s' % args[1:]) |
| 461 option_parser.print_usage() | |
| 462 sys.exit(1) | |
| 463 | 415 |
| 464 run_tests_helper.SetLogLevel(options.verbose_count) | 416 run_tests_helper.SetLogLevel(options.verbose_count) |
| 465 | 417 |
| 466 if options.out_directory: | 418 if options.out_directory: |
| 467 cmd_helper.OutDirectory.set(options.out_directory) | 419 cmd_helper.OutDirectory.set(options.out_directory) |
| 468 | 420 |
| 469 if options.use_emulator: | 421 if options.use_emulator: |
| 470 emulator.DeleteAllTempAVDs() | 422 emulator.DeleteAllTempAVDs() |
| 471 | 423 |
| 472 failed_tests_count = Dispatch(options) | 424 failed_tests_count = Dispatch(options) |
| 473 | 425 |
| 474 # Failures of individual test suites are communicated by printing a | 426 # Failures of individual test suites are communicated by printing a |
| 475 # STEP_FAILURE message. | 427 # STEP_FAILURE message. |
| 476 # Returning a success exit status also prevents the buildbot from incorrectly | 428 # Returning a success exit status also prevents the buildbot from incorrectly |
| 477 # marking the last suite as failed if there were failures in other suites in | 429 # marking the last suite as failed if there were failures in other suites in |
| 478 # the batch (this happens because the exit status is a sum of all failures | 430 # the batch (this happens because the exit status is a sum of all failures |
| 479 # from all suites, but the buildbot associates the exit status only with the | 431 # from all suites, but the buildbot associates the exit status only with the |
| 480 # most recent step). | 432 # most recent step). |
| 481 if options.exit_code: | 433 if options.exit_code: |
| 482 return failed_tests_count | 434 return failed_tests_count |
| 483 return 0 | 435 return 0 |
| 484 | 436 |
| 485 | 437 |
| 486 if __name__ == '__main__': | 438 if __name__ == '__main__': |
| 487 sys.exit(main(sys.argv)) | 439 sys.exit(main(sys.argv)) |
| OLD | NEW |