OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import datetime | 5 import datetime |
6 import functools | 6 import functools |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import tempfile | 10 import tempfile |
11 import threading | 11 import threading |
12 | 12 |
| 13 import devil_chromium |
13 from devil import base_error | 14 from devil import base_error |
14 from devil.android import device_blacklist | 15 from devil.android import device_blacklist |
15 from devil.android import device_errors | 16 from devil.android import device_errors |
16 from devil.android import device_list | 17 from devil.android import device_list |
17 from devil.android import device_utils | 18 from devil.android import device_utils |
18 from devil.android import logcat_monitor | 19 from devil.android import logcat_monitor |
| 20 from devil.android.sdk import adb_wrapper |
19 from devil.utils import file_utils | 21 from devil.utils import file_utils |
20 from devil.utils import parallelizer | 22 from devil.utils import parallelizer |
21 from pylib import constants | 23 from pylib import constants |
22 from pylib.base import environment | 24 from pylib.base import environment |
23 from py_trace_event import trace_event | 25 from py_trace_event import trace_event |
24 from tracing_build import trace2html | 26 from tracing_build import trace2html |
25 | 27 |
26 | 28 |
27 def _DeviceCachePath(device): | 29 def _DeviceCachePath(device): |
28 file_name = 'device_cache_%s.json' % device.adb.GetDeviceSerial() | 30 file_name = 'device_cache_%s.json' % device.adb.GetDeviceSerial() |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 self._enable_device_cache = args.enable_device_cache | 89 self._enable_device_cache = args.enable_device_cache |
88 self._logcat_monitors = [] | 90 self._logcat_monitors = [] |
89 self._logcat_output_dir = args.logcat_output_dir | 91 self._logcat_output_dir = args.logcat_output_dir |
90 self._logcat_output_file = args.logcat_output_file | 92 self._logcat_output_file = args.logcat_output_file |
91 self._max_tries = 1 + args.num_retries | 93 self._max_tries = 1 + args.num_retries |
92 self._skip_clear_data = args.skip_clear_data | 94 self._skip_clear_data = args.skip_clear_data |
93 self._target_devices_file = args.target_devices_file | 95 self._target_devices_file = args.target_devices_file |
94 self._tool_name = args.tool | 96 self._tool_name = args.tool |
95 self._trace_output = args.trace_output | 97 self._trace_output = args.trace_output |
96 | 98 |
| 99 devil_chromium.Initialize( |
| 100 output_directory=constants.GetOutDirectory(), |
| 101 adb_path=args.adb_path) |
| 102 |
| 103 # Some things such as Forwarder require ADB to be in the environment path. |
| 104 adb_dir = os.path.dirname(adb_wrapper.AdbWrapper.GetAdbPath()) |
| 105 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep): |
| 106 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH'] |
| 107 |
97 #override | 108 #override |
98 def SetUp(self): | 109 def SetUp(self): |
99 if self.trace_output: | 110 if self.trace_output: |
100 self.EnableTracing() | 111 self.EnableTracing() |
101 | 112 |
102 def _InitDevices(self): | 113 def _InitDevices(self): |
103 device_arg = 'default' | 114 device_arg = 'default' |
104 if self._target_devices_file: | 115 if self._target_devices_file: |
105 device_arg = device_list.GetPersistentDeviceList( | 116 device_arg = device_list.GetPersistentDeviceList( |
106 self._target_devices_file) | 117 self._target_devices_file) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 else: | 268 else: |
258 trace_event.trace_disable() | 269 trace_event.trace_disable() |
259 self._JsonToTrace(self._trace_output + '.json', | 270 self._JsonToTrace(self._trace_output + '.json', |
260 self._trace_output) | 271 self._trace_output) |
261 | 272 |
262 def EnableTracing(self): | 273 def EnableTracing(self): |
263 if trace_event.trace_is_enabled(): | 274 if trace_event.trace_is_enabled(): |
264 logging.warning('Tracing is already running.') | 275 logging.warning('Tracing is already running.') |
265 else: | 276 else: |
266 trace_event.trace_enable(self._trace_output + '.json') | 277 trace_event.trace_enable(self._trace_output + '.json') |
OLD | NEW |