Chromium Code Reviews| 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 json | |
| 11 import logging | 12 import logging |
| 12 import os | 13 import os |
| 13 import signal | 14 import signal |
| 14 import sys | 15 import sys |
| 15 import threading | 16 import threading |
| 17 import tempfile | |
| 16 import unittest | 18 import unittest |
| 17 | 19 |
| 18 from devil import base_error | 20 from devil import base_error |
| 21 from devil import devil_env | |
| 19 from devil.android import apk_helper | 22 from devil.android import apk_helper |
| 20 from devil.android import device_blacklist | 23 from devil.android import device_blacklist |
| 21 from devil.android import device_errors | 24 from devil.android import device_errors |
| 22 from devil.android import device_utils | 25 from devil.android import device_utils |
| 23 from devil.android import ports | 26 from devil.android import ports |
| 24 from devil.utils import reraiser_thread | 27 from devil.utils import reraiser_thread |
| 25 from devil.utils import run_tests_helper | 28 from devil.utils import run_tests_helper |
| 26 | 29 |
| 27 from pylib import constants | 30 from pylib import constants |
| 28 from pylib import forwarder | 31 from pylib import forwarder |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 46 from pylib.monkey import test_options as monkey_test_options | 49 from pylib.monkey import test_options as monkey_test_options |
| 47 from pylib.perf import setup as perf_setup | 50 from pylib.perf import setup as perf_setup |
| 48 from pylib.perf import test_options as perf_test_options | 51 from pylib.perf import test_options as perf_test_options |
| 49 from pylib.perf import test_runner as perf_test_runner | 52 from pylib.perf import test_runner as perf_test_runner |
| 50 from pylib.results import json_results | 53 from pylib.results import json_results |
| 51 from pylib.results import report_results | 54 from pylib.results import report_results |
| 52 from pylib.uiautomator import setup as uiautomator_setup | 55 from pylib.uiautomator import setup as uiautomator_setup |
| 53 from pylib.uiautomator import test_options as uiautomator_test_options | 56 from pylib.uiautomator import test_options as uiautomator_test_options |
| 54 | 57 |
| 55 | 58 |
| 59 _DEVIL_STATIC_CONFIG_FILE = os.path.abspath(os.path.join( | |
| 60 constants.DIR_SOURCE_ROOT, 'build', 'android', 'devil_config.json')) | |
| 61 | |
| 62 | |
| 56 def AddCommonOptions(parser): | 63 def AddCommonOptions(parser): |
| 57 """Adds all common options to |parser|.""" | 64 """Adds all common options to |parser|.""" |
| 58 | 65 |
| 59 group = parser.add_argument_group('Common Options') | 66 group = parser.add_argument_group('Common Options') |
| 60 | 67 |
| 61 default_build_type = os.environ.get('BUILDTYPE', 'Debug') | 68 default_build_type = os.environ.get('BUILDTYPE', 'Debug') |
| 62 | 69 |
| 63 debug_or_release_group = group.add_mutually_exclusive_group() | 70 debug_or_release_group = group.add_mutually_exclusive_group() |
| 64 debug_or_release_group.add_argument( | 71 debug_or_release_group.add_argument( |
| 65 '--debug', action='store_const', const='Debug', dest='build_type', | 72 '--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): | 117 def ProcessCommonOptions(args): |
| 111 """Processes and handles all common options.""" | 118 """Processes and handles all common options.""" |
| 112 run_tests_helper.SetLogLevel(args.verbose_count) | 119 run_tests_helper.SetLogLevel(args.verbose_count) |
| 113 constants.SetBuildType(args.build_type) | 120 constants.SetBuildType(args.build_type) |
| 114 if args.build_directory: | 121 if args.build_directory: |
| 115 constants.SetBuildDirectory(args.build_directory) | 122 constants.SetBuildDirectory(args.build_directory) |
| 116 if args.output_directory: | 123 if args.output_directory: |
| 117 constants.SetOutputDirectory(args.output_directory) | 124 constants.SetOutputDirectory(args.output_directory) |
| 118 if args.adb_path: | 125 if args.adb_path: |
| 119 constants.SetAdbPath(args.adb_path) | 126 constants.SetAdbPath(args.adb_path) |
| 127 | |
| 128 output_binary = lambda p: os.path.join(args.output_directory, p) | |
| 129 devil_dynamic_deps = { | |
| 130 'md5sum_host': output_binary('md5sum_bin_host'), | |
| 131 'md5sum_device': output_binary('md5sum_dist'), | |
| 132 'forwarder_host': output_binary('host_forwarder'), | |
| 133 'forwarder_device': output_binary('forwarder_dist'), | |
| 134 } | |
| 135 if args.adb_path: | |
| 136 devil_dynamic_deps['adb_path'] = args.adb_path | |
| 137 | |
| 138 with tempfile.NamedTemporaryFile() as devil_dynamic_config_file: | |
|
perezju
2015/09/14 09:13:58
Could we hide this tempfile thing in devil_env?
jbudorick
2015/09/14 13:12:39
I need to talk to Kari about doing dynamic config
| |
| 139 devil_dynamic_config_file.write( | |
| 140 json.dumps(devil_env.GenerateDynamicConfig(devil_dynamic_deps))) | |
| 141 devil_dynamic_config_file.flush() | |
| 142 devil_env.Initialize([ | |
| 143 _DEVIL_STATIC_CONFIG_FILE, | |
| 144 devil_dynamic_config_file.name | |
| 145 ]) | |
| 146 | |
| 120 # Some things such as Forwarder require ADB to be in the environment path. | 147 # Some things such as Forwarder require ADB to be in the environment path. |
| 121 adb_dir = os.path.dirname(constants.GetAdbPath()) | 148 adb_dir = os.path.dirname(constants.GetAdbPath()) |
| 122 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep): | 149 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'] | 150 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH'] |
| 124 | 151 |
| 125 | 152 |
| 126 def AddRemoteDeviceOptions(parser): | 153 def AddRemoteDeviceOptions(parser): |
| 127 group = parser.add_argument_group('Remote Device Options') | 154 group = parser.add_argument_group('Remote Device Options') |
| 128 | 155 |
| 129 group.add_argument('--trigger', | 156 group.add_argument('--trigger', |
| (...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1065 if e.is_infra_error: | 1092 if e.is_infra_error: |
| 1066 return constants.INFRA_EXIT_CODE | 1093 return constants.INFRA_EXIT_CODE |
| 1067 return constants.ERROR_EXIT_CODE | 1094 return constants.ERROR_EXIT_CODE |
| 1068 except: # pylint: disable=W0702 | 1095 except: # pylint: disable=W0702 |
| 1069 logging.exception('Unrecognized error occurred.') | 1096 logging.exception('Unrecognized error occurred.') |
| 1070 return constants.ERROR_EXIT_CODE | 1097 return constants.ERROR_EXIT_CODE |
| 1071 | 1098 |
| 1072 | 1099 |
| 1073 if __name__ == '__main__': | 1100 if __name__ == '__main__': |
| 1074 sys.exit(main()) | 1101 sys.exit(main()) |
| OLD | NEW |