Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 | |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 7 | import collections |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 8 | import os |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 9 | import subprocess |
| 10 | import sys |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 11 | |
| 12 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 13 | DIR_SOURCE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), |
| 14 | os.pardir, os.pardir, os.pardir)) |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 15 | ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir') |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 16 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 17 | CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR = os.path.join( |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 18 | DIR_SOURCE_ROOT, 'chrome', 'android') |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 19 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 20 | |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 21 | PackageInfo = collections.namedtuple('PackageInfo', |
| 22 | ['package', 'activity', 'cmdline_file', 'devtools_socket', |
| 23 | 'test_package']) |
| 24 | |
| 25 | PACKAGE_INFO = { |
| 26 | 'chrome': PackageInfo( |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 27 | 'com.google.android.apps.chrome', |
| 28 | 'com.google.android.apps.chrome.Main', |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 29 | '/data/local/chrome-command-line', |
| 30 | 'chrome_devtools_remote', |
| 31 | 'com.google.android.apps.chrome.tests'), |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 32 | 'chrome_beta': PackageInfo( |
| 33 | 'com.chrome.beta', |
Torne (Richard Coles) | 68043e1 | 2013-09-26 13:24:57 +0100 | [diff] [blame] | 34 | 'com.google.android.apps.chrome.Main', |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 35 | '/data/local/chrome-command-line', |
| 36 | 'chrome_devtools_remote', |
| 37 | None), |
| 38 | 'chrome_stable': PackageInfo( |
| 39 | 'com.android.chrome', |
Torne (Richard Coles) | 68043e1 | 2013-09-26 13:24:57 +0100 | [diff] [blame] | 40 | 'com.google.android.apps.chrome.Main', |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 41 | '/data/local/chrome-command-line', |
| 42 | 'chrome_devtools_remote', |
| 43 | None), |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame^] | 44 | 'chrome_dev': PackageInfo( |
| 45 | 'com.google.android.apps.chrome_dev', |
| 46 | 'com.google.android.apps.chrome.Main', |
| 47 | '/data/local/chrome-command-line', |
| 48 | 'chrome_devtools_remote', |
| 49 | None), |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 50 | 'legacy_browser': PackageInfo( |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 51 | 'com.google.android.browser', |
| 52 | 'com.android.browser.BrowserActivity', |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 53 | None, |
| 54 | None, |
| 55 | None), |
| 56 | 'content_shell': PackageInfo( |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 57 | 'org.chromium.content_shell_apk', |
| 58 | 'org.chromium.content_shell_apk.ContentShellActivity', |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 59 | '/data/local/tmp/content-shell-command-line', |
| 60 | None, |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame^] | 61 | 'org.chromium.content_shell_apk.tests'), |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 62 | 'chromium_test_shell': PackageInfo( |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 63 | 'org.chromium.chrome.testshell', |
| 64 | 'org.chromium.chrome.testshell.ChromiumTestShellActivity', |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 65 | '/data/local/tmp/chromium-testshell-command-line', |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 66 | 'chromium_testshell_devtools_remote', |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 67 | 'org.chromium.chrome.testshell.tests'), |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame^] | 68 | 'android_webview_shell': PackageInfo( |
| 69 | 'org.chromium.android_webview.shell', |
| 70 | 'org.chromium.android_webview.shell.AwShellActivity', |
| 71 | None, |
| 72 | None, |
| 73 | 'org.chromium.android_webview.test'), |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 74 | 'gtest': PackageInfo( |
| 75 | 'org.chromium.native_test', |
| 76 | 'org.chromium.native_test.ChromeNativeTestActivity', |
| 77 | '/data/local/tmp/chrome-native-tests-command-line', |
| 78 | None, |
| 79 | None), |
| 80 | 'content_browsertests': PackageInfo( |
| 81 | 'org.chromium.content_browsertests_apk', |
| 82 | 'org.chromium.content_browsertests_apk.ContentBrowserTestsActivity', |
| 83 | '/data/local/tmp/content-browser-tests-command-line', |
| 84 | None, |
| 85 | None), |
| 86 | } |
| 87 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 88 | |
| 89 | # Ports arrangement for various test servers used in Chrome for Android. |
| 90 | # Lighttpd server will attempt to use 9000 as default port, if unavailable it |
| 91 | # will find a free port from 8001 - 8999. |
| 92 | LIGHTTPD_DEFAULT_PORT = 9000 |
| 93 | LIGHTTPD_RANDOM_PORT_FIRST = 8001 |
| 94 | LIGHTTPD_RANDOM_PORT_LAST = 8999 |
| 95 | TEST_SYNC_SERVER_PORT = 9031 |
Torne (Richard Coles) | 3551c9c | 2013-08-23 16:39:15 +0100 | [diff] [blame] | 96 | TEST_SEARCH_BY_IMAGE_SERVER_PORT = 9041 |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 97 | |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 98 | # The net test server is started from port 10201. |
| 99 | # TODO(pliard): http://crbug.com/239014. Remove this dirty workaround once |
| 100 | # http://crbug.com/239014 is fixed properly. |
| 101 | TEST_SERVER_PORT_FIRST = 10201 |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 102 | TEST_SERVER_PORT_LAST = 30000 |
| 103 | # A file to record next valid port of test server. |
| 104 | TEST_SERVER_PORT_FILE = '/tmp/test_server_port' |
| 105 | TEST_SERVER_PORT_LOCKFILE = '/tmp/test_server_port.lock' |
| 106 | |
| 107 | TEST_EXECUTABLE_DIR = '/data/local/tmp' |
| 108 | # Directories for common java libraries for SDK build. |
| 109 | # These constants are defined in build/android/ant/common.xml |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 110 | SDK_BUILD_JAVALIB_DIR = 'lib.java' |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 111 | SDK_BUILD_TEST_JAVALIB_DIR = 'test.lib.java' |
| 112 | SDK_BUILD_APKS_DIR = 'apks' |
| 113 | |
Torne (Richard Coles) | 58537e2 | 2013-09-12 12:10:22 +0100 | [diff] [blame] | 114 | PERF_OUTPUT_DIR = os.path.join(DIR_SOURCE_ROOT, 'out', 'step_results') |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 115 | # The directory on the device where perf test output gets saved to. |
Torne (Richard Coles) | d0247b1 | 2013-09-19 22:36:51 +0100 | [diff] [blame] | 116 | DEVICE_PERF_OUTPUT_DIR = ( |
| 117 | '/data/data/' + PACKAGE_INFO['chrome'].package + '/files') |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 118 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 119 | SCREENSHOTS_DIR = os.path.join(DIR_SOURCE_ROOT, 'out_screenshots') |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 120 | |
Ben Murdoch | ba5b9a6 | 2013-08-12 14:20:17 +0100 | [diff] [blame] | 121 | ANDROID_SDK_VERSION = 18 |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 122 | ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT, |
| 123 | 'third_party/android_tools/sdk') |
| 124 | ANDROID_NDK_ROOT = os.path.join(DIR_SOURCE_ROOT, |
| 125 | 'third_party/android_tools/ndk') |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 126 | |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame^] | 127 | EMULATOR_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT, 'android_emulator_sdk') |
| 128 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 129 | UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com' |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 130 | |
| 131 | |
Torne (Richard Coles) | 3551c9c | 2013-08-23 16:39:15 +0100 | [diff] [blame] | 132 | def GetBuildType(): |
| 133 | try: |
| 134 | return os.environ['BUILDTYPE'] |
| 135 | except KeyError: |
| 136 | raise Exception('The BUILDTYPE environment variable has not been set') |
| 137 | |
| 138 | |
| 139 | def SetBuildType(build_type): |
| 140 | os.environ['BUILDTYPE'] = build_type |
| 141 | |
| 142 | |
Torne (Richard Coles) | 58537e2 | 2013-09-12 12:10:22 +0100 | [diff] [blame] | 143 | def GetOutDirectory(build_type=None): |
| 144 | """Returns the out directory where the output binaries are built. |
| 145 | |
| 146 | Args: |
| 147 | build_type: Build type, generally 'Debug' or 'Release'. Defaults to the |
| 148 | globally set build type environment variable BUILDTYPE. |
| 149 | """ |
| 150 | return os.path.abspath(os.path.join( |
| 151 | DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), |
| 152 | GetBuildType() if build_type is None else build_type)) |
| 153 | |
| 154 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 155 | def _GetADBPath(): |
| 156 | if os.environ.get('ANDROID_SDK_ROOT'): |
| 157 | return 'adb' |
| 158 | # If envsetup.sh hasn't been sourced and there's no adb in the path, |
| 159 | # set it here. |
| 160 | try: |
| 161 | with file(os.devnull, 'w') as devnull: |
| 162 | subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) |
| 163 | return 'adb' |
| 164 | except OSError: |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 165 | print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.' |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 166 | return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') |
| 167 | |
| 168 | |
| 169 | ADB_PATH = _GetADBPath() |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 170 | |
| 171 | # Exit codes |
| 172 | ERROR_EXIT_CODE = 1 |
| 173 | WARNING_EXIT_CODE = 88 |