blob: 9082b4781192902f9eb6dfcac976b6b951c4ea73 [file] [log] [blame]
Ian Rogersafd9acc2014-06-17 08:21:54 -07001# Copyright (C) 2011 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
16LOCAL_PATH := $(call my-dir)
17
18include art/build/Android.common_test.mk
19
20# List of all tests of the form 003-omnibus-opcodes.
21TEST_ART_RUN_TESTS := $(wildcard $(LOCAL_PATH)/[0-9]*)
22TEST_ART_RUN_TESTS := $(subst $(LOCAL_PATH)/,, $(TEST_ART_RUN_TESTS))
23
Ian Rogersf5c44b32014-08-19 16:52:36 -070024########################################################################
25# The art-run-tests module, used to build all run-tests into an image.
Alex Light9dcc4572014-08-14 14:16:26 -070026
Ian Rogersafd9acc2014-06-17 08:21:54 -070027# The path where build only targets will be output, e.g.
28# out/target/product/generic_x86_64/obj/PACKAGING/art-run-tests_intermediates/DATA
29art_run_tests_dir := $(call intermediates-dir-for,PACKAGING,art-run-tests)/DATA
30
31# A generated list of prerequisites that call 'run-test --build-only', the actual prerequisite is
32# an empty file touched in the intermediate directory.
33TEST_ART_RUN_TEST_BUILD_RULES :=
34
35# Helper to create individual build targets for tests. Must be called with $(eval).
36# $(1): the test number
37define define-build-art-run-test
38 dmart_target := $(art_run_tests_dir)/art-run-tests/$(1)/touch
Andreas Gampe8fda9f22014-10-03 16:15:37 -070039$$(dmart_target): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger
Ian Rogersafd9acc2014-06-17 08:21:54 -070040 $(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
41 $(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
Andreas Gampe8fda9f22014-10-03 16:15:37 -070042 SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
43 DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
Ian Rogersafd9acc2014-06-17 08:21:54 -070044 $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1)
45 $(hide) touch $$@
46
47 TEST_ART_RUN_TEST_BUILD_RULES += $$(dmart_target)
48 dmart_target :=
49endef
Ian Rogersbf66bce2014-06-24 23:15:34 -070050$(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call define-build-art-run-test,$(test))))
Ian Rogersafd9acc2014-06-17 08:21:54 -070051
52include $(CLEAR_VARS)
53LOCAL_MODULE_TAGS := tests
54LOCAL_MODULE := art-run-tests
Andreas Gampe8fda9f22014-10-03 16:15:37 -070055LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_BUILD_RULES) smali dexmerger
Ian Rogersafd9acc2014-06-17 08:21:54 -070056# The build system use this flag to pick up files generated by declare-make-art-run-test.
57LOCAL_PICKUP_FILES := $(art_run_tests_dir)
58
59include $(BUILD_PHONY_PACKAGE)
60
61# Clear temp vars.
Ian Rogersafd9acc2014-06-17 08:21:54 -070062art_run_tests_dir :=
63define-build-art-run-test :=
Ian Rogers8a14b752014-07-18 15:06:53 -070064TEST_ART_RUN_TEST_BUILD_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -070065
66########################################################################
Ian Rogersf5c44b32014-08-19 16:52:36 -070067# General rules to build and run a run-test.
Ian Rogersafd9acc2014-06-17 08:21:54 -070068
Ian Rogersf5c44b32014-08-19 16:52:36 -070069# Test rule names or of the form:
Alex Light03a112d2014-08-25 13:25:56 -070070# test-art-{1: host or target}-run-test-{2: prebuild no-prebuild no-dex2oat}-
71# {3: interpreter default optimizing}-{4: relocate no-relocate relocate-no-patchoat}-
72# {5: trace or no-trace}-{6: gcstress gcverify cms}-{7: forcecopy checkjni jni}-
73# {8: no-image or image}-{9: test name}{10: 32 or 64}
Ian Rogersf5c44b32014-08-19 16:52:36 -070074TARGET_TYPES := host target
Ian Rogers86df3ac2014-08-27 10:54:11 -070075PREBUILD_TYPES := prebuild
76ifeq ($(ART_TEST_RUN_TEST_NO_PREBUILD),true)
77 PREBUILD_TYPES += no-prebuild
78endif
79ifeq ($(ART_TEST_RUN_TEST_NO_DEX2OAT),true)
80 PREBUILD_TYPES += no-dex2oat
81endif
82COMPILER_TYPES :=
83ifeq ($(ART_TEST_DEFAULT_COMPILER),true)
84 COMPILER_TYPES += default
85endif
86ifeq ($(ART_TEST_INTERPRETER),true)
87 COMPILER_TYPES += interpreter
88endif
89ifeq ($(ART_TEST_OPTIMIZING),true)
90 COMPILER_TYPES += optimizing
91endif
92RELOCATE_TYPES := relocate
93ifeq ($(ART_TEST_RUN_TEST_NO_RELOCATE),true)
94 RELOCATE_TYPES += no-relocate
95endif
96ifeq ($(ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT),true)
97 RELOCATE_TYPES := relocate-no-patchoat
98endif
99TRACE_TYPES := no-trace
100ifeq ($(ART_TEST_TRACE),true)
101 TRACE_TYPES += trace
102endif
103GC_TYPES := cms
Alex Light992f1e72014-08-27 16:08:57 -0700104ifeq ($(ART_TEST_GC_STRESS),true)
Ian Rogers86df3ac2014-08-27 10:54:11 -0700105 GC_TYPES += gcstress
106endif
Alex Light992f1e72014-08-27 16:08:57 -0700107ifeq ($(ART_TEST_GC_VERIFY),true)
Ian Rogers86df3ac2014-08-27 10:54:11 -0700108 GC_TYPES += gcverify
109endif
110JNI_TYPES := checkjni
111ifeq ($(ART_TEST_JNI_FORCECOPY),true)
112 JNI_TYPES += forcecopy
113endif
114IMAGE_TYPES := image
115ifeq ($(ART_TEST_RUN_TEST_NO_IMAGE),true)
116 IMAGE_TYPES += no-image
117endif
118ADDRESS_SIZES_TARGET := $(ART_PHONY_TEST_TARGET_SUFFIX) $(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
119ADDRESS_SIZES_HOST := $(ART_PHONY_TEST_HOST_SUFFIX) $(2ND_ART_PHONY_TEST_HOST_SUFFIX)
Ian Rogersf5c44b32014-08-19 16:52:36 -0700120ALL_ADDRESS_SIZES := 64 32
Ian Rogers86df3ac2014-08-27 10:54:11 -0700121
Ian Rogersf5c44b32014-08-19 16:52:36 -0700122# List all run test names with number arguments agreeing with the comment above.
123define all-run-test-names
124 $(foreach target, $(1), \
125 $(foreach prebuild, $(2), \
126 $(foreach compiler, $(3), \
127 $(foreach relocate, $(4), \
128 $(foreach trace, $(5), \
129 $(foreach gc, $(6), \
130 $(foreach jni, $(7), \
Alex Light03a112d2014-08-25 13:25:56 -0700131 $(foreach image, $(8), \
132 $(foreach test, $(9), \
133 $(foreach address_size, $(10), \
134 test-art-$(target)-run-test-$(prebuild)-$(compiler)-$(relocate)-$(trace)-$(gc)-$(jni)-$(image)-$(test)$(address_size) \
135 ))))))))))
Ian Rogersf5c44b32014-08-19 16:52:36 -0700136endef # all-run-test-names
137
138# To generate a full list or tests:
139# $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \
Ian Rogers86df3ac2014-08-27 10:54:11 -0700140# $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
141# $(TEST_ART_RUN_TESTS), $(ALL_ADDRESS_SIZES))
Ian Rogersf5c44b32014-08-19 16:52:36 -0700142
143# Convert's a rule name to the form used in variables, e.g. no-relocate to NO_RELOCATE
144define name-to-var
145$(shell echo $(1) | tr '[:lower:]' '[:upper:]' | tr '-' '_')
146endef # name-to-var
147
148# Tests that are timing sensitive and flaky on heavily loaded systems.
149TEST_ART_TIMING_SENSITIVE_RUN_TESTS := \
150 053-wait-some \
151 055-enum-performance
152
153 # disable timing sensitive tests on "dist" builds.
154ifdef dist_goal
155 ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES), \
Ian Rogers40e19122014-09-02 15:59:28 -0700156 $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
Alex Light03a112d2014-08-25 13:25:56 -0700157 $(IMAGE_TYPES), $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), $(ALL_ADDRESS_SIZES))
Ian Rogersf5c44b32014-08-19 16:52:36 -0700158endif
159
Ian Rogers86df3ac2014-08-27 10:54:11 -0700160TEST_ART_TIMING_SENSITIVE_RUN_TESTS :=
161
Nicolas Geoffray3d56be82014-09-30 15:05:13 +0100162TEST_ART_BROKEN_RUN_TESTS := \
163 004-ThreadStress
164
165ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES), \
166 $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
167 $(IMAGE_TYPES), $(TEST_ART_BROKEN_RUN_TESTS), $(ALL_ADDRESS_SIZES))
168
169TEST_ART_BROKEN_RUN_TESTS :=
170
Ian Rogers40e19122014-09-02 15:59:28 -0700171# Note 116-nodex2oat is not broken per-se it just doesn't (and isn't meant to) work with --prebuild.
Ian Rogersf5c44b32014-08-19 16:52:36 -0700172TEST_ART_BROKEN_PREBUILD_RUN_TESTS := \
173 116-nodex2oat
174
Ian Rogers40e19122014-09-02 15:59:28 -0700175ifneq (,$(filter prebuild,$(PREBUILD_TYPES)))
176 ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),prebuild, \
177 $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
178 $(IMAGE_TYPES), $(TEST_ART_BROKEN_PREBUILD_RUN_TESTS), $(ALL_ADDRESS_SIZES))
179endif
Ian Rogersf5c44b32014-08-19 16:52:36 -0700180
Ian Rogers86df3ac2014-08-27 10:54:11 -0700181TEST_ART_BROKEN_PREBUILD_RUN_TESTS :=
182
Ian Rogersf5c44b32014-08-19 16:52:36 -0700183TEST_ART_BROKEN_NO_PREBUILD_TESTS := \
184 117-nopatchoat
185
Ian Rogers40e19122014-09-02 15:59:28 -0700186ifneq (,$(filter no-prebuild,$(PREBUILD_TYPES)))
187 ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),no-prebuild, \
188 $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
189 $(IMAGE_TYPES), $(TEST_ART_BROKEN_NO_PREBUILD_TESTS), $(ALL_ADDRESS_SIZES))
190endif
Ian Rogersf5c44b32014-08-19 16:52:36 -0700191
Ian Rogers86df3ac2014-08-27 10:54:11 -0700192TEST_ART_BROKEN_NO_PREBUILD_TESTS :=
193
Ian Rogers40e19122014-09-02 15:59:28 -0700194# Note 117-nopatchoat is not broken per-se it just doesn't work (and isn't meant to) without
195# --prebuild --relocate
196TEST_ART_BROKEN_NO_RELOCATE_TESTS := \
197 117-nopatchoat
198
199ifneq (,$(filter no-relocate,$(RELOCATE_TYPES)))
200 ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES), \
201 $(COMPILER_TYPES), no-relocate,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
202 $(IMAGE_TYPES), $(TEST_ART_BROKEN_NO_RELOCATE_TESTS), $(ALL_ADDRESS_SIZES))
203endif
204
205TEST_ART_BROKEN_NO_RELOCATE_TESTS :=
206
Ian Rogers40e19122014-09-02 15:59:28 -0700207# Tests that are broken with GC stress.
208TEST_ART_BROKEN_GCSTRESS_RUN_TESTS := \
Ian Rogers58920cc2014-10-10 12:39:31 -0700209 004-SignalTest \
210 114-ParallelGC
Ian Rogers40e19122014-09-02 15:59:28 -0700211
212ifneq (,$(filter gcstress,$(GC_TYPES)))
213 ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES), \
214 $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),gcstress,$(JNI_TYPES), \
215 $(IMAGE_TYPES), $(TEST_ART_BROKEN_GCSTRESS_RUN_TESTS), $(ALL_ADDRESS_SIZES))
216endif
217
218TEST_ART_BROKEN_GCSTRESS_RUN_TESTS :=
219
Ian Rogersf5c44b32014-08-19 16:52:36 -0700220# 115-native-bridge setup is complicated. Need to implement it correctly for the target.
221ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(PREBUILD_TYPES),$(COMPILER_TYPES), \
Alex Light03a112d2014-08-25 13:25:56 -0700222 $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES),115-native-bridge, \
Ian Rogersf5c44b32014-08-19 16:52:36 -0700223 $(ALL_ADDRESS_SIZES))
224
Alex Light03a112d2014-08-25 13:25:56 -0700225# All these tests check that we have sane behavior if we don't have a patchoat or dex2oat.
226# Therefore we shouldn't run them in situations where we actually don't have these since they
227# explicitly test for them. These all also assume we have an image.
228TEST_ART_BROKEN_FALLBACK_RUN_TESTS := \
229 116-nodex2oat \
230 117-nopatchoat \
231 118-noimage-dex2oat \
232 119-noimage-patchoat
233
Ian Rogers40e19122014-09-02 15:59:28 -0700234ifneq (,$(filter no-dex2oat,$(PREBUILD_TYPES)))
235 ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),no-dex2oat, \
236 $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
237 $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
238endif
Alex Light03a112d2014-08-25 13:25:56 -0700239
Alex Light03a112d2014-08-25 13:25:56 -0700240
Ian Rogers40e19122014-09-02 15:59:28 -0700241ifneq (,$(filter no-image,$(IMAGE_TYPES)))
242 ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES), \
243 $(COMPILER_TYPES), $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),no-image, \
244 $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
245endif
246
247ifneq (,$(filter relocate-no-patchoat,$(RELOCATE_TYPES)))
248 ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES), \
249 $(COMPILER_TYPES), relocate-no-patchoat,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
250 $(IMAGE_TYPES),$(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
251endif
Alex Light03a112d2014-08-25 13:25:56 -0700252
Ian Rogers86df3ac2014-08-27 10:54:11 -0700253TEST_ART_BROKEN_FALLBACK_RUN_TESTS :=
254
Ian Rogersf5c44b32014-08-19 16:52:36 -0700255# Clear variables ahead of appending to them when defining tests.
256$(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=))
257$(foreach target, $(TARGET_TYPES), \
258 $(foreach prebuild, $(PREBUILD_TYPES), \
259 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES :=)))
260$(foreach target, $(TARGET_TYPES), \
261 $(foreach compiler, $(COMPILER_TYPES), \
262 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES :=)))
263$(foreach target, $(TARGET_TYPES), \
264 $(foreach relocate, $(RELOCATE_TYPES), \
265 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES :=)))
266$(foreach target, $(TARGET_TYPES), \
267 $(foreach trace, $(TRACE_TYPES), \
268 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES :=)))
269$(foreach target, $(TARGET_TYPES), \
270 $(foreach gc, $(GC_TYPES), \
271 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES :=)))
272$(foreach target, $(TARGET_TYPES), \
273 $(foreach jni, $(JNI_TYPES), \
274 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=)))
275$(foreach target, $(TARGET_TYPES), \
Alex Light03a112d2014-08-25 13:25:56 -0700276 $(foreach image, $(IMAGE_TYPES), \
277 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=)))
278$(foreach target, $(TARGET_TYPES), \
Ian Rogersf5c44b32014-08-19 16:52:36 -0700279 $(foreach test, $(TEST_ART_RUN_TESTS), \
280 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=)))
281$(foreach target, $(TARGET_TYPES), \
282 $(foreach address_size, $(ALL_ADDRESS_SIZES), \
283 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(address_size))_RULES :=)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700284
285# We need dex2oat and dalvikvm on the target as well as the core image.
286TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_EXECUTABLES) $(TARGET_CORE_IMG_OUT) $(2ND_TARGET_CORE_IMG_OUT)
287
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700288# Also need libarttest.
289TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libarttest.so
290ifdef TARGET_2ND_ARCH
291TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libarttest.so
292endif
293
Andreas Gampe855564b2014-07-25 02:32:19 -0700294# Also need libnativebridgetest.
295TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libnativebridgetest.so
296ifdef TARGET_2ND_ARCH
297TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libnativebridgetest.so
298endif
299
Ian Rogersafd9acc2014-06-17 08:21:54 -0700300# All tests require the host executables and the core images.
301ART_TEST_HOST_RUN_TEST_DEPENDENCIES := \
302 $(ART_HOST_EXECUTABLES) \
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700303 $(ART_HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) \
Andreas Gampe855564b2014-07-25 02:32:19 -0700304 $(ART_HOST_OUT_SHARED_LIBRARIES)/libnativebridgetest$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray4d1231d2014-07-01 10:46:31 +0100305 $(ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION) \
Brian Carlstrom519e3d02014-06-25 00:57:36 -0700306 $(HOST_CORE_IMG_OUT)
Ian Rogers665de8a2014-06-24 21:34:09 -0700307
308ifneq ($(HOST_PREFER_32_BIT),true)
309ART_TEST_HOST_RUN_TEST_DEPENDENCIES += \
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700310 $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) \
Andreas Gampe855564b2014-07-25 02:32:19 -0700311 $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libnativebridgetest$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray4d1231d2014-07-01 10:46:31 +0100312 $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700313 $(2ND_HOST_CORE_IMG_OUT)
Ian Rogers665de8a2014-06-24 21:34:09 -0700314endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700315
Ian Rogersf5c44b32014-08-19 16:52:36 -0700316# Create a rule to build and run a tests following the form:
Alex Light03a112d2014-08-25 13:25:56 -0700317# test-art-{1: host or target}-run-test-{2: prebuild no-prebuild no-dex2oat}-
318# {3: interpreter default optimizing}-{4: relocate no-relocate relocate-no-patchoat}-
319# {5: trace or no-trace}-{6: gcstress gcverify cms}-{7: forcecopy checkjni jni}-
320# {8: no-image image}-{9: test name}{10: 32 or 64}
Ian Rogersafd9acc2014-06-17 08:21:54 -0700321define define-test-art-run-test
Nicolas Geoffray611e1db2014-10-09 17:34:45 +0100322 run_test_options :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700323 prereq_rule :=
Ian Rogersf5c44b32014-08-19 16:52:36 -0700324 test_groups :=
325 uc_host_or_target :=
Alex Lightbfac14a2014-07-30 09:41:21 -0700326 ifeq ($(ART_TEST_RUN_TEST_ALWAYS_CLEAN),true)
327 run_test_options += --always-clean
328 endif
Ian Rogersf5c44b32014-08-19 16:52:36 -0700329 ifeq ($(1),host)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700330 uc_host_or_target := HOST
Ian Rogersf5c44b32014-08-19 16:52:36 -0700331 test_groups := ART_RUN_TEST_HOST_RULES
Ian Rogersafd9acc2014-06-17 08:21:54 -0700332 run_test_options += --host
333 prereq_rule := $(ART_TEST_HOST_RUN_TEST_DEPENDENCIES)
334 else
Ian Rogersf5c44b32014-08-19 16:52:36 -0700335 ifeq ($(1),target)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700336 uc_host_or_target := TARGET
Ian Rogersf5c44b32014-08-19 16:52:36 -0700337 test_groups := ART_RUN_TEST_TARGET_RULES
Ian Rogersafd9acc2014-06-17 08:21:54 -0700338 prereq_rule := test-art-target-sync
339 else
Ian Rogersf5c44b32014-08-19 16:52:36 -0700340 $$(error found $(1) expected $(TARGET_TYPES))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700341 endif
342 endif
Ian Rogersf5c44b32014-08-19 16:52:36 -0700343 ifeq ($(2),prebuild)
344 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_PREBUILD_RULES
345 run_test_options += --prebuild
Alex Lighta59dd802014-07-02 16:28:08 -0700346 else
Ian Rogersf5c44b32014-08-19 16:52:36 -0700347 ifeq ($(2),no-prebuild)
348 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_PREBUILD_RULES
349 run_test_options += --no-prebuild
Alex Lighta59dd802014-07-02 16:28:08 -0700350 else
Alex Light03a112d2014-08-25 13:25:56 -0700351 ifeq ($(2),no-dex2oat)
352 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_DEX2OAT_RULES
353 run_test_options += --no-prebuild --no-dex2oat
354 else
355 $$(error found $(2) expected $(PREBUILD_TYPES))
356 endif
Alex Lighta59dd802014-07-02 16:28:08 -0700357 endif
358 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700359 ifeq ($(3),optimizing)
Ian Rogersf5c44b32014-08-19 16:52:36 -0700360 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_OPTIMIZING_RULES
Ian Rogersafd9acc2014-06-17 08:21:54 -0700361 run_test_options += -Xcompiler-option --compiler-backend=Optimizing
362 else
363 ifeq ($(3),interpreter)
Ian Rogersf5c44b32014-08-19 16:52:36 -0700364 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_INTERPRETER_RULES
Ian Rogersafd9acc2014-06-17 08:21:54 -0700365 run_test_options += --interpreter
366 else
367 ifeq ($(3),default)
Ian Rogersf5c44b32014-08-19 16:52:36 -0700368 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEFAULT_RULES
Ian Rogersafd9acc2014-06-17 08:21:54 -0700369 else
Ian Rogersf5c44b32014-08-19 16:52:36 -0700370 $$(error found $(3) expected $(COMPILER_TYPES))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700371 endif
372 endif
373 endif
Ian Rogersf5c44b32014-08-19 16:52:36 -0700374 ifeq ($(4),relocate)
375 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_RULES
376 run_test_options += --relocate
Ian Rogersafd9acc2014-06-17 08:21:54 -0700377 else
Ian Rogersf5c44b32014-08-19 16:52:36 -0700378 ifeq ($(4),no-relocate)
379 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_RELOCATE_RULES
380 run_test_options += --no-relocate
381 else
Alex Light03a112d2014-08-25 13:25:56 -0700382 ifeq ($(4),relocate-no-patchoat)
383 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_NO_PATCHOAT_RULES
384 run_test_options += --relocate --no-patchoat
385 else
386 $$(error found $(4) expected $(RELOCATE_TYPES))
387 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700388 endif
389 endif
Ian Rogers716e4f82014-07-16 11:18:03 -0700390 ifeq ($(5),trace)
Ian Rogersf5c44b32014-08-19 16:52:36 -0700391 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_TRACE_RULES
Ian Rogers716e4f82014-07-16 11:18:03 -0700392 run_test_options += --trace
Ian Rogers716e4f82014-07-16 11:18:03 -0700393 else
Ian Rogersf5c44b32014-08-19 16:52:36 -0700394 ifeq ($(5),no-trace)
395 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_TRACE_RULES
Ian Rogers701aa642014-07-18 11:38:13 -0700396 else
Ian Rogersf5c44b32014-08-19 16:52:36 -0700397 $$(error found $(5) expected $(TRACE_TYPES))
398 endif
399 endif
400 ifeq ($(6),gcverify)
Ian Rogers86df3ac2014-08-27 10:54:11 -0700401 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_GCVERIFY_RULES
Ian Rogersf5c44b32014-08-19 16:52:36 -0700402 run_test_options += --gcverify
403 else
404 ifeq ($(6),gcstress)
Ian Rogers86df3ac2014-08-27 10:54:11 -0700405 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_GCSTRESS_RULES
Ian Rogersf5c44b32014-08-19 16:52:36 -0700406 run_test_options += --gcstress
407 else
408 ifeq ($(6),cms)
409 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_CMS_RULES
Ian Rogers8a14b752014-07-18 15:06:53 -0700410 else
Ian Rogersf5c44b32014-08-19 16:52:36 -0700411 $$(error found $(6) expected $(GC_TYPES))
Ian Rogers701aa642014-07-18 11:38:13 -0700412 endif
Ian Rogers716e4f82014-07-16 11:18:03 -0700413 endif
414 endif
Ian Rogersf5c44b32014-08-19 16:52:36 -0700415 ifeq ($(7),forcecopy)
Ian Rogers86df3ac2014-08-27 10:54:11 -0700416 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_FORCECOPY_RULES
Ian Rogersf5c44b32014-08-19 16:52:36 -0700417 run_test_options += --runtime-option -Xjniopts:forcecopy
418 ifneq ($$(ART_TEST_JNI_FORCECOPY),true)
419 skip_test := true
420 endif
421 else
422 ifeq ($(7),checkjni)
Ian Rogers86df3ac2014-08-27 10:54:11 -0700423 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_CHECKJNI_RULES
Ian Rogersf5c44b32014-08-19 16:52:36 -0700424 run_test_options += --runtime-option -Xcheck:jni
425 else
426 ifeq ($(7),jni)
427 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_JNI_RULES
428 else
429 $$(error found $(7) expected $(JNI_TYPES))
430 endif
431 endif
432 endif
Alex Light03a112d2014-08-25 13:25:56 -0700433 ifeq ($(8),no-image)
434 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_IMAGE_RULES
435 run_test_options += --no-image
436 else
437 ifeq ($(8),image)
438 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_IMAGE_RULES
439 else
440 $$(error found $(8) expected $(IMAGE_TYPES))
441 endif
442 endif
443 # $(9) is the test name
444 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_$(call name-to-var,$(9))_RULES
445 ifeq ($(10),64)
Ian Rogersf5c44b32014-08-19 16:52:36 -0700446 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_64_RULES
447 run_test_options += --64
448 else
Alex Light03a112d2014-08-25 13:25:56 -0700449 ifeq ($(10),32)
Ian Rogersf5c44b32014-08-19 16:52:36 -0700450 test_groups += ART_RUN_TEST_$$(uc_host_or_target)_32_RULES
451 else
Alex Light03a112d2014-08-25 13:25:56 -0700452 $$(error found $(10) expected $(ALL_ADDRESS_SIZES))
Ian Rogersf5c44b32014-08-19 16:52:36 -0700453 endif
454 endif
Alex Light03a112d2014-08-25 13:25:56 -0700455 run_test_rule_name := test-art-$(1)-run-test-$(2)-$(3)-$(4)-$(5)-$(6)-$(7)-$(8)-$(9)$(10)
Ian Rogersf5c44b32014-08-19 16:52:36 -0700456 run_test_options := --output-path $(ART_HOST_TEST_DIR)/run-test-output/$$(run_test_rule_name) \
Ian Rogers5242c0a2014-07-18 11:02:19 -0700457 $$(run_test_options)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700458$$(run_test_rule_name): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options)
459.PHONY: $$(run_test_rule_name)
Andreas Gampe8fda9f22014-10-03 16:15:37 -0700460$$(run_test_rule_name): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger $$(prereq_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700461 $(hide) $$(call ART_TEST_SKIP,$$@) && \
462 DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
Andreas Gampe8fda9f22014-10-03 16:15:37 -0700463 SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
464 DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
Alex Light03a112d2014-08-25 13:25:56 -0700465 art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(9) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700466 && $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@)
467 $$(hide) (echo $(MAKECMDGOALS) | grep -q $$@ && \
468 echo "run-test run as top-level target, removing test directory $(ART_HOST_TEST_DIR)" && \
469 rm -r $(ART_HOST_TEST_DIR)) || true
470
Ian Rogersf5c44b32014-08-19 16:52:36 -0700471 $$(foreach test_group,$$(test_groups), $$(eval $$(value test_group) += $$(run_test_rule_name)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700472
473 # Clear locally defined variables.
Ian Rogersf5c44b32014-08-19 16:52:36 -0700474 uc_host_or_target :=
475 test_groups :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700476 run_test_options :=
477 run_test_rule_name :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700478 prereq_rule :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700479endef # define-test-art-run-test
480
Ian Rogersf5c44b32014-08-19 16:52:36 -0700481$(foreach target, $(TARGET_TYPES), \
482 $(foreach test, $(TEST_ART_RUN_TESTS), \
483 $(foreach address_size, $(ADDRESS_SIZES_$(call name-to-var,$(target))), \
Ian Rogers86df3ac2014-08-27 10:54:11 -0700484 $(foreach prebuild, $(PREBUILD_TYPES), \
485 $(foreach compiler, $(COMPILER_TYPES), \
486 $(foreach relocate, $(RELOCATE_TYPES), \
487 $(foreach trace, $(TRACE_TYPES), \
488 $(foreach gc, $(GC_TYPES), \
489 $(foreach jni, $(JNI_TYPES), \
490 $(foreach image, $(IMAGE_TYPES), \
Alex Light03a112d2014-08-25 13:25:56 -0700491 $(eval $(call define-test-art-run-test,$(target),$(prebuild),$(compiler),$(relocate),$(trace),$(gc),$(jni),$(image),$(test),$(address_size))) \
492 ))))))))))
Ian Rogersf5c44b32014-08-19 16:52:36 -0700493define-test-art-run-test :=
Ian Rogersf5c44b32014-08-19 16:52:36 -0700494
Ian Rogersafd9acc2014-06-17 08:21:54 -0700495# Define a phony rule whose purpose is to test its prerequisites.
Ian Rogersf5c44b32014-08-19 16:52:36 -0700496# $(1): host or target
Ian Rogersafd9acc2014-06-17 08:21:54 -0700497# $(2): list of prerequisites
Ian Rogersf5c44b32014-08-19 16:52:36 -0700498define define-test-art-run-test-group
Ian Rogersafd9acc2014-06-17 08:21:54 -0700499.PHONY: $(1)
500$(1): $(2)
501 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
502
Ian Rogersafd9acc2014-06-17 08:21:54 -0700503endef # define-test-art-run-test-group
504
Ian Rogersafd9acc2014-06-17 08:21:54 -0700505
Ian Rogersf5c44b32014-08-19 16:52:36 -0700506$(foreach target, $(TARGET_TYPES), $(eval \
507 $(call define-test-art-run-test-group,test-art-$(target)-run-test,$(ART_RUN_TEST_$(call name-to-var,$(target))_RULES))))
508$(foreach target, $(TARGET_TYPES), \
509 $(foreach prebuild, $(PREBUILD_TYPES), $(eval \
510 $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(prebuild),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES)))))
511$(foreach target, $(TARGET_TYPES), \
512 $(foreach compiler, $(COMPILER_TYPES), $(eval \
513 $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(compiler),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES)))))
514$(foreach target, $(TARGET_TYPES), \
515 $(foreach relocate, $(RELOCATE_TYPES), $(eval \
516 $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(relocate),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES)))))
517$(foreach target, $(TARGET_TYPES), \
518 $(foreach trace, $(TRACE_TYPES), $(eval \
519 $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(trace),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES)))))
520$(foreach target, $(TARGET_TYPES), \
521 $(foreach gc, $(GC_TYPES), $(eval \
522 $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(gc),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES)))))
523$(foreach target, $(TARGET_TYPES), \
524 $(foreach jni, $(JNI_TYPES), $(eval \
525 $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(jni),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES)))))
526$(foreach target, $(TARGET_TYPES), \
Alex Light03a112d2014-08-25 13:25:56 -0700527 $(foreach image, $(IMAGE_TYPES), $(eval \
528 $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(image),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES)))))
529$(foreach target, $(TARGET_TYPES), \
Ian Rogersf5c44b32014-08-19 16:52:36 -0700530 $(foreach test, $(TEST_ART_RUN_TESTS), $(eval \
531 $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(test),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES)))))
532$(foreach target, $(TARGET_TYPES), \
Ian Rogers86df3ac2014-08-27 10:54:11 -0700533 $(foreach address_size, $(ADDRESS_SIZES_$(call name-to-var,$(target))), $(eval \
Ian Rogersa3cf6ce2014-10-02 16:35:52 -0700534 $(call define-test-art-run-test-group,test-art-$(target)-run-test$(address_size),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(address_size)_RULES)))))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700535
Ian Rogersf5c44b32014-08-19 16:52:36 -0700536# Clear variables now we're finished with them.
537$(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=))
538$(foreach target, $(TARGET_TYPES), \
539 $(foreach prebuild, $(PREBUILD_TYPES), \
540 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES :=)))
541$(foreach target, $(TARGET_TYPES), \
542 $(foreach compiler, $(COMPILER_TYPES), \
543 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES :=)))
544$(foreach target, $(TARGET_TYPES), \
545 $(foreach relocate, $(RELOCATE_TYPES), \
546 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES :=)))
547$(foreach target, $(TARGET_TYPES), \
548 $(foreach trace, $(TRACE_TYPES), \
549 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES :=)))
550$(foreach target, $(TARGET_TYPES), \
551 $(foreach gc, $(GC_TYPES), \
552 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES :=)))
553$(foreach target, $(TARGET_TYPES), \
554 $(foreach jni, $(JNI_TYPES), \
555 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=)))
556$(foreach target, $(TARGET_TYPES), \
Alex Light03a112d2014-08-25 13:25:56 -0700557 $(foreach image, $(IMAGE_TYPES), \
558 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=)))
559$(foreach target, $(TARGET_TYPES), \
Ian Rogersf5c44b32014-08-19 16:52:36 -0700560 $(foreach test, $(TEST_ART_RUN_TESTS), \
561 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=)))
562$(foreach target, $(TARGET_TYPES), \
563 $(foreach address_size, $(ALL_ADDRESS_SIZES), \
564 $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(address_size))_RULES :=)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700565define-test-art-run-test-group :=
Ian Rogersf5c44b32014-08-19 16:52:36 -0700566TARGET_TYPES :=
567PREBUILD_TYPES :=
568COMPILER_TYPES :=
569RELOCATE_TYPES :=
570TRACE_TYPES :=
571GC_TYPES :=
572JNI_TYPES :=
Alex Light03a112d2014-08-25 13:25:56 -0700573IMAGE_TYPES :=
Ian Rogers86df3ac2014-08-27 10:54:11 -0700574ADDRESS_SIZES_TARGET :=
575ADDRESS_SIZES_HOST :=
Ian Rogersf5c44b32014-08-19 16:52:36 -0700576ALL_ADDRESS_SIZES :=
Ian Rogers9fcaa4b2014-08-26 19:59:52 -0700577
578include $(LOCAL_PATH)/Android.libarttest.mk
579include art/test/Android.libnativebridgetest.mk