blob: a0c4ea8e429acda15a6f494cee390ba5568af601 [file] [log] [blame]
Shubham Ajmera65adb8b2017-02-06 16:04:25 +00001# 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
15import os
Igor Murashkinfecb4ef2017-02-09 10:42:23 -080016import re
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000017import tempfile
18import subprocess
19
Igor Murashkin6b61c802017-04-03 14:33:22 -070020_env = dict(os.environ)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000021
Igor Murashkin6b61c802017-04-03 14:33:22 -070022def _getEnvBoolean(var, default):
23 val = _env.get(var)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000024 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 Murashkinfecb4ef2017-02-09 10:42:23 -080031_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.
Igor Murashkin6b61c802017-04-03 14:33:22 -070038def _dump_many_vars(var_name):
Igor Murashkinfecb4ef2017-02-09 10:42:23 -080039 """
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 Ajmera65adb8b2017-02-06 16:04:25 +000052 # The command is taken from build/envsetup.sh to fetch build variables.
Igor Murashkinfecb4ef2017-02-09 10:42:23 -080053 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 Ajmera65adb8b2017-02-06 16:04:25 +000055 "make --no-print-directory -C \"%s\" -f build/core/config.mk "
Igor Murashkinfecb4ef2017-02-09 10:42:23 -080056 "dump-many-vars DUMP_MANY_VARS=\"%s\"") % (ANDROID_BUILD_TOP, all_vars)
57
Shubham Ajmerafe793492017-03-16 13:31:35 -070058 config = subprocess.Popen(command,
59 stdout=subprocess.PIPE,
60 universal_newlines=True,
Igor Murashkinfecb4ef2017-02-09 10:42:23 -080061 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
Igor Murashkin6b61c802017-04-03 14:33:22 -070077def _get_build_var(var_name):
78 return _dump_many_vars(var_name)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000079
80def get_env(key):
Igor Murashkin6b61c802017-04-03 14:33:22 -070081 return _env.get(key)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000082
Igor Murashkin6b61c802017-04-03 14:33:22 -070083def _get_android_build_top():
84 path_to_top = _env.get('ANDROID_BUILD_TOP')
85 if not path_to_top:
86 # nothing set. try to guess it based on the relative path of this env.py file.
87 this_file_path = os.path.realpath(__file__)
88 path_to_top = os.path.join(os.path.dirname(this_file_path), '../../../')
89 path_to_top = os.path.realpath(path_to_top)
90
91 if not os.path.exists(os.path.join(path_to_top, 'build/envsetup.sh')):
92 raise AssertionError("env.py must be located inside an android source tree")
93
94 return path_to_top
95
96ANDROID_BUILD_TOP = _get_android_build_top()
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000097
Igor Murashkin8889a892017-04-24 16:09:15 -070098# Compiling with jack? Possible values in (True, False, 'default')
99ANDROID_COMPILE_WITH_JACK = _getEnvBoolean('ANDROID_COMPILE_WITH_JACK', 'default')
100
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000101# Directory used for temporary test files on the host.
102ART_HOST_TEST_DIR = tempfile.mkdtemp(prefix = 'test-art-')
103
104# Keep going after encountering a test failure?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700105ART_TEST_KEEP_GOING = _getEnvBoolean('ART_TEST_KEEP_GOING', True)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000106
107# Do you want all tests, even those that are time consuming?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700108ART_TEST_FULL = _getEnvBoolean('ART_TEST_FULL', False)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000109
110# Do you want interpreter tests run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700111ART_TEST_INTERPRETER = _getEnvBoolean('ART_TEST_INTERPRETER', ART_TEST_FULL)
112ART_TEST_INTERPRETER_ACCESS_CHECKS = _getEnvBoolean('ART_TEST_INTERPRETER_ACCESS_CHECKS',
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000113 ART_TEST_FULL)
114
115# Do you want JIT tests run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700116ART_TEST_JIT = _getEnvBoolean('ART_TEST_JIT', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000117
118# Do you want optimizing compiler tests run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700119ART_TEST_OPTIMIZING = _getEnvBoolean('ART_TEST_OPTIMIZING', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000120
121# Do you want to test the optimizing compiler with graph coloring register allocation?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700122ART_TEST_OPTIMIZING_GRAPH_COLOR = _getEnvBoolean('ART_TEST_OPTIMIZING_GRAPH_COLOR', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000123
Jeff Hao002b9312017-03-27 16:23:08 -0700124# Do you want to do run-tests with profiles?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700125ART_TEST_SPEED_PROFILE = _getEnvBoolean('ART_TEST_SPEED_PROFILE', ART_TEST_FULL)
Jeff Hao002b9312017-03-27 16:23:08 -0700126
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000127# Do we want to test PIC-compiled tests ("apps")?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700128ART_TEST_PIC_TEST = _getEnvBoolean('ART_TEST_PIC_TEST', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000129# Do you want tracing tests run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700130ART_TEST_TRACE = _getEnvBoolean('ART_TEST_TRACE', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000131
132# Do you want tracing tests (streaming mode) run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700133ART_TEST_TRACE_STREAM = _getEnvBoolean('ART_TEST_TRACE_STREAM', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000134
135# Do you want tests with GC verification enabled run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700136ART_TEST_GC_VERIFY = _getEnvBoolean('ART_TEST_GC_VERIFY', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000137
138# Do you want tests with the GC stress mode enabled run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700139ART_TEST_GC_STRESS = _getEnvBoolean('ART_TEST_GC_STRESS', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000140
141# Do you want tests with the JNI forcecopy mode enabled run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700142ART_TEST_JNI_FORCECOPY = _getEnvBoolean('ART_TEST_JNI_FORCECOPY', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000143
144# Do you want run-tests with relocation disabled run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700145ART_TEST_RUN_TEST_RELOCATE = _getEnvBoolean('ART_TEST_RUN_TEST_RELOCATE', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000146
147# Do you want run-tests with prebuilding?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700148ART_TEST_RUN_TEST_PREBUILD = _getEnvBoolean('ART_TEST_RUN_TEST_PREBUILD', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000149
150# Do you want run-tests with no prebuilding enabled run?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700151ART_TEST_RUN_TEST_NO_PREBUILD = _getEnvBoolean('ART_TEST_RUN_TEST_NO_PREBUILD', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000152
153# Do you want run-tests with a pregenerated core.art?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700154ART_TEST_RUN_TEST_IMAGE = _getEnvBoolean('ART_TEST_RUN_TEST_IMAGE', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000155
156# Do you want run-tests without a pregenerated core.art?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700157ART_TEST_RUN_TEST_NO_IMAGE = _getEnvBoolean('ART_TEST_RUN_TEST_NO_IMAGE', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000158
159# Do you want run-tests with relocation enabled but patchoat failing?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700160ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT = _getEnvBoolean('ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT',
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000161 ART_TEST_FULL)
162
163# Do you want run-tests without a dex2oat?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700164ART_TEST_RUN_TEST_NO_DEX2OAT = _getEnvBoolean('ART_TEST_RUN_TEST_NO_DEX2OAT', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000165
166# Do you want run-tests with libartd.so?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700167ART_TEST_RUN_TEST_DEBUG = _getEnvBoolean('ART_TEST_RUN_TEST_DEBUG', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000168
169# Do you want run-tests with libart.so?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700170ART_TEST_RUN_TEST_NDEBUG = _getEnvBoolean('ART_TEST_RUN_TEST_NDEBUG', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000171
172# Do you want failed tests to have their artifacts cleaned up?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700173ART_TEST_RUN_TEST_ALWAYS_CLEAN = _getEnvBoolean('ART_TEST_RUN_TEST_ALWAYS_CLEAN', True)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000174
175# Do you want run-tests with the --debuggable flag
Igor Murashkin6b61c802017-04-03 14:33:22 -0700176ART_TEST_RUN_TEST_DEBUGGABLE = _getEnvBoolean('ART_TEST_RUN_TEST_DEBUGGABLE', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000177
178# Do you want to test multi-part boot-image functionality?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700179ART_TEST_RUN_TEST_MULTI_IMAGE = _getEnvBoolean('ART_TEST_RUN_TEST_MULTI_IMAGE', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000180
Igor Murashkin6b61c802017-04-03 14:33:22 -0700181ART_TEST_DEBUG_GC = _getEnvBoolean('ART_TEST_DEBUG_GC', False)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000182
Igor Murashkin6b61c802017-04-03 14:33:22 -0700183ART_TEST_BISECTION = _getEnvBoolean('ART_TEST_BISECTION', False)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000184
Igor Murashkin6b61c802017-04-03 14:33:22 -0700185DEX2OAT_HOST_INSTRUCTION_SET_FEATURES = _env.get('DEX2OAT_HOST_INSTRUCTION_SET_FEATURES')
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000186
187# Do you want run-tests with the host/target's second arch?
Igor Murashkin6b61c802017-04-03 14:33:22 -0700188ART_TEST_RUN_TEST_2ND_ARCH = _getEnvBoolean('ART_TEST_RUN_TEST_2ND_ARCH', True)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000189
Igor Murashkin6b61c802017-04-03 14:33:22 -0700190HOST_2ND_ARCH_PREFIX = _get_build_var('HOST_2ND_ARCH_PREFIX')
191HOST_2ND_ARCH_PREFIX_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES = _env.get(
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000192 HOST_2ND_ARCH_PREFIX + 'DEX2OAT_HOST_INSTRUCTION_SET_FEATURES')
193
Igor Murashkin6b61c802017-04-03 14:33:22 -0700194ART_TEST_ANDROID_ROOT = _env.get('ART_TEST_ANDROID_ROOT')
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000195
Igor Murashkin6b61c802017-04-03 14:33:22 -0700196ART_TEST_WITH_STRACE = _getEnvBoolean('ART_TEST_DEBUG_GC', False)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000197
Igor Murashkin6b61c802017-04-03 14:33:22 -0700198EXTRA_DISABLED_TESTS = set(_env.get("ART_TEST_RUN_TEST_SKIP", "").split())
Alex Lightbc319b22017-02-17 14:21:33 -0800199
Igor Murashkin6b61c802017-04-03 14:33:22 -0700200ART_TEST_RUN_TEST_BUILD = _getEnvBoolean('ART_TEST_RUN_TEST_BUILD', False)
Alex Light9b6b13e2017-02-22 11:46:50 -0800201
Igor Murashkin6b61c802017-04-03 14:33:22 -0700202TARGET_2ND_ARCH = _get_build_var('TARGET_2ND_ARCH')
203TARGET_ARCH = _get_build_var('TARGET_ARCH')
204
205# Note: ART_2ND_PHONY_TEST_TARGET_SUFFIX is 2ND_ART_PHONY_TEST_TARGET_SUFFIX in .mk files
206# Note: ART_2ND_PHONY_TEST_HOST_SUFFIX is 2ND_ART_PHONY_HOST_TARGET_SUFFIX in .mk files
207# Python does not let us have variable names starting with a digit, so it has differ.
Alex Light8f2c6d42017-04-10 16:27:35 -0700208
209ART_TEST_RUN_TEST_JVMTI_STRESS = _getEnvBoolean('ART_TEST_RUN_TEST_JVMTI_STRESS', ART_TEST_FULL)
210
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000211if TARGET_2ND_ARCH:
212 if "64" in TARGET_ARCH:
213 ART_PHONY_TEST_TARGET_SUFFIX = "64"
Igor Murashkin6b61c802017-04-03 14:33:22 -0700214 ART_2ND_PHONY_TEST_TARGET_SUFFIX = "32"
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000215 else:
216 ART_PHONY_TEST_TARGET_SUFFIX = "32"
Igor Murashkin6b61c802017-04-03 14:33:22 -0700217 ART_2ND_PHONY_TEST_TARGET_SUFFIX = ""
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000218else:
219 if "64" in TARGET_ARCH:
220 ART_PHONY_TEST_TARGET_SUFFIX = "64"
Igor Murashkin6b61c802017-04-03 14:33:22 -0700221 ART_2ND_PHONY_TEST_TARGET_SUFFIX = ""
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000222 else:
223 ART_PHONY_TEST_TARGET_SUFFIX = "32"
Igor Murashkin6b61c802017-04-03 14:33:22 -0700224 ART_2ND_PHONY_TEST_TARGET_SUFFIX = ""
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000225
Igor Murashkin6b61c802017-04-03 14:33:22 -0700226HOST_PREFER_32_BIT = _get_build_var('HOST_PREFER_32_BIT')
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000227if HOST_PREFER_32_BIT == "true":
228 ART_PHONY_TEST_HOST_SUFFIX = "32"
Igor Murashkin6b61c802017-04-03 14:33:22 -0700229 ART_2ND_PHONY_TEST_HOST_SUFFIX = ""
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000230else:
231 ART_PHONY_TEST_HOST_SUFFIX = "64"
Igor Murashkin6b61c802017-04-03 14:33:22 -0700232 ART_2ND_PHONY_TEST_HOST_SUFFIX = "32"
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000233
Alex Light699c2552017-02-08 10:09:31 -0800234HOST_OUT_EXECUTABLES = os.path.join(ANDROID_BUILD_TOP,
Igor Murashkin6b61c802017-04-03 14:33:22 -0700235 _get_build_var("HOST_OUT_EXECUTABLES"))
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000236os.environ['JACK'] = HOST_OUT_EXECUTABLES + '/jack'
237os.environ['DX'] = HOST_OUT_EXECUTABLES + '/dx'
238os.environ['SMALI'] = HOST_OUT_EXECUTABLES + '/smali'
239os.environ['JASMIN'] = HOST_OUT_EXECUTABLES + '/jasmin'
240os.environ['DXMERGER'] = HOST_OUT_EXECUTABLES + '/dexmerger'