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."""
14 DIR_SOURCE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
15 os.pardir, os.pardir, os.pardir))
16 ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir')
18 CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR = os.path.join(
19 DIR_SOURCE_ROOT, 'chrome', 'android')
22 PackageInfo = collections.namedtuple('PackageInfo',
23 ['package', 'activity', 'cmdline_file', 'devtools_socket',
27 'chrome': PackageInfo(
28 'com.google.android.apps.chrome',
29 'com.google.android.apps.chrome.Main',
30 '/data/local/chrome-command-line',
31 'chrome_devtools_remote',
32 'com.google.android.apps.chrome.tests'),
33 'chrome_beta': PackageInfo(
35 'com.google.android.apps.chrome.Main',
36 '/data/local/chrome-command-line',
37 'chrome_devtools_remote',
39 'chrome_stable': PackageInfo(
41 'com.google.android.apps.chrome.Main',
42 '/data/local/chrome-command-line',
43 'chrome_devtools_remote',
45 'chrome_dev': PackageInfo(
46 'com.google.android.apps.chrome_dev',
47 'com.google.android.apps.chrome.Main',
48 '/data/local/chrome-command-line',
49 'chrome_devtools_remote',
51 'legacy_browser': PackageInfo(
52 'com.google.android.browser',
53 'com.android.browser.BrowserActivity',
57 'content_shell': PackageInfo(
58 'org.chromium.content_shell_apk',
59 'org.chromium.content_shell_apk.ContentShellActivity',
60 '/data/local/tmp/content-shell-command-line',
62 'org.chromium.content_shell_apk.tests'),
63 'chromium_test_shell': PackageInfo(
64 'org.chromium.chrome.testshell',
65 'org.chromium.chrome.testshell.ChromiumTestShellActivity',
66 '/data/local/tmp/chromium-testshell-command-line',
67 'chromium_testshell_devtools_remote',
68 'org.chromium.chrome.testshell.tests'),
69 'android_webview_shell': PackageInfo(
70 'org.chromium.android_webview.shell',
71 'org.chromium.android_webview.shell.AwShellActivity',
74 'org.chromium.android_webview.test'),
76 'org.chromium.native_test',
77 'org.chromium.native_test.ChromeNativeTestActivity',
78 '/data/local/tmp/chrome-native-tests-command-line',
81 'content_browsertests': PackageInfo(
82 'org.chromium.content_browsertests_apk',
83 'org.chromium.content_browsertests_apk.ContentBrowserTestsActivity',
84 '/data/local/tmp/content-browser-tests-command-line',
87 'chromedriver_webview_shell': PackageInfo(
88 'org.chromium.chromedriver_webview_shell',
89 'org.chromium.chromedriver_webview_shell.Main',
96 # Ports arrangement for various test servers used in Chrome for Android.
97 # Lighttpd server will attempt to use 9000 as default port, if unavailable it
98 # will find a free port from 8001 - 8999.
99 LIGHTTPD_DEFAULT_PORT = 9000
100 LIGHTTPD_RANDOM_PORT_FIRST = 8001
101 LIGHTTPD_RANDOM_PORT_LAST = 8999
102 TEST_SYNC_SERVER_PORT = 9031
103 TEST_SEARCH_BY_IMAGE_SERVER_PORT = 9041
105 # The net test server is started from port 10201.
106 # TODO(pliard): http://crbug.com/239014. Remove this dirty workaround once
107 # http://crbug.com/239014 is fixed properly.
108 TEST_SERVER_PORT_FIRST = 10201
109 TEST_SERVER_PORT_LAST = 30000
110 # A file to record next valid port of test server.
111 TEST_SERVER_PORT_FILE = '/tmp/test_server_port'
112 TEST_SERVER_PORT_LOCKFILE = '/tmp/test_server_port.lock'
114 TEST_EXECUTABLE_DIR = '/data/local/tmp'
115 # Directories for common java libraries for SDK build.
116 # These constants are defined in build/android/ant/common.xml
117 SDK_BUILD_JAVALIB_DIR = 'lib.java'
118 SDK_BUILD_TEST_JAVALIB_DIR = 'test.lib.java'
119 SDK_BUILD_APKS_DIR = 'apks'
121 PERF_OUTPUT_DIR = os.path.join(DIR_SOURCE_ROOT, 'out', 'step_results')
122 # The directory on the device where perf test output gets saved to.
123 DEVICE_PERF_OUTPUT_DIR = (
124 '/data/data/' + PACKAGE_INFO['chrome'].package + '/files')
126 SCREENSHOTS_DIR = os.path.join(DIR_SOURCE_ROOT, 'out_screenshots')
128 ANDROID_SDK_VERSION = 19
129 ANDROID_SDK_BUILD_TOOLS_VERSION = '19.0.0'
130 ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT,
131 'third_party/android_tools/sdk')
132 ANDROID_SDK_TOOLS = os.path.join(ANDROID_SDK_ROOT,
133 'build-tools', ANDROID_SDK_BUILD_TOOLS_VERSION)
134 ANDROID_NDK_ROOT = os.path.join(DIR_SOURCE_ROOT,
135 'third_party/android_tools/ndk')
137 EMULATOR_SDK_ROOT = os.environ.get('ANDROID_EMULATOR_SDK_ROOT',
138 os.path.join(DIR_SOURCE_ROOT,
139 'android_emulator_sdk'))
141 UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com'
146 return os.environ['BUILDTYPE']
148 raise Exception('The BUILDTYPE environment variable has not been set')
151 def SetBuildType(build_type):
152 os.environ['BUILDTYPE'] = build_type
155 def GetOutDirectory(build_type=None):
156 """Returns the out directory where the output binaries are built.
159 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the
160 globally set build type environment variable BUILDTYPE.
162 return os.path.abspath(os.path.join(
163 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'),
164 GetBuildType() if build_type is None else build_type))
171 except AttributeError:
172 func._result = func()
179 if os.environ.get('ANDROID_SDK_ROOT'):
181 # If envsetup.sh hasn't been sourced and there's no adb in the path,
184 with file(os.devnull, 'w') as devnull:
185 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull)
188 logging.debug('No adb found in $PATH, fallback to checked in binary.')
189 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb')
194 WARNING_EXIT_CODE = 88