Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2017, The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import os |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame^] | 18 | import re |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 19 | import tempfile |
| 20 | import subprocess |
| 21 | |
| 22 | env = dict(os.environ) |
| 23 | |
| 24 | def getEnvBoolean(var, default): |
| 25 | val = env.get(var) |
| 26 | if val: |
| 27 | if val == "True" or val == "true": |
| 28 | return True |
| 29 | if val == "False" or val == "false": |
| 30 | return False |
| 31 | return default |
| 32 | |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame^] | 33 | _DUMP_MANY_VARS_LIST = ['HOST_2ND_ARCH_PREFIX', |
| 34 | 'TARGET_2ND_ARCH', |
| 35 | 'TARGET_ARCH', |
| 36 | 'HOST_PREFER_32_BIT', |
| 37 | 'HOST_OUT_EXECUTABLES'] |
| 38 | _DUMP_MANY_VARS = None # To be set to a dictionary with above list being the keys, |
| 39 | # and the build variable being the value. |
| 40 | def dump_many_vars(var_name): |
| 41 | """ |
| 42 | Reach into the Android build system to dump many build vars simultaneously. |
| 43 | Since the make system is so slow, we want to avoid calling into build frequently. |
| 44 | """ |
| 45 | global _DUMP_MANY_VARS |
| 46 | global _DUMP_MANY_VARS_LIST |
| 47 | |
| 48 | # Look up var from cache. |
| 49 | if _DUMP_MANY_VARS: |
| 50 | return _DUMP_MANY_VARS[var_name] |
| 51 | |
| 52 | all_vars=" ".join(_DUMP_MANY_VARS_LIST) |
| 53 | |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 54 | # The command is taken from build/envsetup.sh to fetch build variables. |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame^] | 55 | command = ("CALLED_FROM_SETUP=true " # Enable the 'dump-many-vars' make target. |
| 56 | "BUILD_SYSTEM=build/core " # Set up lookup path for make includes. |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 57 | "make --no-print-directory -C \"%s\" -f build/core/config.mk " |
Igor Murashkin | fecb4ef | 2017-02-09 10:42:23 -0800 | [diff] [blame^] | 58 | "dump-many-vars DUMP_MANY_VARS=\"%s\"") % (ANDROID_BUILD_TOP, all_vars) |
| 59 | |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 60 | config = subprocess.Popen(command, stdout=subprocess.PIPE, |
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? |
| 103 | ART_TEST_OPTIMIZING = getEnvBoolean('ART_TEST_OPTIMIZING', True) |
| 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 | |
| 108 | # Do we want to test a non-PIC-compiled core image? |
| 109 | ART_TEST_NPIC_IMAGE = getEnvBoolean('ART_TEST_NPIC_IMAGE', ART_TEST_FULL) |
| 110 | |
| 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? |
| 132 | ART_TEST_RUN_TEST_PREBUILD = getEnvBoolean('ART_TEST_RUN_TEST_PREBUILD', True) |
| 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? |
| 138 | ART_TEST_RUN_TEST_IMAGE = getEnvBoolean('ART_TEST_RUN_TEST_IMAGE', True) |
| 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? |
| 151 | ART_TEST_RUN_TEST_DEBUG = getEnvBoolean('ART_TEST_RUN_TEST_DEBUG', True) |
| 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 | |
| 182 | TARGET_2ND_ARCH = get_build_var('TARGET_2ND_ARCH') |
| 183 | TARGET_ARCH = get_build_var('TARGET_ARCH') |
| 184 | if TARGET_2ND_ARCH: |
| 185 | if "64" in TARGET_ARCH: |
| 186 | ART_PHONY_TEST_TARGET_SUFFIX = "64" |
| 187 | _2ND_ART_PHONY_TEST_TARGET_SUFFIX = "32" |
| 188 | else: |
| 189 | ART_PHONY_TEST_TARGET_SUFFIX = "32" |
| 190 | _2ND_ART_PHONY_TEST_TARGET_SUFFIX = "" |
| 191 | else: |
| 192 | if "64" in TARGET_ARCH: |
| 193 | ART_PHONY_TEST_TARGET_SUFFIX = "64" |
| 194 | _2ND_ART_PHONY_TEST_TARGET_SUFFIX = "" |
| 195 | else: |
| 196 | ART_PHONY_TEST_TARGET_SUFFIX = "32" |
| 197 | _2ND_ART_PHONY_TEST_TARGET_SUFFIX = "" |
| 198 | |
| 199 | HOST_PREFER_32_BIT = get_build_var('HOST_PREFER_32_BIT') |
| 200 | if HOST_PREFER_32_BIT == "true": |
| 201 | ART_PHONY_TEST_HOST_SUFFIX = "32" |
| 202 | _2ND_ART_PHONY_TEST_HOST_SUFFIX = "" |
| 203 | else: |
| 204 | ART_PHONY_TEST_HOST_SUFFIX = "64" |
| 205 | _2ND_ART_PHONY_TEST_HOST_SUFFIX = "32" |
| 206 | |
Alex Light | 699c255 | 2017-02-08 10:09:31 -0800 | [diff] [blame] | 207 | HOST_OUT_EXECUTABLES = os.path.join(ANDROID_BUILD_TOP, |
Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 208 | get_build_var("HOST_OUT_EXECUTABLES")) |
| 209 | os.environ['JACK'] = HOST_OUT_EXECUTABLES + '/jack' |
| 210 | os.environ['DX'] = HOST_OUT_EXECUTABLES + '/dx' |
| 211 | os.environ['SMALI'] = HOST_OUT_EXECUTABLES + '/smali' |
| 212 | os.environ['JASMIN'] = HOST_OUT_EXECUTABLES + '/jasmin' |
| 213 | os.environ['DXMERGER'] = HOST_OUT_EXECUTABLES + '/dexmerger' |