1*c2e18aaaSAndroid Build Coastguard Worker# Copyright 2017, The Android Open Source Project 2*c2e18aaaSAndroid Build Coastguard Worker# 3*c2e18aaaSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*c2e18aaaSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*c2e18aaaSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*c2e18aaaSAndroid Build Coastguard Worker# 7*c2e18aaaSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*c2e18aaaSAndroid Build Coastguard Worker# 9*c2e18aaaSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*c2e18aaaSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*c2e18aaaSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*c2e18aaaSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*c2e18aaaSAndroid Build Coastguard Worker# limitations under the License. 14*c2e18aaaSAndroid Build Coastguard Worker 15*c2e18aaaSAndroid Build Coastguard Worker"""Various globals used by atest.""" 16*c2e18aaaSAndroid Build Coastguard Worker 17*c2e18aaaSAndroid Build Coastguard Worker 18*c2e18aaaSAndroid Build Coastguard Workerfrom collections import namedtuple 19*c2e18aaaSAndroid Build Coastguard Workerimport os 20*c2e18aaaSAndroid Build Coastguard Workerfrom pathlib import Path 21*c2e18aaaSAndroid Build Coastguard Workerimport re 22*c2e18aaaSAndroid Build Coastguard Workerimport tempfile 23*c2e18aaaSAndroid Build Coastguard Worker 24*c2e18aaaSAndroid Build Coastguard Worker# Result server constants for atest_utils. 25*c2e18aaaSAndroid Build Coastguard WorkerRESULT_SERVER = '' 26*c2e18aaaSAndroid Build Coastguard WorkerRESULT_SERVER_ARGS = [] 27*c2e18aaaSAndroid Build Coastguard WorkerRESULT_SERVER_TIMEOUT = 5 28*c2e18aaaSAndroid Build Coastguard Worker# Result arguments if tests are configured in TEST_MAPPING. 29*c2e18aaaSAndroid Build Coastguard WorkerTEST_MAPPING_RESULT_SERVER_ARGS = [] 30*c2e18aaaSAndroid Build Coastguard Worker 31*c2e18aaaSAndroid Build Coastguard Worker# Google service key for gts tests. 32*c2e18aaaSAndroid Build Coastguard WorkerGTS_GOOGLE_SERVICE_ACCOUNT = '' 33*c2e18aaaSAndroid Build Coastguard Worker 34*c2e18aaaSAndroid Build Coastguard Worker# Arg constants. 35*c2e18aaaSAndroid Build Coastguard WorkerWAIT_FOR_DEBUGGER = 'WAIT_FOR_DEBUGGER' 36*c2e18aaaSAndroid Build Coastguard WorkerDISABLE_INSTALL = 'DISABLE_INSTALL' 37*c2e18aaaSAndroid Build Coastguard WorkerDISABLE_TEARDOWN = 'DISABLE_TEARDOWN' 38*c2e18aaaSAndroid Build Coastguard WorkerSERIAL = 'SERIAL' 39*c2e18aaaSAndroid Build Coastguard WorkerSHARDING = 'SHARDING' 40*c2e18aaaSAndroid Build Coastguard WorkerALL_ABI = 'ALL_ABI' 41*c2e18aaaSAndroid Build Coastguard WorkerHOST = 'HOST' 42*c2e18aaaSAndroid Build Coastguard WorkerDEVICE_ONLY = 'DEVICE_ONLY' 43*c2e18aaaSAndroid Build Coastguard WorkerCUSTOM_ARGS = 'CUSTOM_ARGS' 44*c2e18aaaSAndroid Build Coastguard WorkerDRY_RUN = 'DRY_RUN' 45*c2e18aaaSAndroid Build Coastguard WorkerANDROID_SERIAL = 'ANDROID_SERIAL' 46*c2e18aaaSAndroid Build Coastguard WorkerINSTANT = 'INSTANT' 47*c2e18aaaSAndroid Build Coastguard WorkerUSER_TYPE = 'USER_TYPE' 48*c2e18aaaSAndroid Build Coastguard WorkerITERATIONS = 'ITERATIONS' 49*c2e18aaaSAndroid Build Coastguard WorkerRERUN_UNTIL_FAILURE = 'RERUN_UNTIL_FAILURE' 50*c2e18aaaSAndroid Build Coastguard WorkerRETRY_ANY_FAILURE = 'RETRY_ANY_FAILURE' 51*c2e18aaaSAndroid Build Coastguard WorkerTF_DEBUG = 'TF_DEBUG' 52*c2e18aaaSAndroid Build Coastguard WorkerDEFAULT_DEBUG_PORT = '10888' 53*c2e18aaaSAndroid Build Coastguard WorkerCOLLECT_TESTS_ONLY = 'COLLECT_TESTS_ONLY' 54*c2e18aaaSAndroid Build Coastguard WorkerTF_TEMPLATE = 'TF_TEMPLATE' 55*c2e18aaaSAndroid Build Coastguard WorkerBAZEL_MODE_FEATURES = 'BAZEL_MODE_FEATURES' 56*c2e18aaaSAndroid Build Coastguard WorkerREQUEST_UPLOAD_RESULT = 'REQUEST_UPLOAD_RESULT' 57*c2e18aaaSAndroid Build Coastguard WorkerDISABLE_UPLOAD_RESULT = 'DISABLE_UPLOAD_RESULT' 58*c2e18aaaSAndroid Build Coastguard WorkerMODULES_IN = 'MODULES-IN-' 59*c2e18aaaSAndroid Build Coastguard WorkerAGGREGATE_METRIC_FILTER_ARG = 'AGGREGATE_METRIC_FILTER' 60*c2e18aaaSAndroid Build Coastguard WorkerANNOTATION_FILTER = 'ANNOTATION_FILTER' 61*c2e18aaaSAndroid Build Coastguard WorkerBAZEL_ARG = 'BAZEL_ARG' 62*c2e18aaaSAndroid Build Coastguard WorkerCOVERAGE = 'COVERAGE' 63*c2e18aaaSAndroid Build Coastguard WorkerTEST_FILTER = 'TEST_FILTER' 64*c2e18aaaSAndroid Build Coastguard WorkerTEST_TIMEOUT = 'TEST_TIMEOUT' 65*c2e18aaaSAndroid Build Coastguard WorkerVERBOSE = 'VERBOSE' 66*c2e18aaaSAndroid Build Coastguard WorkerLD_LIBRARY_PATH = 'LD_LIBRARY_PATH' 67*c2e18aaaSAndroid Build Coastguard WorkerUSE_TF_MIN_BASE_TEMPLATE = 'USE_TF_MIN_BASE_TEMPLATE' 68*c2e18aaaSAndroid Build Coastguard Worker 69*c2e18aaaSAndroid Build Coastguard Worker# Robolectric Types: 70*c2e18aaaSAndroid Build Coastguard WorkerROBOTYPE_MODERN = 1 71*c2e18aaaSAndroid Build Coastguard WorkerROBOTYPE_LEGACY = 2 72*c2e18aaaSAndroid Build Coastguard Worker 73*c2e18aaaSAndroid Build Coastguard Worker# Codes of specific events. These are exceptions that don't stop anything 74*c2e18aaaSAndroid Build Coastguard Worker# but sending metrics. 75*c2e18aaaSAndroid Build Coastguard WorkerACCESS_CACHE_FAILURE = 101 76*c2e18aaaSAndroid Build Coastguard WorkerACCESS_HISTORY_FAILURE = 102 77*c2e18aaaSAndroid Build Coastguard WorkerIMPORT_FAILURE = 103 78*c2e18aaaSAndroid Build Coastguard WorkerPLOCATEDB_LOCKED = 104 79*c2e18aaaSAndroid Build Coastguard Worker 80*c2e18aaaSAndroid Build Coastguard Worker# Test finder constants. 81*c2e18aaaSAndroid Build Coastguard WorkerMODULE_CONFIG = 'AndroidTest.xml' 82*c2e18aaaSAndroid Build Coastguard WorkerMODULE_COMPATIBILITY_SUITES = 'compatibility_suites' 83*c2e18aaaSAndroid Build Coastguard WorkerMODULE_NAME = 'module_name' 84*c2e18aaaSAndroid Build Coastguard WorkerMODULE_PATH = 'path' 85*c2e18aaaSAndroid Build Coastguard WorkerMODULE_CLASS = 'class' 86*c2e18aaaSAndroid Build Coastguard WorkerMODULE_AUTO_TEST_CONFIG = 'auto_test_config' 87*c2e18aaaSAndroid Build Coastguard WorkerMODULE_INSTALLED = 'installed' 88*c2e18aaaSAndroid Build Coastguard WorkerMODULE_CLASS_ROBOLECTRIC = 'ROBOLECTRIC' 89*c2e18aaaSAndroid Build Coastguard WorkerMODULE_CLASS_NATIVE_TESTS = 'NATIVE_TESTS' 90*c2e18aaaSAndroid Build Coastguard WorkerMODULE_CLASS_JAVA_LIBRARIES = 'JAVA_LIBRARIES' 91*c2e18aaaSAndroid Build Coastguard WorkerMODULE_TEST_CONFIG = 'test_config' 92*c2e18aaaSAndroid Build Coastguard WorkerMODULE_MAINLINE_MODULES = 'test_mainline_modules' 93*c2e18aaaSAndroid Build Coastguard WorkerMODULE_DEPENDENCIES = 'dependencies' 94*c2e18aaaSAndroid Build Coastguard WorkerMODULE_SRCS = 'srcs' 95*c2e18aaaSAndroid Build Coastguard WorkerMODULE_IS_UNIT_TEST = 'is_unit_test' 96*c2e18aaaSAndroid Build Coastguard WorkerMODULE_SHARED_LIBS = 'shared_libs' 97*c2e18aaaSAndroid Build Coastguard WorkerMODULE_RUNTIME_DEPS = 'runtime_dependencies' 98*c2e18aaaSAndroid Build Coastguard WorkerMODULE_STATIC_DEPS = 'static_dependencies' 99*c2e18aaaSAndroid Build Coastguard WorkerMODULE_DATA_DEPS = 'data_dependencies' 100*c2e18aaaSAndroid Build Coastguard WorkerMODULE_SUPPORTED_VARIANTS = 'supported_variants' 101*c2e18aaaSAndroid Build Coastguard WorkerMODULE_LIBS = 'libs' 102*c2e18aaaSAndroid Build Coastguard WorkerMODULE_STATIC_LIBS = 'static_libs' 103*c2e18aaaSAndroid Build Coastguard WorkerMODULE_HOST_DEPS = 'host_dependencies' 104*c2e18aaaSAndroid Build Coastguard WorkerMODULE_TARGET_DEPS = 'target_dependencies' 105*c2e18aaaSAndroid Build Coastguard WorkerMODULE_TEST_OPTIONS_TAGS = 'test_options_tags' 106*c2e18aaaSAndroid Build Coastguard WorkerMODULE_INFO_ID = 'module_info_id' 107*c2e18aaaSAndroid Build Coastguard Worker 108*c2e18aaaSAndroid Build Coastguard Worker 109*c2e18aaaSAndroid Build Coastguard Worker# Env constants 110*c2e18aaaSAndroid Build Coastguard WorkerANDROID_BUILD_TOP = 'ANDROID_BUILD_TOP' 111*c2e18aaaSAndroid Build Coastguard WorkerANDROID_OUT = 'OUT' 112*c2e18aaaSAndroid Build Coastguard WorkerANDROID_OUT_DIR = 'OUT_DIR' 113*c2e18aaaSAndroid Build Coastguard WorkerANDROID_OUT_DIR_COMMON_BASE = 'OUT_DIR_COMMON_BASE' 114*c2e18aaaSAndroid Build Coastguard WorkerANDROID_HOST_OUT = 'ANDROID_HOST_OUT' 115*c2e18aaaSAndroid Build Coastguard WorkerANDROID_PRODUCT_OUT = 'ANDROID_PRODUCT_OUT' 116*c2e18aaaSAndroid Build Coastguard WorkerANDROID_TARGET_PRODUCT = 'TARGET_PRODUCT' 117*c2e18aaaSAndroid Build Coastguard WorkerTARGET_BUILD_VARIANT = 'TARGET_BUILD_VARIANT' 118*c2e18aaaSAndroid Build Coastguard WorkerANDROID_TARGET_OUT_TESTCASES = 'ANDROID_TARGET_OUT_TESTCASES' 119*c2e18aaaSAndroid Build Coastguard Worker 120*c2e18aaaSAndroid Build Coastguard Worker# Test Info data keys 121*c2e18aaaSAndroid Build Coastguard Worker# Value of include-filter option. 122*c2e18aaaSAndroid Build Coastguard WorkerTI_FILTER = 'filter' 123*c2e18aaaSAndroid Build Coastguard WorkerTI_REL_CONFIG = 'rel_config' 124*c2e18aaaSAndroid Build Coastguard WorkerTI_MODULE_CLASS = 'module_class' 125*c2e18aaaSAndroid Build Coastguard Worker# Value of module-arg option 126*c2e18aaaSAndroid Build Coastguard WorkerTI_MODULE_ARG = 'module-arg' 127*c2e18aaaSAndroid Build Coastguard Worker 128*c2e18aaaSAndroid Build Coastguard Worker# Google TF 129*c2e18aaaSAndroid Build Coastguard WorkerGTF_MODULE = 'google-tradefed' 130*c2e18aaaSAndroid Build Coastguard WorkerGTF_TARGET = 'google-tradefed-core' 131*c2e18aaaSAndroid Build Coastguard Worker# Defines the TF build targets which only exist in internal branches. 132*c2e18aaaSAndroid Build Coastguard Worker# TODO(b/283364305) Have a flag and use the setup in vendor to define the flag. 133*c2e18aaaSAndroid Build Coastguard WorkerGTF_TARGETS = set() 134*c2e18aaaSAndroid Build Coastguard Worker 135*c2e18aaaSAndroid Build Coastguard Worker# TEST_MAPPING filename 136*c2e18aaaSAndroid Build Coastguard WorkerTEST_MAPPING = 'TEST_MAPPING' 137*c2e18aaaSAndroid Build Coastguard Worker# Test group for tests in TEST_MAPPING 138*c2e18aaaSAndroid Build Coastguard WorkerTEST_GROUP_PRESUBMIT = 'presubmit' 139*c2e18aaaSAndroid Build Coastguard WorkerTEST_GROUP_PRESUBMIT_LARGE = 'presubmit-large' 140*c2e18aaaSAndroid Build Coastguard WorkerTEST_GROUP_POSTSUBMIT = 'postsubmit' 141*c2e18aaaSAndroid Build Coastguard WorkerTEST_GROUP_ALL = 'all' 142*c2e18aaaSAndroid Build Coastguard WorkerDEFAULT_TEST_GROUPS = [TEST_GROUP_PRESUBMIT, TEST_GROUP_PRESUBMIT_LARGE] 143*c2e18aaaSAndroid Build Coastguard Worker# Key in TEST_MAPPING file for a list of imported TEST_MAPPING file 144*c2e18aaaSAndroid Build Coastguard WorkerTEST_MAPPING_IMPORTS = 'imports' 145*c2e18aaaSAndroid Build Coastguard Worker 146*c2e18aaaSAndroid Build Coastguard Worker# TradeFed command line args 147*c2e18aaaSAndroid Build Coastguard WorkerTF_INCLUDE_FILTER_OPTION = 'include-filter' 148*c2e18aaaSAndroid Build Coastguard WorkerTF_EXCLUDE_FILTER_OPTION = 'exclude-filter' 149*c2e18aaaSAndroid Build Coastguard WorkerTF_INCLUDE_FILTER = '--include-filter' 150*c2e18aaaSAndroid Build Coastguard WorkerTF_EXCLUDE_FILTER = '--exclude-filter' 151*c2e18aaaSAndroid Build Coastguard WorkerTF_ATEST_INCLUDE_FILTER = '--atest-include-filter' 152*c2e18aaaSAndroid Build Coastguard WorkerTF_ATEST_INCLUDE_FILTER_VALUE_FMT = '{test_name}:{test_filter}' 153*c2e18aaaSAndroid Build Coastguard WorkerTF_MODULE_ARG = '--module-arg' 154*c2e18aaaSAndroid Build Coastguard WorkerTF_MODULE_ARG_VALUE_FMT = '{test_name}:{option_name}:{option_value}' 155*c2e18aaaSAndroid Build Coastguard WorkerTF_SUITE_FILTER_ARG_VALUE_FMT = '"{test_name} {option_value}"' 156*c2e18aaaSAndroid Build Coastguard WorkerTF_SKIP_LOADING_CONFIG_JAR = '--skip-loading-config-jar' 157*c2e18aaaSAndroid Build Coastguard WorkerTF_MODULE_FILTER = '--module' 158*c2e18aaaSAndroid Build Coastguard WorkerTF_ENABLE_MAINLINE_PARAMETERIZED_MODULES = ( 159*c2e18aaaSAndroid Build Coastguard Worker '--enable-mainline-parameterized-modules' 160*c2e18aaaSAndroid Build Coastguard Worker) 161*c2e18aaaSAndroid Build Coastguard WorkerTF_ENABLE_PARAMETERIZED_MODULES = '--enable-parameterized-modules' 162*c2e18aaaSAndroid Build Coastguard WorkerTF_MODULE_PARAMETER = '--module-parameter' 163*c2e18aaaSAndroid Build Coastguard Worker 164*c2e18aaaSAndroid Build Coastguard Worker# Mobly constants 165*c2e18aaaSAndroid Build Coastguard WorkerMOBLY_TEST_OPTIONS_TAG = 'mobly' 166*c2e18aaaSAndroid Build Coastguard Worker 167*c2e18aaaSAndroid Build Coastguard Worker# Suite Plans 168*c2e18aaaSAndroid Build Coastguard WorkerSUITE_PLANS = frozenset(['cts']) 169*c2e18aaaSAndroid Build Coastguard Worker 170*c2e18aaaSAndroid Build Coastguard Worker# Constants of Steps 171*c2e18aaaSAndroid Build Coastguard WorkerREBUILD_MODULE_INFO_FLAG = '--rebuild-module-info' 172*c2e18aaaSAndroid Build Coastguard WorkerBUILD_STEP = 'build' 173*c2e18aaaSAndroid Build Coastguard WorkerDEVICE_UPDATE_STEP = 'update_device' 174*c2e18aaaSAndroid Build Coastguard WorkerINSTALL_STEP = 'install' 175*c2e18aaaSAndroid Build Coastguard WorkerTEST_STEP = 'test' 176*c2e18aaaSAndroid Build Coastguard WorkerALL_STEPS = [BUILD_STEP, INSTALL_STEP, TEST_STEP] 177*c2e18aaaSAndroid Build Coastguard Worker 178*c2e18aaaSAndroid Build Coastguard Worker# ANSI code shift for colorful print 179*c2e18aaaSAndroid Build Coastguard WorkerBLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8) 180*c2e18aaaSAndroid Build Coastguard Worker 181*c2e18aaaSAndroid Build Coastguard Worker# Types of Levenshetine Distance Cost 182*c2e18aaaSAndroid Build Coastguard WorkerCOST_TYPO = (1, 1, 1) 183*c2e18aaaSAndroid Build Coastguard WorkerCOST_SEARCH = (8, 1, 5) 184*c2e18aaaSAndroid Build Coastguard WorkerLD_RANGE = 2 185*c2e18aaaSAndroid Build Coastguard Worker 186*c2e18aaaSAndroid Build Coastguard Worker# Value of TestInfo install_locations. 187*c2e18aaaSAndroid Build Coastguard WorkerDEVICELESS_TEST = 'host' 188*c2e18aaaSAndroid Build Coastguard WorkerDEVICE_TEST = 'device' 189*c2e18aaaSAndroid Build Coastguard WorkerBOTH_TEST = 'both' 190*c2e18aaaSAndroid Build Coastguard Worker 191*c2e18aaaSAndroid Build Coastguard Worker# Metrics 192*c2e18aaaSAndroid Build Coastguard WorkerNO_METRICS_ARG = '--no-metrics' 193*c2e18aaaSAndroid Build Coastguard WorkerEXTERNAL = 'EXTERNAL_RUN' 194*c2e18aaaSAndroid Build Coastguard WorkerINTERNAL = 'INTERNAL_RUN' 195*c2e18aaaSAndroid Build Coastguard WorkerINTERNAL_EMAIL = '@google.com' 196*c2e18aaaSAndroid Build Coastguard WorkerINTERNAL_HOSTNAME = ['.google.com', 'c.googlers.com'] 197*c2e18aaaSAndroid Build Coastguard WorkerTOOL_NAME = 'atest' 198*c2e18aaaSAndroid Build Coastguard WorkerSUB_TOOL_NAME = '' 199*c2e18aaaSAndroid Build Coastguard WorkerUSER_FROM_TOOL = 'USER_FROM_TOOL' 200*c2e18aaaSAndroid Build Coastguard WorkerUSER_FROM_SUB_TOOL = 'USER_FROM_SUB_TOOL' 201*c2e18aaaSAndroid Build Coastguard WorkerTF_PREPARATION = 'tf-preparation' 202*c2e18aaaSAndroid Build Coastguard Worker 203*c2e18aaaSAndroid Build Coastguard Worker# Detect type for local_detect_event. 204*c2e18aaaSAndroid Build Coastguard Worker# XTS suite types encode from 100 to 199 205*c2e18aaaSAndroid Build Coastguard WorkerDETECT_TYPE_XTS_SUITE = {'cts': 101, 'vts': 104} 206*c2e18aaaSAndroid Build Coastguard Worker 207*c2e18aaaSAndroid Build Coastguard Worker# Considering a trade-off between speed and size, we set UPPER_LIMIT to 100000 208*c2e18aaaSAndroid Build Coastguard Worker# to make maximum file space 10M(100000(records)*100(byte/record)) at most. 209*c2e18aaaSAndroid Build Coastguard Worker# Therefore, to update history file will spend 1 sec at most in each run. 210*c2e18aaaSAndroid Build Coastguard WorkerUPPER_LIMIT = 100000 211*c2e18aaaSAndroid Build Coastguard WorkerTRIM_TO_SIZE = 50000 212*c2e18aaaSAndroid Build Coastguard Worker 213*c2e18aaaSAndroid Build Coastguard Worker# VTS plans 214*c2e18aaaSAndroid Build Coastguard WorkerVTS_STAGING_PLAN = 'vts-staging-default' 215*c2e18aaaSAndroid Build Coastguard Worker 216*c2e18aaaSAndroid Build Coastguard Worker# TreeHugger TEST_MAPPING SUITE_PLANS 217*c2e18aaaSAndroid Build Coastguard WorkerTEST_MAPPING_SUITES = ['device-tests', 'general-tests'] 218*c2e18aaaSAndroid Build Coastguard Worker 219*c2e18aaaSAndroid Build Coastguard Worker# VTS10 TF 220*c2e18aaaSAndroid Build Coastguard WorkerVTS_TF_MODULE = 'vts10-tradefed' 221*c2e18aaaSAndroid Build Coastguard Worker 222*c2e18aaaSAndroid Build Coastguard Worker# VTS TF 223*c2e18aaaSAndroid Build Coastguard WorkerVTS_CORE_TF_MODULE = 'vts-tradefed' 224*c2e18aaaSAndroid Build Coastguard Worker 225*c2e18aaaSAndroid Build Coastguard Worker# VTS suite set 226*c2e18aaaSAndroid Build Coastguard WorkerVTS_CORE_SUITE = 'vts' 227*c2e18aaaSAndroid Build Coastguard Worker 228*c2e18aaaSAndroid Build Coastguard Worker# MTS suite set 229*c2e18aaaSAndroid Build Coastguard WorkerMTS_SUITE = 'mts' 230*c2e18aaaSAndroid Build Coastguard Worker 231*c2e18aaaSAndroid Build Coastguard Worker# CTS tradefed jar 232*c2e18aaaSAndroid Build Coastguard WorkerCTS_JAR = 'cts-tradefed' 233*c2e18aaaSAndroid Build Coastguard Worker 234*c2e18aaaSAndroid Build Coastguard Worker# ATest TF 235*c2e18aaaSAndroid Build Coastguard WorkerATEST_TF_MODULE = 'atest-tradefed' 236*c2e18aaaSAndroid Build Coastguard Worker 237*c2e18aaaSAndroid Build Coastguard Worker# Atest index path and relative dirs/caches. 238*c2e18aaaSAndroid Build Coastguard WorkerINDEX_DIR = os.path.join(os.getenv(ANDROID_HOST_OUT, ''), 'indices') 239*c2e18aaaSAndroid Build Coastguard WorkerLOCATE_CACHE = os.path.join(INDEX_DIR, 'plocate.db') 240*c2e18aaaSAndroid Build Coastguard WorkerBUILDFILES_STP = os.path.join(INDEX_DIR, 'buildfiles.stp') 241*c2e18aaaSAndroid Build Coastguard WorkerINT_INDEX = os.path.join(INDEX_DIR, 'integration.idx') 242*c2e18aaaSAndroid Build Coastguard WorkerCLASS_INDEX = os.path.join(INDEX_DIR, 'classes.idx') 243*c2e18aaaSAndroid Build Coastguard WorkerCC_CLASS_INDEX = os.path.join(INDEX_DIR, 'cc_classes.idx') 244*c2e18aaaSAndroid Build Coastguard WorkerPACKAGE_INDEX = os.path.join(INDEX_DIR, 'packages.idx') 245*c2e18aaaSAndroid Build Coastguard WorkerQCLASS_INDEX = os.path.join(INDEX_DIR, 'fqcn.idx') 246*c2e18aaaSAndroid Build Coastguard Worker 247*c2e18aaaSAndroid Build Coastguard Worker# Regeular Expressions 248*c2e18aaaSAndroid Build Coastguard WorkerCC_EXT_RE = re.compile(r'.*\.(cc|cpp)$') 249*c2e18aaaSAndroid Build Coastguard WorkerJAVA_EXT_RE = re.compile(r'.*\.(java|kt)$') 250*c2e18aaaSAndroid Build Coastguard Worker# e.g. /path/to/ccfile.cc: TYPED_TEST_P(test_name, method_name){ 251*c2e18aaaSAndroid Build Coastguard WorkerCC_OUTPUT_RE = re.compile( 252*c2e18aaaSAndroid Build Coastguard Worker r'(?P<file_path>/.*):\s*(TYPED_TEST(_P)*|TEST(_F|_P)*)\s*\(' 253*c2e18aaaSAndroid Build Coastguard Worker r'(?P<test_name>\w+)\s*,\s*(?P<method_name>\w+)\)\s*\{' 254*c2e18aaaSAndroid Build Coastguard Worker) 255*c2e18aaaSAndroid Build Coastguard Worker# Used by locate command. 256*c2e18aaaSAndroid Build Coastguard WorkerCC_GREP_RE = r'^\s*(TYPED_TEST(_P)*|TEST(_F|_P)*)\s*\(\w+,' 257*c2e18aaaSAndroid Build Coastguard Worker# e.g. /path/to/Javafile.java:package com.android.settings.accessibility 258*c2e18aaaSAndroid Build Coastguard Worker# grab the path, Javafile(class) and com.android.settings.accessibility(package) 259*c2e18aaaSAndroid Build Coastguard WorkerCLASS_OUTPUT_RE = re.compile(r'(?P<java_path>.*/(?P<class>[A-Z]\w+)\.\w+)[:].*') 260*c2e18aaaSAndroid Build Coastguard WorkerQCLASS_OUTPUT_RE = re.compile( 261*c2e18aaaSAndroid Build Coastguard Worker r'(?P<java_path>.*/(?P<class>[A-Z]\w+)\.\w+)' 262*c2e18aaaSAndroid Build Coastguard Worker r'[:]\s*package\s+(?P<package>[^(;|\s)]+)\s*' 263*c2e18aaaSAndroid Build Coastguard Worker) 264*c2e18aaaSAndroid Build Coastguard WorkerPACKAGE_OUTPUT_RE = re.compile( 265*c2e18aaaSAndroid Build Coastguard Worker r'(?P<java_dir>/.*/).*[.](java|kt)[:]\s*package\s+' 266*c2e18aaaSAndroid Build Coastguard Worker r'(?P<package>[^(;|\s)]+)\s*' 267*c2e18aaaSAndroid Build Coastguard Worker) 268*c2e18aaaSAndroid Build Coastguard Worker 269*c2e18aaaSAndroid Build Coastguard WorkerATEST_RESULT_ROOT = Path( 270*c2e18aaaSAndroid Build Coastguard Worker tempfile.gettempdir(), 271*c2e18aaaSAndroid Build Coastguard Worker 'atest_result_%s' % Path('~').expanduser().name.replace(' ', '_'), 272*c2e18aaaSAndroid Build Coastguard Worker) 273*c2e18aaaSAndroid Build Coastguard WorkerATEST_TEST_RECORD_PROTO = 'test_record.proto' 274*c2e18aaaSAndroid Build Coastguard WorkerLATEST_RESULT_FILE = os.path.join(ATEST_RESULT_ROOT, 'LATEST', 'test_result') 275*c2e18aaaSAndroid Build Coastguard Worker 276*c2e18aaaSAndroid Build Coastguard Worker# Tests list which need vts_ltp_tests as test dependency 277*c2e18aaaSAndroid Build Coastguard WorkerREQUIRED_LTP_TEST_MODULES = [ 278*c2e18aaaSAndroid Build Coastguard Worker 'vts_ltp_test_arm', 279*c2e18aaaSAndroid Build Coastguard Worker 'vts_ltp_test_arm_64', 280*c2e18aaaSAndroid Build Coastguard Worker 'vts_ltp_test_arm_64_lowmem', 281*c2e18aaaSAndroid Build Coastguard Worker 'vts_ltp_test_arm_64_hwasan', 282*c2e18aaaSAndroid Build Coastguard Worker 'vts_ltp_test_arm_64_lowmem_hwasan', 283*c2e18aaaSAndroid Build Coastguard Worker 'vts_ltp_test_arm_lowmem', 284*c2e18aaaSAndroid Build Coastguard Worker 'vts_ltp_test_x86_64', 285*c2e18aaaSAndroid Build Coastguard Worker 'vts_ltp_test_x86', 286*c2e18aaaSAndroid Build Coastguard Worker] 287*c2e18aaaSAndroid Build Coastguard Worker# Tests list which need vts_kselftest_tests as test dependency 288*c2e18aaaSAndroid Build Coastguard WorkerREQUIRED_KSELFTEST_TEST_MODULES = [ 289*c2e18aaaSAndroid Build Coastguard Worker 'vts_linux_kselftest_arm_32', 290*c2e18aaaSAndroid Build Coastguard Worker 'vts_linux_kselftest_arm_64', 291*c2e18aaaSAndroid Build Coastguard Worker 'vts_linux_kselftest_x86_32', 292*c2e18aaaSAndroid Build Coastguard Worker 'vts_linux_kselftest_x86_64', 293*c2e18aaaSAndroid Build Coastguard Worker] 294*c2e18aaaSAndroid Build Coastguard Worker 295*c2e18aaaSAndroid Build Coastguard Worker# XTS suite set dependency. 296*c2e18aaaSAndroid Build Coastguard WorkerSUITE_DEPS = {} 297*c2e18aaaSAndroid Build Coastguard Worker 298*c2e18aaaSAndroid Build Coastguard Worker# Tradefed log file name term. 299*c2e18aaaSAndroid Build Coastguard WorkerTF_HOST_LOG = 'host_log_*' 300*c2e18aaaSAndroid Build Coastguard Worker 301*c2e18aaaSAndroid Build Coastguard WorkerASUITE_REPO_PROJECT_NAME = 'platform/tools/asuite' 302*c2e18aaaSAndroid Build Coastguard Worker 303*c2e18aaaSAndroid Build Coastguard Worker# logstorage api scope. 304*c2e18aaaSAndroid Build Coastguard WorkerSCOPE_BUILD_API_SCOPE = '' 305*c2e18aaaSAndroid Build Coastguard WorkerSTORAGE_API_VERSION = '' 306*c2e18aaaSAndroid Build Coastguard WorkerSTORAGE_API_VERSION_LEGACY = '' 307*c2e18aaaSAndroid Build Coastguard WorkerSTORAGE_SERVICE_NAME = '' 308*c2e18aaaSAndroid Build Coastguard WorkerCLIENT_ID = '' 309*c2e18aaaSAndroid Build Coastguard WorkerCLIENT_SECRET = '' 310*c2e18aaaSAndroid Build Coastguard WorkerCREDENTIAL_FILE_NAME = '' 311*c2e18aaaSAndroid Build Coastguard WorkerTOKEN_FILE_PATH = '' 312*c2e18aaaSAndroid Build Coastguard WorkerINVOCATION_ID = 'INVOCATION_ID' 313*c2e18aaaSAndroid Build Coastguard WorkerWORKUNIT_ID = 'WORKUNIT_ID' 314*c2e18aaaSAndroid Build Coastguard WorkerLOCAL_BUILD_ID = 'LOCAL_BUILD_ID' 315*c2e18aaaSAndroid Build Coastguard WorkerBUILD_TARGET = 'BUILD_TARGET' 316*c2e18aaaSAndroid Build Coastguard WorkerRESULT_LINK = '' 317*c2e18aaaSAndroid Build Coastguard WorkerTF_GLOBAL_CONFIG = '' 318*c2e18aaaSAndroid Build Coastguard WorkerDISCOVERY_SERVICE = '' 319*c2e18aaaSAndroid Build Coastguard WorkerDISCOVERY_SERVICE_LEGACY = '' 320*c2e18aaaSAndroid Build Coastguard WorkerSTORAGE2_TEST_URI = '' 321*c2e18aaaSAndroid Build Coastguard Worker 322*c2e18aaaSAndroid Build Coastguard Worker# SSO constants. 323*c2e18aaaSAndroid Build Coastguard WorkerTOKEN_EXCHANGE_COMMAND = '' 324*c2e18aaaSAndroid Build Coastguard WorkerTOKEN_EXCHANGE_REQUEST = '' 325*c2e18aaaSAndroid Build Coastguard WorkerSCOPE = '' 326*c2e18aaaSAndroid Build Coastguard Worker 327*c2e18aaaSAndroid Build Coastguard Worker# Example arguments used in ~/.atest/config 328*c2e18aaaSAndroid Build Coastguard WorkerATEST_EXAMPLE_ARGS = ( 329*c2e18aaaSAndroid Build Coastguard Worker '## Specify only one option per line; any test name/path will be ignored' 330*c2e18aaaSAndroid Build Coastguard Worker ' automatically.\n## Option that follows a "#" will be' 331*c2e18aaaSAndroid Build Coastguard Worker ' ignored.\nhello_world_test # Test name will be skipped WITHOUT' 332*c2e18aaaSAndroid Build Coastguard Worker ' warning.\n# -- --module-arg Foo:variable:value # Only support atest' 333*c2e18aaaSAndroid Build Coastguard Worker ' arguments so "--" will be ignored.\n ' 334*c2e18aaaSAndroid Build Coastguard Worker ' # and will stop running tests.\n# --iterations=3\n#' 335*c2e18aaaSAndroid Build Coastguard Worker ' --retry-any-failure=5\n# --rerun-until-failure=5\n# --start-avd #' 336*c2e18aaaSAndroid Build Coastguard Worker ' also run "acloud create" concurrently.\n# --all-abi # Set to run' 337*c2e18aaaSAndroid Build Coastguard Worker ' tests for all abis.\n# --verbose # turn on verbose mode for' 338*c2e18aaaSAndroid Build Coastguard Worker ' debugging.\n' 339*c2e18aaaSAndroid Build Coastguard Worker) 340*c2e18aaaSAndroid Build Coastguard Worker 341*c2e18aaaSAndroid Build Coastguard Worker# AndroidJUnitTest related argument. 342*c2e18aaaSAndroid Build Coastguard WorkerANDROID_JUNIT_CLASS = 'com.android.tradefed.testtype.AndroidJUnitTest' 343*c2e18aaaSAndroid Build Coastguard WorkerINCLUDE_ANNOTATION = 'include-annotation' 344*c2e18aaaSAndroid Build Coastguard WorkerEXCLUDE_ANNOTATION = 'exclude-annotation' 345*c2e18aaaSAndroid Build Coastguard WorkerSUPPORTED_FILTERS = [INCLUDE_ANNOTATION, EXCLUDE_ANNOTATION] 346*c2e18aaaSAndroid Build Coastguard Worker 347*c2e18aaaSAndroid Build Coastguard Worker# Tradefed config-descriptor metadata. 348*c2e18aaaSAndroid Build Coastguard WorkerCONFIG_DESCRIPTOR = 'config-descriptor:metadata' 349*c2e18aaaSAndroid Build Coastguard WorkerPARAMETER_KEY = 'parameter' 350*c2e18aaaSAndroid Build Coastguard WorkerMAINLINE_PARAM_KEY = 'mainline-param' 351*c2e18aaaSAndroid Build Coastguard Worker 352*c2e18aaaSAndroid Build Coastguard Worker# Tradefed related constant. 353*c2e18aaaSAndroid Build Coastguard WorkerTF_TEST_ARG = '--test-arg' 354*c2e18aaaSAndroid Build Coastguard WorkerTF_AND_JUNIT_CLASS = 'com.android.tradefed.testtype.AndroidJUnitTest' 355*c2e18aaaSAndroid Build Coastguard WorkerTF_EXCLUDE_ANNOTATE = 'exclude-annotation' 356*c2e18aaaSAndroid Build Coastguard WorkerINSTANT_MODE_ANNOTATE = 'android.platform.test.annotations.AppModeInstant' 357*c2e18aaaSAndroid Build Coastguard WorkerTF_PARA_INSTANT_APP = 'instant_app' 358*c2e18aaaSAndroid Build Coastguard WorkerTF_PARA_SECOND_USR = 'secondary_user' 359*c2e18aaaSAndroid Build Coastguard WorkerTF_PARA_MULTIABI = 'multi_abi' 360*c2e18aaaSAndroid Build Coastguard WorkerDEFAULT_EXCLUDE_PARAS = { 361*c2e18aaaSAndroid Build Coastguard Worker TF_PARA_INSTANT_APP, 362*c2e18aaaSAndroid Build Coastguard Worker TF_PARA_SECOND_USR, 363*c2e18aaaSAndroid Build Coastguard Worker TF_PARA_MULTIABI, 364*c2e18aaaSAndroid Build Coastguard Worker} 365*c2e18aaaSAndroid Build Coastguard WorkerDEFAULT_EXCLUDE_NOT_PARAS = { 366*c2e18aaaSAndroid Build Coastguard Worker 'not_' + TF_PARA_INSTANT_APP, 367*c2e18aaaSAndroid Build Coastguard Worker 'not_' + TF_PARA_SECOND_USR, 368*c2e18aaaSAndroid Build Coastguard Worker 'not_' + TF_PARA_MULTIABI, 369*c2e18aaaSAndroid Build Coastguard Worker} 370*c2e18aaaSAndroid Build Coastguard WorkerRUNNER_COMMAND_PATH = os.path.join( 371*c2e18aaaSAndroid Build Coastguard Worker os.environ.get(ANDROID_BUILD_TOP, os.getcwd()), 372*c2e18aaaSAndroid Build Coastguard Worker 'tools/asuite/atest/test_data/runner_commands.json', 373*c2e18aaaSAndroid Build Coastguard Worker) 374*c2e18aaaSAndroid Build Coastguard Worker 375*c2e18aaaSAndroid Build Coastguard Worker# Tradefed log saver template for ATest 376*c2e18aaaSAndroid Build Coastguard WorkerATEST_TF_LOG_SAVER = 'template/log/atest_log_saver' 377*c2e18aaaSAndroid Build Coastguard WorkerDEVICE_SETUP_PREPARER = 'template/preparers/device-preparer' 378*c2e18aaaSAndroid Build Coastguard WorkerLOG_ROOT_OPTION_NAME = 'atest-log-file-path' 379*c2e18aaaSAndroid Build Coastguard WorkerLOG_SAVER_EXT_OPTION = '' 380*c2e18aaaSAndroid Build Coastguard Worker 381*c2e18aaaSAndroid Build Coastguard Worker# Tradefed log saver template for uploading logs to cloud storage. 382*c2e18aaaSAndroid Build Coastguard WorkerGOOGLE_LOG_SAVER = '' 383*c2e18aaaSAndroid Build Coastguard WorkerGOOGLE_LOG_SAVER_LOG_ROOT_OPTION_NAME = '' 384*c2e18aaaSAndroid Build Coastguard WorkerGOOGLE_LOG_SAVER_EXT_OPTION = '' 385*c2e18aaaSAndroid Build Coastguard Worker 386*c2e18aaaSAndroid Build Coastguard Worker# Log messages here. 387*c2e18aaaSAndroid Build Coastguard WorkerREQUIRE_DEVICES_MSG = ( 388*c2e18aaaSAndroid Build Coastguard Worker 'Please ensure there is at least one connected device via:\n' 389*c2e18aaaSAndroid Build Coastguard Worker ' $ adb devices' 390*c2e18aaaSAndroid Build Coastguard Worker) 391*c2e18aaaSAndroid Build Coastguard Worker 392*c2e18aaaSAndroid Build Coastguard Worker# Default shard num. 393*c2e18aaaSAndroid Build Coastguard WorkerSHARD_NUM = 2 394