OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Defines a set of constants shared by test runners and other scripts.""" | 5 """Defines a set of constants shared by test runners and other scripts.""" |
6 # pylint: disable=W0212 | 6 # pylint: disable=W0212 |
7 | 7 |
8 import collections | 8 import collections |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com' | 181 UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com' |
182 | 182 |
183 DEVICE_LOCAL_PROPERTIES_PATH = '/data/local.prop' | 183 DEVICE_LOCAL_PROPERTIES_PATH = '/data/local.prop' |
184 | 184 |
185 PYTHON_UNIT_TEST_SUITES = { | 185 PYTHON_UNIT_TEST_SUITES = { |
186 'pylib_py_unittests': { | 186 'pylib_py_unittests': { |
187 'path': os.path.join(DIR_SOURCE_ROOT, 'build', 'android'), | 187 'path': os.path.join(DIR_SOURCE_ROOT, 'build', 'android'), |
188 'test_modules': [ | 188 'test_modules': [ |
189 'pylib.device.device_utils_test', | 189 'pylib.device.device_utils_test', |
| 190 'pylib.utils.md5sum_test', |
190 ] | 191 ] |
191 }, | 192 }, |
192 'gyp_py_unittests': { | 193 'gyp_py_unittests': { |
193 'path': os.path.join(DIR_SOURCE_ROOT, 'build', 'android', 'gyp'), | 194 'path': os.path.join(DIR_SOURCE_ROOT, 'build', 'android', 'gyp'), |
194 'test_modules': [ | 195 'test_modules': [ |
195 'java_cpp_enum_tests', | 196 'java_cpp_enum_tests', |
196 ] | 197 ] |
197 }, | 198 }, |
198 } | 199 } |
199 | 200 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 def _Memoize(func): | 240 def _Memoize(func): |
240 def Wrapper(): | 241 def Wrapper(): |
241 try: | 242 try: |
242 return func._result | 243 return func._result |
243 except AttributeError: | 244 except AttributeError: |
244 func._result = func() | 245 func._result = func() |
245 return func._result | 246 return func._result |
246 return Wrapper | 247 return Wrapper |
247 | 248 |
248 | 249 |
| 250 def SetAdbPath(adb_path): |
| 251 os.environ['ADB_PATH'] = adb_path |
| 252 |
| 253 |
| 254 def GetAdbPath(): |
| 255 # Check if a custom adb path as been set. If not, try to find adb |
| 256 # on the system. |
| 257 if os.environ.get('ADB_PATH'): |
| 258 return os.environ.get('ADB_PATH') |
| 259 else: |
| 260 return _FindAdbPath() |
| 261 |
| 262 |
249 @_Memoize | 263 @_Memoize |
250 def GetAdbPath(): | 264 def _FindAdbPath(): |
251 if os.environ.get('ANDROID_SDK_ROOT'): | 265 if os.environ.get('ANDROID_SDK_ROOT'): |
252 return 'adb' | 266 return 'adb' |
253 # If envsetup.sh hasn't been sourced and there's no adb in the path, | 267 # If envsetup.sh hasn't been sourced and there's no adb in the path, |
254 # set it here. | 268 # set it here. |
255 try: | 269 try: |
256 with file(os.devnull, 'w') as devnull: | 270 with file(os.devnull, 'w') as devnull: |
257 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) | 271 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) |
258 return 'adb' | 272 return 'adb' |
259 except OSError: | 273 except OSError: |
260 logging.debug('No adb found in $PATH, fallback to checked in binary.') | 274 logging.debug('No adb found in $PATH, fallback to checked in binary.') |
261 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') | 275 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') |
262 | 276 |
263 | |
264 # Exit codes | 277 # Exit codes |
265 ERROR_EXIT_CODE = 1 | 278 ERROR_EXIT_CODE = 1 |
266 WARNING_EXIT_CODE = 88 | 279 WARNING_EXIT_CODE = 88 |
OLD | NEW |