Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: build/android/test_runner.py

Issue 25525003: Add new Android test runner command to handle linker tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: formatting Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/linker/test_runner.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 import collections 9 import collections
10 import logging 10 import logging
11 import optparse 11 import optparse
12 import os 12 import os
13 import shutil 13 import shutil
14 import sys 14 import sys
15 15
16 from pylib import android_commands 16 from pylib import android_commands
17 from pylib import constants 17 from pylib import constants
18 from pylib import ports 18 from pylib import ports
19 from pylib.base import base_test_result 19 from pylib.base import base_test_result
20 from pylib.base import test_dispatcher 20 from pylib.base import test_dispatcher
21 from pylib.gtest import gtest_config 21 from pylib.gtest import gtest_config
22 from pylib.gtest import setup as gtest_setup 22 from pylib.gtest import setup as gtest_setup
23 from pylib.gtest import test_options as gtest_test_options 23 from pylib.gtest import test_options as gtest_test_options
24 from pylib.linker import setup as linker_setup
24 from pylib.host_driven import setup as host_driven_setup 25 from pylib.host_driven import setup as host_driven_setup
25 from pylib.instrumentation import setup as instrumentation_setup 26 from pylib.instrumentation import setup as instrumentation_setup
26 from pylib.instrumentation import test_options as instrumentation_test_options 27 from pylib.instrumentation import test_options as instrumentation_test_options
27 from pylib.monkey import setup as monkey_setup 28 from pylib.monkey import setup as monkey_setup
28 from pylib.monkey import test_options as monkey_test_options 29 from pylib.monkey import test_options as monkey_test_options
29 from pylib.perf import setup as perf_setup 30 from pylib.perf import setup as perf_setup
30 from pylib.perf import test_options as perf_test_options 31 from pylib.perf import test_options as perf_test_options
31 from pylib.perf import test_runner as perf_test_runner 32 from pylib.perf import test_runner as perf_test_runner
32 from pylib.uiautomator import setup as uiautomator_setup 33 from pylib.uiautomator import setup as uiautomator_setup
33 from pylib.uiautomator import test_options as uiautomator_test_options 34 from pylib.uiautomator import test_options as uiautomator_test_options
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 help='Additional arguments to pass to the test.') 109 help='Additional arguments to pass to the test.')
109 option_parser.add_option('-t', dest='timeout', 110 option_parser.add_option('-t', dest='timeout',
110 help='Timeout to wait for each test', 111 help='Timeout to wait for each test',
111 type='int', 112 type='int',
112 default=60) 113 default=60)
113 # TODO(gkanwar): Move these to Common Options once we have the plumbing 114 # TODO(gkanwar): Move these to Common Options once we have the plumbing
114 # in our other test types to handle these commands 115 # in our other test types to handle these commands
115 AddCommonOptions(option_parser) 116 AddCommonOptions(option_parser)
116 117
117 118
119 def AddLinkerTestOptions(option_parser):
120 option_parser.usage = '%prog linker'
121 option_parser.commands_dict = {}
122 option_parser.example = '%prog linker'
123
124 AddCommonOptions(option_parser)
125
126
118 def ProcessGTestOptions(options): 127 def ProcessGTestOptions(options):
119 """Intercept test suite help to list test suites. 128 """Intercept test suite help to list test suites.
120 129
121 Args: 130 Args:
122 options: Command line options. 131 options: Command line options.
123 """ 132 """
124 if options.suite_name == 'help': 133 if options.suite_name == 'help':
125 print 'Available test suites are:' 134 print 'Available test suites are:'
126 for test_suite in (gtest_config.STABLE_TEST_SUITES + 135 for test_suite in (gtest_config.STABLE_TEST_SUITES +
127 gtest_config.EXPERIMENTAL_TEST_SUITES): 136 gtest_config.EXPERIMENTAL_TEST_SUITES):
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 test_type='Unit test', 501 test_type='Unit test',
493 test_package=suite_name, 502 test_package=suite_name,
494 flakiness_server=options.flakiness_dashboard_server) 503 flakiness_server=options.flakiness_dashboard_server)
495 504
496 if os.path.isdir(constants.ISOLATE_DEPS_DIR): 505 if os.path.isdir(constants.ISOLATE_DEPS_DIR):
497 shutil.rmtree(constants.ISOLATE_DEPS_DIR) 506 shutil.rmtree(constants.ISOLATE_DEPS_DIR)
498 507
499 return exit_code 508 return exit_code
500 509
501 510
511 def _RunLinkerTests(options, error_func, devices):
512 """Subcommand of RunTestsCommands which runs linker tests."""
513 runner_factory, tests = linker_setup.Setup(options, devices)
514
515 results, exit_code = test_dispatcher.RunTests(
516 tests, runner_factory, devices, shard=True, test_timeout=60,
517 num_retries=options.num_retries)
518
519 report_results.LogFull(
520 results=results,
521 test_type='Linker test',
522 test_package='ContentLinkerTest')
523
524 return exit_code
525
526
502 def _RunInstrumentationTests(options, error_func, devices): 527 def _RunInstrumentationTests(options, error_func, devices):
503 """Subcommand of RunTestsCommands which runs instrumentation tests.""" 528 """Subcommand of RunTestsCommands which runs instrumentation tests."""
504 instrumentation_options = ProcessInstrumentationOptions(options, error_func) 529 instrumentation_options = ProcessInstrumentationOptions(options, error_func)
505 530
506 if len(devices) > 1 and options.wait_for_debugger: 531 if len(devices) > 1 and options.wait_for_debugger:
507 logging.warning('Debugger can not be sharded, using first available device') 532 logging.warning('Debugger can not be sharded, using first available device')
508 devices = devices[:1] 533 devices = devices[:1]
509 534
510 results = base_test_result.TestRunResults() 535 results = base_test_result.TestRunResults()
511 exit_code = 0 536 exit_code = 0
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 if len(args) > 2: 675 if len(args) > 2:
651 option_parser.error('Unrecognized arguments: %s' % (' '.join(args[2:]))) 676 option_parser.error('Unrecognized arguments: %s' % (' '.join(args[2:])))
652 return constants.ERROR_EXIT_CODE 677 return constants.ERROR_EXIT_CODE
653 678
654 ProcessCommonOptions(options) 679 ProcessCommonOptions(options)
655 680
656 devices = _GetAttachedDevices(options.test_device) 681 devices = _GetAttachedDevices(options.test_device)
657 682
658 if command == 'gtest': 683 if command == 'gtest':
659 return _RunGTests(options, option_parser.error, devices) 684 return _RunGTests(options, option_parser.error, devices)
685 elif command == 'linker':
686 return _RunLinkerTests(options, option_parser.error, devices)
660 elif command == 'instrumentation': 687 elif command == 'instrumentation':
661 return _RunInstrumentationTests(options, option_parser.error, devices) 688 return _RunInstrumentationTests(options, option_parser.error, devices)
662 elif command == 'uiautomator': 689 elif command == 'uiautomator':
663 return _RunUIAutomatorTests(options, option_parser.error, devices) 690 return _RunUIAutomatorTests(options, option_parser.error, devices)
664 elif command == 'monkey': 691 elif command == 'monkey':
665 return _RunMonkeyTests(options, option_parser.error, devices) 692 return _RunMonkeyTests(options, option_parser.error, devices)
666 elif command == 'perf': 693 elif command == 'perf':
667 return _RunPerfTests(options, option_parser.error, devices) 694 return _RunPerfTests(options, option_parser.error, devices)
668 else: 695 else:
669 raise Exception('Unknown test type.') 696 raise Exception('Unknown test type.')
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 VALID_COMMANDS = { 745 VALID_COMMANDS = {
719 'gtest': CommandFunctionTuple(AddGTestOptions, RunTestsCommand), 746 'gtest': CommandFunctionTuple(AddGTestOptions, RunTestsCommand),
720 'instrumentation': CommandFunctionTuple( 747 'instrumentation': CommandFunctionTuple(
721 AddInstrumentationTestOptions, RunTestsCommand), 748 AddInstrumentationTestOptions, RunTestsCommand),
722 'uiautomator': CommandFunctionTuple( 749 'uiautomator': CommandFunctionTuple(
723 AddUIAutomatorTestOptions, RunTestsCommand), 750 AddUIAutomatorTestOptions, RunTestsCommand),
724 'monkey': CommandFunctionTuple( 751 'monkey': CommandFunctionTuple(
725 AddMonkeyTestOptions, RunTestsCommand), 752 AddMonkeyTestOptions, RunTestsCommand),
726 'perf': CommandFunctionTuple( 753 'perf': CommandFunctionTuple(
727 AddPerfTestOptions, RunTestsCommand), 754 AddPerfTestOptions, RunTestsCommand),
755 'linker': CommandFunctionTuple(
756 AddLinkerTestOptions, RunTestsCommand),
728 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand) 757 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand)
729 } 758 }
730 759
731 760
732 def main(argv): 761 def main(argv):
733 option_parser = command_option_parser.CommandOptionParser( 762 option_parser = command_option_parser.CommandOptionParser(
734 commands_dict=VALID_COMMANDS) 763 commands_dict=VALID_COMMANDS)
735 return command_option_parser.ParseAndExecute(option_parser) 764 return command_option_parser.ParseAndExecute(option_parser)
736 765
737 766
738 if __name__ == '__main__': 767 if __name__ == '__main__':
739 sys.exit(main(sys.argv)) 768 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/pylib/linker/test_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698