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