Android.run-test.mk revision 53c42b68e5264012e9b16f9584cc1f3a58bc14fc
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
116ifeq ($(ART_TEST_PIC_IMAGE),true)
117  IMAGE_TYPES += picimage
118endif
119PICTEST_TYPES := nopictest
120ifeq ($(ART_TEST_PIC_TEST),true)
121  PICTEST_TYPES += pictest
122endif
123RUN_TYPES :=
124ifeq ($(ART_TEST_RUN_TEST_DEBUG),true)
125  RUN_TYPES += debug
126endif
127ifeq ($(ART_TEST_RUN_TEST_NDEBUG),true)
128  RUN_TYPES += ndebug
129endif
130ADDRESS_SIZES_TARGET := $(ART_PHONY_TEST_TARGET_SUFFIX)
131ADDRESS_SIZES_HOST := $(ART_PHONY_TEST_HOST_SUFFIX)
132ifeq ($(ART_TEST_RUN_TEST_2ND_ARCH),true)
133  ADDRESS_SIZES_TARGET += $(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
134  ADDRESS_SIZES_HOST += $(2ND_ART_PHONY_TEST_HOST_SUFFIX)
135endif
136ALL_ADDRESS_SIZES := 64 32
137
138# List all run test names with number arguments agreeing with the comment above.
139define all-run-test-names
140  $(foreach target, $(1), \
141    $(foreach run-type, $(2), \
142      $(foreach prebuild, $(3), \
143        $(foreach compiler, $(4), \
144          $(foreach relocate, $(5), \
145            $(foreach trace, $(6), \
146              $(foreach gc, $(7), \
147                $(foreach jni, $(8), \
148                  $(foreach image, $(9), \
149                    $(foreach pictest, $(10), \
150                      $(foreach test, $(11), \
151                        $(foreach address_size, $(12), \
152                          test-art-$(target)-run-test-$(run-type)-$(prebuild)-$(compiler)-$(relocate)-$(trace)-$(gc)-$(jni)-$(image)-$(pictest)-$(test)$(address_size) \
153                    ))))))))))))
154endef  # all-run-test-names
155
156# To generate a full list or tests:
157# $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \
158#        $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
159#        $(TEST_ART_RUN_TESTS), $(ALL_ADDRESS_SIZES))
160
161# Convert's a rule name to the form used in variables, e.g. no-relocate to NO_RELOCATE
162define name-to-var
163$(shell echo $(1) | tr '[:lower:]' '[:upper:]' | tr '-' '_')
164endef  # name-to-var
165
166# Tests that are timing sensitive and flaky on heavily loaded systems.
167TEST_ART_TIMING_SENSITIVE_RUN_TESTS := \
168  053-wait-some \
169  055-enum-performance
170
171 # disable timing sensitive tests on "dist" builds.
172ifdef dist_goal
173  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
174        $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
175        $(IMAGE_TYPES), $(PICTEST_TYPES), $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), $(ALL_ADDRESS_SIZES))
176endif
177
178TEST_ART_TIMING_SENSITIVE_RUN_TESTS :=
179
180TEST_ART_BROKEN_RUN_TESTS := \
181  004-ThreadStress
182
183ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
184      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
185      $(IMAGE_TYPES), $(PICTEST_TYPES), $(TEST_ART_BROKEN_RUN_TESTS), $(ALL_ADDRESS_SIZES))
186
187TEST_ART_BROKEN_RUN_TESTS :=
188
189# Note 116-nodex2oat is not broken per-se it just doesn't (and isn't meant to) work with --prebuild.
190TEST_ART_BROKEN_PREBUILD_RUN_TESTS := \
191  116-nodex2oat
192
193ifneq (,$(filter prebuild,$(PREBUILD_TYPES)))
194  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),prebuild, \
195      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
196      $(IMAGE_TYPES), $(PICTEST_TYPES), $(TEST_ART_BROKEN_PREBUILD_RUN_TESTS), $(ALL_ADDRESS_SIZES))
197endif
198
199TEST_ART_BROKEN_PREBUILD_RUN_TESTS :=
200
201TEST_ART_BROKEN_NO_PREBUILD_TESTS := \
202  117-nopatchoat
203
204ifneq (,$(filter no-prebuild,$(PREBUILD_TYPES)))
205  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),no-prebuild, \
206      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
207      $(IMAGE_TYPES), $(PICTEST_TYPES), $(TEST_ART_BROKEN_NO_PREBUILD_TESTS), $(ALL_ADDRESS_SIZES))
208endif
209
210TEST_ART_BROKEN_NO_PREBUILD_TESTS :=
211
212# Note 117-nopatchoat is not broken per-se it just doesn't work (and isn't meant to) without
213# --prebuild --relocate
214TEST_ART_BROKEN_NO_RELOCATE_TESTS := \
215  117-nopatchoat
216
217ifneq (,$(filter no-relocate,$(RELOCATE_TYPES)))
218  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
219      $(COMPILER_TYPES), no-relocate,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
220      $(IMAGE_TYPES), $(PICTEST_TYPES), $(TEST_ART_BROKEN_NO_RELOCATE_TESTS), $(ALL_ADDRESS_SIZES))
221endif
222
223TEST_ART_BROKEN_NO_RELOCATE_TESTS :=
224
225# Tests that are broken with GC stress.
226TEST_ART_BROKEN_GCSTRESS_RUN_TESTS := \
227  004-SignalTest \
228  114-ParallelGC
229
230ifneq (,$(filter gcstress,$(GC_TYPES)))
231  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
232      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),gcstress,$(JNI_TYPES), \
233      $(IMAGE_TYPES), $(PICTEST_TYPES), $(TEST_ART_BROKEN_GCSTRESS_RUN_TESTS), $(ALL_ADDRESS_SIZES))
234endif
235
236TEST_ART_BROKEN_GCSTRESS_RUN_TESTS :=
237
238# 115-native-bridge setup is complicated. Need to implement it correctly for the target.
239ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(RUN_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \
240    $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES),$(PICTEST_TYPES),115-native-bridge, \
241    $(ALL_ADDRESS_SIZES))
242
243# All these tests check that we have sane behavior if we don't have a patchoat or dex2oat.
244# Therefore we shouldn't run them in situations where we actually don't have these since they
245# explicitly test for them. These all also assume we have an image.
246TEST_ART_BROKEN_FALLBACK_RUN_TESTS := \
247  116-nodex2oat \
248  117-nopatchoat \
249  118-noimage-dex2oat \
250  119-noimage-patchoat
251
252ifneq (,$(filter no-dex2oat,$(PREBUILD_TYPES)))
253  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),no-dex2oat, \
254      $(COMPILER_TYPES),$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
255      $(PICTEST_TYPES),$(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
256endif
257
258
259ifneq (,$(filter no-image,$(IMAGE_TYPES)))
260  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
261      $(COMPILER_TYPES), $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),no-image, \
262      $(PICTEST_TYPES), $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
263endif
264
265ifneq (,$(filter relocate-no-patchoat,$(RELOCATE_TYPES)))
266  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
267      $(COMPILER_TYPES), relocate-no-patchoat,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
268      $(IMAGE_TYPES),$(PICTEST_TYPES),$(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES))
269endif
270
271TEST_ART_BROKEN_FALLBACK_RUN_TESTS :=
272
273# The following tests use libarttest.so, which is linked against libartd.so, so will
274# not work when libart.so is the one loaded.
275# TODO: Find a way to run these tests in ndebug mode.
276TEST_ART_BROKEN_NDEBUG_TESTS := \
277  004-JniTest \
278  004-ReferenceMap \
279  004-SignalTest \
280  004-StackWalk \
281  004-UnsafeTest \
282  115-native-bridge \
283  116-nodex2oat \
284  117-nopatchoat \
285  118-noimage-dex2oat \
286  119-noimage-patchoat \
287
288ifneq (,$(filter ndebug,$(RUN_TYPES)))
289  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),ndebug,$(PREBUILD_TYPES), \
290      $(COMPILER_TYPES), $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \
291      $(PICTEST_TYPES),$(TEST_ART_BROKEN_NDEBUG_TESTS),$(ALL_ADDRESS_SIZES))
292endif
293
294TEST_ART_BROKEN_NDEBUG_TESTS :=
295
296# Known broken tests for the default compiler (Quick).
297TEST_ART_BROKEN_DEFAULT_RUN_TESTS := \
298  412-new-array
299
300ifneq (,$(filter default,$(COMPILER_TYPES)))
301  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
302      default,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
303      $(IMAGE_TYPES),$(PICTEST_TYPES),$(TEST_ART_BROKEN_DEFAULT_RUN_TESTS),$(ALL_ADDRESS_SIZES))
304endif
305
306TEST_ART_BROKEN_DEFAULT_RUN_TESTS :=
307
308# Known broken tests for the arm64 optimizing compiler backend.
309TEST_ART_BROKEN_OPTIMIZING_ARM64_RUN_TESTS := \
310  001-HelloWorld \
311  003-omnibus-opcodes \
312  004-InterfaceTest \
313  004-JniTest \
314  004-StackWalk \
315  006-args \
316  007-count10 \
317  011-array-copy \
318  013-math2 \
319  016-intern \
320  017-float \
321  018-stack-overflow \
322  020-string \
323  022-interface \
324  023-many-interfaces \
325  026-access \
326  028-array-write \
327  030-bad-finalizer \
328  031-class-attributes \
329  032-concrete-sub \
330  036-finalizer \
331  037-inherit \
332  038-inner-null \
333  043-privates \
334  044-proxy \
335  045-reflect-array \
336  046-reflect \
337  047-returns \
338  049-show-object \
339  050-sync-test \
340  051-thread \
341  052-verifier-fun \
342  054-uncaught \
343  056-const-string-jumbo \
344  061-out-of-memory \
345  063-process-manager \
346  067-preemptive-unpark \
347  068-classloader \
348  069-field-type \
349  070-nio-buffer \
350  071-dexfile \
351  072-precise-gc \
352  074-gc-thrash \
353  076-boolean-put \
354  077-method-override \
355  079-phantom \
356  080-oom-throw \
357  082-inline-execute \
358  083-compiler-regressions \
359  084-class-init \
360  085-old-style-inner-class \
361  086-null-super \
362  087-gc-after-link \
363  090-loop-formation \
364  092-locale \
365  093-serialization \
366  094-pattern \
367  096-array-copy-concurrent-gc \
368  097-duplicate-method \
369  098-ddmc \
370  100-reflect2 \
371  102-concurrent-gc \
372  103-string-append \
373  105-invoke \
374  106-exceptions2 \
375  107-int-math2 \
376  109-suspend-check \
377  110-field-access \
378  112-double-math \
379  113-multidex \
380  117-nopatchoat \
381  121-modifiers \
382  122-npe \
383  123-compiler-regressions-mt \
384  124-missing-classes \
385  125-gc-and-classloading \
386  300-package-override \
387  301-abstract-protected \
388  303-verification-stress \
389  401-optimizing-compiler \
390  403-optimizing-long \
391  405-optimizing-long-allocator \
392  406-fields \
393  407-arrays \
394  409-materialized-condition \
395  410-floats \
396  411-optimizing-arith \
397  412-new-array \
398  413-regalloc-regression \
399  414-optimizing-arith-sub \
400  414-static-fields \
401  415-optimizing-arith-neg \
402  416-optimizing-arith-not \
403  417-optimizing-arith-div \
404  418-const-string \
405  419-long-parameter \
406  700-LoadArgRegs \
407  701-easy-div-rem \
408  702-LargeBranchOffset \
409  800-smali
410
411ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
412  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(RUN_TYPES),$(PREBUILD_TYPES), \
413      optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
414      $(IMAGE_TYPES),$(PICTEST_TYPES),$(TEST_ART_BROKEN_OPTIMIZING_ARM64_RUN_TESTS),64)
415endif
416
417TEST_ART_BROKEN_OPTIMIZING_ARM64_RUN_TESTS :=
418
419# Known broken tests for the optimizing compiler.
420TEST_ART_BROKEN_OPTIMIZING_RUN_TESTS := \
421  099-vmdebug \ # b/18098594
422
423ifneq (,$(filter optimizing,$(COMPILER_TYPES)))
424  ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
425      optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
426      $(IMAGE_TYPES),$(PICTEST_TYPES),$(TEST_ART_BROKEN_OPTIMIZING_RUN_TESTS),$(ALL_ADDRESS_SIZES))
427endif
428
429TEST_ART_BROKEN_OPTIMIZING_RUN_TESTS :=
430
431
432# Clear variables ahead of appending to them when defining tests.
433$(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=))
434$(foreach target, $(TARGET_TYPES), \
435  $(foreach prebuild, $(PREBUILD_TYPES), \
436    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES :=)))
437$(foreach target, $(TARGET_TYPES), \
438  $(foreach compiler, $(COMPILER_TYPES), \
439    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES :=)))
440$(foreach target, $(TARGET_TYPES), \
441  $(foreach relocate, $(RELOCATE_TYPES), \
442    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES :=)))
443$(foreach target, $(TARGET_TYPES), \
444  $(foreach trace, $(TRACE_TYPES), \
445    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES :=)))
446$(foreach target, $(TARGET_TYPES), \
447  $(foreach gc, $(GC_TYPES), \
448    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES :=)))
449$(foreach target, $(TARGET_TYPES), \
450  $(foreach jni, $(JNI_TYPES), \
451    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=)))
452$(foreach target, $(TARGET_TYPES), \
453  $(foreach image, $(IMAGE_TYPES), \
454    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=)))
455$(foreach target, $(TARGET_TYPES), \
456  $(foreach test, $(TEST_ART_RUN_TESTS), \
457    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=)))
458$(foreach target, $(TARGET_TYPES), \
459  $(foreach address_size, $(ALL_ADDRESS_SIZES), \
460    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(address_size))_RULES :=)))
461$(foreach target, $(TARGET_TYPES), \
462  $(foreach run_type, $(RUN_TYPES), \
463    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(run_type))_RULES :=)))
464
465# We need dex2oat and dalvikvm on the target as well as the core images (all images as we sync
466# only once).
467TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_EXECUTABLES) $(TARGET_CORE_IMG_OUTS)
468
469# Also need libarttest.
470TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libarttest.so
471ifdef TARGET_2ND_ARCH
472TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libarttest.so
473endif
474
475# Also need libnativebridgetest.
476TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libnativebridgetest.so
477ifdef TARGET_2ND_ARCH
478TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libnativebridgetest.so
479endif
480
481# All tests require the host executables. The tests also depend on the core images, but on
482# specific version depending on the compiler.
483ART_TEST_HOST_RUN_TEST_DEPENDENCIES := \
484  $(ART_HOST_EXECUTABLES) \
485  $(ART_HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) \
486  $(ART_HOST_OUT_SHARED_LIBRARIES)/libnativebridgetest$(ART_HOST_SHLIB_EXTENSION) \
487  $(ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION)
488
489ifneq ($(HOST_PREFER_32_BIT),true)
490ART_TEST_HOST_RUN_TEST_DEPENDENCIES += \
491  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) \
492  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libnativebridgetest$(ART_HOST_SHLIB_EXTENSION) \
493  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION)
494endif
495
496# Create a rule to build and run a tests following the form:
497# test-art-{1: host or target}-run-test-{2: debug ndebug}-{3: prebuild no-prebuild no-dex2oat}-
498#    {4: interpreter default optimizing}-{5: relocate no-relocate relocate-no-patchoat}-
499#    {6: trace or no-trace}-{7: gcstress gcverify cms}-{8: forcecopy checkjni jni}-
500#    {9: no-image image picimage}-{10: pictest nopictest}-{11: test name}{12: 32 or 64}
501define define-test-art-run-test
502  run_test_options :=
503  prereq_rule :=
504  test_groups :=
505  uc_host_or_target :=
506  ifeq ($(ART_TEST_RUN_TEST_ALWAYS_CLEAN),true)
507    run_test_options += --always-clean
508  endif
509  ifeq ($(1),host)
510    uc_host_or_target := HOST
511    test_groups := ART_RUN_TEST_HOST_RULES
512    run_test_options += --host
513    prereq_rule := $(ART_TEST_HOST_RUN_TEST_DEPENDENCIES)
514  else
515    ifeq ($(1),target)
516      uc_host_or_target := TARGET
517      test_groups := ART_RUN_TEST_TARGET_RULES
518      prereq_rule := test-art-target-sync
519    else
520      $$(error found $(1) expected $(TARGET_TYPES))
521    endif
522  endif
523  ifeq ($(2),debug)
524    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEBUG_RULES
525  else
526    ifeq ($(2),ndebug)
527      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELEASE_RULES
528      run_test_options += -O
529    else
530      $$(error found $(2) expected $(RUN_TYPES))
531    endif
532  endif
533  ifeq ($(3),prebuild)
534    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_PREBUILD_RULES
535    run_test_options += --prebuild
536  else
537    ifeq ($(3),no-prebuild)
538      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_PREBUILD_RULES
539      run_test_options += --no-prebuild
540    else
541      ifeq ($(3),no-dex2oat)
542        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_DEX2OAT_RULES
543        run_test_options += --no-prebuild --no-dex2oat
544      else
545        $$(error found $(3) expected $(PREBUILD_TYPES))
546      endif
547    endif
548  endif
549  ifeq ($(4),optimizing)
550    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_OPTIMIZING_RULES
551    run_test_options += --optimizing
552  else
553    ifeq ($(4),interpreter)
554      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_INTERPRETER_RULES
555      run_test_options += --interpreter
556    else
557      ifeq ($(4),default)
558        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEFAULT_RULES
559      else
560        $$(error found $(4) expected $(COMPILER_TYPES))
561      endif
562    endif
563  endif
564
565  ifeq ($(5),relocate)
566    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_RULES
567    run_test_options += --relocate
568  else
569    ifeq ($(5),no-relocate)
570      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_RELOCATE_RULES
571      run_test_options += --no-relocate
572    else
573      ifeq ($(5),relocate-no-patchoat)
574        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_NO_PATCHOAT_RULES
575        run_test_options += --relocate --no-patchoat
576      else
577        $$(error found $(5) expected $(RELOCATE_TYPES))
578      endif
579    endif
580  endif
581  ifeq ($(6),trace)
582    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_TRACE_RULES
583    run_test_options += --trace
584  else
585    ifeq ($(6),no-trace)
586      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_TRACE_RULES
587    else
588      $$(error found $(6) expected $(TRACE_TYPES))
589    endif
590  endif
591  ifeq ($(7),gcverify)
592    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_GCVERIFY_RULES
593    run_test_options += --gcverify
594  else
595    ifeq ($(7),gcstress)
596      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_GCSTRESS_RULES
597      run_test_options += --gcstress
598    else
599      ifeq ($(7),cms)
600        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_CMS_RULES
601      else
602        $$(error found $(7) expected $(GC_TYPES))
603      endif
604    endif
605  endif
606  ifeq ($(8),forcecopy)
607    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_FORCECOPY_RULES
608    run_test_options += --runtime-option -Xjniopts:forcecopy
609    ifneq ($$(ART_TEST_JNI_FORCECOPY),true)
610      skip_test := true
611    endif
612  else
613    ifeq ($(8),checkjni)
614      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_CHECKJNI_RULES
615      run_test_options += --runtime-option -Xcheck:jni
616    else
617      ifeq ($(8),jni)
618        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_JNI_RULES
619      else
620        $$(error found $(8) expected $(JNI_TYPES))
621      endif
622    endif
623  endif
624  ifeq ($(9),no-image)
625    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_IMAGE_RULES
626    run_test_options += --no-image
627    # Add the core dependency. This is required for pre-building.
628    ifeq ($(1),host)
629      prereq_rule += $(HOST_CORE_IMAGE_$(4)_no-pic_$(12))
630    else
631      prereq_rule += $(TARGET_CORE_IMAGE_$(4)_no-pic_$(12))
632    endif
633  else
634    ifeq ($(9),image)
635      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_IMAGE_RULES
636      # Add the core dependency.
637      ifeq ($(1),host)
638        prereq_rule += $(HOST_CORE_IMAGE_$(4)_no-pic_$(12))
639      else
640        prereq_rule += $(TARGET_CORE_IMAGE_$(4)_no-pic_$(12))
641      endif
642    else
643      ifeq ($(9),picimage)
644        test_groups += ART_RUN_TEST_$$(uc_host_or_target)_PICIMAGE_RULES
645        run_test_options += --pic-image
646        ifeq ($(1),host)
647          prereq_rule += $(HOST_CORE_IMAGE_$(4)_pic_$(12))
648        else
649          prereq_rule += $(TARGET_CORE_IMAGE_$(4)_pic_$(12))
650        endif
651      else
652        $$(error found $(9) expected $(IMAGE_TYPES))
653      endif
654    endif
655  endif
656  ifeq ($(10),pictest)
657    run_test_options += --pic-test
658  else
659    ifeq ($(10),nopictest)
660      # Nothing to be done.
661    else
662      $$(error found $(10) expected $(PICTEST_TYPES))
663    endif
664  endif
665  # $(11) is the test name
666  test_groups += ART_RUN_TEST_$$(uc_host_or_target)_$(call name-to-var,$(11))_RULES
667  ifeq ($(12),64)
668    test_groups += ART_RUN_TEST_$$(uc_host_or_target)_64_RULES
669    run_test_options += --64
670  else
671    ifeq ($(12),32)
672      test_groups += ART_RUN_TEST_$$(uc_host_or_target)_32_RULES
673    else
674      $$(error found $(12) expected $(ALL_ADDRESS_SIZES))
675    endif
676  endif
677  run_test_rule_name := test-art-$(1)-run-test-$(2)-$(3)-$(4)-$(5)-$(6)-$(7)-$(8)-$(9)-$(10)-$(11)$(12)
678  run_test_options := --output-path $(ART_HOST_TEST_DIR)/run-test-output/$$(run_test_rule_name) \
679      $$(run_test_options)
680  ifneq ($(ART_TEST_ANDROID_ROOT),)
681    run_test_options := --android-root $(ART_TEST_ANDROID_ROOT) $$(run_test_options)
682  endif
683$$(run_test_rule_name): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options)
684.PHONY: $$(run_test_rule_name)
685$$(run_test_rule_name): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger $$(prereq_rule)
686	$(hide) $$(call ART_TEST_SKIP,$$@) && \
687	  DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
688	    SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
689	    DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
690	    art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(11) \
691	      && $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@)
692	$$(hide) (echo $(MAKECMDGOALS) | grep -q $$@ && \
693	  echo "run-test run as top-level target, removing test directory $(ART_HOST_TEST_DIR)" && \
694	  rm -r $(ART_HOST_TEST_DIR)) || true
695
696  $$(foreach test_group,$$(test_groups), $$(eval $$(value test_group) += $$(run_test_rule_name)))
697
698  # Clear locally defined variables.
699  uc_host_or_target :=
700  test_groups :=
701  run_test_options :=
702  run_test_rule_name :=
703  prereq_rule :=
704endef  # define-test-art-run-test
705
706$(foreach target, $(TARGET_TYPES), \
707  $(foreach test, $(TEST_ART_RUN_TESTS), \
708    $(foreach run_type, $(RUN_TYPES), \
709      $(foreach address_size, $(ADDRESS_SIZES_$(call name-to-var,$(target))), \
710        $(foreach prebuild, $(PREBUILD_TYPES), \
711          $(foreach compiler, $(COMPILER_TYPES), \
712            $(foreach relocate, $(RELOCATE_TYPES), \
713              $(foreach trace, $(TRACE_TYPES), \
714                $(foreach gc, $(GC_TYPES), \
715                  $(foreach jni, $(JNI_TYPES), \
716                    $(foreach image, $(IMAGE_TYPES), \
717                      $(foreach pictest, $(PICTEST_TYPES), \
718                        $(eval $(call define-test-art-run-test,$(target),$(run_type),$(prebuild),$(compiler),$(relocate),$(trace),$(gc),$(jni),$(image),$(pictest),$(test),$(address_size))) \
719                  ))))))))))))
720define-test-art-run-test :=
721
722# Define a phony rule whose purpose is to test its prerequisites.
723# $(1): host or target
724# $(2): list of prerequisites
725define define-test-art-run-test-group
726.PHONY: $(1)
727$(1): $(2)
728	$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
729
730endef  # define-test-art-run-test-group
731
732
733$(foreach target, $(TARGET_TYPES), $(eval \
734  $(call define-test-art-run-test-group,test-art-$(target)-run-test,$(ART_RUN_TEST_$(call name-to-var,$(target))_RULES))))
735$(foreach target, $(TARGET_TYPES), \
736  $(foreach prebuild, $(PREBUILD_TYPES), $(eval \
737    $(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)))))
738$(foreach target, $(TARGET_TYPES), \
739  $(foreach run-type, $(RUN_TYPES), $(eval \
740    $(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)))))
741$(foreach target, $(TARGET_TYPES), \
742  $(foreach compiler, $(COMPILER_TYPES), $(eval \
743    $(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)))))
744$(foreach target, $(TARGET_TYPES), \
745  $(foreach relocate, $(RELOCATE_TYPES), $(eval \
746    $(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)))))
747$(foreach target, $(TARGET_TYPES), \
748  $(foreach trace, $(TRACE_TYPES), $(eval \
749    $(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)))))
750$(foreach target, $(TARGET_TYPES), \
751  $(foreach gc, $(GC_TYPES), $(eval \
752    $(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)))))
753$(foreach target, $(TARGET_TYPES), \
754  $(foreach jni, $(JNI_TYPES), $(eval \
755    $(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)))))
756$(foreach target, $(TARGET_TYPES), \
757  $(foreach image, $(IMAGE_TYPES), $(eval \
758    $(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)))))
759$(foreach target, $(TARGET_TYPES), \
760  $(foreach test, $(TEST_ART_RUN_TESTS), $(eval \
761    $(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)))))
762$(foreach target, $(TARGET_TYPES), \
763  $(foreach address_size, $(ADDRESS_SIZES_$(call name-to-var,$(target))), $(eval \
764    $(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)))))
765
766# Clear variables now we're finished with them.
767$(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=))
768$(foreach target, $(TARGET_TYPES), \
769  $(foreach prebuild, $(PREBUILD_TYPES), \
770    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(prebuild))_RULES :=)))
771$(foreach target, $(TARGET_TYPES), \
772  $(foreach compiler, $(COMPILER_TYPES), \
773    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(compiler))_RULES :=)))
774$(foreach target, $(TARGET_TYPES), \
775  $(foreach relocate, $(RELOCATE_TYPES), \
776    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(relocate))_RULES :=)))
777$(foreach target, $(TARGET_TYPES), \
778  $(foreach trace, $(TRACE_TYPES), \
779    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(trace))_RULES :=)))
780$(foreach target, $(TARGET_TYPES), \
781  $(foreach gc, $(GC_TYPES), \
782    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(gc))_RULES :=)))
783$(foreach target, $(TARGET_TYPES), \
784  $(foreach jni, $(JNI_TYPES), \
785    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=)))
786$(foreach target, $(TARGET_TYPES), \
787  $(foreach image, $(IMAGE_TYPES), \
788    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=)))
789$(foreach target, $(TARGET_TYPES), \
790  $(foreach test, $(TEST_ART_RUN_TESTS), \
791    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=)))
792$(foreach target, $(TARGET_TYPES), \
793  $(foreach address_size, $(ALL_ADDRESS_SIZES), \
794    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(address_size))_RULES :=)))
795$(foreach target, $(TARGET_TYPES), \
796  $(foreach run_type, $(RUN_TYPES), \
797    $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(run_type))_RULES :=)))
798define-test-art-run-test-group :=
799TARGET_TYPES :=
800PREBUILD_TYPES :=
801COMPILER_TYPES :=
802RELOCATE_TYPES :=
803TRACE_TYPES :=
804GC_TYPES :=
805JNI_TYPES :=
806IMAGE_TYPES :=
807ADDRESS_SIZES_TARGET :=
808ADDRESS_SIZES_HOST :=
809ALL_ADDRESS_SIZES :=
810RUN_TYPES :=
811
812include $(LOCAL_PATH)/Android.libarttest.mk
813include art/test/Android.libnativebridgetest.mk
814