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