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 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', | 62 _TEST_SUITES = ['base_unittests', |
63 'cc_unittests', | 63 'cc_unittests', |
64 'content_unittests', | 64 'content_unittests', |
65 'gpu_unittests', | 65 'gpu_unittests', |
66 'ipc_tests', | 66 'ipc_tests', |
67 'media_unittests', | 67 'media_unittests', |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 337 |
338 def ListTestSuites(): | 338 def ListTestSuites(): |
339 """Display a list of available test suites.""" | 339 """Display a list of available test suites.""" |
340 print 'Available test suites are:' | 340 print 'Available test suites are:' |
341 for test_suite in _TEST_SUITES: | 341 for test_suite in _TEST_SUITES: |
342 print test_suite | 342 print test_suite |
343 | 343 |
344 | 344 |
345 def main(argv): | 345 def main(argv): |
346 option_parser = optparse.OptionParser() | 346 option_parser = optparse.OptionParser() |
347 test_options_parser.AddTestRunnerOptions(option_parser, default_timeout=0) | 347 test_options_parser.AddGTestOptions(option_parser) |
348 option_parser.add_option('-s', '--suite', dest='test_suite', | |
349 help='Executable name of the test suite to run ' | |
350 '(use -s help to list them)') | |
351 option_parser.add_option('--out-directory', dest='out_directory', | |
352 help='Path to the out/ directory, irrespective of ' | |
353 'the build type. Only for non-Chromium uses.') | |
354 option_parser.add_option('-d', '--device', dest='test_device', | |
355 help='Target device the test suite to run ') | |
356 option_parser.add_option('-f', '--gtest_filter', dest='gtest_filter', | |
357 help='gtest filter') | |
358 option_parser.add_option('-a', '--test_arguments', dest='test_arguments', | |
359 help='Additional arguments to pass to the test') | |
360 option_parser.add_option('-L', dest='log_dump', | |
361 help='file name of log dump, which will be put in ' | |
362 'subfolder debug_info_dumps under the same ' | |
363 'directory in where the test_suite exists.') | |
364 option_parser.add_option('-e', '--emulator', dest='use_emulator', | |
365 action='store_true', | |
366 help='Run tests in a new instance of emulator') | |
367 option_parser.add_option('-n', '--emulator_count', | |
368 type='int', default=1, | |
369 help='Number of emulators to launch for running the ' | |
370 'tests.') | |
371 option_parser.add_option('-x', '--xvfb', dest='use_xvfb', | |
372 action='store_true', | |
373 help='Use Xvfb around tests (ignored if not Linux)') | |
374 option_parser.add_option('--webkit', action='store_true', | |
375 help='Run the tests from a WebKit checkout.') | |
376 option_parser.add_option('--fast', '--fast_and_loose', dest='fast_and_loose', | |
377 action='store_true', | |
378 help='Go faster (but be less stable), ' | |
379 'for quick testing. Example: when tracking down ' | |
380 'tests that hang to add to the disabled list, ' | |
381 'there is no need to redeploy the test binary ' | |
382 'or data to the device again. ' | |
383 'Don\'t use on bots by default!') | |
384 option_parser.add_option('--repeat', dest='repeat', type='int', | |
385 default=2, | |
386 help='Repeat count on test timeout') | |
387 option_parser.add_option('--exit_code', action='store_true', | |
388 help='If set, the exit code will be total number ' | |
389 'of failures.') | |
390 option_parser.add_option('--exe', action='store_true', | |
391 help='If set, use the exe test runner instead of ' | |
392 'the APK.') | |
393 | |
394 options, args = option_parser.parse_args(argv) | 348 options, args = option_parser.parse_args(argv) |
395 | 349 |
396 if len(args) > 1: | 350 if len(args) > 1: |
397 print 'Unknown argument:', args[1:] | 351 option_parser.error('Unknown argument: %s' % args[1:]) |
398 option_parser.print_usage() | |
399 sys.exit(1) | |
400 | 352 |
401 run_tests_helper.SetLogLevel(options.verbose_count) | 353 run_tests_helper.SetLogLevel(options.verbose_count) |
402 | 354 |
403 if options.out_directory: | 355 if options.out_directory: |
404 cmd_helper.OutDirectory.set(options.out_directory) | 356 cmd_helper.OutDirectory.set(options.out_directory) |
405 | 357 |
406 if options.use_emulator: | 358 if options.use_emulator: |
407 emulator.DeleteAllTempAVDs() | 359 emulator.DeleteAllTempAVDs() |
408 | 360 |
409 failed_tests_count = Dispatch(options) | 361 failed_tests_count = Dispatch(options) |
410 | 362 |
411 # Failures of individual test suites are communicated by printing a | 363 # Failures of individual test suites are communicated by printing a |
412 # STEP_FAILURE message. | 364 # STEP_FAILURE message. |
413 # Returning a success exit status also prevents the buildbot from incorrectly | 365 # Returning a success exit status also prevents the buildbot from incorrectly |
414 # marking the last suite as failed if there were failures in other suites in | 366 # marking the last suite as failed if there were failures in other suites in |
415 # the batch (this happens because the exit status is a sum of all failures | 367 # the batch (this happens because the exit status is a sum of all failures |
416 # from all suites, but the buildbot associates the exit status only with the | 368 # from all suites, but the buildbot associates the exit status only with the |
417 # most recent step). | 369 # most recent step). |
418 if options.exit_code: | 370 if options.exit_code: |
419 return failed_tests_count | 371 return failed_tests_count |
420 return 0 | 372 return 0 |
421 | 373 |
422 | 374 |
423 if __name__ == '__main__': | 375 if __name__ == '__main__': |
424 sys.exit(main(sys.argv)) | 376 sys.exit(main(sys.argv)) |
OLD | NEW |