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 | 8 |
9 import argparse | 9 import argparse |
10 import collections | 10 import collections |
11 import itertools | 11 import itertools |
12 import logging | 12 import logging |
13 import os | 13 import os |
14 import signal | 14 import signal |
15 import sys | 15 import sys |
16 import threading | 16 import threading |
17 import unittest | 17 import unittest |
18 | 18 |
19 from devil import base_error | 19 from devil import base_error |
| 20 from devil import devil_env |
20 from devil.android import apk_helper | 21 from devil.android import apk_helper |
21 from devil.android import device_blacklist | 22 from devil.android import device_blacklist |
22 from devil.android import device_errors | 23 from devil.android import device_errors |
23 from devil.android import device_utils | 24 from devil.android import device_utils |
24 from devil.android import ports | 25 from devil.android import ports |
25 from devil.utils import reraiser_thread | 26 from devil.utils import reraiser_thread |
26 from devil.utils import run_tests_helper | 27 from devil.utils import run_tests_helper |
27 | 28 |
28 from pylib import constants | 29 from pylib import constants |
29 from pylib import forwarder | 30 from pylib import forwarder |
(...skipping 12 matching lines...) Expand all Loading... |
42 from pylib.monkey import test_options as monkey_test_options | 43 from pylib.monkey import test_options as monkey_test_options |
43 from pylib.perf import setup as perf_setup | 44 from pylib.perf import setup as perf_setup |
44 from pylib.perf import test_options as perf_test_options | 45 from pylib.perf import test_options as perf_test_options |
45 from pylib.perf import test_runner as perf_test_runner | 46 from pylib.perf import test_runner as perf_test_runner |
46 from pylib.results import json_results | 47 from pylib.results import json_results |
47 from pylib.results import report_results | 48 from pylib.results import report_results |
48 from pylib.uiautomator import setup as uiautomator_setup | 49 from pylib.uiautomator import setup as uiautomator_setup |
49 from pylib.uiautomator import test_options as uiautomator_test_options | 50 from pylib.uiautomator import test_options as uiautomator_test_options |
50 | 51 |
51 | 52 |
| 53 _DEVIL_STATIC_CONFIG_FILE = os.path.abspath(os.path.join( |
| 54 constants.DIR_SOURCE_ROOT, 'build', 'android', 'devil_config.json')) |
| 55 |
| 56 |
52 def AddCommonOptions(parser): | 57 def AddCommonOptions(parser): |
53 """Adds all common options to |parser|.""" | 58 """Adds all common options to |parser|.""" |
54 | 59 |
55 group = parser.add_argument_group('Common Options') | 60 group = parser.add_argument_group('Common Options') |
56 | 61 |
57 default_build_type = os.environ.get('BUILDTYPE', 'Debug') | 62 default_build_type = os.environ.get('BUILDTYPE', 'Debug') |
58 | 63 |
59 debug_or_release_group = group.add_mutually_exclusive_group() | 64 debug_or_release_group = group.add_mutually_exclusive_group() |
60 debug_or_release_group.add_argument( | 65 debug_or_release_group.add_argument( |
61 '--debug', action='store_const', const='Debug', dest='build_type', | 66 '--debug', action='store_const', const='Debug', dest='build_type', |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 def ProcessCommonOptions(args): | 111 def ProcessCommonOptions(args): |
107 """Processes and handles all common options.""" | 112 """Processes and handles all common options.""" |
108 run_tests_helper.SetLogLevel(args.verbose_count) | 113 run_tests_helper.SetLogLevel(args.verbose_count) |
109 constants.SetBuildType(args.build_type) | 114 constants.SetBuildType(args.build_type) |
110 if args.build_directory: | 115 if args.build_directory: |
111 constants.SetBuildDirectory(args.build_directory) | 116 constants.SetBuildDirectory(args.build_directory) |
112 if args.output_directory: | 117 if args.output_directory: |
113 constants.SetOutputDirectory(args.output_directory) | 118 constants.SetOutputDirectory(args.output_directory) |
114 if args.adb_path: | 119 if args.adb_path: |
115 constants.SetAdbPath(args.adb_path) | 120 constants.SetAdbPath(args.adb_path) |
| 121 |
| 122 output_binary = lambda p: os.path.join(constants.GetOutDirectory(), p) |
| 123 devil_dynamic_deps = { |
| 124 'md5sum_host': [output_binary('md5sum_bin_host')], |
| 125 'md5sum_device': [output_binary('md5sum_dist')], |
| 126 'forwarder_host': [output_binary('host_forwarder')], |
| 127 'forwarder_device': [output_binary('forwarder_dist')], |
| 128 } |
| 129 if args.adb_path: |
| 130 devil_dynamic_deps['adb_path'] = [args.adb_path] |
| 131 |
| 132 devil_dynamic_config = devil_env.GenerateDynamicConfig(devil_dynamic_deps) |
| 133 devil_env.config.Initialize( |
| 134 configs=[devil_dynamic_config], |
| 135 config_files=[_DEVIL_STATIC_CONFIG_FILE]) |
| 136 |
116 # Some things such as Forwarder require ADB to be in the environment path. | 137 # Some things such as Forwarder require ADB to be in the environment path. |
117 adb_dir = os.path.dirname(constants.GetAdbPath()) | 138 adb_dir = os.path.dirname(constants.GetAdbPath()) |
118 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep): | 139 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep): |
119 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH'] | 140 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH'] |
120 | 141 |
121 | 142 |
122 def AddRemoteDeviceOptions(parser): | 143 def AddRemoteDeviceOptions(parser): |
123 group = parser.add_argument_group('Remote Device Options') | 144 group = parser.add_argument_group('Remote Device Options') |
124 | 145 |
125 group.add_argument('--trigger', | 146 group.add_argument('--trigger', |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 if e.is_infra_error: | 1070 if e.is_infra_error: |
1050 return constants.INFRA_EXIT_CODE | 1071 return constants.INFRA_EXIT_CODE |
1051 return constants.ERROR_EXIT_CODE | 1072 return constants.ERROR_EXIT_CODE |
1052 except: # pylint: disable=W0702 | 1073 except: # pylint: disable=W0702 |
1053 logging.exception('Unrecognized error occurred.') | 1074 logging.exception('Unrecognized error occurred.') |
1054 return constants.ERROR_EXIT_CODE | 1075 return constants.ERROR_EXIT_CODE |
1055 | 1076 |
1056 | 1077 |
1057 if __name__ == '__main__': | 1078 if __name__ == '__main__': |
1058 sys.exit(main()) | 1079 sys.exit(main()) |
OLD | NEW |