Android.run-test.mk revision 63fc30e201a74dbad9422a6dbd4c39e4b60ac4c5
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# Helper to create individual build targets for tests. Must be called with $(eval).
36# $(1): the test number
37define define-build-art-run-test
38  dmart_target := $(art_run_tests_dir)/art-run-tests/$(1)/touch
39$$(dmart_target): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger
40	$(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
41	$(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
42	  SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
43	  DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
44	  $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1)
45	$(hide) touch $$@
46
47  TEST_ART_RUN_TEST_BUILD_RULES += $$(dmart_target)
48  dmart_target :=
49endef
50$(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call define-build-art-run-test,$(test))))
51
52include $(CLEAR_VARS)
53LOCAL_MODULE_TAGS := tests
54LOCAL_MODULE := art-run-tests
55LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_BUILD_RULES)
56# The build system use this flag to pick up files generated by declare-make-art-run-test.
57LOCAL_PICKUP_FILES := $(art_run_tests_dir)
58
59include $(BUILD_PHONY_PACKAGE)
60
61# Clear temp vars.
62art_run_tests_dir :=
63define-build-art-run-test :=
64TEST_ART_RUN_TEST_BUILD_RULES :=
65
66########################################################################
67# General rules to build and run a run-test.
68
69TARGET_TYPES := host target
70PREBUILD_TYPES :=
71ifeq ($(ART_TEST_RUN_TEST_PREBUILD),true)
72  PREBUILD_TYPES += prebuild
73endif
74ifeq ($(ART_TEST_RUN_TEST_NO_PREBUILD),true)
75  PREBUILD_TYPES += no-prebuild
76endif
77ifeq ($(ART_TEST_RUN_TEST_NO_DEX2OAT),true)
78  PREBUILD_TYPES += no-dex2oat
79endif
80COMPILER_TYPES :=
81ifeq ($(ART_TEST_DEFAULT_COMPILER),true)
82  COMPILER_TYPES += default
83endif
84ifeq ($(ART_TEST_INTERPRETER),true)
85  COMPILER_TYPES += interpreter
86endif
87ifeq ($(ART_TEST_OPTIMIZING),true)
88  COMPILER_TYPES += optimizing
89endif
90RELOCATE_TYPES := relocate
91ifeq ($(ART_TEST_RUN_TEST_NO_RELOCATE),true)
92  RELOCATE_TYPES += no-relocate
93endif
94ifeq ($(ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT),true)
95  RELOCATE_TYPES := relocate-no-patchoat
96endif
97TRACE_TYPES := no-trace
98ifeq ($(ART_TEST_TRACE),true)
99  TRACE_TYPES += trace
100endif
101GC_TYPES := cms
102ifeq ($(ART_TEST_GC_STRESS),true)
103  GC_TYPES += gcstress
104endif
105ifeq ($(ART_TEST_GC_VERIFY),true)
106  GC_TYPES += gcverify
107endif
108JNI_TYPES := checkjni
109ifeq ($(ART_TEST_JNI_FORCECOPY),true)
110  JNI_TYPES += forcecopy
111endif
112IMAGE_TYPES := image
113ifeq ($(ART_TEST_RUN_TEST_NO_IMAGE),true)
114  IMAGE_TYPES += no-image
115endif
116RUN_TYPES :=
117ifeq ($(ART_TEST_RUN_TEST_DEBUG),true)
118  RUN_TYPES += debug
119endif
120ifeq ($(ART_TEST_RUN_TEST_NDEBUG),true)
121  RUN_TYPES += ndebug
122endif
123ADDRESS_SIZES_TARGET := $(ART_PHONY_TEST_TARGET_SUFFIX)
124ADDRESS_SIZES_HOST := $(ART_PHONY_TEST_HOST_SUFFIX)
125ifeq ($(ART_TEST_RUN_TEST_2ND_ARCH),true)
126  ADDRESS_SIZES_TARGET += $(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
127  ADDRESS_SIZES_HOST += $(2ND_ART_PHONY_TEST_HOST_SUFFIX)
128endif
129ALL_ADDRESS_SIZES := 64 32
130
131# List all run test names with number arguments agreeing with the comment above.
132define all-run-test-names
133  $(foreach target, $(1), \
134    $(foreach run-type, $(2), \
135      $(foreach prebuild, $(3), \
136        $(foreach compiler, $(4), \
137          $(foreach relocate, $(5), \
138            $(foreach trace, $(6), \
139              $(foreach gc, $(7), \
140                $(foreach jni, $(8), \
141                  $(foreach image, $(9), \
142                    $(foreach test, $(10), \
143                      $(foreach address_size, $(11), \
144                        test-art-$(target)-run-test-$(run-type)-$(prebuild)-$(compiler)-$(relocate)-$(trace)-$(gc)-$(jni)-$(image)-$(test)$(address_size) \
145                    )))))))))))
146endef  # all-run-test-names
147
148# To generate a full list or tests:
149# $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \
150#        $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
151#        $(TEST_ART_RUN_TESTS), $(ALL_ADDRESS_SIZES))
152
153# Convert's a rule name to the form used in variables, e.g. no-relocate to NO_RELOCATE
154define name-to-var
155$(shell echo $(1) | tr '[:lower:]' '[:upper:]' | tr '-' '_')
156endef  # name-to-var
157
158# Tests that are timing sensitive and flaky on heavily loaded systems.
159TEST_ART_TIMING_SENSITIVE_RUN_TESTS := \
160  053-wait-some \
161  055-enum-performance
162
163 # disable timing sensitive tests on "dist" builds.
164ifdef dist_goal
165  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
166        $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
167        $(IMAGE_TYPES), $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), $(ALL_ADDRESS_SIZES))
168endif
169
170TEST_ART_TIMING_SENSITIVE_RUN_TESTS :=
171
172TEST_ART_BROKEN_RUN_TESTS := \
173  004-ThreadStress
174
175ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
176      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
177      $(IMAGE_TYPES), $(TEST_ART_BROKEN_RUN_TESTS), $(ALL_ADDRESS_SIZES))
178
179TEST_ART_BROKEN_RUN_TESTS :=
180
181# Note 116-nodex2oat is not broken per-se it just doesn't (and isn't meant to) work with --prebuild.
182TEST_ART_BROKEN_PREBUILD_RUN_TESTS := \
183  116-nodex2oat
184
185ifneq (,$(filter prebuild,$(PREBUILD_TYPES)))
186  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),prebuild, \
187      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
188      $(IMAGE_TYPES), $(TEST_ART_BROKEN_PREBUILD_RUN_TESTS), $(ALL_ADDRESS_SIZES))
189endif
190
191TEST_ART_BROKEN_PREBUILD_RUN_TESTS :=
192
193TEST_ART_BROKEN_NO_PREBUILD_TESTS := \
194  117-nopatchoat
195
196ifneq (,$(filter no-prebuild,$(PREBUILD_TYPES)))
197  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),no-prebuild, \
198      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
199      $(IMAGE_TYPES), $(TEST_ART_BROKEN_NO_PREBUILD_TESTS), $(ALL_ADDRESS_SIZES))
200endif
201
202TEST_ART_BROKEN_NO_PREBUILD_TESTS :=
203
204# Note 117-nopatchoat is not broken per-se it just doesn't work (and isn't meant to) without
205# --prebuild --relocate
206TEST_ART_BROKEN_NO_RELOCATE_TESTS := \
207  117-nopatchoat
208
209ifneq (,$(filter no-relocate,$(RELOCATE_TYPES)))
210  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
211      $(COMPILER_TYPES), no-relocate,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
212      $(IMAGE_TYPES), $(TEST_ART_BROKEN_NO_RELOCATE_TESTS), $(ALL_ADDRESS_SIZES))
213endif
214
215TEST_ART_BROKEN_NO_RELOCATE_TESTS :=
216
217# Tests that are broken with GC stress.
218TEST_ART_BROKEN_GCSTRESS_RUN_TESTS := \
219  004-SignalTest \
220  114-ParallelGC
221
222ifneq (,$(filter gcstress,$(GC_TYPES)))
223  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
224      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),gcstress,$(JNI_TYPES), \
225      $(IMAGE_TYPES), $(TEST_ART_BROKEN_GCSTRESS_RUN_TESTS), $(ALL_ADDRESS_SIZES))
226endif
227
228TEST_ART_BROKEN_GCSTRESS_RUN_TESTS :=
229
230# 115-native-bridge setup is complicated. Need to implement it correctly for the target.
231ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(RUN_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \
232    $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES),115-native-bridge, \
233    $(ALL_ADDRESS_SIZES))
234
235# All these tests check that we have sane behavior if we don't have a patchoat or dex2oat.
236# Therefore we shouldn't run them in situations where we actually don't have these since they
237# explicitly test for them. These all also assume we have an image.
238TEST_ART_BROKEN_FALLBACK_RUN_TESTS := \
239  116-nodex2oat \
240  117-nopatchoat \
241  118-noimage-dex2oat \
242  119-noimage-patchoat
243
244ifneq (,$(filter no-dex2oat,$(PREBUILD_TYPES)))
245  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),no-dex2oat, \
246      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
247      $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
248endif
249
250
251ifneq (,$(filter no-image,$(IMAGE_TYPES)))
252  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
253      $(COMPILER_TYPES), $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),no-image, \
254      $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
255endif
256
257ifneq (,$(filter relocate-no-patchoat,$(RELOCATE_TYPES)))
258  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
259      $(COMPILER_TYPES), relocate-no-patchoat,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
260      $(IMAGE_TYPES),$(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
261endif
262
263TEST_ART_BROKEN_FALLBACK_RUN_TESTS :=
264
265# The following tests use libarttest.so, which is linked against libartd.so, so will
266# not work when libart.so is the one loaded.
267# TODO: Find a way to run these tests in ndebug mode.
268TEST_ART_BROKEN_NDEBUG_TESTS := \
269  004-JniTest \
270  004-ReferenceMap \
271  004-SignalTest \
272  004-StackWalk \
273  004-UnsafeTest \
274  115-native-bridge \
275  116-nodex2oat \
276  117-nopatchoat \
277  118-noimage-dex2oat \
278  119-noimage-patchoat \
279
280ifneq (,$(filter ndebug,$(RUN_TYPES)))
281  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),ndebug,$(PREBUILD_TYPES), \
282      $(COMPILER_TYPES), $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
283      $(TEST_ART_BROKEN_NDEBUG_TESTS),$(ALL_ADDRESS_SIZES))
284endif
285
286TEST_ART_BROKEN_NDEBUG_TESTS :=
287
288# Known broken tests for the default compiler (Quick).
289TEST_ART_BROKEN_DEFAULT_RUN_TESTS := \
290  412-new-array
291
292ifneq (,$(filter default,$(COMPILER_TYPES)))
293  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
294      default,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
295      $(IMAGE_TYPES),$(TEST_ART_BROKEN_DEFAULT_RUN_TESTS),$(ALL_ADDRESS_SIZES))
296endif
297
298TEST_ART_BROKEN_DEFAULT_RUN_TESTS :=
299
300# Known broken tests for the arm64 optimizing compiler backend.
301TEST_ART_BROKEN_OPTIMIZING_ARM64_RUN_TESTS := \
302  003-omnibus-opcodes \
303  006-args \
304  011-array-copy \
305  018-stack-overflow \
306  036-finalizer \
307  044-proxy \
308  070-nio-buffer \
309  072-precise-gc \
310  082-inline-execute \
311  083-compiler-regressions \
312  093-serialization \
313  096-array-copy-concurrent-gc \
314  100-reflect2 \
315  106-exceptions2 \
316  107-int-math2 \
317  121-modifiers \
318  122-npe \
319  123-compiler-regressions-mt \
320  405-optimizing-long-allocator \
321  407-arrays \
322  410-floats \
323  411-optimizing-arith \
324  412-new-array \
325  413-regalloc-regression \
326  414-optimizing-arith-sub \
327  415-optimizing-arith-neg \
328  417-optimizing-arith-div \
329  700-LoadArgRegs \
330  800-smali
331
332ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
333  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(RUN_TYPES),$(PREBUILD_TYPES), \
334      optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
335      $(IMAGE_TYPES),$(TEST_ART_BROKEN_OPTIMIZING_ARM64_RUN_TESTS),64)
336endif
337
338TEST_ART_BROKEN_OPTIMIZING_ARM64_RUN_TESTS :=
339
340
341# Clear variables ahead of appending to them when defining tests.
342$(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=))
343$(foreach target, $(TARGET_TYPES), \
344  $(foreach prebuild, $(PREBUILD_TYPES), \
345    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES :=)))
346$(foreach target, $(TARGET_TYPES), \
347  $(foreach compiler, $(COMPILER_TYPES), \
348    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES :=)))
349$(foreach target, $(TARGET_TYPES), \
350  $(foreach relocate, $(RELOCATE_TYPES), \
351    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES :=)))
352$(foreach target, $(TARGET_TYPES), \
353  $(foreach trace, $(TRACE_TYPES), \
354    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES :=)))
355$(foreach target, $(TARGET_TYPES), \
356  $(foreach gc, $(GC_TYPES), \
357    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES :=)))
358$(foreach target, $(TARGET_TYPES), \
359  $(foreach jni, $(JNI_TYPES), \
360    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=)))
361$(foreach target, $(TARGET_TYPES), \
362  $(foreach image, $(IMAGE_TYPES), \
363    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=)))
364$(foreach target, $(TARGET_TYPES), \
365  $(foreach test, $(TEST_ART_RUN_TESTS), \
366    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=)))
367$(foreach target, $(TARGET_TYPES), \
368  $(foreach address_size, $(ALL_ADDRESS_SIZES), \
369    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(address_size))_RULES :=)))
370$(foreach target, $(TARGET_TYPES), \
371  $(foreach run_type, $(RUN_TYPES), \
372    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(run_type))_RULES :=)))
373
374# We need dex2oat and dalvikvm on the target as well as the core images (all images as we sync
375# only once).
376TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_EXECUTABLES) $(TARGET_CORE_IMG_OUTS)
377
378# Also need libarttest.
379TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libarttest.so
380ifdef TARGET_2ND_ARCH
381TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libarttest.so
382endif
383
384# Also need libnativebridgetest.
385TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libnativebridgetest.so
386ifdef TARGET_2ND_ARCH
387TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libnativebridgetest.so
388endif
389
390# All tests require the host executables. The tests also depend on the core images, but on
391# specific version depending on the compiler.
392ART_TEST_HOST_RUN_TEST_DEPENDENCIES := \
393  $(ART_HOST_EXECUTABLES) \
394  $(ART_HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) \
395  $(ART_HOST_OUT_SHARED_LIBRARIES)/libnativebridgetest$(ART_HOST_SHLIB_EXTENSION) \
396  $(ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION)
397
398ifneq ($(HOST_PREFER_32_BIT),true)
399ART_TEST_HOST_RUN_TEST_DEPENDENCIES += \
400  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) \
401  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libnativebridgetest$(ART_HOST_SHLIB_EXTENSION) \
402  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION)
403endif
404
405# Create a rule to build and run a tests following the form:
406# test-art-{1: host or target}-run-test-{2: debug ndebug}-{3: prebuild no-prebuild no-dex2oat}-
407#    {4: interpreter default optimizing}-{5: relocate no-relocate relocate-no-patchoat}-
408#    {6: trace or no-trace}-{7: gcstress gcverify cms}-{8: forcecopy checkjni jni}-
409#    {9: no-image image}-{10: test name}{11: 32 or 64}
410define define-test-art-run-test
411  run_test_options :=
412  prereq_rule :=
413  test_groups :=
414  uc_host_or_target :=
415  ifeq ($(ART_TEST_RUN_TEST_ALWAYS_CLEAN),true)
416    run_test_options += --always-clean
417  endif
418  ifeq ($(1),host)
419    uc_host_or_target := HOST
420    test_groups := ART_RUN_TEST_HOST_RULES
421    run_test_options += --host
422    prereq_rule := $(ART_TEST_HOST_RUN_TEST_DEPENDENCIES)
423  else
424    ifeq ($(1),target)
425      uc_host_or_target := TARGET
426      test_groups := ART_RUN_TEST_TARGET_RULES
427      prereq_rule := test-art-target-sync
428    else
429      $$(error found $(1) expected $(TARGET_TYPES))
430    endif
431  endif
432  ifeq ($(2),debug)
433    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEBUG_RULES
434  else
435    ifeq ($(2),ndebug)
436      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELEASE_RULES
437      run_test_options += -O
438    else
439      $$(error found $(2) expected $(RUN_TYPES))
440    endif
441  endif
442  ifeq ($(3),prebuild)
443    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_PREBUILD_RULES
444    run_test_options += --prebuild
445  else
446    ifeq ($(3),no-prebuild)
447      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_PREBUILD_RULES
448      run_test_options += --no-prebuild
449    else
450      ifeq ($(3),no-dex2oat)
451        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_DEX2OAT_RULES
452        run_test_options += --no-prebuild --no-dex2oat
453      else
454        $$(error found $(3) expected $(PREBUILD_TYPES))
455      endif
456    endif
457  endif
458  ifeq ($(4),optimizing)
459    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_OPTIMIZING_RULES
460    run_test_options += --optimizing
461  else
462    ifeq ($(4),interpreter)
463      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_INTERPRETER_RULES
464      run_test_options += --interpreter
465    else
466      ifeq ($(4),default)
467        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEFAULT_RULES
468      else
469        $$(error found $(4) expected $(COMPILER_TYPES))
470      endif
471    endif
472  endif
473  # Add the core dependency.
474  ifeq ($(1),host)
475    prereq_rule += $(HOST_CORE_IMAGE_$(4)_$(11))
476  else
477    prereq_rule += $(TARGET_CORE_IMAGE_$(4)_$(11))
478  endif
479
480  ifeq ($(5),relocate)
481    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_RULES
482    run_test_options += --relocate
483  else
484    ifeq ($(5),no-relocate)
485      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_RELOCATE_RULES
486      run_test_options += --no-relocate
487    else
488      ifeq ($(5),relocate-no-patchoat)
489        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_NO_PATCHOAT_RULES
490        run_test_options += --relocate --no-patchoat
491      else
492        $$(error found $(5) expected $(RELOCATE_TYPES))
493      endif
494    endif
495  endif
496  ifeq ($(6),trace)
497    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_TRACE_RULES
498    run_test_options += --trace
499  else
500    ifeq ($(6),no-trace)
501      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_TRACE_RULES
502    else
503      $$(error found $(6) expected $(TRACE_TYPES))
504    endif
505  endif
506  ifeq ($(7),gcverify)
507    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_GCVERIFY_RULES
508    run_test_options += --gcverify
509  else
510    ifeq ($(7),gcstress)
511      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_GCSTRESS_RULES
512      run_test_options += --gcstress
513    else
514      ifeq ($(7),cms)
515        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_CMS_RULES
516      else
517        $$(error found $(7) expected $(GC_TYPES))
518      endif
519    endif
520  endif
521  ifeq ($(8),forcecopy)
522    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_FORCECOPY_RULES
523    run_test_options += --runtime-option -Xjniopts:forcecopy
524    ifneq ($$(ART_TEST_JNI_FORCECOPY),true)
525      skip_test := true
526    endif
527  else
528    ifeq ($(8),checkjni)
529      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_CHECKJNI_RULES
530      run_test_options += --runtime-option -Xcheck:jni
531    else
532      ifeq ($(8),jni)
533        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_JNI_RULES
534      else
535        $$(error found $(8) expected $(JNI_TYPES))
536      endif
537    endif
538  endif
539  ifeq ($(9),no-image)
540    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_IMAGE_RULES
541    run_test_options += --no-image
542  else
543    ifeq ($(9),image)
544      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_IMAGE_RULES
545    else
546      $$(error found $(9) expected $(IMAGE_TYPES))
547    endif
548  endif
549  # $(10) is the test name
550  test_groups += ART_RUN_TEST_$$(uc_host_or_target)_$(call name-to-var,$(10))_RULES
551  ifeq ($(11),64)
552    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_64_RULES
553    run_test_options += --64
554  else
555    ifeq ($(11),32)
556      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_32_RULES
557    else
558      $$(error found $(11) expected $(ALL_ADDRESS_SIZES))
559    endif
560  endif
561  run_test_rule_name := test-art-$(1)-run-test-$(2)-$(3)-$(4)-$(5)-$(6)-$(7)-$(8)-$(9)-$(10)$(11)
562  run_test_options := --output-path $(ART_HOST_TEST_DIR)/run-test-output/$$(run_test_rule_name) \
563      $$(run_test_options)
564$$(run_test_rule_name): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options)
565.PHONY: $$(run_test_rule_name)
566$$(run_test_rule_name): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger $$(prereq_rule)
567	$(hide) $$(call ART_TEST_SKIP,$$@) && \
568	  DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
569	    SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
570	    DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
571	    art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(10) \
572	      && $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@)
573	$$(hide) (echo $(MAKECMDGOALS) | grep -q $$@ && \
574	  echo "run-test run as top-level target, removing test directory $(ART_HOST_TEST_DIR)" && \
575	  rm -r $(ART_HOST_TEST_DIR)) || true
576
577  $$(foreach test_group,$$(test_groups), $$(eval $$(value test_group) += $$(run_test_rule_name)))
578
579  # Clear locally defined variables.
580  uc_host_or_target :=
581  test_groups :=
582  run_test_options :=
583  run_test_rule_name :=
584  prereq_rule :=
585endef  # define-test-art-run-test
586
587$(foreach target, $(TARGET_TYPES), \
588  $(foreach test, $(TEST_ART_RUN_TESTS), \
589    $(foreach run_type, $(RUN_TYPES), \
590      $(foreach address_size, $(ADDRESS_SIZES_$(call name-to-var,$(target))), \
591        $(foreach prebuild, $(PREBUILD_TYPES), \
592          $(foreach compiler, $(COMPILER_TYPES), \
593            $(foreach relocate, $(RELOCATE_TYPES), \
594              $(foreach trace, $(TRACE_TYPES), \
595                $(foreach gc, $(GC_TYPES), \
596                  $(foreach jni, $(JNI_TYPES), \
597                    $(foreach image, $(IMAGE_TYPES), \
598                      $(eval $(call define-test-art-run-test,$(target),$(run_type),$(prebuild),$(compiler),$(relocate),$(trace),$(gc),$(jni),$(image),$(test),$(address_size))) \
599                  )))))))))))
600define-test-art-run-test :=
601
602# Define a phony rule whose purpose is to test its prerequisites.
603# $(1): host or target
604# $(2): list of prerequisites
605define define-test-art-run-test-group
606.PHONY: $(1)
607$(1): $(2)
608	$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
609
610endef  # define-test-art-run-test-group
611
612
613$(foreach target, $(TARGET_TYPES), $(eval \
614  $(call define-test-art-run-test-group,test-art-$(target)-run-test,$(ART_RUN_TEST_$(call name-to-var,$(target))_RULES))))
615$(foreach target, $(TARGET_TYPES), \
616  $(foreach prebuild, $(PREBUILD_TYPES), $(eval \
617    $(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)))))
618$(foreach target, $(TARGET_TYPES), \
619  $(foreach run-type, $(RUN_TYPES), $(eval \
620    $(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)))))
621$(foreach target, $(TARGET_TYPES), \
622  $(foreach compiler, $(COMPILER_TYPES), $(eval \
623    $(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)))))
624$(foreach target, $(TARGET_TYPES), \
625  $(foreach relocate, $(RELOCATE_TYPES), $(eval \
626    $(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)))))
627$(foreach target, $(TARGET_TYPES), \
628  $(foreach trace, $(TRACE_TYPES), $(eval \
629    $(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)))))
630$(foreach target, $(TARGET_TYPES), \
631  $(foreach gc, $(GC_TYPES), $(eval \
632    $(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)))))
633$(foreach target, $(TARGET_TYPES), \
634  $(foreach jni, $(JNI_TYPES), $(eval \
635    $(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)))))
636$(foreach target, $(TARGET_TYPES), \
637  $(foreach image, $(IMAGE_TYPES), $(eval \
638    $(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)))))
639$(foreach target, $(TARGET_TYPES), \
640  $(foreach test, $(TEST_ART_RUN_TESTS), $(eval \
641    $(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)))))
642$(foreach target, $(TARGET_TYPES), \
643  $(foreach address_size, $(ADDRESS_SIZES_$(call name-to-var,$(target))), $(eval \
644    $(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)))))
645
646# Clear variables now we're finished with them.
647$(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=))
648$(foreach target, $(TARGET_TYPES), \
649  $(foreach prebuild, $(PREBUILD_TYPES), \
650    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES :=)))
651$(foreach target, $(TARGET_TYPES), \
652  $(foreach compiler, $(COMPILER_TYPES), \
653    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES :=)))
654$(foreach target, $(TARGET_TYPES), \
655  $(foreach relocate, $(RELOCATE_TYPES), \
656    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES :=)))
657$(foreach target, $(TARGET_TYPES), \
658  $(foreach trace, $(TRACE_TYPES), \
659    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES :=)))
660$(foreach target, $(TARGET_TYPES), \
661  $(foreach gc, $(GC_TYPES), \
662    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES :=)))
663$(foreach target, $(TARGET_TYPES), \
664  $(foreach jni, $(JNI_TYPES), \
665    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=)))
666$(foreach target, $(TARGET_TYPES), \
667  $(foreach image, $(IMAGE_TYPES), \
668    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=)))
669$(foreach target, $(TARGET_TYPES), \
670  $(foreach test, $(TEST_ART_RUN_TESTS), \
671    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=)))
672$(foreach target, $(TARGET_TYPES), \
673  $(foreach address_size, $(ALL_ADDRESS_SIZES), \
674    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(address_size))_RULES :=)))
675$(foreach target, $(TARGET_TYPES), \
676  $(foreach run_type, $(RUN_TYPES), \
677    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(run_type))_RULES :=)))
678define-test-art-run-test-group :=
679TARGET_TYPES :=
680PREBUILD_TYPES :=
681COMPILER_TYPES :=
682RELOCATE_TYPES :=
683TRACE_TYPES :=
684GC_TYPES :=
685JNI_TYPES :=
686IMAGE_TYPES :=
687ADDRESS_SIZES_TARGET :=
688ADDRESS_SIZES_HOST :=
689ALL_ADDRESS_SIZES :=
690RUN_TYPES :=
691
692include $(LOCAL_PATH)/Android.libarttest.mk
693include art/test/Android.libnativebridgetest.mk
694