Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 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 | import os |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame] | 16 | import re |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 17 | import tempfile |
| 18 | import subprocess |
| 19 | |
| 20 | env = dict(os.environ) |
| 21 | |
| 22 | def getEnvBoolean(var, default): |
| 23 | val = env.get(var) |
| 24 | if val: |
| 25 | if val == "True" or val == "true": |
| 26 | return True |
| 27 | if val == "False" or val == "false": |
| 28 | return False |
| 29 | return default |
| 30 | |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame] | 31 | _DUMP_MANY_VARS_LIST = ['HOST_2ND_ARCH_PREFIX', |
| 32 | 'TARGET_2ND_ARCH', |
| 33 | 'TARGET_ARCH', |
| 34 | 'HOST_PREFER_32_BIT', |
| 35 | 'HOST_OUT_EXECUTABLES'] |
| 36 | _DUMP_MANY_VARS = None # To be set to a dictionary with above list being the keys, |
| 37 | # and the build variable being the value. |
| 38 | def dump_many_vars(var_name): |
| 39 | """ |
| 40 | Reach into the Android build system to dump many build vars simultaneously. |
| 41 | Since the make system is so slow, we want to avoid calling into build frequently. |
| 42 | """ |
| 43 | global _DUMP_MANY_VARS |
| 44 | global _DUMP_MANY_VARS_LIST |
| 45 | |
| 46 | # Look up var from cache. |
| 47 | if _DUMP_MANY_VARS: |
| 48 | return _DUMP_MANY_VARS[var_name] |
| 49 | |
| 50 | all_vars=" ".join(_DUMP_MANY_VARS_LIST) |
| 51 | |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 52 | # The command is taken from build/envsetup.sh to fetch build variables. |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame] | 53 | command = ("CALLED_FROM_SETUP=true " # Enable the 'dump-many-vars' make target. |
| 54 | "BUILD_SYSTEM=build/core " # Set up lookup path for make includes. |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 55 | "make --no-print-directory -C \"%s\" -f build/core/config.mk " |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame] | 56 | "dump-many-vars DUMP_MANY_VARS=\"%s\"") % (ANDROID_BUILD_TOP, all_vars) |
| 57 | |
Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 58 | config = subprocess.Popen(command, |
| 59 | stdout=subprocess.PIPE, |
| 60 | universal_newlines=True, |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame] | 61 | shell=True).communicate()[0] # read until EOF, select stdin |
| 62 | # Prints out something like: |
| 63 | # TARGET_ARCH='arm64' |
| 64 | # HOST_ARCH='x86_64' |
| 65 | _DUMP_MANY_VARS = {} |
| 66 | for line in config.split("\n"): |
| 67 | # Split out "$key='$value'" via regex. |
| 68 | match = re.search("([^=]+)='([^']*)", line) |
| 69 | if not match: |
| 70 | continue |
| 71 | key = match.group(1) |
| 72 | value = match.group(2) |
| 73 | _DUMP_MANY_VARS[key] = value |
| 74 | |
| 75 | return _DUMP_MANY_VARS[var_name] |
| 76 | |
| 77 | def get_build_var(var_name): |
| 78 | return dump_many_vars(var_name) |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 79 | |
| 80 | def get_env(key): |
| 81 | return env.get(key) |
| 82 | |
| 83 | ANDROID_BUILD_TOP = env.get('ANDROID_BUILD_TOP', os.getcwd()) |
| 84 | |
| 85 | # Directory used for temporary test files on the host. |
| 86 | ART_HOST_TEST_DIR = tempfile.mkdtemp(prefix = 'test-art-') |
| 87 | |
| 88 | # Keep going after encountering a test failure? |
| 89 | ART_TEST_KEEP_GOING = getEnvBoolean('ART_TEST_KEEP_GOING', True) |
| 90 | |
| 91 | # Do you want all tests, even those that are time consuming? |
| 92 | ART_TEST_FULL = getEnvBoolean('ART_TEST_FULL', False) |
| 93 | |
| 94 | # Do you want interpreter tests run? |
| 95 | ART_TEST_INTERPRETER = getEnvBoolean('ART_TEST_INTERPRETER', ART_TEST_FULL) |
| 96 | ART_TEST_INTERPRETER_ACCESS_CHECKS = getEnvBoolean('ART_TEST_INTERPRETER_ACCESS_CHECKS', |
| 97 | ART_TEST_FULL) |
| 98 | |
| 99 | # Do you want JIT tests run? |
| 100 | ART_TEST_JIT = getEnvBoolean('ART_TEST_JIT', ART_TEST_FULL) |
| 101 | |
| 102 | # Do you want optimizing compiler tests run? |
Shubham Ajmera | 4b8c53d | 2017-02-15 16:38:16 +0000 | [diff] [blame] | 103 | ART_TEST_OPTIMIZING = getEnvBoolean('ART_TEST_OPTIMIZING', ART_TEST_FULL) |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 104 | |
| 105 | # Do you want to test the optimizing compiler with graph coloring register allocation? |
| 106 | ART_TEST_OPTIMIZING_GRAPH_COLOR = getEnvBoolean('ART_TEST_OPTIMIZING_GRAPH_COLOR', ART_TEST_FULL) |
| 107 | |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame^] | 108 | # Do you want to do run-tests with profiles? |
| 109 | ART_TEST_SPEED_PROFILE = getEnvBoolean('ART_TEST_SPEED_PROFILE', ART_TEST_FULL) |
| 110 | |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 111 | # Do we want to test PIC-compiled tests ("apps")? |
| 112 | ART_TEST_PIC_TEST = getEnvBoolean('ART_TEST_PIC_TEST', ART_TEST_FULL) |
| 113 | # Do you want tracing tests run? |
| 114 | ART_TEST_TRACE = getEnvBoolean('ART_TEST_TRACE', ART_TEST_FULL) |
| 115 | |
| 116 | # Do you want tracing tests (streaming mode) run? |
| 117 | ART_TEST_TRACE_STREAM = getEnvBoolean('ART_TEST_TRACE_STREAM', ART_TEST_FULL) |
| 118 | |
| 119 | # Do you want tests with GC verification enabled run? |
| 120 | ART_TEST_GC_VERIFY = getEnvBoolean('ART_TEST_GC_VERIFY', ART_TEST_FULL) |
| 121 | |
| 122 | # Do you want tests with the GC stress mode enabled run? |
| 123 | ART_TEST_GC_STRESS = getEnvBoolean('ART_TEST_GC_STRESS', ART_TEST_FULL) |
| 124 | |
| 125 | # Do you want tests with the JNI forcecopy mode enabled run? |
| 126 | ART_TEST_JNI_FORCECOPY = getEnvBoolean('ART_TEST_JNI_FORCECOPY', ART_TEST_FULL) |
| 127 | |
| 128 | # Do you want run-tests with relocation disabled run? |
| 129 | ART_TEST_RUN_TEST_RELOCATE = getEnvBoolean('ART_TEST_RUN_TEST_RELOCATE', ART_TEST_FULL) |
| 130 | |
| 131 | # Do you want run-tests with prebuilding? |
Shubham Ajmera | 4b8c53d | 2017-02-15 16:38:16 +0000 | [diff] [blame] | 132 | ART_TEST_RUN_TEST_PREBUILD = getEnvBoolean('ART_TEST_RUN_TEST_PREBUILD', ART_TEST_FULL) |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 133 | |
| 134 | # Do you want run-tests with no prebuilding enabled run? |
| 135 | ART_TEST_RUN_TEST_NO_PREBUILD = getEnvBoolean('ART_TEST_RUN_TEST_NO_PREBUILD', ART_TEST_FULL) |
| 136 | |
| 137 | # Do you want run-tests with a pregenerated core.art? |
Shubham Ajmera | 4b8c53d | 2017-02-15 16:38:16 +0000 | [diff] [blame] | 138 | ART_TEST_RUN_TEST_IMAGE = getEnvBoolean('ART_TEST_RUN_TEST_IMAGE', ART_TEST_FULL) |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 139 | |
| 140 | # Do you want run-tests without a pregenerated core.art? |
| 141 | ART_TEST_RUN_TEST_NO_IMAGE = getEnvBoolean('ART_TEST_RUN_TEST_NO_IMAGE', ART_TEST_FULL) |
| 142 | |
| 143 | # Do you want run-tests with relocation enabled but patchoat failing? |
| 144 | ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT = getEnvBoolean('ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT', |
| 145 | ART_TEST_FULL) |
| 146 | |
| 147 | # Do you want run-tests without a dex2oat? |
| 148 | ART_TEST_RUN_TEST_NO_DEX2OAT = getEnvBoolean('ART_TEST_RUN_TEST_NO_DEX2OAT', ART_TEST_FULL) |
| 149 | |
| 150 | # Do you want run-tests with libartd.so? |
Shubham Ajmera | 4b8c53d | 2017-02-15 16:38:16 +0000 | [diff] [blame] | 151 | ART_TEST_RUN_TEST_DEBUG = getEnvBoolean('ART_TEST_RUN_TEST_DEBUG', ART_TEST_FULL) |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 152 | |
| 153 | # Do you want run-tests with libart.so? |
| 154 | ART_TEST_RUN_TEST_NDEBUG = getEnvBoolean('ART_TEST_RUN_TEST_NDEBUG', ART_TEST_FULL) |
| 155 | |
| 156 | # Do you want failed tests to have their artifacts cleaned up? |
| 157 | ART_TEST_RUN_TEST_ALWAYS_CLEAN = getEnvBoolean('ART_TEST_RUN_TEST_ALWAYS_CLEAN', True) |
| 158 | |
| 159 | # Do you want run-tests with the --debuggable flag |
| 160 | ART_TEST_RUN_TEST_DEBUGGABLE = getEnvBoolean('ART_TEST_RUN_TEST_DEBUGGABLE', ART_TEST_FULL) |
| 161 | |
| 162 | # Do you want to test multi-part boot-image functionality? |
| 163 | ART_TEST_RUN_TEST_MULTI_IMAGE = getEnvBoolean('ART_TEST_RUN_TEST_MULTI_IMAGE', ART_TEST_FULL) |
| 164 | |
| 165 | ART_TEST_DEBUG_GC = getEnvBoolean('ART_TEST_DEBUG_GC', False) |
| 166 | |
| 167 | ART_TEST_BISECTION = getEnvBoolean('ART_TEST_BISECTION', False) |
| 168 | |
| 169 | DEX2OAT_HOST_INSTRUCTION_SET_FEATURES = env.get('DEX2OAT_HOST_INSTRUCTION_SET_FEATURES') |
| 170 | |
| 171 | # Do you want run-tests with the host/target's second arch? |
| 172 | ART_TEST_RUN_TEST_2ND_ARCH = getEnvBoolean('ART_TEST_RUN_TEST_2ND_ARCH', True) |
| 173 | |
| 174 | HOST_2ND_ARCH_PREFIX = get_build_var('HOST_2ND_ARCH_PREFIX') |
| 175 | HOST_2ND_ARCH_PREFIX_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES = env.get( |
| 176 | HOST_2ND_ARCH_PREFIX + 'DEX2OAT_HOST_INSTRUCTION_SET_FEATURES') |
| 177 | |
| 178 | ART_TEST_ANDROID_ROOT = env.get('ART_TEST_ANDROID_ROOT') |
| 179 | |
| 180 | ART_TEST_WITH_STRACE = getEnvBoolean('ART_TEST_DEBUG_GC', False) |
| 181 | |
Alex Light | bc319b2 | 2017-02-17 14:21:33 -0800 | [diff] [blame] | 182 | EXTRA_DISABLED_TESTS = set(env.get("ART_TEST_RUN_TEST_SKIP", "").split()) |
| 183 | |
Alex Light | 9b6b13e | 2017-02-22 11:46:50 -0800 | [diff] [blame] | 184 | ART_TEST_RUN_TEST_BUILD = getEnvBoolean('ART_TEST_RUN_TEST_BUILD', False) |
| 185 | |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 186 | TARGET_2ND_ARCH = get_build_var('TARGET_2ND_ARCH') |
| 187 | TARGET_ARCH = get_build_var('TARGET_ARCH') |
| 188 | if TARGET_2ND_ARCH: |
| 189 | if "64" in TARGET_ARCH: |
| 190 | ART_PHONY_TEST_TARGET_SUFFIX = "64" |
| 191 | _2ND_ART_PHONY_TEST_TARGET_SUFFIX = "32" |
| 192 | else: |
| 193 | ART_PHONY_TEST_TARGET_SUFFIX = "32" |
| 194 | _2ND_ART_PHONY_TEST_TARGET_SUFFIX = "" |
| 195 | else: |
| 196 | if "64" in TARGET_ARCH: |
| 197 | ART_PHONY_TEST_TARGET_SUFFIX = "64" |
| 198 | _2ND_ART_PHONY_TEST_TARGET_SUFFIX = "" |
| 199 | else: |
| 200 | ART_PHONY_TEST_TARGET_SUFFIX = "32" |
| 201 | _2ND_ART_PHONY_TEST_TARGET_SUFFIX = "" |
| 202 | |
| 203 | HOST_PREFER_32_BIT = get_build_var('HOST_PREFER_32_BIT') |
| 204 | if HOST_PREFER_32_BIT == "true": |
| 205 | ART_PHONY_TEST_HOST_SUFFIX = "32" |
| 206 | _2ND_ART_PHONY_TEST_HOST_SUFFIX = "" |
| 207 | else: |
| 208 | ART_PHONY_TEST_HOST_SUFFIX = "64" |
| 209 | _2ND_ART_PHONY_TEST_HOST_SUFFIX = "32" |
| 210 | |
Alex Light | 699c255 | 2017-02-08 10:09:31 -0800 | [diff] [blame] | 211 | HOST_OUT_EXECUTABLES = os.path.join(ANDROID_BUILD_TOP, |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 212 | get_build_var("HOST_OUT_EXECUTABLES")) |
| 213 | os.environ['JACK'] = HOST_OUT_EXECUTABLES + '/jack' |
| 214 | os.environ['DX'] = HOST_OUT_EXECUTABLES + '/dx' |
| 215 | os.environ['SMALI'] = HOST_OUT_EXECUTABLES + '/smali' |
| 216 | os.environ['JASMIN'] = HOST_OUT_EXECUTABLES + '/jasmin' |
| 217 | os.environ['DXMERGER'] = HOST_OUT_EXECUTABLES + '/dexmerger' |