blob: 0b69718f93ac7a85e77b22e40ff5ee4bb4be829b [file] [log] [blame]
Shubham Ajmera65adb8b2017-02-06 16:04:25 +00001#!/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
17import os
Igor Murashkinfecb4ef2017-02-09 10:42:23 -080018import re
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000019import tempfile
20import subprocess
21
22env = dict(os.environ)
23
24def 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 Murashkinfecb4ef2017-02-09 10:42:23 -080033_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.
40def 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 Ajmera65adb8b2017-02-06 16:04:25 +000054 # The command is taken from build/envsetup.sh to fetch build variables.
Igor Murashkinfecb4ef2017-02-09 10:42:23 -080055 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 Ajmera65adb8b2017-02-06 16:04:25 +000057 "make --no-print-directory -C \"%s\" -f build/core/config.mk "
Igor Murashkinfecb4ef2017-02-09 10:42:23 -080058 "dump-many-vars DUMP_MANY_VARS=\"%s\"") % (ANDROID_BUILD_TOP, all_vars)
59
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000060 config = subprocess.Popen(command, stdout=subprocess.PIPE,
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
77def get_build_var(var_name):
78 return dump_many_vars(var_name)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +000079
80def get_env(key):
81 return env.get(key)
82
83ANDROID_BUILD_TOP = env.get('ANDROID_BUILD_TOP', os.getcwd())
84
85# Directory used for temporary test files on the host.
86ART_HOST_TEST_DIR = tempfile.mkdtemp(prefix = 'test-art-')
87
88# Keep going after encountering a test failure?
89ART_TEST_KEEP_GOING = getEnvBoolean('ART_TEST_KEEP_GOING', True)
90
91# Do you want all tests, even those that are time consuming?
92ART_TEST_FULL = getEnvBoolean('ART_TEST_FULL', False)
93
94# Do you want interpreter tests run?
95ART_TEST_INTERPRETER = getEnvBoolean('ART_TEST_INTERPRETER', ART_TEST_FULL)
96ART_TEST_INTERPRETER_ACCESS_CHECKS = getEnvBoolean('ART_TEST_INTERPRETER_ACCESS_CHECKS',
97 ART_TEST_FULL)
98
99# Do you want JIT tests run?
100ART_TEST_JIT = getEnvBoolean('ART_TEST_JIT', ART_TEST_FULL)
101
102# Do you want optimizing compiler tests run?
Shubham Ajmera4b8c53d2017-02-15 16:38:16 +0000103ART_TEST_OPTIMIZING = getEnvBoolean('ART_TEST_OPTIMIZING', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000104
105# Do you want to test the optimizing compiler with graph coloring register allocation?
106ART_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?
109ART_TEST_NPIC_IMAGE = getEnvBoolean('ART_TEST_NPIC_IMAGE', ART_TEST_FULL)
110
111# Do we want to test PIC-compiled tests ("apps")?
112ART_TEST_PIC_TEST = getEnvBoolean('ART_TEST_PIC_TEST', ART_TEST_FULL)
113# Do you want tracing tests run?
114ART_TEST_TRACE = getEnvBoolean('ART_TEST_TRACE', ART_TEST_FULL)
115
116# Do you want tracing tests (streaming mode) run?
117ART_TEST_TRACE_STREAM = getEnvBoolean('ART_TEST_TRACE_STREAM', ART_TEST_FULL)
118
119# Do you want tests with GC verification enabled run?
120ART_TEST_GC_VERIFY = getEnvBoolean('ART_TEST_GC_VERIFY', ART_TEST_FULL)
121
122# Do you want tests with the GC stress mode enabled run?
123ART_TEST_GC_STRESS = getEnvBoolean('ART_TEST_GC_STRESS', ART_TEST_FULL)
124
125# Do you want tests with the JNI forcecopy mode enabled run?
126ART_TEST_JNI_FORCECOPY = getEnvBoolean('ART_TEST_JNI_FORCECOPY', ART_TEST_FULL)
127
128# Do you want run-tests with relocation disabled run?
129ART_TEST_RUN_TEST_RELOCATE = getEnvBoolean('ART_TEST_RUN_TEST_RELOCATE', ART_TEST_FULL)
130
131# Do you want run-tests with prebuilding?
Shubham Ajmera4b8c53d2017-02-15 16:38:16 +0000132ART_TEST_RUN_TEST_PREBUILD = getEnvBoolean('ART_TEST_RUN_TEST_PREBUILD', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000133
134# Do you want run-tests with no prebuilding enabled run?
135ART_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 Ajmera4b8c53d2017-02-15 16:38:16 +0000138ART_TEST_RUN_TEST_IMAGE = getEnvBoolean('ART_TEST_RUN_TEST_IMAGE', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000139
140# Do you want run-tests without a pregenerated core.art?
141ART_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?
144ART_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?
148ART_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 Ajmera4b8c53d2017-02-15 16:38:16 +0000151ART_TEST_RUN_TEST_DEBUG = getEnvBoolean('ART_TEST_RUN_TEST_DEBUG', ART_TEST_FULL)
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000152
153# Do you want run-tests with libart.so?
154ART_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?
157ART_TEST_RUN_TEST_ALWAYS_CLEAN = getEnvBoolean('ART_TEST_RUN_TEST_ALWAYS_CLEAN', True)
158
159# Do you want run-tests with the --debuggable flag
160ART_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?
163ART_TEST_RUN_TEST_MULTI_IMAGE = getEnvBoolean('ART_TEST_RUN_TEST_MULTI_IMAGE', ART_TEST_FULL)
164
165ART_TEST_DEBUG_GC = getEnvBoolean('ART_TEST_DEBUG_GC', False)
166
167ART_TEST_BISECTION = getEnvBoolean('ART_TEST_BISECTION', False)
168
169DEX2OAT_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?
172ART_TEST_RUN_TEST_2ND_ARCH = getEnvBoolean('ART_TEST_RUN_TEST_2ND_ARCH', True)
173
174HOST_2ND_ARCH_PREFIX = get_build_var('HOST_2ND_ARCH_PREFIX')
175HOST_2ND_ARCH_PREFIX_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES = env.get(
176 HOST_2ND_ARCH_PREFIX + 'DEX2OAT_HOST_INSTRUCTION_SET_FEATURES')
177
178ART_TEST_ANDROID_ROOT = env.get('ART_TEST_ANDROID_ROOT')
179
180ART_TEST_WITH_STRACE = getEnvBoolean('ART_TEST_DEBUG_GC', False)
181
182TARGET_2ND_ARCH = get_build_var('TARGET_2ND_ARCH')
183TARGET_ARCH = get_build_var('TARGET_ARCH')
184if 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 = ""
191else:
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
199HOST_PREFER_32_BIT = get_build_var('HOST_PREFER_32_BIT')
200if HOST_PREFER_32_BIT == "true":
201 ART_PHONY_TEST_HOST_SUFFIX = "32"
202 _2ND_ART_PHONY_TEST_HOST_SUFFIX = ""
203else:
204 ART_PHONY_TEST_HOST_SUFFIX = "64"
205 _2ND_ART_PHONY_TEST_HOST_SUFFIX = "32"
206
Alex Light699c2552017-02-08 10:09:31 -0800207HOST_OUT_EXECUTABLES = os.path.join(ANDROID_BUILD_TOP,
Shubham Ajmera65adb8b2017-02-06 16:04:25 +0000208 get_build_var("HOST_OUT_EXECUTABLES"))
209os.environ['JACK'] = HOST_OUT_EXECUTABLES + '/jack'
210os.environ['DX'] = HOST_OUT_EXECUTABLES + '/dx'
211os.environ['SMALI'] = HOST_OUT_EXECUTABLES + '/smali'
212os.environ['JASMIN'] = HOST_OUT_EXECUTABLES + '/jasmin'
213os.environ['DXMERGER'] = HOST_OUT_EXECUTABLES + '/dexmerger'