constants.py revision 3551c9c881056c480085172ff9840cab31610854
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. 4 5"""Defines a set of constants shared by test runners and other scripts.""" 6 7import os 8import subprocess 9import sys 10 11 12DIR_SOURCE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), 13 os.pardir, os.pardir, os.pardir)) 14ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir') 15EMULATOR_SDK_ROOT = os.path.abspath(os.path.join(DIR_SOURCE_ROOT, os.pardir, 16 os.pardir)) 17CHROME_PACKAGE = 'com.google.android.apps.chrome' 18CHROME_ACTIVITY = 'com.google.android.apps.chrome.Main' 19CHROME_DEVTOOLS_SOCKET = 'chrome_devtools_remote' 20 21CHROME_STABLE_PACKAGE = 'com.android.chrome' 22CHROME_BETA_PACKAGE = 'com.chrome.beta' 23 24CHROME_TESTS_PACKAGE = 'com.google.android.apps.chrome.tests' 25 26LEGACY_BROWSER_PACKAGE = 'com.google.android.browser' 27LEGACY_BROWSER_ACTIVITY = 'com.android.browser.BrowserActivity' 28 29CONTENT_SHELL_PACKAGE = 'org.chromium.content_shell_apk' 30CONTENT_SHELL_ACTIVITY = 'org.chromium.content_shell_apk.ContentShellActivity' 31 32CHROME_SHELL_PACKAGE = 'org.chromium.chrome.browser.test' 33 34CHROMIUM_TEST_SHELL_PACKAGE = 'org.chromium.chrome.testshell' 35CHROMIUM_TEST_SHELL_ACTIVITY = ( 36 'org.chromium.chrome.testshell.ChromiumTestShellActivity') 37CHROMIUM_TEST_SHELL_DEVTOOLS_SOCKET = 'chromium_testshell_devtools_remote' 38CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR = os.path.join( 39 DIR_SOURCE_ROOT, 'chrome', 'android') 40 41GTEST_TEST_PACKAGE_NAME = 'org.chromium.native_test' 42GTEST_TEST_ACTIVITY_NAME = 'org.chromium.native_test.ChromeNativeTestActivity' 43GTEST_COMMAND_LINE_FILE = 'chrome-native-tests-command-line' 44 45BROWSERTEST_TEST_PACKAGE_NAME = 'org.chromium.content_browsertests_apk' 46BROWSERTEST_TEST_ACTIVITY_NAME = ( 47 'org.chromium.content_browsertests_apk.ContentBrowserTestsActivity') 48BROWSERTEST_COMMAND_LINE_FILE = 'content-browser-tests-command-line' 49 50# Ports arrangement for various test servers used in Chrome for Android. 51# Lighttpd server will attempt to use 9000 as default port, if unavailable it 52# will find a free port from 8001 - 8999. 53LIGHTTPD_DEFAULT_PORT = 9000 54LIGHTTPD_RANDOM_PORT_FIRST = 8001 55LIGHTTPD_RANDOM_PORT_LAST = 8999 56TEST_SYNC_SERVER_PORT = 9031 57TEST_SEARCH_BY_IMAGE_SERVER_PORT = 9041 58 59# The net test server is started from port 10201. 60# TODO(pliard): http://crbug.com/239014. Remove this dirty workaround once 61# http://crbug.com/239014 is fixed properly. 62TEST_SERVER_PORT_FIRST = 10201 63TEST_SERVER_PORT_LAST = 30000 64# A file to record next valid port of test server. 65TEST_SERVER_PORT_FILE = '/tmp/test_server_port' 66TEST_SERVER_PORT_LOCKFILE = '/tmp/test_server_port.lock' 67 68TEST_EXECUTABLE_DIR = '/data/local/tmp' 69# Directories for common java libraries for SDK build. 70# These constants are defined in build/android/ant/common.xml 71SDK_BUILD_JAVALIB_DIR = 'lib.java' 72SDK_BUILD_TEST_JAVALIB_DIR = 'test.lib.java' 73SDK_BUILD_APKS_DIR = 'apks' 74 75# The directory on the device where perf test output gets saved to. 76DEVICE_PERF_OUTPUT_DIR = '/data/data/' + CHROME_PACKAGE + '/files' 77 78SCREENSHOTS_DIR = os.path.join(DIR_SOURCE_ROOT, 'out_screenshots') 79 80ANDROID_SDK_VERSION = 18 81ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT, 82 'third_party/android_tools/sdk') 83ANDROID_NDK_ROOT = os.path.join(DIR_SOURCE_ROOT, 84 'third_party/android_tools/ndk') 85 86UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com' 87 88 89def GetBuildType(): 90 try: 91 return os.environ['BUILDTYPE'] 92 except KeyError: 93 raise Exception('The BUILDTYPE environment variable has not been set') 94 95 96def SetBuildType(build_type): 97 os.environ['BUILDTYPE'] = build_type 98 99 100def _GetADBPath(): 101 if os.environ.get('ANDROID_SDK_ROOT'): 102 return 'adb' 103 # If envsetup.sh hasn't been sourced and there's no adb in the path, 104 # set it here. 105 try: 106 with file(os.devnull, 'w') as devnull: 107 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) 108 return 'adb' 109 except OSError: 110 print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.' 111 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') 112 113 114ADB_PATH = _GetADBPath() 115 116# Exit codes 117ERROR_EXIT_CODE = 1 118WARNING_EXIT_CODE = 88 119