Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 types of tests from one unified interface. | 7 """Runs all types of tests from one unified interface.""" |
| 8 | |
| 9 TODO(gkanwar): | |
| 10 * Add options to run Monkey tests. | |
| 11 """ | |
| 12 | 8 |
| 13 import collections | 9 import collections |
| 14 import logging | 10 import logging |
| 15 import optparse | 11 import optparse |
| 16 import os | 12 import os |
| 17 import shutil | 13 import shutil |
| 18 import sys | 14 import sys |
| 19 | 15 |
| 20 from pylib import android_commands | 16 from pylib import android_commands |
| 21 from pylib import constants | 17 from pylib import constants |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 options.extra_args) | 422 options.extra_args) |
| 427 | 423 |
| 428 | 424 |
| 429 def AddPerfTestOptions(option_parser): | 425 def AddPerfTestOptions(option_parser): |
| 430 """Adds perf test options to |option_parser|.""" | 426 """Adds perf test options to |option_parser|.""" |
| 431 | 427 |
| 432 option_parser.usage = '%prog perf [options]' | 428 option_parser.usage = '%prog perf [options]' |
| 433 option_parser.command_list = [] | 429 option_parser.command_list = [] |
| 434 option_parser.example = ('%prog perf --steps perf_steps.json') | 430 option_parser.example = ('%prog perf --steps perf_steps.json') |
| 435 | 431 |
| 436 option_parser.add_option('--steps', help='JSON file containing the list ' | 432 option_parser.add_option( |
| 437 'of perf steps to run.') | 433 '--steps', |
| 438 option_parser.add_option('--flaky-steps', | 434 help='JSON file containing the list of perf steps to run.') |
| 439 help='A JSON file containing steps that are flaky ' | 435 option_parser.add_option( |
| 440 'and will have its exit code ignored.') | 436 '--flaky-steps', |
| 441 option_parser.add_option('--print-step', help='The name of a previously ' | 437 help=('A JSON file containing steps that are flaky ' |
| 442 'executed perf step to print.') | 438 'and will have its exit code ignored.')) |
| 443 | 439 option_parser.add_option( |
| 440 '--print-step', | |
| 441 help='The name of a previously executed perf step to print.') | |
| 442 option_parser.add_option( | |
| 443 '--no-timeout', action='store_true', | |
| 444 help=('Do not impose a timeout. Each step is responsible for settting ' | |
|
craigdh
2013/09/05 22:25:56
The word "setting" is unclear. Is each step respon
frankf
2013/09/05 22:36:07
Rephrased.
On 2013/09/05 22:25:56, craigdh wrote:
| |
| 445 'a reasonable timeout.')) | |
| 444 AddCommonOptions(option_parser) | 446 AddCommonOptions(option_parser) |
| 445 | 447 |
| 446 | 448 |
| 447 def ProcessPerfTestOptions(options, error_func): | 449 def ProcessPerfTestOptions(options, error_func): |
| 448 """Processes all perf test options. | 450 """Processes all perf test options. |
| 449 | 451 |
| 450 Args: | 452 Args: |
| 451 options: optparse.Options object. | 453 options: optparse.Options object. |
| 452 error_func: Function to call with the error message in case of an error. | 454 error_func: Function to call with the error message in case of an error. |
| 453 | 455 |
| 454 Returns: | 456 Returns: |
| 455 A PerfOptions named tuple which contains all options relevant to | 457 A PerfOptions named tuple which contains all options relevant to |
| 456 perf tests. | 458 perf tests. |
| 457 """ | 459 """ |
| 458 if not options.steps and not options.print_step: | 460 if not options.steps and not options.print_step: |
| 459 error_func('Please specify --steps or --print-step') | 461 error_func('Please specify --steps or --print-step') |
| 460 return perf_test_options.PerfOptions( | 462 return perf_test_options.PerfOptions( |
| 461 options.steps, options.flaky_steps, options.print_step) | 463 options.steps, options.flaky_steps, options.print_step, |
| 464 options.no_timeout) | |
| 462 | 465 |
| 463 | 466 |
| 464 def _RunGTests(options, error_func, devices): | 467 def _RunGTests(options, error_func, devices): |
| 465 """Subcommand of RunTestsCommands which runs gtests.""" | 468 """Subcommand of RunTestsCommands which runs gtests.""" |
| 466 ProcessGTestOptions(options) | 469 ProcessGTestOptions(options) |
| 467 | 470 |
| 468 exit_code = 0 | 471 exit_code = 0 |
| 469 for suite_name in options.suite_name: | 472 for suite_name in options.suite_name: |
| 470 # TODO(gkanwar): Move this into ProcessGTestOptions once we require -s for | 473 # TODO(gkanwar): Move this into ProcessGTestOptions once we require -s for |
| 471 # the gtest command. | 474 # the gtest command. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 727 | 730 |
| 728 | 731 |
| 729 def main(argv): | 732 def main(argv): |
| 730 option_parser = command_option_parser.CommandOptionParser( | 733 option_parser = command_option_parser.CommandOptionParser( |
| 731 commands_dict=VALID_COMMANDS) | 734 commands_dict=VALID_COMMANDS) |
| 732 return command_option_parser.ParseAndExecute(option_parser) | 735 return command_option_parser.ParseAndExecute(option_parser) |
| 733 | 736 |
| 734 | 737 |
| 735 if __name__ == '__main__': | 738 if __name__ == '__main__': |
| 736 sys.exit(main(sys.argv)) | 739 sys.exit(main(sys.argv)) |
| OLD | NEW |