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 perf step is responsible for ' |
| 445 'implementing the timeout logic.')) |
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 return exit_code | 567 return exit_code |
565 | 568 |
566 | 569 |
567 def _RunMonkeyTests(options, error_func, devices): | 570 def _RunMonkeyTests(options, error_func, devices): |
568 """Subcommand of RunTestsCommands which runs monkey tests.""" | 571 """Subcommand of RunTestsCommands which runs monkey tests.""" |
569 monkey_options = ProcessMonkeyTestOptions(options, error_func) | 572 monkey_options = ProcessMonkeyTestOptions(options, error_func) |
570 | 573 |
571 runner_factory, tests = monkey_setup.Setup(monkey_options) | 574 runner_factory, tests = monkey_setup.Setup(monkey_options) |
572 | 575 |
573 results, exit_code = test_dispatcher.RunTests( | 576 results, exit_code = test_dispatcher.RunTests( |
574 tests, runner_factory, devices, shard=False, test_timeout=None) | 577 tests, runner_factory, devices, shard=False, test_timeout=None, |
| 578 num_retries=options.num_retries) |
575 | 579 |
576 report_results.LogFull( | 580 report_results.LogFull( |
577 results=results, | 581 results=results, |
578 test_type='Monkey', | 582 test_type='Monkey', |
579 test_package='Monkey') | 583 test_package='Monkey') |
580 | 584 |
581 return exit_code | 585 return exit_code |
582 | 586 |
583 | 587 |
584 def _RunPerfTests(options, error_func, devices): | 588 def _RunPerfTests(options, error_func, devices): |
585 """Subcommand of RunTestsCommands which runs perf tests.""" | 589 """Subcommand of RunTestsCommands which runs perf tests.""" |
586 perf_options = ProcessPerfTestOptions(options, error_func) | 590 perf_options = ProcessPerfTestOptions(options, error_func) |
587 # Just print the results from a single previously executed step. | 591 # Just print the results from a single previously executed step. |
588 if perf_options.print_step: | 592 if perf_options.print_step: |
589 return perf_test_runner.PrintTestOutput(perf_options.print_step) | 593 return perf_test_runner.PrintTestOutput(perf_options.print_step) |
590 | 594 |
591 runner_factory, tests = perf_setup.Setup(perf_options) | 595 runner_factory, tests = perf_setup.Setup(perf_options) |
592 | 596 |
593 results, _ = test_dispatcher.RunTests( | 597 results, _ = test_dispatcher.RunTests( |
594 tests, runner_factory, devices, shard=True, test_timeout=None) | 598 tests, runner_factory, devices, shard=True, test_timeout=None, |
| 599 num_retries=options.num_retries) |
595 | 600 |
596 report_results.LogFull( | 601 report_results.LogFull( |
597 results=results, | 602 results=results, |
598 test_type='Perf', | 603 test_type='Perf', |
599 test_package='Perf') | 604 test_package='Perf') |
600 # Always return 0 on the sharding stage. Individual tests exit_code | 605 # Always return 0 on the sharding stage. Individual tests exit_code |
601 # will be returned on the print_step stage. | 606 # will be returned on the print_step stage. |
602 return 0 | 607 return 0 |
603 | 608 |
604 | 609 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 | 732 |
728 | 733 |
729 def main(argv): | 734 def main(argv): |
730 option_parser = command_option_parser.CommandOptionParser( | 735 option_parser = command_option_parser.CommandOptionParser( |
731 commands_dict=VALID_COMMANDS) | 736 commands_dict=VALID_COMMANDS) |
732 return command_option_parser.ParseAndExecute(option_parser) | 737 return command_option_parser.ParseAndExecute(option_parser) |
733 | 738 |
734 | 739 |
735 if __name__ == '__main__': | 740 if __name__ == '__main__': |
736 sys.exit(main(sys.argv)) | 741 sys.exit(main(sys.argv)) |
OLD | NEW |