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
3 # found in the LICENSE file.
5 """Defines a set of constants shared by test runners and other scripts."""
6 # pylint: disable=W0212
14 DIR_SOURCE_ROOT = os.environ.get('CHECKOUT_SOURCE_ROOT',
15 os.path.abspath(os.path.join(os.path.dirname(__file__),
16 os.pardir, os.pardir, os.pardir)))
17 ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir')
19 CHROME_SHELL_HOST_DRIVEN_DIR = os.path.join(
20 DIR_SOURCE_ROOT, 'chrome', 'android')
23 PackageInfo = collections.namedtuple('PackageInfo',
24 ['package', 'activity', 'cmdline_file', 'devtools_socket',
28 'chrome_document': PackageInfo(
29 'com.google.android.apps.chrome.document',
30 'com.google.android.apps.chrome.document.ChromeLauncherActivity',
31 '/data/local/chrome-command-line',
32 'chrome_devtools_remote',
34 'chrome': PackageInfo(
35 'com.google.android.apps.chrome',
36 'com.google.android.apps.chrome.Main',
37 '/data/local/chrome-command-line',
38 'chrome_devtools_remote',
39 'com.google.android.apps.chrome.tests'),
40 'chrome_beta': PackageInfo(
42 'com.google.android.apps.chrome.Main',
43 '/data/local/chrome-command-line',
44 'chrome_devtools_remote',
46 'chrome_stable': PackageInfo(
48 'com.google.android.apps.chrome.Main',
49 '/data/local/chrome-command-line',
50 'chrome_devtools_remote',
52 'chrome_dev': PackageInfo(
53 'com.google.android.apps.chrome_dev',
54 'com.google.android.apps.chrome.Main',
55 '/data/local/chrome-command-line',
56 'chrome_devtools_remote',
58 'chrome_canary': PackageInfo(
60 'com.google.android.apps.chrome.Main',
61 '/data/local/chrome-command-line',
62 'chrome_devtools_remote',
64 'legacy_browser': PackageInfo(
65 'com.google.android.browser',
66 'com.android.browser.BrowserActivity',
70 'content_shell': PackageInfo(
71 'org.chromium.content_shell_apk',
72 'org.chromium.content_shell_apk.ContentShellActivity',
73 '/data/local/tmp/content-shell-command-line',
75 'org.chromium.content_shell_apk.tests'),
76 'chrome_shell': PackageInfo(
77 'org.chromium.chrome.shell',
78 'org.chromium.chrome.shell.ChromeShellActivity',
79 '/data/local/tmp/chrome-shell-command-line',
80 'chrome_shell_devtools_remote',
81 'org.chromium.chrome.shell.tests'),
82 'android_webview_shell': PackageInfo(
83 'org.chromium.android_webview.shell',
84 'org.chromium.android_webview.shell.AwShellActivity',
87 'org.chromium.android_webview.test'),
89 'org.chromium.native_test',
90 'org.chromium.native_test.ChromeNativeTestActivity',
91 '/data/local/tmp/chrome-native-tests-command-line',
94 'content_browsertests': PackageInfo(
95 'org.chromium.content_browsertests_apk',
96 'org.chromium.content_browsertests_apk.ContentBrowserTestsActivity',
97 '/data/local/tmp/content-browser-tests-command-line',
100 'chromedriver_webview_shell': PackageInfo(
101 'org.chromium.chromedriver_webview_shell',
102 'org.chromium.chromedriver_webview_shell.Main',
109 # Ports arrangement for various test servers used in Chrome for Android.
110 # Lighttpd server will attempt to use 9000 as default port, if unavailable it
111 # will find a free port from 8001 - 8999.
112 LIGHTTPD_DEFAULT_PORT = 9000
113 LIGHTTPD_RANDOM_PORT_FIRST = 8001
114 LIGHTTPD_RANDOM_PORT_LAST = 8999
115 TEST_SYNC_SERVER_PORT = 9031
116 TEST_SEARCH_BY_IMAGE_SERVER_PORT = 9041
118 # The net test server is started from port 10201.
119 # TODO(pliard): http://crbug.com/239014. Remove this dirty workaround once
120 # http://crbug.com/239014 is fixed properly.
121 TEST_SERVER_PORT_FIRST = 10201
122 TEST_SERVER_PORT_LAST = 30000
123 # A file to record next valid port of test server.
124 TEST_SERVER_PORT_FILE = '/tmp/test_server_port'
125 TEST_SERVER_PORT_LOCKFILE = '/tmp/test_server_port.lock'
127 TEST_EXECUTABLE_DIR = '/data/local/tmp'
128 # Directories for common java libraries for SDK build.
129 # These constants are defined in build/android/ant/common.xml
130 SDK_BUILD_JAVALIB_DIR = 'lib.java'
131 SDK_BUILD_TEST_JAVALIB_DIR = 'test.lib.java'
132 SDK_BUILD_APKS_DIR = 'apks'
134 ADB_KEYS_FILE = '/data/misc/adb/adb_keys'
136 PERF_OUTPUT_DIR = os.path.join(DIR_SOURCE_ROOT, 'out', 'step_results')
137 # The directory on the device where perf test output gets saved to.
138 DEVICE_PERF_OUTPUT_DIR = (
139 '/data/data/' + PACKAGE_INFO['chrome'].package + '/files')
141 SCREENSHOTS_DIR = os.path.join(DIR_SOURCE_ROOT, 'out_screenshots')
143 ANDROID_SDK_VERSION = 20
144 ANDROID_SDK_BUILD_TOOLS_VERSION = '20.0.0'
145 ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT,
146 'third_party/android_tools/sdk')
147 ANDROID_SDK_TOOLS = os.path.join(ANDROID_SDK_ROOT,
148 'build-tools', ANDROID_SDK_BUILD_TOOLS_VERSION)
149 ANDROID_NDK_ROOT = os.path.join(DIR_SOURCE_ROOT,
150 'third_party/android_tools/ndk')
152 EMULATOR_SDK_ROOT = os.environ.get('ANDROID_EMULATOR_SDK_ROOT',
153 os.path.join(DIR_SOURCE_ROOT,
154 'android_emulator_sdk'))
156 BAD_DEVICES_JSON = os.path.join(DIR_SOURCE_ROOT,
157 os.environ.get('CHROMIUM_OUT_DIR', 'out'),
160 UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com'
162 DEVICE_LOCAL_PROPERTIES_PATH = '/data/local.prop'
166 return os.environ['BUILDTYPE']
168 raise Exception('The BUILDTYPE environment variable has not been set')
171 def SetBuildType(build_type):
172 os.environ['BUILDTYPE'] = build_type
175 def GetOutDirectory(build_type=None):
176 """Returns the out directory where the output binaries are built.
179 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the
180 globally set build type environment variable BUILDTYPE.
182 return os.path.abspath(os.path.join(
183 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'),
184 GetBuildType() if build_type is None else build_type))
191 except AttributeError:
192 func._result = func()
199 if os.environ.get('ANDROID_SDK_ROOT'):
201 # If envsetup.sh hasn't been sourced and there's no adb in the path,
204 with file(os.devnull, 'w') as devnull:
205 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull)
208 logging.debug('No adb found in $PATH, fallback to checked in binary.')
209 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb')
214 WARNING_EXIT_CODE = 88