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

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: Trivial rebase + reupload 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
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 option_parser.add_option('-a', '--test-arguments', dest='test_arguments', 107 option_parser.add_option('-a', '--test-arguments', dest='test_arguments',
107 default='', 108 default='',
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
bulach 2013/10/02 11:16:50 nit: another \n here and after this method
digit1 2013/10/02 14:01:52 Done.
118 def AddLinkerTestOptions(option_parser):
119 option_parser.usage = '%prog linker'
120 option_parser.commands_dict = {}
121 option_parser.example = '%prog linker'
122
123 AddCommonOptions(option_parser)
117 124
118 def ProcessGTestOptions(options): 125 def ProcessGTestOptions(options):
119 """Intercept test suite help to list test suites. 126 """Intercept test suite help to list test suites.
120 127
121 Args: 128 Args:
122 options: Command line options. 129 options: Command line options.
123 """ 130 """
124 if options.suite_name == 'help': 131 if options.suite_name == 'help':
125 print 'Available test suites are:' 132 print 'Available test suites are:'
126 for test_suite in (gtest_config.STABLE_TEST_SUITES + 133 for test_suite in (gtest_config.STABLE_TEST_SUITES +
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 results=results, 498 results=results,
492 test_type='Unit test', 499 test_type='Unit test',
493 test_package=suite_name, 500 test_package=suite_name,
494 flakiness_server=options.flakiness_dashboard_server) 501 flakiness_server=options.flakiness_dashboard_server)
495 502
496 if os.path.isdir(constants.ISOLATE_DEPS_DIR): 503 if os.path.isdir(constants.ISOLATE_DEPS_DIR):
497 shutil.rmtree(constants.ISOLATE_DEPS_DIR) 504 shutil.rmtree(constants.ISOLATE_DEPS_DIR)
498 505
499 return exit_code 506 return exit_code
500 507
508 def _RunLinkerTests(options, error_func, devices):
509 """Subcommand of RunTestsCommands which runs linker tests."""
510 runner_factory, tests = linker_setup.Setup(options, devices)
511
512 results, exit_code = test_dispatcher.RunTests(
513 tests, runner_factory, devices, shard=True, test_timeout=60,
514 num_retries=options.num_retries)
515
516 report_results.LogFull(
517 results=results,
518 test_type='Linker test',
519 test_package='ContentLinkerTest')
520
521 return exit_code
501 522
502 def _RunInstrumentationTests(options, error_func, devices): 523 def _RunInstrumentationTests(options, error_func, devices):
503 """Subcommand of RunTestsCommands which runs instrumentation tests.""" 524 """Subcommand of RunTestsCommands which runs instrumentation tests."""
504 instrumentation_options = ProcessInstrumentationOptions(options, error_func) 525 instrumentation_options = ProcessInstrumentationOptions(options, error_func)
505 526
506 if len(devices) > 1 and options.wait_for_debugger: 527 if len(devices) > 1 and options.wait_for_debugger:
507 logging.warning('Debugger can not be sharded, using first available device') 528 logging.warning('Debugger can not be sharded, using first available device')
508 devices = devices[:1] 529 devices = devices[:1]
509 530
510 results = base_test_result.TestRunResults() 531 results = base_test_result.TestRunResults()
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 if len(args) > 2: 671 if len(args) > 2:
651 option_parser.error('Unrecognized arguments: %s' % (' '.join(args[2:]))) 672 option_parser.error('Unrecognized arguments: %s' % (' '.join(args[2:])))
652 return constants.ERROR_EXIT_CODE 673 return constants.ERROR_EXIT_CODE
653 674
654 ProcessCommonOptions(options) 675 ProcessCommonOptions(options)
655 676
656 devices = _GetAttachedDevices(options.test_device) 677 devices = _GetAttachedDevices(options.test_device)
657 678
658 if command == 'gtest': 679 if command == 'gtest':
659 return _RunGTests(options, option_parser.error, devices) 680 return _RunGTests(options, option_parser.error, devices)
681 elif command == 'linker':
682 return _RunLinkerTests(options, option_parser.error, devices)
660 elif command == 'instrumentation': 683 elif command == 'instrumentation':
661 return _RunInstrumentationTests(options, option_parser.error, devices) 684 return _RunInstrumentationTests(options, option_parser.error, devices)
662 elif command == 'uiautomator': 685 elif command == 'uiautomator':
663 return _RunUIAutomatorTests(options, option_parser.error, devices) 686 return _RunUIAutomatorTests(options, option_parser.error, devices)
664 elif command == 'monkey': 687 elif command == 'monkey':
665 return _RunMonkeyTests(options, option_parser.error, devices) 688 return _RunMonkeyTests(options, option_parser.error, devices)
666 elif command == 'perf': 689 elif command == 'perf':
667 return _RunPerfTests(options, option_parser.error, devices) 690 return _RunPerfTests(options, option_parser.error, devices)
668 else: 691 else:
669 raise Exception('Unknown test type.') 692 raise Exception('Unknown test type.')
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 VALID_COMMANDS = { 741 VALID_COMMANDS = {
719 'gtest': CommandFunctionTuple(AddGTestOptions, RunTestsCommand), 742 'gtest': CommandFunctionTuple(AddGTestOptions, RunTestsCommand),
720 'instrumentation': CommandFunctionTuple( 743 'instrumentation': CommandFunctionTuple(
721 AddInstrumentationTestOptions, RunTestsCommand), 744 AddInstrumentationTestOptions, RunTestsCommand),
722 'uiautomator': CommandFunctionTuple( 745 'uiautomator': CommandFunctionTuple(
723 AddUIAutomatorTestOptions, RunTestsCommand), 746 AddUIAutomatorTestOptions, RunTestsCommand),
724 'monkey': CommandFunctionTuple( 747 'monkey': CommandFunctionTuple(
725 AddMonkeyTestOptions, RunTestsCommand), 748 AddMonkeyTestOptions, RunTestsCommand),
726 'perf': CommandFunctionTuple( 749 'perf': CommandFunctionTuple(
727 AddPerfTestOptions, RunTestsCommand), 750 AddPerfTestOptions, RunTestsCommand),
751 'linker': CommandFunctionTuple(
752 AddLinkerTestOptions, RunTestsCommand),
728 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand) 753 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand)
729 } 754 }
730 755
731 756
732 def main(argv): 757 def main(argv):
733 option_parser = command_option_parser.CommandOptionParser( 758 option_parser = command_option_parser.CommandOptionParser(
734 commands_dict=VALID_COMMANDS) 759 commands_dict=VALID_COMMANDS)
735 return command_option_parser.ParseAndExecute(option_parser) 760 return command_option_parser.ParseAndExecute(option_parser)
736 761
737 762
738 if __name__ == '__main__': 763 if __name__ == '__main__':
739 sys.exit(main(sys.argv)) 764 sys.exit(main(sys.argv))
OLDNEW
« build/android/pylib/linker/test_case.py ('K') | « 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