2012-07-10 17:21:43 +04:00
|
|
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
"""Defines a set of constants shared by test runners and other scripts."""
|
|
|
|
|
2013-08-29 20:26:02 +04:00
|
|
|
import collections
|
2012-07-10 17:21:43 +04:00
|
|
|
import os
|
2013-06-06 01:16:21 +04:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2012-07-10 17:21:43 +04:00
|
|
|
|
|
|
|
|
2013-06-06 03:28:09 +04:00
|
|
|
DIR_SOURCE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
|
|
|
os.pardir, os.pardir, os.pardir))
|
2013-07-16 07:57:39 +04:00
|
|
|
ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir')
|
2013-08-29 20:26:02 +04:00
|
|
|
|
2013-02-14 23:29:17 +04:00
|
|
|
CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR = os.path.join(
|
2013-06-06 03:28:09 +04:00
|
|
|
DIR_SOURCE_ROOT, 'chrome', 'android')
|
2012-07-10 17:21:43 +04:00
|
|
|
|
2013-02-22 06:26:14 +04:00
|
|
|
|
2013-08-29 20:26:02 +04:00
|
|
|
PackageInfo = collections.namedtuple('PackageInfo',
|
|
|
|
['package', 'activity', 'cmdline_file', 'devtools_socket',
|
|
|
|
'test_package'])
|
|
|
|
|
|
|
|
PACKAGE_INFO = {
|
|
|
|
'chrome': PackageInfo(
|
2013-09-18 00:17:08 +04:00
|
|
|
'com.google.android.apps.chrome',
|
|
|
|
'com.google.android.apps.chrome.Main',
|
2013-08-29 20:26:02 +04:00
|
|
|
'/data/local/chrome-command-line',
|
|
|
|
'chrome_devtools_remote',
|
|
|
|
'com.google.android.apps.chrome.tests'),
|
2013-09-18 00:17:08 +04:00
|
|
|
'chrome_beta': PackageInfo(
|
|
|
|
'com.chrome.beta',
|
2013-09-21 01:03:14 +04:00
|
|
|
'com.google.android.apps.chrome.Main',
|
2013-09-18 00:17:08 +04:00
|
|
|
'/data/local/chrome-command-line',
|
|
|
|
'chrome_devtools_remote',
|
|
|
|
None),
|
|
|
|
'chrome_stable': PackageInfo(
|
|
|
|
'com.android.chrome',
|
2013-09-21 01:03:14 +04:00
|
|
|
'com.google.android.apps.chrome.Main',
|
2013-10-01 21:45:20 +04:00
|
|
|
'/data/local/chrome-command-line',
|
|
|
|
'chrome_devtools_remote',
|
|
|
|
None),
|
|
|
|
'chrome_dev': PackageInfo(
|
|
|
|
'com.google.android.apps.chrome_dev',
|
|
|
|
'com.google.android.apps.chrome.Main',
|
2013-09-18 00:17:08 +04:00
|
|
|
'/data/local/chrome-command-line',
|
|
|
|
'chrome_devtools_remote',
|
|
|
|
None),
|
2013-08-29 20:26:02 +04:00
|
|
|
'legacy_browser': PackageInfo(
|
2013-09-18 00:17:08 +04:00
|
|
|
'com.google.android.browser',
|
|
|
|
'com.android.browser.BrowserActivity',
|
2013-08-29 20:26:02 +04:00
|
|
|
None,
|
|
|
|
None,
|
|
|
|
None),
|
|
|
|
'content_shell': PackageInfo(
|
2013-09-18 00:17:08 +04:00
|
|
|
'org.chromium.content_shell_apk',
|
|
|
|
'org.chromium.content_shell_apk.ContentShellActivity',
|
2013-08-29 20:26:02 +04:00
|
|
|
'/data/local/tmp/content-shell-command-line',
|
|
|
|
None,
|
|
|
|
None),
|
|
|
|
'chromium_test_shell': PackageInfo(
|
2013-09-18 00:17:08 +04:00
|
|
|
'org.chromium.chrome.testshell',
|
|
|
|
'org.chromium.chrome.testshell.ChromiumTestShellActivity',
|
2013-08-29 20:26:02 +04:00
|
|
|
'/data/local/tmp/chromium-testshell-command-line',
|
2013-09-18 00:17:08 +04:00
|
|
|
'chromium_testshell_devtools_remote',
|
2013-08-29 20:26:02 +04:00
|
|
|
'org.chromium.chrome.testshell.tests'),
|
|
|
|
'gtest': PackageInfo(
|
|
|
|
'org.chromium.native_test',
|
|
|
|
'org.chromium.native_test.ChromeNativeTestActivity',
|
|
|
|
'/data/local/tmp/chrome-native-tests-command-line',
|
|
|
|
None,
|
|
|
|
None),
|
|
|
|
'content_browsertests': PackageInfo(
|
|
|
|
'org.chromium.content_browsertests_apk',
|
|
|
|
'org.chromium.content_browsertests_apk.ContentBrowserTestsActivity',
|
|
|
|
'/data/local/tmp/content-browser-tests-command-line',
|
|
|
|
None,
|
|
|
|
None),
|
|
|
|
}
|
|
|
|
|
2013-02-22 06:26:14 +04:00
|
|
|
|
2012-08-31 18:42:49 +04:00
|
|
|
# Ports arrangement for various test servers used in Chrome for Android.
|
2012-07-10 17:21:43 +04:00
|
|
|
# Lighttpd server will attempt to use 9000 as default port, if unavailable it
|
|
|
|
# will find a free port from 8001 - 8999.
|
|
|
|
LIGHTTPD_DEFAULT_PORT = 9000
|
|
|
|
LIGHTTPD_RANDOM_PORT_FIRST = 8001
|
|
|
|
LIGHTTPD_RANDOM_PORT_LAST = 8999
|
|
|
|
TEST_SYNC_SERVER_PORT = 9031
|
2013-08-23 02:50:55 +04:00
|
|
|
TEST_SEARCH_BY_IMAGE_SERVER_PORT = 9041
|
2012-07-10 17:21:43 +04:00
|
|
|
|
2013-05-13 16:48:06 +04:00
|
|
|
# The net test server is started from port 10201.
|
|
|
|
# TODO(pliard): http://crbug.com/239014. Remove this dirty workaround once
|
|
|
|
# http://crbug.com/239014 is fixed properly.
|
|
|
|
TEST_SERVER_PORT_FIRST = 10201
|
2012-07-10 17:21:43 +04:00
|
|
|
TEST_SERVER_PORT_LAST = 30000
|
|
|
|
# A file to record next valid port of test server.
|
|
|
|
TEST_SERVER_PORT_FILE = '/tmp/test_server_port'
|
2012-08-20 23:30:17 +04:00
|
|
|
TEST_SERVER_PORT_LOCKFILE = '/tmp/test_server_port.lock'
|
2012-08-29 22:01:09 +04:00
|
|
|
|
|
|
|
TEST_EXECUTABLE_DIR = '/data/local/tmp'
|
2012-09-19 22:19:18 +04:00
|
|
|
# Directories for common java libraries for SDK build.
|
|
|
|
# These constants are defined in build/android/ant/common.xml
|
2013-04-03 21:33:57 +04:00
|
|
|
SDK_BUILD_JAVALIB_DIR = 'lib.java'
|
2012-09-19 22:19:18 +04:00
|
|
|
SDK_BUILD_TEST_JAVALIB_DIR = 'test.lib.java'
|
|
|
|
SDK_BUILD_APKS_DIR = 'apks'
|
2012-10-16 20:23:30 +04:00
|
|
|
|
2013-09-06 21:37:27 +04:00
|
|
|
PERF_OUTPUT_DIR = os.path.join(DIR_SOURCE_ROOT, 'out', 'step_results')
|
2012-10-16 20:23:30 +04:00
|
|
|
# The directory on the device where perf test output gets saved to.
|
2013-09-18 00:17:08 +04:00
|
|
|
DEVICE_PERF_OUTPUT_DIR = (
|
|
|
|
'/data/data/' + PACKAGE_INFO['chrome'].package + '/files')
|
2012-11-07 01:44:58 +04:00
|
|
|
|
2013-06-06 03:28:09 +04:00
|
|
|
SCREENSHOTS_DIR = os.path.join(DIR_SOURCE_ROOT, 'out_screenshots')
|
2013-01-09 07:49:57 +04:00
|
|
|
|
2013-08-09 10:48:18 +04:00
|
|
|
ANDROID_SDK_VERSION = 18
|
2013-06-06 03:28:09 +04:00
|
|
|
ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT,
|
|
|
|
'third_party/android_tools/sdk')
|
|
|
|
ANDROID_NDK_ROOT = os.path.join(DIR_SOURCE_ROOT,
|
|
|
|
'third_party/android_tools/ndk')
|
2013-01-19 07:55:22 +04:00
|
|
|
|
2013-10-05 03:01:59 +04:00
|
|
|
EMULATOR_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT, 'android_emulator_sdk')
|
|
|
|
|
2013-01-19 07:55:22 +04:00
|
|
|
UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com'
|
2013-06-06 01:16:21 +04:00
|
|
|
|
|
|
|
|
2013-08-16 02:25:28 +04:00
|
|
|
def GetBuildType():
|
|
|
|
try:
|
2013-08-17 00:37:02 +04:00
|
|
|
return os.environ['BUILDTYPE']
|
2013-08-16 02:25:28 +04:00
|
|
|
except KeyError:
|
2013-08-17 00:37:02 +04:00
|
|
|
raise Exception('The BUILDTYPE environment variable has not been set')
|
2013-08-16 02:25:28 +04:00
|
|
|
|
|
|
|
|
|
|
|
def SetBuildType(build_type):
|
2013-08-17 00:37:02 +04:00
|
|
|
os.environ['BUILDTYPE'] = build_type
|
2013-08-16 02:25:28 +04:00
|
|
|
|
|
|
|
|
2013-09-10 22:29:03 +04:00
|
|
|
def GetOutDirectory(build_type=None):
|
|
|
|
"""Returns the out directory where the output binaries are built.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
build_type: Build type, generally 'Debug' or 'Release'. Defaults to the
|
|
|
|
globally set build type environment variable BUILDTYPE.
|
|
|
|
"""
|
|
|
|
return os.path.abspath(os.path.join(
|
|
|
|
DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'),
|
|
|
|
GetBuildType() if build_type is None else build_type))
|
|
|
|
|
|
|
|
|
2013-06-06 01:16:21 +04:00
|
|
|
def _GetADBPath():
|
|
|
|
if os.environ.get('ANDROID_SDK_ROOT'):
|
|
|
|
return 'adb'
|
|
|
|
# If envsetup.sh hasn't been sourced and there's no adb in the path,
|
|
|
|
# set it here.
|
|
|
|
try:
|
|
|
|
with file(os.devnull, 'w') as devnull:
|
|
|
|
subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull)
|
|
|
|
return 'adb'
|
|
|
|
except OSError:
|
2013-07-09 18:27:12 +04:00
|
|
|
print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.'
|
2013-06-06 01:16:21 +04:00
|
|
|
return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb')
|
|
|
|
|
|
|
|
|
|
|
|
ADB_PATH = _GetADBPath()
|
2013-07-10 08:57:10 +04:00
|
|
|
|
|
|
|
# Exit codes
|
|
|
|
ERROR_EXIT_CODE = 1
|
|
|
|
WARNING_EXIT_CODE = 88
|