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# Dependencies for actually running a run-test.
21TEST_ART_RUN_TEST_DEPENDENCIES := \
22  $(HOST_OUT_EXECUTABLES)/dx \
23  $(HOST_OUT_EXECUTABLES)/d8 \
24  $(HOST_OUT_EXECUTABLES)/hiddenapi \
25  $(HOST_OUT_EXECUTABLES)/jasmin \
26  $(HOST_OUT_EXECUTABLES)/smali \
27  $(HOST_OUT_EXECUTABLES)/dexmerger \
28  $(HOST_OUT_JAVA_LIBRARIES)/desugar.jar
29
30# Add d8 dependency, if enabled.
31ifeq ($(USE_D8),true)
32TEST_ART_RUN_TEST_DEPENDENCIES += \
33  $(HOST_OUT_EXECUTABLES)/d8-compat-dx
34endif
35
36# We need dex2oat and dalvikvm on the target as well as the core images (all images as we sync
37# only once).
38TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_EXECUTABLES) $(TARGET_CORE_IMG_OUTS)
39
40# Also need libartagent.
41TEST_ART_TARGET_SYNC_DEPS += libartagent-target libartagentd-target
42
43# Also need libtiagent.
44TEST_ART_TARGET_SYNC_DEPS += libtiagent-target libtiagentd-target
45
46# Also need libtistress.
47TEST_ART_TARGET_SYNC_DEPS += libtistress-target libtistressd-target
48
49# Also need libarttest.
50TEST_ART_TARGET_SYNC_DEPS += libarttest-target libarttestd-target
51
52# Also need libnativebridgetest.
53TEST_ART_TARGET_SYNC_DEPS += libnativebridgetest-target
54
55# Also need libopenjdkjvmti.
56TEST_ART_TARGET_SYNC_DEPS += libopenjdkjvmti-target libopenjdkjvmtid-target
57
58TEST_ART_TARGET_SYNC_DEPS += $(TARGET_OUT_JAVA_LIBRARIES)/core-libart-testdex.jar
59TEST_ART_TARGET_SYNC_DEPS += $(TARGET_OUT_JAVA_LIBRARIES)/core-oj-testdex.jar
60TEST_ART_TARGET_SYNC_DEPS += $(TARGET_OUT_JAVA_LIBRARIES)/okhttp-testdex.jar
61TEST_ART_TARGET_SYNC_DEPS += $(TARGET_OUT_JAVA_LIBRARIES)/bouncycastle-testdex.jar
62TEST_ART_TARGET_SYNC_DEPS += $(TARGET_OUT_JAVA_LIBRARIES)/conscrypt-testdex.jar
63
64# All tests require the host executables. The tests also depend on the core images, but on
65# specific version depending on the compiler.
66ART_TEST_HOST_RUN_TEST_DEPENDENCIES := \
67  $(ART_HOST_EXECUTABLES) \
68  $(HOST_OUT_EXECUTABLES)/hprof-conv \
69  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libtiagent) \
70  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libtiagentd) \
71  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libtistress) \
72  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libtistressd) \
73  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libartagent) \
74  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libartagentd) \
75  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libarttest) \
76  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libarttestd) \
77  $(OUT_DIR)/$(ART_TEST_LIST_host_$(ART_HOST_ARCH)_libnativebridgetest) \
78  $(ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION) \
79  $(ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdk$(ART_HOST_SHLIB_EXTENSION) \
80  $(ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$(ART_HOST_SHLIB_EXTENSION) \
81  $(ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkjvmti$(ART_HOST_SHLIB_EXTENSION) \
82  $(ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkjvmtid$(ART_HOST_SHLIB_EXTENSION) \
83
84ifneq ($(HOST_PREFER_32_BIT),true)
85ART_TEST_HOST_RUN_TEST_DEPENDENCIES += \
86  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libtiagent) \
87  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libtiagentd) \
88  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libtistress) \
89  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libtistressd) \
90  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libartagent) \
91  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libartagentd) \
92  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libarttest) \
93  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libarttestd) \
94  $(OUT_DIR)/$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_libnativebridgetest) \
95  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION) \
96  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdk$(ART_HOST_SHLIB_EXTENSION) \
97  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$(ART_HOST_SHLIB_EXTENSION) \
98  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkjvmti$(ART_HOST_SHLIB_EXTENSION) \
99  $(2ND_ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkjvmtid$(ART_HOST_SHLIB_EXTENSION) \
100
101endif
102
103# Host executables.
104host_prereq_rules := $(ART_TEST_HOST_RUN_TEST_DEPENDENCIES)
105
106# Required for dx, jasmin, smali, dexmerger.
107host_prereq_rules += $(TEST_ART_RUN_TEST_DEPENDENCIES)
108
109# Sync test files to the target, depends upon all things that must be pushed
110#to the target.
111target_prereq_rules += test-art-target-sync
112
113define core-image-dependencies
114  image_suffix := $(3)
115  ifeq ($(3),regalloc_gc)
116    image_suffix:=optimizing
117  else
118    ifeq ($(3),jit)
119      image_suffix:=interpreter
120    endif
121  endif
122  ifeq ($(2),no-image)
123    $(1)_prereq_rules += $$($(call to-upper,$(1))_CORE_IMAGE_$$(image_suffix)_$(4))
124  else
125    ifeq ($(2),picimage)
126      $(1)_prereq_rules += $$($(call to-upper,$(1))_CORE_IMAGE_$$(image_suffix)_$(4))
127    else
128      ifeq ($(2),multipicimage)
129        $(1)_prereq_rules += $$($(call to-upper,$(1))_CORE_IMAGE_$$(image_suffix)_multi_$(4))
130      endif
131    endif
132  endif
133endef
134
135TARGET_TYPES := host target
136COMPILER_TYPES := jit interpreter optimizing regalloc_gc jit interp-ac speed-profile
137IMAGE_TYPES := picimage no-image multipicimage
138ALL_ADDRESS_SIZES := 64 32
139
140# Add core image dependencies required for given target - HOST or TARGET,
141# IMAGE_TYPE, COMPILER_TYPE and ADDRESS_SIZE to the prereq_rules.
142$(foreach target, $(TARGET_TYPES), \
143  $(foreach image, $(IMAGE_TYPES), \
144    $(foreach compiler, $(COMPILER_TYPES), \
145      $(foreach address_size, $(ALL_ADDRESS_SIZES), $(eval \
146        $(call core-image-dependencies,$(target),$(image),$(compiler),$(address_size)))))))
147
148test-art-host-run-test-dependencies : $(host_prereq_rules)
149test-art-target-run-test-dependencies : $(target_prereq_rules)
150test-art-run-test-dependencies : test-art-host-run-test-dependencies test-art-target-run-test-dependencies
151
152# Create a rule to build and run a test group of the following form:
153# test-art-{1: host target}-run-test
154define define-test-art-host-or-target-run-test-group
155  build_target := test-art-$(1)-run-test
156  .PHONY: $$(build_target)
157
158  $$(build_target) : args := --$(1) --verbose
159  $$(build_target) : test-art-$(1)-run-test-dependencies
160	./art/test/testrunner/testrunner.py $$(args)
161  build_target :=
162  args :=
163endef  # define-test-art-host-or-target-run-test-group
164
165$(foreach target, $(TARGET_TYPES), $(eval \
166  $(call define-test-art-host-or-target-run-test-group,$(target))))
167
168test-art-run-test : test-art-host-run-test test-art-target-run-test
169
170host_prereq_rules :=
171target_prereq_rules :=
172core-image-dependencies :=
173define-test-art-host-or-target-run-test-group :=
174TARGET_TYPES :=
175COMPILER_TYPES :=
176IMAGE_TYPES :=
177ALL_ADDRESS_SIZES :=
178LOCAL_PATH :=
179