Android.run-test.mk revision c26f1288aaf9141ac4b2150869f0c594d52dbf36
1# 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
24########################################################################
25# The art-run-tests module, used to build all run-tests into an image.
26
27# 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# Dependencies for actually running a run-test.
36TEST_ART_RUN_TEST_DEPENDENCIES := \
37  $(DX) \
38  $(HOST_OUT_EXECUTABLES)/jasmin \
39  $(HOST_OUT_EXECUTABLES)/smali \
40  $(HOST_OUT_EXECUTABLES)/dexmerger
41TEST_ART_RUN_TEST_ORDERONLY_DEPENDENCIES :=
42
43ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
44  TEST_ART_RUN_TEST_DEPENDENCIES += \
45    $(JACK) \
46    $(JILL_JAR)
47  TEST_ART_RUN_TEST_ORDERONLY_DEPENDENCIES += setup-jack-server
48endif
49
50ifeq ($(ART_TEST_DEBUG_GC),true)
51  ART_TEST_WITH_STRACE := true
52endif
53
54# Helper to create individual build targets for tests. Must be called with $(eval).
55# $(1): the test number
56define define-build-art-run-test
57  dmart_target := $(art_run_tests_dir)/art-run-tests/$(1)/touch
58  run_test_options = --build-only
59  ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
60    run_test_options += --build-with-jack
61  else
62    run_test_options += --build-with-javac-dx
63  endif
64  ifeq ($(ART_TEST_QUIET),true)
65    run_test_options += --quiet
66  endif
67$$(dmart_target): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options)
68$$(dmart_target): $(TEST_ART_RUN_TEST_DEPENDENCIES) $(TARGET_JACK_CLASSPATH_DEPENDENCIES) | $(TEST_ART_RUN_TEST_ORDERONLY_DEPENDENCIES)
69	$(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
70	$(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
71	  SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
72	  DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
73	  JACK_VERSION=$(JACK_DEFAULT_VERSION) \
74	  JACK=$(abspath $(JACK)) \
75	  JACK_CLASSPATH=$(TARGET_JACK_CLASSPATH) \
76	  JILL_JAR=$(abspath $(JILL_JAR)) \
77	  $(LOCAL_PATH)/run-test $$(PRIVATE_RUN_TEST_OPTIONS) --output-path $$(abspath $$(dir $$@)) $(1)
78	$(hide) touch $$@
79
80  TEST_ART_RUN_TEST_BUILD_RULES += $$(dmart_target)
81  dmart_target :=
82  run_test_options :=
83endef
84$(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call define-build-art-run-test,$(test))))
85
86include $(CLEAR_VARS)
87LOCAL_MODULE_TAGS := tests
88LOCAL_MODULE := art-run-tests
89LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_BUILD_RULES)
90# The build system use this flag to pick up files generated by declare-make-art-run-test.
91LOCAL_PICKUP_FILES := $(art_run_tests_dir)
92
93include $(BUILD_PHONY_PACKAGE)
94
95# Clear temp vars.
96art_run_tests_dir :=
97define-build-art-run-test :=
98TEST_ART_RUN_TEST_BUILD_RULES :=
99
100########################################################################
101# General rules to build and run a run-test.
102
103TARGET_TYPES := host target
104PREBUILD_TYPES :=
105ifeq ($(ART_TEST_RUN_TEST_PREBUILD),true)
106  PREBUILD_TYPES += prebuild
107endif
108ifeq ($(ART_TEST_RUN_TEST_NO_PREBUILD),true)
109  PREBUILD_TYPES += no-prebuild
110endif
111ifeq ($(ART_TEST_RUN_TEST_NO_DEX2OAT),true)
112  PREBUILD_TYPES += no-dex2oat
113endif
114COMPILER_TYPES :=
115ifeq ($(ART_TEST_DEFAULT_COMPILER),true)
116  COMPILER_TYPES += default
117endif
118ifeq ($(ART_TEST_INTERPRETER_ACCESS_CHECKS),true)
119  COMPILER_TYPES += interp-ac
120endif
121ifeq ($(ART_TEST_INTERPRETER),true)
122  COMPILER_TYPES += interpreter
123endif
124ifeq ($(ART_TEST_JIT),true)
125  COMPILER_TYPES += jit
126endif
127ifeq ($(ART_TEST_OPTIMIZING),true)
128  COMPILER_TYPES += optimizing
129endif
130RELOCATE_TYPES := relocate
131ifeq ($(ART_TEST_RUN_TEST_NO_RELOCATE),true)
132  RELOCATE_TYPES += no-relocate
133endif
134ifeq ($(ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT),true)
135  RELOCATE_TYPES += relocate-npatchoat
136endif
137TRACE_TYPES := ntrace
138ifeq ($(ART_TEST_TRACE),true)
139  TRACE_TYPES += trace
140endif
141ifeq ($(ART_TEST_TRACE_STREAM),true)
142  TRACE_TYPES += stream
143endif
144GC_TYPES := cms
145ifeq ($(ART_TEST_GC_STRESS),true)
146  GC_TYPES += gcstress
147endif
148ifeq ($(ART_TEST_GC_VERIFY),true)
149  GC_TYPES += gcverify
150endif
151JNI_TYPES := checkjni
152ifeq ($(ART_TEST_JNI_FORCECOPY),true)
153  JNI_TYPES += forcecopy
154endif
155IMAGE_TYPES := image
156ifeq ($(ART_TEST_RUN_TEST_NO_IMAGE),true)
157  IMAGE_TYPES += no-image
158endif
159ifeq ($(ART_TEST_RUN_TEST_MULTI_IMAGE),true)
160  IMAGE_TYPES := multiimage
161endif
162ifeq ($(ART_TEST_PIC_IMAGE),true)
163  IMAGE_TYPES += picimage
164  ifeq ($(ART_TEST_RUN_TEST_MULTI_IMAGE),true)
165    IMAGE_TYPES := multipicimage
166  endif
167endif
168PICTEST_TYPES := npictest
169ifeq ($(ART_TEST_PIC_TEST),true)
170  PICTEST_TYPES += pictest
171endif
172RUN_TYPES :=
173ifeq ($(ART_TEST_RUN_TEST_DEBUG),true)
174  RUN_TYPES += debug
175endif
176ifeq ($(ART_TEST_RUN_TEST_NDEBUG),true)
177  RUN_TYPES += ndebug
178endif
179DEBUGGABLE_TYPES := ndebuggable
180ifeq ($(ART_TEST_RUN_TEST_DEBUGGABLE),true)
181DEBUGGABLE_TYPES += debuggable
182endif
183ADDRESS_SIZES_TARGET := $(ART_PHONY_TEST_TARGET_SUFFIX)
184ADDRESS_SIZES_HOST := $(ART_PHONY_TEST_HOST_SUFFIX)
185ifeq ($(ART_TEST_RUN_TEST_2ND_ARCH),true)
186  ADDRESS_SIZES_TARGET += $(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
187  ADDRESS_SIZES_HOST += $(2ND_ART_PHONY_TEST_HOST_SUFFIX)
188endif
189ALL_ADDRESS_SIZES := 64 32
190
191# List all run test names with number arguments agreeing with the comment above.
192define all-run-test-names
193  $(foreach target, $(1), \
194    $(foreach run-type, $(2), \
195      $(foreach prebuild, $(3), \
196        $(foreach compiler, $(4), \
197          $(foreach relocate, $(5), \
198            $(foreach trace, $(6), \
199              $(foreach gc, $(7), \
200                $(foreach jni, $(8), \
201                  $(foreach image, $(9), \
202                    $(foreach pictest, $(10), \
203                      $(foreach debuggable, $(11), \
204                        $(foreach test, $(12), \
205                          $(foreach address_size, $(13), \
206                            test-art-$(target)-run-test-$(run-type)-$(prebuild)-$(compiler)-$(relocate)-$(trace)-$(gc)-$(jni)-$(image)-$(pictest)-$(debuggable)-$(test)$(address_size) \
207                    )))))))))))))
208endef  # all-run-test-names
209
210# To generate a full list or tests:
211# $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \
212#        $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
213#        $(PICTEST_TYPES),$(DEBUGGABLE_TYPES),$(TEST_ART_RUN_TESTS),$(ALL_ADDRESS_SIZES))
214
215# Convert's a rule name to the form used in variables, e.g. no-relocate to NO_RELOCATE
216define name-to-var
217$(shell echo $(1) | tr '[:lower:]' '[:upper:]' | tr '-' '_')
218endef  # name-to-var
219
220ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
221        $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
222        $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(ART_TEST_RUN_TEST_SKIP), $(ALL_ADDRESS_SIZES))
223
224# Tests that are timing sensitive and flaky on heavily loaded systems.
225TEST_ART_TIMING_SENSITIVE_RUN_TESTS := \
226  002-sleep \
227  053-wait-some \
228  055-enum-performance \
229  133-static-invoke-super
230
231# disable timing sensitive tests on "dist" builds.
232ifdef dist_goal
233  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
234        $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
235        $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), $(ALL_ADDRESS_SIZES))
236endif
237
238# Tests that require python3.
239TEST_ART_PYTHON3_DEPENDENCY_RUN_TESTS := \
240  960-default-smali \
241  961-default-iface-resolution-generated \
242  964-default-iface-init-generated \
243  968-default-partial-compile-generated \
244  969-iface-super \
245  970-iface-super-resolution-generated \
246  971-iface-super
247
248# Check if we have python3 to run our tests.
249ifeq ($(wildcard /usr/bin/python3),)
250  $(warning "No python3 found. Disabling tests: $(TEST_ART_PYTHON3_DEPENDENCY_RUN_TESTS)")
251
252  # Currently disable tests requiring python3 when it is not installed.
253  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
254        $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
255        $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_PYTHON3_DEPENDENCY_RUN_TESTS), $(ALL_ADDRESS_SIZES))
256endif
257
258TEST_ART_TIMING_SENSITIVE_RUN_TESTS :=
259
260# Note 116-nodex2oat is not broken per-se it just doesn't (and isn't meant to) work with --prebuild.
261TEST_ART_BROKEN_PREBUILD_RUN_TESTS := \
262  116-nodex2oat \
263  118-noimage-dex2oat \
264  134-nodex2oat-nofallback
265
266ifneq (,$(filter prebuild,$(PREBUILD_TYPES)))
267  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),prebuild, \
268      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
269      $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_PREBUILD_RUN_TESTS), $(ALL_ADDRESS_SIZES))
270endif
271
272TEST_ART_BROKEN_PREBUILD_RUN_TESTS :=
273
274# 554-jit-profile-file is disabled because it needs a primary oat file to know what it should save.
275TEST_ART_BROKEN_NO_PREBUILD_TESTS := \
276  117-nopatchoat \
277  554-jit-profile-file
278
279ifneq (,$(filter no-prebuild,$(PREBUILD_TYPES)))
280  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),no-prebuild, \
281      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
282      $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_NO_PREBUILD_TESTS), $(ALL_ADDRESS_SIZES))
283endif
284
285TEST_ART_BROKEN_NO_PREBUILD_TESTS :=
286
287# Note 117-nopatchoat is not broken per-se it just doesn't work (and isn't meant to) without
288# --prebuild --relocate
289TEST_ART_BROKEN_NO_RELOCATE_TESTS := \
290  117-nopatchoat \
291  118-noimage-dex2oat \
292  119-noimage-patchoat \
293  554-jit-profile-file
294
295ifneq (,$(filter no-relocate,$(RELOCATE_TYPES)))
296  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
297      $(COMPILER_TYPES), no-relocate,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
298      $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_NO_RELOCATE_TESTS), $(ALL_ADDRESS_SIZES))
299endif
300
301TEST_ART_BROKEN_NO_RELOCATE_TESTS :=
302
303# Temporarily disable some broken tests when forcing access checks in interpreter b/22414682
304TEST_ART_BROKEN_INTERPRETER_ACCESS_CHECK_TESTS := \
305  004-JniTest \
306  005-annotations \
307  044-proxy \
308  073-mismatched-field \
309  088-monitor-verification \
310  135-MirandaDispatch \
311  137-cfi \
312  412-new-array \
313  471-uninitialized-locals \
314  506-verify-aput \
315  554-jit-profile-file \
316  800-smali
317
318ifneq (,$(filter interp-ac,$(COMPILER_TYPES)))
319  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
320      interp-ac,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
321      $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_INTERPRETER_ACCESS_CHECK_TESTS), $(ALL_ADDRESS_SIZES))
322endif
323
324TEST_ART_BROKEN_INTERPRETER_ACCESS_CHECK_TESTS :=
325
326# Tests that are broken with GC stress.
327# * 137-cfi needs to unwind a second forked process. We're using a primitive sleep to wait till we
328#   hope the second process got into the expected state. The slowness of gcstress makes this bad.
329# * 961-default-iface-resolution-generated and 964-default-iface-init-generated are very long tests
330#   that often will take more than the timeout to run when gcstress is enabled. This is because
331#   gcstress slows down allocations significantly which these tests do a lot.
332TEST_ART_BROKEN_GCSTRESS_RUN_TESTS := \
333  137-cfi \
334  961-default-iface-resolution-generated \
335  964-default-iface-init-generated
336
337ifneq (,$(filter gcstress,$(GC_TYPES)))
338  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
339      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),gcstress,$(JNI_TYPES), \
340      $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_GCSTRESS_RUN_TESTS), $(ALL_ADDRESS_SIZES))
341endif
342
343TEST_ART_BROKEN_GCSTRESS_RUN_TESTS :=
344
345# 115-native-bridge setup is complicated. Need to implement it correctly for the target.
346ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(RUN_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \
347    $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), 115-native-bridge, \
348    $(ALL_ADDRESS_SIZES))
349
350# 130-hprof dumps the heap and runs hprof-conv to check whether the file is somewhat readable. This
351# is only possible on the host.
352# TODO: Turn off all the other combinations, this is more about testing actual ART code. A gtest is
353#       very hard to write here, as (for a complete test) JDWP must be set up.
354ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(RUN_TYPES),$(PREBUILD_TYPES), \
355    $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
356    $(PICTEST_TYPES),$(DEBUGGABLE_TYPES),130-hprof,$(ALL_ADDRESS_SIZES))
357
358# 131 is an old test. The functionality has been implemented at an earlier stage and is checked
359# in tests 138. Blacklisted for debug builds since these builds have duplicate classes checks which
360# punt to interpreter.
361ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),debug,$(PREBUILD_TYPES), \
362    $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
363    $(PICTEST_TYPES),$(DEBUGGABLE_TYPES),131-structural-change,$(ALL_ADDRESS_SIZES))
364
365# 138-duplicate-classes-check. Turned on for debug builds since debug builds have duplicate classes
366# checks enabled, b/2133391.
367ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),ndebug,$(PREBUILD_TYPES), \
368    $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
369    $(PICTEST_TYPES),$(DEBUGGABLE_TYPES),138-duplicate-classes-check,$(ALL_ADDRESS_SIZES))
370
371# All these tests check that we have sane behavior if we don't have a patchoat or dex2oat.
372# Therefore we shouldn't run them in situations where we actually don't have these since they
373# explicitly test for them. These all also assume we have an image.
374# 554-jit-profile-file is disabled because it needs a primary oat file to know what it should save.
375TEST_ART_BROKEN_FALLBACK_RUN_TESTS := \
376  116-nodex2oat \
377  117-nopatchoat \
378  118-noimage-dex2oat \
379  119-noimage-patchoat \
380  137-cfi \
381  138-duplicate-classes-check2 \
382  554-jit-profile-file
383
384# This test fails without an image.
385TEST_ART_BROKEN_NO_IMAGE_RUN_TESTS := \
386  137-cfi \
387  138-duplicate-classes-check
388
389ifneq (,$(filter no-dex2oat,$(PREBUILD_TYPES)))
390  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),no-dex2oat, \
391      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
392      $(PICTEST_TYPES),$(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
393endif
394
395
396ifneq (,$(filter no-image,$(IMAGE_TYPES)))
397  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
398      $(COMPILER_TYPES), $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),no-image, \
399      $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
400  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
401      $(COMPILER_TYPES), $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),no-image, \
402      $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_NO_IMAGE_RUN_TESTS),$(ALL_ADDRESS_SIZES))
403endif
404
405ifneq (,$(filter relocate-npatchoat,$(RELOCATE_TYPES)))
406  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
407      $(COMPILER_TYPES), relocate-npatchoat,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
408      $(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
409endif
410
411TEST_ART_BROKEN_FALLBACK_RUN_TESTS :=
412
413# 137:
414# This test unrolls and expects managed frames, but tracing means we run the interpreter.
415# 802:
416# This test dynamically enables tracing to force a deoptimization. This makes the test meaningless
417# when already tracing, and writes an error message that we do not want to check for.
418TEST_ART_BROKEN_TRACING_RUN_TESTS := \
419  087-gc-after-link \
420  137-cfi \
421  141-class-unload \
422  802-deoptimization
423
424ifneq (,$(filter trace stream,$(TRACE_TYPES)))
425  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
426      $(COMPILER_TYPES),$(RELOCATE_TYPES),trace stream,$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
427      $(PICTEST_TYPES),$(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_TRACING_RUN_TESTS),$(ALL_ADDRESS_SIZES))
428endif
429
430# Known broken tests for the interpreter.
431# CFI unwinding expects managed frames.
432TEST_ART_BROKEN_INTERPRETER_RUN_TESTS := \
433  137-cfi \
434  554-jit-profile-file
435
436ifneq (,$(filter interpreter,$(COMPILER_TYPES)))
437  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
438      interpreter,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
439      $(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES),$(TEST_ART_BROKEN_INTERPRETER_RUN_TESTS),$(ALL_ADDRESS_SIZES))
440endif
441
442TEST_ART_BROKEN_INTERPRETER_RUN_TESTS :=
443
444# Known broken tests for the JIT.
445# CFI unwinding expects managed frames, and the test does not iterate enough to even compile. JIT
446# also uses Generic JNI instead of the JNI compiler.
447TEST_ART_BROKEN_JIT_RUN_TESTS := \
448  137-cfi
449
450ifneq (,$(filter jit,$(COMPILER_TYPES)))
451  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
452      jit,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
453      $(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES),$(TEST_ART_BROKEN_JIT_RUN_TESTS),$(ALL_ADDRESS_SIZES))
454endif
455
456TEST_ART_BROKEN_JIT_RUN_TESTS :=
457
458# Known broken tests for the default compiler (Quick).
459TEST_ART_BROKEN_DEFAULT_RUN_TESTS := \
460  457-regs \
461  563-checker-fakestring
462
463ifneq (,$(filter default,$(COMPILER_TYPES)))
464  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
465      default,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
466      $(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES),$(TEST_ART_BROKEN_DEFAULT_RUN_TESTS),$(ALL_ADDRESS_SIZES))
467endif
468
469TEST_ART_BROKEN_DEFAULT_RUN_TESTS :=
470
471# Known broken tests for the mips32 optimizing compiler backend.
472TEST_ART_BROKEN_OPTIMIZING_MIPS_RUN_TESTS := \
473    441-checker-inliner \
474    510-checker-try-catch \
475    536-checker-intrinsic-optimization \
476    557-checker-instruction-simplifier-ror \
477
478ifeq (mips,$(TARGET_ARCH))
479  ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
480    ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(RUN_TYPES),$(PREBUILD_TYPES), \
481        optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
482        $(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), \
483        $(TEST_ART_BROKEN_OPTIMIZING_MIPS_RUN_TESTS),$(ALL_ADDRESS_SIZES))
484  endif
485endif
486
487TEST_ART_BROKEN_OPTIMIZING_MIPS_RUN_TESTS :=
488
489# Known broken tests for the mips64 optimizing compiler backend.
490TEST_ART_BROKEN_OPTIMIZING_MIPS64_RUN_TESTS := \
491    557-checker-instruction-simplifier-ror \
492
493ifeq (mips64,$(TARGET_ARCH))
494  ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
495    ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(RUN_TYPES),$(PREBUILD_TYPES), \
496        optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
497        $(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), \
498        $(TEST_ART_BROKEN_OPTIMIZING_MIPS64_RUN_TESTS),$(ALL_ADDRESS_SIZES))
499  endif
500endif
501
502TEST_ART_BROKEN_OPTIMIZING_MIPS64_RUN_TESTS :=
503
504# Tests that should fail when the optimizing compiler compiles them non-debuggable.
505TEST_ART_BROKEN_OPTIMIZING_NONDEBUGGABLE_RUN_TESTS := \
506  454-get-vreg \
507  457-regs \
508
509ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
510  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
511      optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
512      $(IMAGE_TYPES),$(PICTEST_TYPES),ndebuggable,$(TEST_ART_BROKEN_OPTIMIZING_NONDEBUGGABLE_RUN_TESTS),$(ALL_ADDRESS_SIZES))
513endif
514
515TEST_ART_BROKEN_OPTIMIZING_NONDEBUGGABLE_RUN_TESTS :=
516
517# Tests that should fail when the optimizing compiler compiles them debuggable.
518TEST_ART_BROKEN_OPTIMIZING_DEBUGGABLE_RUN_TESTS := \
519
520ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
521  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
522      optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
523      $(IMAGE_TYPES),$(PICTEST_TYPES),debuggable,$(TEST_ART_BROKEN_OPTIMIZING_DEBUGGABLE_RUN_TESTS),$(ALL_ADDRESS_SIZES))
524endif
525
526TEST_ART_BROKEN_OPTIMIZING_DEBUGGABLE_RUN_TESTS :=
527
528# Tests that should fail in the read barrier configuration with the interpreter.
529TEST_ART_BROKEN_INTERPRETER_READ_BARRIER_RUN_TESTS :=
530
531# Tests that should fail in the read barrier configuration with the default (Quick) compiler (AOT).
532# Quick has no support for read barriers and punts to the interpreter, so this list is composed of
533# tests expected to fail with the interpreter, both on the concurrent collector and in general.
534TEST_ART_BROKEN_DEFAULT_READ_BARRIER_RUN_TESTS := \
535  $(TEST_ART_BROKEN_INTERPRETER_READ_BARRIER_RUN_TESTS) \
536  $(TEST_ART_BROKEN_INTERPRETER_RUN_TESTS)
537
538# Tests that should fail in the read barrier configuration with the Optimizing compiler (AOT).
539# 484: Baker's fast path based read barrier compiler instrumentation generates code containing
540#      more parallel moves on x86, thus some Checker assertions may fail.
541# 527: On ARM64, the read barrier instrumentation does not support the HArm64IntermediateAddress
542#      instruction yet (b/26601270).
543# 537: Expects an array copy to be intrinsified on x86-64, but calling-on-slowpath intrinsics are
544#      not yet handled in the read barrier configuration.
545TEST_ART_BROKEN_OPTIMIZING_READ_BARRIER_RUN_TESTS := \
546  484-checker-register-hints \
547  527-checker-array-access-split \
548  537-checker-arraycopy
549
550# Tests that should fail in the read barrier configuration with JIT.
551# 496: Occasional timeout: "Fault message: timeout: the monitored command dumped core" (b/26786304).
552TEST_ART_BROKEN_JIT_READ_BARRIER_RUN_TESTS := \
553  496-checker-inlining-and-class-loader
554
555ifeq ($(ART_USE_READ_BARRIER),true)
556  ifneq (,$(filter interpreter,$(COMPILER_TYPES)))
557    ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES), \
558        $(PREBUILD_TYPES),interpreter,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES), \
559        $(JNI_TYPES),$(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), \
560        $(TEST_ART_BROKEN_INTERPRETER_READ_BARRIER_RUN_TESTS),$(ALL_ADDRESS_SIZES))
561  endif
562
563  ifneq (,$(filter default,$(COMPILER_TYPES)))
564    ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES), \
565        $(PREBUILD_TYPES),default,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES), \
566        $(JNI_TYPES),$(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), \
567        $(TEST_ART_BROKEN_DEFAULT_READ_BARRIER_RUN_TESTS),$(ALL_ADDRESS_SIZES))
568  endif
569
570  ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
571    ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES), \
572        $(PREBUILD_TYPES),optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES), \
573        $(JNI_TYPES),$(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), \
574        $(TEST_ART_BROKEN_OPTIMIZING_READ_BARRIER_RUN_TESTS),$(ALL_ADDRESS_SIZES))
575  endif
576
577  ifneq (,$(filter jit,$(COMPILER_TYPES)))
578    ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES), \
579        $(PREBUILD_TYPES),jit,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES), \
580        $(JNI_TYPES),$(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), \
581        $(TEST_ART_BROKEN_JIT_READ_BARRIER_RUN_TESTS),$(ALL_ADDRESS_SIZES))
582  endif
583endif
584
585TEST_ART_BROKEN_DEFAULT_READ_BARRIER_RUN_TESTS :=
586TEST_ART_BROKEN_OPTIMIZING_READ_BARRIER_RUN_TESTS :=
587TEST_ART_BROKEN_JIT_READ_BARRIER_RUN_TESTS :=
588
589# Tests that should fail in the heap poisoning configuration with the default (Quick) compiler.
590# 137: Quick has no support for read barriers and punts to the
591#      interpreter, but CFI unwinding expects managed frames.
592# 554: Quick does not support JIT profiling.
593TEST_ART_BROKEN_DEFAULT_HEAP_POISONING_RUN_TESTS := \
594  137-cfi \
595  554-jit-profile-file
596# Tests that should fail in the heap poisoning configuration with the Optimizing compiler.
597# 055: Exceeds run time limits due to heap poisoning instrumentation (on ARM and ARM64 devices).
598TEST_ART_BROKEN_OPTIMIZING_HEAP_POISONING_RUN_TESTS := \
599  055-enum-performance
600
601ifeq ($(ART_HEAP_POISONING),true)
602  ifneq (,$(filter default,$(COMPILER_TYPES)))
603    ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES), \
604        $(PREBUILD_TYPES),default,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
605        $(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), \
606        $(TEST_ART_BROKEN_DEFAULT_HEAP_POISONING_RUN_TESTS),$(ALL_ADDRESS_SIZES))
607  endif
608
609  ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
610    ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES), \
611        $(PREBUILD_TYPES),optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
612        $(IMAGE_TYPES),$(PICTEST_TYPES),$(DEBUGGABLE_TYPES), \
613        $(TEST_ART_BROKEN_OPTIMIZING_HEAP_POISONING_RUN_TESTS),$(ALL_ADDRESS_SIZES))
614  endif
615endif
616
617TEST_ART_BROKEN_DEFAULT_HEAP_POISONING_RUN_TESTS :=
618TEST_ART_BROKEN_OPTIMIZING_HEAP_POISONING_RUN_TESTS :=
619
620# Tests broken by multi-image.
621TEST_ART_BROKEN_MULTI_IMAGE_RUN_TESTS := \
622  476-checker-ctor-memory-barrier \
623  530-checker-lse
624
625ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
626    $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
627    $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), \
628    $(TEST_ART_BROKEN_MULTI_IMAGE_RUN_TESTS),  $(ALL_ADDRESS_SIZES))
629
630TEST_ART_BROKEN_MULTI_IMAGE_RUN_TESTS :=
631
632# Clear variables ahead of appending to them when defining tests.
633$(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=))
634$(foreach target, $(TARGET_TYPES), \
635  $(foreach prebuild, $(PREBUILD_TYPES), \
636    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES :=)))
637$(foreach target, $(TARGET_TYPES), \
638  $(foreach compiler, $(COMPILER_TYPES), \
639    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES :=)))
640$(foreach target, $(TARGET_TYPES), \
641  $(foreach relocate, $(RELOCATE_TYPES), \
642    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES :=)))
643$(foreach target, $(TARGET_TYPES), \
644  $(foreach trace, $(TRACE_TYPES), \
645    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES :=)))
646$(foreach target, $(TARGET_TYPES), \
647  $(foreach gc, $(GC_TYPES), \
648    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES :=)))
649$(foreach target, $(TARGET_TYPES), \
650  $(foreach jni, $(JNI_TYPES), \
651    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=)))
652$(foreach target, $(TARGET_TYPES), \
653  $(foreach image, $(IMAGE_TYPES), \
654    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=)))
655$(foreach target, $(TARGET_TYPES), \
656  $(foreach test, $(TEST_ART_RUN_TESTS), \
657    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=)))
658$(foreach target, $(TARGET_TYPES), \
659  $(foreach address_size, $(ALL_ADDRESS_SIZES), \
660    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(address_size))_RULES :=)))
661$(foreach target, $(TARGET_TYPES), \
662  $(foreach run_type, $(RUN_TYPES), \
663    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(run_type))_RULES :=)))
664$(foreach target, $(TARGET_TYPES), \
665  $(foreach debuggable_type, $(DEBUGGABLE_TYPES), \
666    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(debuggable_type))_RULES :=)))
667
668# We need dex2oat and dalvikvm on the target as well as the core images (all images as we sync
669# only once).
670TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_EXECUTABLES) $(TARGET_CORE_IMG_OUTS)
671
672# Also need libarttest.
673TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libarttest.so
674TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libarttestd.so
675ifdef TARGET_2ND_ARCH
676TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libarttest.so
677TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libarttestd.so
678endif
679
680# Also need libnativebridgetest.
681TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libnativebridgetest.so
682ifdef TARGET_2ND_ARCH
683TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libnativebridgetest.so
684endif
685
686# All tests require the host executables. The tests also depend on the core images, but on
687# specific version depending on the compiler.
688ART_TEST_HOST_RUN_TEST_DEPENDENCIES := \
689  $(ART_HOST_EXECUTABLES) \
690  $(ART_HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) \
691  $(ART_HOST_OUT_SHARED_LIBRARIES)/libarttestd$(ART_HOST_SHLIB_EXTENSION) \
692  $(ART_HOST_OUT_SHARED_LIBRARIES)/libnativebridgetest$(ART_HOST_SHLIB_EXTENSION) \
693  $(ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION) \
694  $(ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdk$(ART_HOST_SHLIB_EXTENSION) \
695  $(ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$(ART_HOST_SHLIB_EXTENSION)
696
697ifneq ($(HOST_PREFER_32_BIT),true)
698ART_TEST_HOST_RUN_TEST_DEPENDENCIES += \
699  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) \
700  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libarttestd$(ART_HOST_SHLIB_EXTENSION) \
701  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libnativebridgetest$(ART_HOST_SHLIB_EXTENSION) \
702  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION) \
703  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdk$(ART_HOST_SHLIB_EXTENSION) \
704  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$(ART_HOST_SHLIB_EXTENSION)
705endif
706
707# Create a rule to build and run a tests following the form:
708# test-art-{1: host or target}-run-test-{2: debug ndebug}-{3: prebuild no-prebuild no-dex2oat}-
709#    {4: interpreter default optimizing jit interp-ac}-
710#    {5: relocate nrelocate relocate-npatchoat}-
711#    {6: trace or ntrace}-{7: gcstress gcverify cms}-{8: forcecopy checkjni jni}-
712#    {9: no-image image picimage}-{10: pictest npictest}-
713#    {11: ndebuggable debuggable}-{12: test name}{13: 32 or 64}
714define define-test-art-run-test
715  run_test_options :=
716  prereq_rule :=
717  test_groups :=
718  uc_host_or_target :=
719  jack_classpath :=
720  ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
721    run_test_options += --build-with-jack
722  else
723    run_test_options += --build-with-javac-dx
724  endif
725  ifeq ($(ART_TEST_WITH_STRACE),true)
726    run_test_options += --strace
727  endif
728  ifeq ($(ART_TEST_RUN_TEST_ALWAYS_CLEAN),true)
729    run_test_options += --always-clean
730  endif
731  ifeq ($(1),host)
732    uc_host_or_target := HOST
733    test_groups := ART_RUN_TEST_HOST_RULES
734    run_test_options += --host
735    prereq_rule := $(ART_TEST_HOST_RUN_TEST_DEPENDENCIES) $(HOST_JACK_CLASSPATH_DEPENDENCIES)
736    jack_classpath := $(HOST_JACK_CLASSPATH)
737  else
738    ifeq ($(1),target)
739      uc_host_or_target := TARGET
740      test_groups := ART_RUN_TEST_TARGET_RULES
741      prereq_rule := test-art-target-sync $(TARGET_JACK_CLASSPATH_DEPENDENCIES)
742      jack_classpath := $(TARGET_JACK_CLASSPATH)
743    else
744      $$(error found $(1) expected $(TARGET_TYPES))
745    endif
746  endif
747  ifeq ($(2),debug)
748    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEBUG_RULES
749  else
750    ifeq ($(2),ndebug)
751      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELEASE_RULES
752      run_test_options += -O
753    else
754      $$(error found $(2) expected $(RUN_TYPES))
755    endif
756  endif
757  ifeq ($(3),prebuild)
758    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_PREBUILD_RULES
759    run_test_options += --prebuild
760  else
761    ifeq ($(3),no-prebuild)
762      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_PREBUILD_RULES
763      run_test_options += --no-prebuild
764    else
765      ifeq ($(3),no-dex2oat)
766        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_DEX2OAT_RULES
767        run_test_options += --no-prebuild --no-dex2oat
768      else
769        $$(error found $(3) expected $(PREBUILD_TYPES))
770      endif
771    endif
772  endif
773  ifeq ($(4),optimizing)
774    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_OPTIMIZING_RULES
775    run_test_options += --optimizing
776  else
777    ifeq ($(4),interpreter)
778      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_INTERPRETER_RULES
779      run_test_options += --interpreter
780    else ifeq ($(4),interp-ac)
781      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_INTERPRETER_ACCESS_CHECKS_RULES
782      run_test_options += --interpreter --verify-soft-fail
783    else
784      ifeq ($(4),default)
785        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEFAULT_RULES
786        run_test_options += --quick
787      else
788        ifeq ($(4),jit)
789          test_groups += ART_RUN_TEST_$$(uc_host_or_target)_JIT_RULES
790          run_test_options += --jit
791        else
792          $$(error found $(4) expected $(COMPILER_TYPES))
793        endif
794      endif
795    endif
796  endif
797
798  ifeq ($(5),relocate)
799    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_RULES
800    run_test_options += --relocate
801  else
802    ifeq ($(5),no-relocate)
803      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_RELOCATE_RULES
804      run_test_options += --no-relocate
805    else
806      ifeq ($(5),relocate-npatchoat)
807        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_NO_PATCHOAT_RULES
808        run_test_options += --relocate --no-patchoat
809      else
810        $$(error found $(5) expected $(RELOCATE_TYPES))
811      endif
812    endif
813  endif
814  ifeq ($(6),trace)
815    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_TRACE_RULES
816    run_test_options += --trace
817  else
818    ifeq ($(6),ntrace)
819      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_TRACE_RULES
820    else
821      ifeq ($(6),stream)
822        # Group streaming under normal tracing rules.
823        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_TRACE_RULES
824        run_test_options += --trace --stream
825      else
826        $$(error found $(6) expected $(TRACE_TYPES))
827      endif
828    endif
829  endif
830  ifeq ($(7),gcverify)
831    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_GCVERIFY_RULES
832    run_test_options += --gcverify
833  else
834    ifeq ($(7),gcstress)
835      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_GCSTRESS_RULES
836      run_test_options += --gcstress
837    else
838      ifeq ($(7),cms)
839        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_CMS_RULES
840      else
841        $$(error found $(7) expected $(GC_TYPES))
842      endif
843    endif
844  endif
845  ifeq ($(8),forcecopy)
846    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_FORCECOPY_RULES
847    run_test_options += --runtime-option -Xjniopts:forcecopy
848    ifneq ($$(ART_TEST_JNI_FORCECOPY),true)
849      skip_test := true
850    endif
851  else
852    ifeq ($(8),checkjni)
853      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_CHECKJNI_RULES
854      run_test_options += --runtime-option -Xcheck:jni
855    else
856      ifeq ($(8),jni)
857        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_JNI_RULES
858      else
859        $$(error found $(8) expected $(JNI_TYPES))
860      endif
861    endif
862  endif
863  image_suffix := $(4)
864  ifeq ($(9),no-image)
865    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_IMAGE_RULES
866    run_test_options += --no-image
867    # Add the core dependency. This is required for pre-building.
868    ifeq ($(1),host)
869      prereq_rule += $$(HOST_CORE_IMAGE_$$(image_suffix)_no-pic_$(13))
870    else
871      prereq_rule += $$(TARGET_CORE_IMAGE_$$(image_suffix)_no-pic_$(13))
872    endif
873  else
874    ifeq ($(9),image)
875      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_IMAGE_RULES
876      # Add the core dependency.
877      ifeq ($(1),host)
878        prereq_rule += $$(HOST_CORE_IMAGE_$$(image_suffix)_no-pic_$(13))
879      else
880        prereq_rule += $$(TARGET_CORE_IMAGE_$$(image_suffix)_no-pic_$(13))
881      endif
882    else
883      ifeq ($(9),picimage)
884        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_PICIMAGE_RULES
885        run_test_options += --pic-image
886        ifeq ($(1),host)
887          prereq_rule += $$(HOST_CORE_IMAGE_$$(image_suffix)_pic_$(13))
888        else
889          prereq_rule += $$(TARGET_CORE_IMAGE_$$(image_suffix)_pic_$(13))
890        endif
891      else
892        ifeq ($(9),multiimage)
893          test_groups += ART_RUN_TEST_$$(uc_host_or_target)_IMAGE_RULES
894          run_test_options += --multi-image
895                ifeq ($(1),host)
896                        prereq_rule += $$(HOST_CORE_IMAGE_$$(image_suffix)_no-pic_multi_$(13))
897                else
898                        prereq_rule += $$(TARGET_CORE_IMAGE_$$(image_suffix)_no-pic_multi_$(13))
899                endif
900        else
901          ifeq ($(9),multipicimage)
902            test_groups += ART_RUN_TEST_$$(uc_host_or_target)_PICIMAGE_RULES
903                        run_test_options += --pic-image --multi-image
904                        ifeq ($(1),host)
905                        prereq_rule += $$(HOST_CORE_IMAGE_$$(image_suffix)_pic_multi_$(13))
906                        else
907                        prereq_rule += $$(TARGET_CORE_IMAGE_$$(image_suffix)_pic_multi_$(13))
908                        endif
909          else
910            $$(error found $(9) expected $(IMAGE_TYPES))
911          endif
912        endif
913      endif
914    endif
915  endif
916  ifeq ($(10),pictest)
917    run_test_options += --pic-test
918  else
919    ifeq ($(10),npictest)
920      # Nothing to be done.
921    else
922      $$(error found $(10) expected $(PICTEST_TYPES))
923    endif
924  endif
925  ifeq ($(11),debuggable)
926    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEBUGGABLE_RULES
927    run_test_options += --debuggable
928  else
929    ifeq ($(11),ndebuggable)
930    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NONDEBUGGABLE_RULES
931      # Nothing to be done.
932    else
933      $$(error found $(11) expected $(DEBUGGABLE_TYPES))
934    endif
935  endif
936  # $(12) is the test name.
937  test_groups += ART_RUN_TEST_$$(uc_host_or_target)_$(call name-to-var,$(12))_RULES
938  ifeq ($(13),64)
939    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_64_RULES
940    run_test_options += --64
941  else
942    ifeq ($(13),32)
943      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_32_RULES
944    else
945      $$(error found $(13) expected $(ALL_ADDRESS_SIZES))
946    endif
947  endif
948  # Override of host instruction-set-features. Required to test advanced x86 intrinsics. The
949  # conditionals aren't really correct, they will fail to do the right thing on a 32-bit only
950  # host. However, this isn't common enough to worry here and make the conditions complicated.
951  ifneq ($(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),)
952    ifeq ($(13),64)
953      run_test_options += --instruction-set-features $(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES)
954    endif
955  endif
956  ifneq ($($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),)
957    ifeq ($(13),32)
958      run_test_options += --instruction-set-features $($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES)
959    endif
960  endif
961  run_test_rule_name := test-art-$(1)-run-test-$(2)-$(3)-$(4)-$(5)-$(6)-$(7)-$(8)-$(9)-$(10)-$(11)-$(12)$(13)
962  run_test_options := --output-path $(ART_HOST_TEST_DIR)/run-test-output/$$(run_test_rule_name) \
963      $$(run_test_options)
964  ifneq ($(ART_TEST_ANDROID_ROOT),)
965    run_test_options := --android-root $(ART_TEST_ANDROID_ROOT) $$(run_test_options)
966  endif
967  ifeq ($(ART_TEST_QUIET),true)
968    run_test_options += --quiet
969  endif
970$$(run_test_rule_name): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options)
971$$(run_test_rule_name): PRIVATE_JACK_CLASSPATH := $$(jack_classpath)
972.PHONY: $$(run_test_rule_name)
973$$(run_test_rule_name): $(TEST_ART_RUN_TEST_DEPENDENCIES) $(HOST_OUT_EXECUTABLES)/hprof-conv $$(prereq_rule) | $(TEST_ART_RUN_TEST_ORDERONLY_DEPENDENCIES)
974	$(hide) $$(call ART_TEST_SKIP,$$@) && \
975	  DX=$(abspath $(DX)) \
976	    JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
977	    SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
978	    DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
979	    JACK_VERSION=$(JACK_DEFAULT_VERSION) \
980	    JACK=$(abspath $(JACK)) \
981	    JACK_CLASSPATH=$$(PRIVATE_JACK_CLASSPATH) \
982	    JILL_JAR=$(abspath $(JILL_JAR)) \
983	    art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(12) \
984	      && $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@)
985	$$(hide) (echo $(MAKECMDGOALS) | grep -q $$@ && \
986	  echo "run-test run as top-level target, removing test directory $(ART_HOST_TEST_DIR)" && \
987	  rm -r $(ART_HOST_TEST_DIR)) || true
988
989  $$(foreach test_group,$$(test_groups), $$(eval $$(value test_group) += $$(run_test_rule_name)))
990
991  # Clear locally defined variables.
992  uc_host_or_target :=
993  test_groups :=
994  run_test_options :=
995  run_test_rule_name :=
996  prereq_rule :=
997  jack_classpath :=
998endef  # define-test-art-run-test
999
1000$(foreach target, $(TARGET_TYPES), \
1001  $(foreach test, $(TEST_ART_RUN_TESTS), \
1002    $(foreach run_type, $(RUN_TYPES), \
1003      $(foreach address_size, $(ADDRESS_SIZES_$(call name-to-var,$(target))), \
1004        $(foreach prebuild, $(PREBUILD_TYPES), \
1005          $(foreach compiler, $(COMPILER_TYPES), \
1006            $(foreach relocate, $(RELOCATE_TYPES), \
1007              $(foreach trace, $(TRACE_TYPES), \
1008                $(foreach gc, $(GC_TYPES), \
1009                  $(foreach jni, $(JNI_TYPES), \
1010                    $(foreach image, $(IMAGE_TYPES), \
1011                      $(foreach pictest, $(PICTEST_TYPES), \
1012                        $(foreach debuggable, $(DEBUGGABLE_TYPES), \
1013                          $(eval $(call define-test-art-run-test,$(target),$(run_type),$(prebuild),$(compiler),$(relocate),$(trace),$(gc),$(jni),$(image),$(pictest),$(debuggable),$(test),$(address_size))) \
1014                  )))))))))))))
1015define-test-art-run-test :=
1016
1017# Define a phony rule whose purpose is to test its prerequisites.
1018# $(1): host or target
1019# $(2): list of prerequisites
1020define define-test-art-run-test-group
1021.PHONY: $(1)
1022$(1): $(2)
1023	$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
1024
1025endef  # define-test-art-run-test-group
1026
1027
1028$(foreach target, $(TARGET_TYPES), $(eval \
1029  $(call define-test-art-run-test-group,test-art-$(target)-run-test,$(ART_RUN_TEST_$(call name-to-var,$(target))_RULES))))
1030$(foreach target, $(TARGET_TYPES), \
1031  $(foreach prebuild, $(PREBUILD_TYPES), $(eval \
1032    $(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)))))
1033$(foreach target, $(TARGET_TYPES), \
1034  $(foreach run-type, $(RUN_TYPES), $(eval \
1035    $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(run-type),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(run-type))_RULES)))))
1036$(foreach target, $(TARGET_TYPES), \
1037  $(foreach compiler, $(COMPILER_TYPES), $(eval \
1038    $(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)))))
1039$(foreach target, $(TARGET_TYPES), \
1040  $(foreach relocate, $(RELOCATE_TYPES), $(eval \
1041    $(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)))))
1042$(foreach target, $(TARGET_TYPES), \
1043  $(foreach trace, $(TRACE_TYPES), $(eval \
1044    $(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)))))
1045$(foreach target, $(TARGET_TYPES), \
1046  $(foreach gc, $(GC_TYPES), $(eval \
1047    $(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)))))
1048$(foreach target, $(TARGET_TYPES), \
1049  $(foreach jni, $(JNI_TYPES), $(eval \
1050    $(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)))))
1051$(foreach target, $(TARGET_TYPES), \
1052  $(foreach debuggable, $(DEBUGGABLE_TYPES), $(eval \
1053    $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(debuggable),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(debuggable))_RULES)))))
1054$(foreach target, $(TARGET_TYPES), \
1055  $(foreach image, $(IMAGE_TYPES), $(eval \
1056    $(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)))))
1057$(foreach target, $(TARGET_TYPES), \
1058  $(foreach test, $(TEST_ART_RUN_TESTS), $(eval \
1059    $(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)))))
1060$(foreach target, $(TARGET_TYPES), \
1061  $(foreach address_size, $(ADDRESS_SIZES_$(call name-to-var,$(target))), $(eval \
1062    $(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)))))
1063
1064# Clear variables now we're finished with them.
1065$(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=))
1066$(foreach target, $(TARGET_TYPES), \
1067  $(foreach prebuild, $(PREBUILD_TYPES), \
1068    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES :=)))
1069$(foreach target, $(TARGET_TYPES), \
1070  $(foreach compiler, $(COMPILER_TYPES), \
1071    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES :=)))
1072$(foreach target, $(TARGET_TYPES), \
1073  $(foreach relocate, $(RELOCATE_TYPES), \
1074    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES :=)))
1075$(foreach target, $(TARGET_TYPES), \
1076  $(foreach trace, $(TRACE_TYPES), \
1077    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES :=)))
1078$(foreach target, $(TARGET_TYPES), \
1079  $(foreach gc, $(GC_TYPES), \
1080    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES :=)))
1081$(foreach target, $(TARGET_TYPES), \
1082  $(foreach jni, $(JNI_TYPES), \
1083    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=)))
1084$(foreach target, $(TARGET_TYPES), \
1085  $(foreach debuggable, $(DEBUGGABLE_TYPES), \
1086    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(debuggable))_RULES :=)))
1087$(foreach target, $(TARGET_TYPES), \
1088  $(foreach image, $(IMAGE_TYPES), \
1089    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=)))
1090$(foreach target, $(TARGET_TYPES), \
1091  $(foreach test, $(TEST_ART_RUN_TESTS), \
1092    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=)))
1093$(foreach target, $(TARGET_TYPES), \
1094  $(foreach address_size, $(ALL_ADDRESS_SIZES), \
1095    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(address_size))_RULES :=)))
1096$(foreach target, $(TARGET_TYPES), \
1097  $(foreach run_type, $(RUN_TYPES), \
1098    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(run_type))_RULES :=)))
1099define-test-art-run-test-group :=
1100TARGET_TYPES :=
1101PREBUILD_TYPES :=
1102COMPILER_TYPES :=
1103RELOCATE_TYPES :=
1104TRACE_TYPES :=
1105GC_TYPES :=
1106JNI_TYPES :=
1107IMAGE_TYPES :=
1108ADDRESS_SIZES_TARGET :=
1109ADDRESS_SIZES_HOST :=
1110ALL_ADDRESS_SIZES :=
1111RUN_TYPES :=
1112DEBUGGABLE_TYPES :=
1113
1114include $(LOCAL_PATH)/Android.libarttest.mk
1115include art/test/Android.libnativebridgetest.mk
1116