• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017, The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""
16Various globals used by atest.
17"""
18
19# pylint: disable=line-too-long
20
21import os
22import re
23
24MODE = 'DEFAULT'
25
26# Result server constants for atest_utils.
27RESULT_SERVER = ''
28RESULT_SERVER_ARGS = []
29RESULT_SERVER_TIMEOUT = 5
30# Result arguments if tests are configured in TEST_MAPPING.
31TEST_MAPPING_RESULT_SERVER_ARGS = []
32
33# Google service key for gts tests.
34GTS_GOOGLE_SERVICE_ACCOUNT = ''
35
36# Arg constants.
37WAIT_FOR_DEBUGGER = 'WAIT_FOR_DEBUGGER'
38DISABLE_INSTALL = 'DISABLE_INSTALL'
39DISABLE_TEARDOWN = 'DISABLE_TEARDOWN'
40PRE_PATCH_ITERATIONS = 'PRE_PATCH_ITERATIONS'
41POST_PATCH_ITERATIONS = 'POST_PATCH_ITERATIONS'
42PRE_PATCH_FOLDER = 'PRE_PATCH_FOLDER'
43POST_PATCH_FOLDER = 'POST_PATCH_FOLDER'
44SERIAL = 'SERIAL'
45SHARDING = 'SHARDING'
46ALL_ABI = 'ALL_ABI'
47HOST = 'HOST'
48CUSTOM_ARGS = 'CUSTOM_ARGS'
49DRY_RUN = 'DRY_RUN'
50ANDROID_SERIAL = 'ANDROID_SERIAL'
51INSTANT = 'INSTANT'
52USER_TYPE = 'USER_TYPE'
53ITERATIONS = 'ITERATIONS'
54RERUN_UNTIL_FAILURE = 'RERUN_UNTIL_FAILURE'
55RETRY_ANY_FAILURE = 'RETRY_ANY_FAILURE'
56TF_DEBUG = 'TF_DEBUG'
57COLLECT_TESTS_ONLY = 'COLLECT_TESTS_ONLY'
58TF_TEMPLATE = 'TF_TEMPLATE'
59FLAKES_INFO = 'FLAKES_INFO'
60TF_EARLY_DEVICE_RELEASE = 'TF_EARLY_DEVICE_RELEASE'
61REQUEST_UPLOAD_RESULT = 'REQUEST_UPLOAD_RESULT'
62MODULES_IN = 'MODULES-IN-'
63
64# Application exit codes.
65EXIT_CODE_SUCCESS = 0
66EXIT_CODE_ENV_NOT_SETUP = 1
67EXIT_CODE_BUILD_FAILURE = 2
68EXIT_CODE_ERROR = 3
69EXIT_CODE_TEST_NOT_FOUND = 4
70EXIT_CODE_TEST_FAILURE = 5
71EXIT_CODE_VERIFY_FAILURE = 6
72EXIT_CODE_OUTSIDE_ROOT = 7
73EXIT_CODE_AVD_CREATE_FAILURE = 8
74EXIT_CODE_AVD_INVALID_ARGS = 9
75# Conditions that atest should exit without sending result to metrics.
76EXIT_CODES_BEFORE_TEST = [EXIT_CODE_ENV_NOT_SETUP,
77                          EXIT_CODE_TEST_NOT_FOUND,
78                          EXIT_CODE_OUTSIDE_ROOT,
79                          EXIT_CODE_AVD_CREATE_FAILURE,
80                          EXIT_CODE_AVD_INVALID_ARGS]
81
82# Codes of specific events. These are exceptions that don't stop anything
83# but sending metrics.
84ACCESS_CACHE_FAILURE = 101
85ACCESS_HISTORY_FAILURE = 102
86IMPORT_FAILURE = 103
87MLOCATEDB_LOCKED = 104
88
89# Test finder constants.
90MODULE_CONFIG = 'AndroidTest.xml'
91MODULE_COMPATIBILITY_SUITES = 'compatibility_suites'
92MODULE_NAME = 'module_name'
93MODULE_PATH = 'path'
94MODULE_CLASS = 'class'
95MODULE_INSTALLED = 'installed'
96MODULE_CLASS_ROBOLECTRIC = 'ROBOLECTRIC'
97MODULE_CLASS_NATIVE_TESTS = 'NATIVE_TESTS'
98MODULE_CLASS_JAVA_LIBRARIES = 'JAVA_LIBRARIES'
99MODULE_TEST_CONFIG = 'test_config'
100MODULE_MAINLINE_MODULES = 'test_mainline_modules'
101MODULE_DEPENDENCIES = 'dependencies'
102MODULE_SRCS = 'srcs'
103MODULE_IS_UNIT_TEST = 'is_unit_test'
104
105# Env constants
106ANDROID_BUILD_TOP = 'ANDROID_BUILD_TOP'
107ANDROID_OUT = 'OUT'
108ANDROID_OUT_DIR = 'OUT_DIR'
109ANDROID_OUT_DIR_COMMON_BASE = 'OUT_DIR_COMMON_BASE'
110ANDROID_HOST_OUT = 'ANDROID_HOST_OUT'
111ANDROID_PRODUCT_OUT = 'ANDROID_PRODUCT_OUT'
112ANDROID_TARGET_PRODUCT = 'TARGET_PRODUCT'
113
114# Test Info data keys
115# Value of include-filter option.
116TI_FILTER = 'filter'
117TI_REL_CONFIG = 'rel_config'
118TI_MODULE_CLASS = 'module_class'
119# Value of module-arg option
120TI_MODULE_ARG = 'module-arg'
121
122# Google TF
123GTF_MODULE = 'google-tradefed'
124GTF_TARGET = 'google-tradefed-core'
125
126# TEST_MAPPING filename
127TEST_MAPPING = 'TEST_MAPPING'
128# Test group for tests in TEST_MAPPING
129TEST_GROUP_PRESUBMIT = 'presubmit'
130TEST_GROUP_PRESUBMIT_LARGE = 'presubmit-large'
131TEST_GROUP_POSTSUBMIT = 'postsubmit'
132TEST_GROUP_ALL = 'all'
133DEFAULT_TEST_GROUPS = [TEST_GROUP_PRESUBMIT, TEST_GROUP_PRESUBMIT_LARGE]
134# Key in TEST_MAPPING file for a list of imported TEST_MAPPING file
135TEST_MAPPING_IMPORTS = 'imports'
136
137# TradeFed command line args
138TF_INCLUDE_FILTER_OPTION = 'include-filter'
139TF_EXCLUDE_FILTER_OPTION = 'exclude-filter'
140TF_INCLUDE_FILTER = '--include-filter'
141TF_EXCLUDE_FILTER = '--exclude-filter'
142TF_ATEST_INCLUDE_FILTER = '--atest-include-filter'
143TF_ATEST_INCLUDE_FILTER_VALUE_FMT = '{test_name}:{test_filter}'
144TF_MODULE_ARG = '--module-arg'
145TF_MODULE_ARG_VALUE_FMT = '{test_name}:{option_name}:{option_value}'
146TF_SUITE_FILTER_ARG_VALUE_FMT = '"{test_name} {option_value}"'
147TF_SKIP_LOADING_CONFIG_JAR = '--skip-loading-config-jar'
148TF_MODULE_FILTER = '--module'
149
150# Suite Plans
151SUITE_PLANS = frozenset(['cts'])
152
153# Constants of Steps
154REBUILD_MODULE_INFO_FLAG = '--rebuild-module-info'
155BUILD_STEP = 'build'
156INSTALL_STEP = 'install'
157TEST_STEP = 'test'
158ALL_STEPS = [BUILD_STEP, INSTALL_STEP, TEST_STEP]
159
160# ANSI code shift for colorful print
161BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
162
163# Types of Levenshetine Distance Cost
164COST_TYPO = (1, 1, 1)
165COST_SEARCH = (8, 1, 5)
166LD_RANGE = 2
167
168# Value of TestInfo install_locations.
169DEVICELESS_TEST = 'host'
170DEVICE_TEST = 'device'
171BOTH_TEST = 'both'
172
173# Metrics
174NO_METRICS_ARG = '--no-metrics'
175METRICS_URL = 'http://asuite-218222.appspot.com/atest/metrics'
176EXTERNAL = 'EXTERNAL_RUN'
177INTERNAL = 'INTERNAL_RUN'
178INTERNAL_EMAIL = '@google.com'
179INTERNAL_HOSTNAME = ['.google.com', 'c.googlers.com']
180CONTENT_LICENSES_URL = 'https://source.android.com/setup/start/licenses'
181CONTRIBUTOR_AGREEMENT_URL = {
182    'INTERNAL': 'https://cla.developers.google.com/',
183    'EXTERNAL': 'https://opensource.google.com/docs/cla/'
184}
185PRIVACY_POLICY_URL = 'https://policies.google.com/privacy'
186TERMS_SERVICE_URL = 'https://policies.google.com/terms'
187TOOL_NAME = 'atest'
188USER_FROM_TOOL = 'USER_FROM_TOOL'
189TF_PREPARATION = 'tf-preparation'
190
191# Detect type for local_detect_event.
192# Next expansion : DETECT_TYPE_XXX = 8
193DETECT_TYPE_BUG_DETECTED = 0
194DETECT_TYPE_ACLOUD_CREATE = 1
195DETECT_TYPE_FIND_BUILD = 2
196DETECT_TYPE_NO_FLAKE = 3
197DETECT_TYPE_HAS_FLAKE = 4
198DETECT_TYPE_TF_TEARDOWN_LOGCAT = 5
199DETECT_TYPE_REBUILD_MODULE_INFO = 6
200DETECT_TYPE_NOT_REBUILD_MODULE_INFO = 7
201DETECT_TYPE_ONLY_BUILD_MODULE_INFO = 8
202# XTS suite types encode from 100 to 199
203DETECT_TYPE_XTS_SUITE = {'cts': 101,
204                         'vts': 104}
205
206# Considering a trade-off between speed and size, we set UPPER_LIMIT to 100000
207# to make maximum file space 10M(100000(records)*100(byte/record)) at most.
208# Therefore, to update history file will spend 1 sec at most in each run.
209UPPER_LIMIT = 100000
210TRIM_TO_SIZE = 50000
211
212# VTS plans
213VTS_STAGING_PLAN = 'vts-staging-default'
214
215# TreeHugger TEST_MAPPING SUITE_PLANS
216TEST_MAPPING_SUITES = ['device-tests', 'general-tests']
217
218# VTS10 TF
219VTS_TF_MODULE = 'vts10-tradefed'
220
221# VTS TF
222VTS_CORE_TF_MODULE = 'vts-tradefed'
223
224# VTS suite set
225VTS_CORE_SUITE = 'vts'
226
227# ATest TF
228ATEST_TF_MODULE = 'atest-tradefed'
229
230# Build environment variable for each build on ATest
231# With RECORD_ALL_DEPS enabled, ${ANDROID_PRODUCT_OUT}/module-info.json will
232# generate modules' dependencies info when make.
233# With SOONG_COLLECT_JAVA_DEPS enabled, out/soong/module_bp_java_deps.json will
234# be generated when make.
235ATEST_BUILD_ENV = {'RECORD_ALL_DEPS':'true', 'SOONG_COLLECT_JAVA_DEPS':'true',
236                   'SOONG_COLLECT_CC_DEPS':'true'}
237
238# Atest index path and relative dirs/caches.
239INDEX_DIR = os.path.join(os.getenv(ANDROID_HOST_OUT, ''), 'indexes')
240LOCATE_CACHE = os.path.join(INDEX_DIR, 'mlocate.db')
241LOCATE_CACHE_MD5 = os.path.join(INDEX_DIR, 'mlocate.md5')
242INT_INDEX = os.path.join(INDEX_DIR, 'integration.idx')
243CLASS_INDEX = os.path.join(INDEX_DIR, 'classes.idx')
244CC_CLASS_INDEX = os.path.join(INDEX_DIR, 'cc_classes.idx')
245PACKAGE_INDEX = os.path.join(INDEX_DIR, 'packages.idx')
246QCLASS_INDEX = os.path.join(INDEX_DIR, 'fqcn.idx')
247MODULE_INDEX = os.path.join(INDEX_DIR, 'modules.idx')
248VERSION_FILE = os.path.join(os.path.dirname(__file__), 'VERSION')
249
250# Regeular Expressions
251CC_EXT_RE = re.compile(r'.*\.(cc|cpp)$')
252JAVA_EXT_RE = re.compile(r'.*\.(java|kt)$')
253# e.g. /path/to/ccfile.cc: TEST_F(test_name, method_name){
254CC_OUTPUT_RE = re.compile(r'(?P<file_path>/.*):\s*TEST(_F|_P)?[ ]*\('
255                          r'(?P<test_name>\w+)\s*,\s*(?P<method_name>\w+)\)'
256                          r'\s*\{')
257CC_GREP_RE = r'^[ ]*TEST(_P|_F)?[ ]*\([[:alnum:]].*,'
258# e.g. /path/to/Javafile.java:package com.android.settings.accessibility
259# grab the path, Javafile(class) and com.android.settings.accessibility(package)
260CLASS_OUTPUT_RE = re.compile(r'(?P<java_path>.*/(?P<class>[A-Z]\w+)\.\w+)[:].*')
261QCLASS_OUTPUT_RE = re.compile(r'(?P<java_path>.*/(?P<class>[A-Z]\w+)\.\w+)'
262                              r'[:]\s*package\s+(?P<package>[^(;|\s)]+)\s*')
263PACKAGE_OUTPUT_RE = re.compile(r'(?P<java_dir>/.*/).*[.](java|kt)[:]\s*package\s+'
264                               r'(?P<package>[^(;|\s)]+)\s*')
265
266ATEST_RESULT_ROOT = '/tmp/atest_result'
267ATEST_TEST_RECORD_PROTO = 'test_record.proto'
268LATEST_RESULT_FILE = os.path.join(ATEST_RESULT_ROOT, 'LATEST', 'test_result')
269ACLOUD_REPORT_FILE_RE = re.compile(r'.*--report[_-]file(=|\s+)(?P<report_file>[\w/.]+)')
270TEST_WITH_MAINLINE_MODULES_RE = re.compile(r'(?P<test>.*)\[(?P<mainline_modules>.*'
271                                           r'[.](apk|apks|apex))\]$')
272
273# Tests list which need vts_kernel_tests as test dependency
274REQUIRED_KERNEL_TEST_MODULES = [
275    'vts_ltp_test_arm',
276    'vts_ltp_test_arm_64',
277    'vts_linux_kselftest_arm_32',
278    'vts_linux_kselftest_arm_64',
279    'vts_linux_kselftest_x86_32',
280    'vts_linux_kselftest_x86_64',
281    'vts_ltp_test_arm_64_lowmem',
282    'vts_ltp_test_arm_64_hwasan',
283    'vts_ltp_test_arm_64_lowmem_hwasan',
284    'vts_ltp_test_arm_lowmem',
285    'vts_ltp_test_x86_64',
286    'vts_ltp_test_x86'
287]
288
289# XTS suite set dependency.
290SUITE_DEPS = {}
291
292# Tradefed log file name term.
293TF_HOST_LOG = 'host_log_*'
294
295# Flake service par path
296FLAKE_SERVICE_PATH = '/foo'
297FLAKE_TMP_PATH = '/tmp'
298FLAKE_FILE = 'flakes_info.par'
299FLAKE_TARGET = 'aosp_cf_x86_phone-userdebug'
300FLAKE_BRANCH = 'aosp-master'
301FLAKE_TEST_NAME = 'suite/test-mapping-presubmit-retry_cloud-tf'
302FLAKE_PERCENT = 'flake_percent'
303FLAKE_POSTSUBMIT = 'postsubmit_flakes_per_week'
304
305# cert status command
306CERT_STATUS_CMD = ''
307
308ASUITE_REPO_PROJECT_NAME = 'platform/tools/asuite'
309
310# logstorage api scope.
311SCOPE_BUILD_API_SCOPE = ''
312STORAGE_API_VERSION = ''
313STORAGE_SERVICE_NAME = ''
314DO_NOT_UPLOAD = 'DO_NOT_UPLOAD'
315CLIENT_ID = ''
316CLIENT_SECRET = ''
317CREDENTIAL_FILE_NAME = ''
318TOKEN_FILE_PATH = ''
319INVOCATION_ID = 'INVOCATION_ID'
320WORKUNIT_ID = 'WORKUNIT_ID'
321RESULT_LINK = ''
322TF_GLOBAL_CONFIG = ''
323UPLOAD_TEST_RESULT_MSG = 'Upload test result?'
324
325# messages that share among libraries.
326REBUILD_MODULE_INFO_MSG = ('(This can happen after a repo sync or if the test'
327                           ' is new. Running with "{}" may resolve the issue.)')
328
329# AndroidJUnitTest related argument.
330ANDROID_JUNIT_CLASS = 'com.android.tradefed.testtype.AndroidJUnitTest'
331INCLUDE_ANNOTATION = 'include-annotation'
332EXCLUDE_ANNOTATION = 'exclude-annotation'
333SUPPORTED_FILTERS = [INCLUDE_ANNOTATION, EXCLUDE_ANNOTATION]
334
335# Tradefed config-descriptor metadata.
336CONFIG_DESCRIPTOR = 'config-descriptor:metadata'
337PARAMETER_KEY = 'parameter'
338
339# Tradefed related constant.
340TF_TEST_ARG = '--test-arg'
341TF_AND_JUNIT_CLASS = 'com.android.tradefed.testtype.AndroidJUnitTest'
342TF_EXCLUDE_ANNOTATE = 'exclude-annotation'
343INSTANT_MODE_ANNOTATE = 'android.platform.test.annotations.AppModeInstant'
344TF_PARA_INSTANT_APP = 'instant_app'
345TF_PARA_SECOND_USR = 'secondary_user'
346TF_PARA_MULTIABI = 'multi_abi'
347DEFAULT_EXCLUDE_PARAS = {TF_PARA_INSTANT_APP,
348                         TF_PARA_SECOND_USR,
349                         TF_PARA_MULTIABI
350                         }
351DEFAULT_EXCLUDE_NOT_PARAS = {'not_' + TF_PARA_INSTANT_APP,
352                            'not_' + TF_PARA_SECOND_USR,
353                            'not_' + TF_PARA_MULTIABI}
354