• 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'
48DEVICE_ONLY = 'DEVICE_ONLY'
49CUSTOM_ARGS = 'CUSTOM_ARGS'
50DRY_RUN = 'DRY_RUN'
51ANDROID_SERIAL = 'ANDROID_SERIAL'
52INSTANT = 'INSTANT'
53USER_TYPE = 'USER_TYPE'
54ITERATIONS = 'ITERATIONS'
55RERUN_UNTIL_FAILURE = 'RERUN_UNTIL_FAILURE'
56RETRY_ANY_FAILURE = 'RETRY_ANY_FAILURE'
57TF_DEBUG = 'TF_DEBUG'
58DEFAULT_DEBUG_PORT = '10888'
59COLLECT_TESTS_ONLY = 'COLLECT_TESTS_ONLY'
60TF_TEMPLATE = 'TF_TEMPLATE'
61FLAKES_INFO = 'FLAKES_INFO'
62TF_EARLY_DEVICE_RELEASE = 'TF_EARLY_DEVICE_RELEASE'
63BAZEL_MODE_FEATURES = 'BAZEL_MODE_FEATURES'
64REQUEST_UPLOAD_RESULT = 'REQUEST_UPLOAD_RESULT'
65DISABLE_UPLOAD_RESULT = 'DISABLE_UPLOAD_RESULT'
66MODULES_IN = 'MODULES-IN-'
67NO_ENABLE_ROOT = 'NO_ENABLE_ROOT'
68VERIFY_ENV_VARIABLE = 'VERIFY_ENV_VARIABLE'
69SKIP_VARS = [VERIFY_ENV_VARIABLE]
70AGGREGATE_METRIC_FILTER_ARG = 'AGGREGATE_METRIC_FILTER'
71ENABLE_DEVICE_PREPARER = 'ENABLE_DEVICE_PREPARER'
72ANNOTATION_FILTER = 'ANNOTATION_FILTER'
73BAZEL_ARG = 'BAZEL_ARG'
74COVERAGE = 'COVERAGE'
75TEST_FILTER = 'TEST_FILTER'
76TEST_TIMEOUT = 'TEST_TIMEOUT'
77VERBOSE = 'VERBOSE'
78LD_LIBRARY_PATH = 'LD_LIBRARY_PATH'
79
80# Robolectric Types:
81ROBOTYPE_MODERN = 1
82ROBOTYPE_LEGACY = 2
83
84# Codes of specific events. These are exceptions that don't stop anything
85# but sending metrics.
86ACCESS_CACHE_FAILURE = 101
87ACCESS_HISTORY_FAILURE = 102
88IMPORT_FAILURE = 103
89PLOCATEDB_LOCKED = 104
90
91# Test finder constants.
92MODULE_CONFIG = 'AndroidTest.xml'
93MODULE_COMPATIBILITY_SUITES = 'compatibility_suites'
94MODULE_NAME = 'module_name'
95MODULE_PATH = 'path'
96MODULE_CLASS = 'class'
97MODULE_INSTALLED = 'installed'
98MODULE_CLASS_ROBOLECTRIC = 'ROBOLECTRIC'
99MODULE_CLASS_NATIVE_TESTS = 'NATIVE_TESTS'
100MODULE_CLASS_JAVA_LIBRARIES = 'JAVA_LIBRARIES'
101MODULE_TEST_CONFIG = 'test_config'
102MODULE_MAINLINE_MODULES = 'test_mainline_modules'
103MODULE_DEPENDENCIES = 'dependencies'
104MODULE_SRCS = 'srcs'
105MODULE_IS_UNIT_TEST = 'is_unit_test'
106MODULE_SHARED_LIBS = 'shared_libs'
107MODULE_RUNTIME_DEPS = 'runtime_dependencies'
108MODULE_STATIC_DEPS = 'static_dependencies'
109MODULE_DATA_DEPS = 'data_dependencies'
110MODULE_SUPPORTED_VARIANTS = 'supported_variants'
111MODULE_LIBS = 'libs'
112MODULE_STATIC_LIBS = 'static_libs'
113MODULE_HOST_DEPS = 'host_dependencies'
114MODULE_TARGET_DEPS = 'target_dependencies'
115MODULE_TEST_OPTIONS_TAGS = 'test_options_tags'
116MODULE_INFO_ID = 'module_info_id'
117
118
119# Env constants
120ANDROID_BUILD_TOP = 'ANDROID_BUILD_TOP'
121ANDROID_OUT = 'OUT'
122ANDROID_OUT_DIR = 'OUT_DIR'
123ANDROID_OUT_DIR_COMMON_BASE = 'OUT_DIR_COMMON_BASE'
124ANDROID_HOST_OUT = 'ANDROID_HOST_OUT'
125ANDROID_PRODUCT_OUT = 'ANDROID_PRODUCT_OUT'
126ANDROID_TARGET_PRODUCT = 'TARGET_PRODUCT'
127TARGET_BUILD_VARIANT = 'TARGET_BUILD_VARIANT'
128ANDROID_TARGET_OUT_TESTCASES = 'ANDROID_TARGET_OUT_TESTCASES'
129
130# Test Info data keys
131# Value of include-filter option.
132TI_FILTER = 'filter'
133TI_REL_CONFIG = 'rel_config'
134TI_MODULE_CLASS = 'module_class'
135# Value of module-arg option
136TI_MODULE_ARG = 'module-arg'
137
138# Google TF
139GTF_MODULE = 'google-tradefed'
140GTF_TARGET = 'google-tradefed-core'
141
142# TEST_MAPPING filename
143TEST_MAPPING = 'TEST_MAPPING'
144# Test group for tests in TEST_MAPPING
145TEST_GROUP_PRESUBMIT = 'presubmit'
146TEST_GROUP_PRESUBMIT_LARGE = 'presubmit-large'
147TEST_GROUP_POSTSUBMIT = 'postsubmit'
148TEST_GROUP_ALL = 'all'
149DEFAULT_TEST_GROUPS = [TEST_GROUP_PRESUBMIT,
150                       TEST_GROUP_PRESUBMIT_LARGE]
151# Key in TEST_MAPPING file for a list of imported TEST_MAPPING file
152TEST_MAPPING_IMPORTS = 'imports'
153
154# TradeFed command line args
155TF_INCLUDE_FILTER_OPTION = 'include-filter'
156TF_EXCLUDE_FILTER_OPTION = 'exclude-filter'
157TF_INCLUDE_FILTER = '--include-filter'
158TF_EXCLUDE_FILTER = '--exclude-filter'
159TF_ATEST_INCLUDE_FILTER = '--atest-include-filter'
160TF_ATEST_INCLUDE_FILTER_VALUE_FMT = '{test_name}:{test_filter}'
161TF_MODULE_ARG = '--module-arg'
162TF_MODULE_ARG_VALUE_FMT = '{test_name}:{option_name}:{option_value}'
163TF_SUITE_FILTER_ARG_VALUE_FMT = '"{test_name} {option_value}"'
164TF_SKIP_LOADING_CONFIG_JAR = '--skip-loading-config-jar'
165TF_MODULE_FILTER = '--module'
166TF_ENABLE_MAINLINE_PARAMETERIZED_MODULES = '--enable-mainline-parameterized-modules'
167TF_ENABLE_PARAMETERIZED_MODULES = '--enable-parameterized-modules'
168TF_MODULE_PARAMETER = '--module-parameter'
169
170# Suite Plans
171SUITE_PLANS = frozenset(['cts'])
172
173# Constants of Steps
174REBUILD_MODULE_INFO_FLAG = '--rebuild-module-info'
175BUILD_STEP = 'build'
176INSTALL_STEP = 'install'
177TEST_STEP = 'test'
178ALL_STEPS = [BUILD_STEP, INSTALL_STEP, TEST_STEP]
179
180# ANSI code shift for colorful print
181BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
182
183# Types of Levenshetine Distance Cost
184COST_TYPO = (1, 1, 1)
185COST_SEARCH = (8, 1, 5)
186LD_RANGE = 2
187
188# Value of TestInfo install_locations.
189DEVICELESS_TEST = 'host'
190DEVICE_TEST = 'device'
191BOTH_TEST = 'both'
192
193# Metrics
194NO_METRICS_ARG = '--no-metrics'
195METRICS_URL = 'http://asuite-218222.appspot.com/atest/metrics'
196EXTERNAL = 'EXTERNAL_RUN'
197INTERNAL = 'INTERNAL_RUN'
198INTERNAL_EMAIL = '@google.com'
199INTERNAL_HOSTNAME = ['.google.com', 'c.googlers.com']
200TOOL_NAME = 'atest'
201SUB_TOOL_NAME = ''
202USER_FROM_TOOL = 'USER_FROM_TOOL'
203USER_FROM_SUB_TOOL = 'USER_FROM_SUB_TOOL'
204TF_PREPARATION = 'tf-preparation'
205
206# Detect type for local_detect_event.
207# XTS suite types encode from 100 to 199
208DETECT_TYPE_XTS_SUITE = {'cts': 101,
209                         'vts': 104}
210
211# Considering a trade-off between speed and size, we set UPPER_LIMIT to 100000
212# to make maximum file space 10M(100000(records)*100(byte/record)) at most.
213# Therefore, to update history file will spend 1 sec at most in each run.
214UPPER_LIMIT = 100000
215TRIM_TO_SIZE = 50000
216
217# VTS plans
218VTS_STAGING_PLAN = 'vts-staging-default'
219
220# TreeHugger TEST_MAPPING SUITE_PLANS
221TEST_MAPPING_SUITES = ['device-tests', 'general-tests']
222
223# VTS10 TF
224VTS_TF_MODULE = 'vts10-tradefed'
225
226# VTS TF
227VTS_CORE_TF_MODULE = 'vts-tradefed'
228
229# VTS suite set
230VTS_CORE_SUITE = 'vts'
231
232# MTS suite set
233MTS_SUITE = 'mts'
234
235# CTS tradefed jar
236CTS_JAR = "cts-tradefed"
237
238# ATest TF
239ATEST_TF_MODULE = 'atest-tradefed'
240
241# Atest index path and relative dirs/caches.
242INDEX_DIR = os.path.join(os.getenv(ANDROID_HOST_OUT, ''), 'indexes')
243LOCATE_CACHE = os.path.join(INDEX_DIR, 'plocate.db')
244BUILDFILES_MD5 = os.path.join(INDEX_DIR, 'buildfiles.md5')
245INT_INDEX = os.path.join(INDEX_DIR, 'integration.idx')
246CLASS_INDEX = os.path.join(INDEX_DIR, 'classes.idx')
247CC_CLASS_INDEX = os.path.join(INDEX_DIR, 'cc_classes.idx')
248PACKAGE_INDEX = os.path.join(INDEX_DIR, 'packages.idx')
249QCLASS_INDEX = os.path.join(INDEX_DIR, 'fqcn.idx')
250MODULE_INDEX = 'modules.idx'
251MODULE_INFO_MD5 = 'module-info.md5'
252
253# Regeular Expressions
254CC_EXT_RE = re.compile(r'.*\.(cc|cpp)$')
255JAVA_EXT_RE = re.compile(r'.*\.(java|kt)$')
256# e.g. /path/to/ccfile.cc: TYPED_TEST_P(test_name, method_name){
257CC_OUTPUT_RE = re.compile(
258    r'(?P<file_path>/.*):\s*(TYPED_TEST(_P)*|TEST(_F|_P)*)\s*\('
259    r'(?P<test_name>\w+)\s*,\s*(?P<method_name>\w+)\)\s*\{')
260# Used by locate command.
261CC_GREP_RE = r'^\s*(TYPED_TEST(_P)*|TEST(_F|_P)*)\s*\(\w+,'
262# e.g. /path/to/Javafile.java:package com.android.settings.accessibility
263# grab the path, Javafile(class) and com.android.settings.accessibility(package)
264CLASS_OUTPUT_RE = re.compile(r'(?P<java_path>.*/(?P<class>[A-Z]\w+)\.\w+)[:].*')
265QCLASS_OUTPUT_RE = re.compile(r'(?P<java_path>.*/(?P<class>[A-Z]\w+)\.\w+)'
266                              r'[:]\s*package\s+(?P<package>[^(;|\s)]+)\s*')
267PACKAGE_OUTPUT_RE = re.compile(r'(?P<java_dir>/.*/).*[.](java|kt)[:]\s*package\s+'
268                               r'(?P<package>[^(;|\s)]+)\s*')
269
270ATEST_RESULT_ROOT = '/tmp/atest_result'
271ATEST_TEST_RECORD_PROTO = 'test_record.proto'
272LATEST_RESULT_FILE = os.path.join(ATEST_RESULT_ROOT, 'LATEST', 'test_result')
273TEST_WITH_MAINLINE_MODULES_RE = re.compile(r'(?P<test>.*)\[(?P<mainline_modules>.*'
274                                           r'[.](apk|apks|apex))\]$')
275
276# Tests list which need vts_ltp_tests as test dependency
277REQUIRED_LTP_TEST_MODULES = [
278    'vts_ltp_test_arm',
279    'vts_ltp_test_arm_64',
280    'vts_ltp_test_arm_64_lowmem',
281    'vts_ltp_test_arm_64_hwasan',
282    'vts_ltp_test_arm_64_lowmem_hwasan',
283    'vts_ltp_test_arm_lowmem',
284    'vts_ltp_test_x86_64',
285    'vts_ltp_test_x86'
286]
287# Tests list which need vts_kselftest_tests as test dependency
288REQUIRED_KSELFTEST_TEST_MODULES = [
289    'vts_linux_kselftest_arm_32',
290    'vts_linux_kselftest_arm_64',
291    'vts_linux_kselftest_x86_32',
292    'vts_linux_kselftest_x86_64',
293]
294
295# XTS suite set dependency.
296SUITE_DEPS = {}
297
298# Tradefed log file name term.
299TF_HOST_LOG = 'host_log_*'
300
301# Flake service par path
302FLAKE_SERVICE_PATH = '/foo'
303FLAKE_TMP_PATH = '/tmp'
304FLAKE_FILE = 'flakes_info.par'
305FLAKE_TARGET = 'aosp_cf_x86_phone-userdebug'
306FLAKE_BRANCH = 'aosp-master'
307FLAKE_TEST_NAME = 'suite/test-mapping-presubmit-retry_cloud-tf'
308FLAKE_PERCENT = 'flake_percent'
309FLAKE_POSTSUBMIT = 'postsubmit_flakes_per_week'
310
311# cert status command
312CERT_STATUS_CMD = ''
313
314ASUITE_REPO_PROJECT_NAME = 'platform/tools/asuite'
315
316# logstorage api scope.
317SCOPE_BUILD_API_SCOPE = ''
318STORAGE_API_VERSION = ''
319STORAGE_SERVICE_NAME = ''
320DO_NOT_UPLOAD = 'DO_NOT_UPLOAD'
321CLIENT_ID = ''
322CLIENT_SECRET = ''
323CREDENTIAL_FILE_NAME = ''
324TOKEN_FILE_PATH = ''
325INVOCATION_ID = 'INVOCATION_ID'
326WORKUNIT_ID = 'WORKUNIT_ID'
327LOCAL_BUILD_ID = 'LOCAL_BUILD_ID'
328BUILD_TARGET = 'BUILD_TARGET'
329RESULT_LINK = ''
330TF_GLOBAL_CONFIG = ''
331UPLOAD_TEST_RESULT_MSG = 'Upload test result?'
332DISCOVERY_SERVICE = ''
333STORAGE2_TEST_URI = ''
334
335# SSO constants.
336TOKEN_EXCHANGE_COMMAND = ''
337TOKEN_EXCHANGE_REQUEST = ''
338SCOPE = ''
339
340# Example arguments used in ~/.atest/config
341ATEST_EXAMPLE_ARGS = ('## Specify only one option per line; any test name/path will be ignored automatically.\n'
342                      '## Option that follows a "#" will be ignored.\n'
343                      'hello_world_test   # Test name will be skipped WITHOUT warning.\n'
344                      '# -- --module-arg Foo:variable:value   # Only support atest arguments so "--" will be ignored.\n'
345                      '                                       # and will stop running tests.\n'
346                      '# --iterations=3\n'
347                      '# --retry-any-failure=5\n'
348                      '# --rerun-until-failure=5\n'
349                      '# --start-avd        # also run "acloud create" concurrently.\n'
350                      '# --all-abi          # Set to run tests for all abis.\n'
351                      '# --verbose          # turn on verbose mode for debugging.\n')
352
353# AndroidJUnitTest related argument.
354ANDROID_JUNIT_CLASS = 'com.android.tradefed.testtype.AndroidJUnitTest'
355INCLUDE_ANNOTATION = 'include-annotation'
356EXCLUDE_ANNOTATION = 'exclude-annotation'
357SUPPORTED_FILTERS = [INCLUDE_ANNOTATION, EXCLUDE_ANNOTATION]
358
359# Tradefed config-descriptor metadata.
360CONFIG_DESCRIPTOR = 'config-descriptor:metadata'
361PARAMETER_KEY = 'parameter'
362MAINLINE_PARAM_KEY = 'mainline-param'
363
364# Tradefed related constant.
365TF_TEST_ARG = '--test-arg'
366TF_AND_JUNIT_CLASS = 'com.android.tradefed.testtype.AndroidJUnitTest'
367TF_EXCLUDE_ANNOTATE = 'exclude-annotation'
368INSTANT_MODE_ANNOTATE = 'android.platform.test.annotations.AppModeInstant'
369TF_PARA_INSTANT_APP = 'instant_app'
370TF_PARA_SECOND_USR = 'secondary_user'
371TF_PARA_MULTIABI = 'multi_abi'
372DEFAULT_EXCLUDE_PARAS = {TF_PARA_INSTANT_APP,
373                         TF_PARA_SECOND_USR,
374                         TF_PARA_MULTIABI
375                         }
376DEFAULT_EXCLUDE_NOT_PARAS = {'not_' + TF_PARA_INSTANT_APP,
377                            'not_' + TF_PARA_SECOND_USR,
378                            'not_' + TF_PARA_MULTIABI}
379
380# ATest integration test related constants.
381VERIFY_DATA_PATH = os.path.join(
382    os.environ.get(ANDROID_BUILD_TOP, os.getcwd()),
383    'tools/asuite/atest/test_data/test_commands.json')
384VERIFY_ENV_PATH = os.path.join(
385    os.environ.get(ANDROID_BUILD_TOP, os.getcwd()),
386    'tools/asuite/atest/test_data/test_environ.json')
387RUNNER_COMMAND_PATH = os.path.join(
388    os.environ.get(ANDROID_BUILD_TOP, os.getcwd()),
389    'tools/asuite/atest/test_data/runner_commands.json')
390
391# Gtest Types
392GTEST_REGULAR = 'regular native test'
393GTEST_TYPED = 'typed test'
394GTEST_TYPED_PARAM = 'typed-parameterized test'
395GTEST_PARAM = 'value-parameterized test'
396
397# Tradefed log saver template for ATest
398ATEST_TF_LOG_SAVER = 'template/log/atest_log_saver'
399DEVICE_SETUP_PREPARER = 'template/preparers/device-preparer'
400LOG_ROOT_OPTION_NAME = 'atest-log-file-path'
401LOG_SAVER_EXT_OPTION = ''
402
403# Log messages here.
404REQUIRE_DEVICES_MSG = (
405    'Please ensure there is at least one connected device via:\n'
406    '    $ adb devices')
407
408# Default shard num.
409SHARD_NUM = 2
410