blob: 08a925c7a4b47962560420fd91245f3c4179d6bb [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001# Copyright (C) 2011 The Android Open Source Project
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -07002#
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
Brian Carlstrom7940e442013-07-12 13:46:57 -070018include art/build/Android.common.mk
19
20########################################################################
21
22# subdirectories which are used as inputs for gtests
23TEST_DEX_DIRECTORIES := \
24 AbstractMethod \
25 AllFields \
Brian Carlstrom7940e442013-07-12 13:46:57 -070026 ExceptionHandle \
Ian Rogersd91d6d62013-09-25 20:26:14 -070027 GetMethodSignature \
Brian Carlstrom7940e442013-07-12 13:46:57 -070028 Interfaces \
29 Main \
30 MyClass \
31 MyClassNatives \
32 Nested \
33 NonStaticLeafMethods \
34 ProtoCompare \
35 ProtoCompare2 \
36 StaticLeafMethods \
37 Statics \
38 StaticsFromCode \
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010039 Transaction \
Brian Carlstrom7940e442013-07-12 13:46:57 -070040 XandY
41
42# subdirectories of which are used with test-art-target-oat
43# Declare the simplest tests (Main, HelloWorld) first, the rest are alphabetical
44TEST_OAT_DIRECTORIES := \
45 Main \
46 HelloWorld \
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000047 InterfaceTest \
Brian Carlstromce888532013-10-10 00:32:58 -070048 JniTest \
Brian Carlstrom1db91132013-07-12 18:05:20 -070049 NativeAllocations \
Brian Carlstrom7940e442013-07-12 13:46:57 -070050 ParallelGC \
51 ReferenceMap \
52 StackWalk \
Hiroshi Yamauchi4d2efce2014-02-10 16:19:09 -080053 ThreadStress \
54 UnsafeTest
Brian Carlstrom7940e442013-07-12 13:46:57 -070055
56# TODO: Enable when the StackWalk2 tests are passing
57# StackWalk2 \
58
59ART_TEST_TARGET_DEX_FILES :=
Andreas Gampe2fe07922014-04-21 07:50:39 -070060ART_TEST_TARGET_DEX_FILES$(ART_PHONY_TEST_TARGET_SUFFIX) :=
61ART_TEST_TARGET_DEX_FILES$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) :=
Brian Carlstrom7940e442013-07-12 13:46:57 -070062ART_TEST_HOST_DEX_FILES :=
63
64# $(1): module prefix
65# $(2): input test directory
66# $(3): target output module path (default module path is used on host)
67define build-art-test-dex
68 ifeq ($(ART_BUILD_TARGET),true)
69 include $(CLEAR_VARS)
70 LOCAL_MODULE := $(1)-$(2)
71 LOCAL_MODULE_TAGS := tests
72 LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
73 LOCAL_JAVA_LIBRARIES := $(TARGET_CORE_JARS)
74 LOCAL_NO_STANDARD_LIBRARIES := true
75 LOCAL_MODULE_PATH := $(3)
76 LOCAL_DEX_PREOPT_IMAGE := $(TARGET_CORE_IMG_OUT)
Brian Carlstrom76c8e592014-01-27 22:56:32 -080077 LOCAL_DEX_PREOPT := false
Brian Carlstrom7940e442013-07-12 13:46:57 -070078 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
79 LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
80 include $(BUILD_JAVA_LIBRARY)
Andreas Gampe2fe07922014-04-21 07:50:39 -070081
Brian Carlstromafb2c322014-01-24 17:43:55 -080082 ART_TEST_TARGET_DEX_FILES += $$(LOCAL_INSTALLED_MODULE)
Andreas Gampe2fe07922014-04-21 07:50:39 -070083 ART_TEST_TARGET_DEX_FILES$(ART_PHONY_TEST_TARGET_SUFFIX) += $$(LOCAL_INSTALLED_MODULE)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -070084
85 ifdef TARGET_2ND_ARCH
Andreas Gampe2fe07922014-04-21 07:50:39 -070086 ART_TEST_TARGET_DEX_FILES$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) += $(4)/$(1)-$(2).jar
87
Andreas Gampeafbaa1a2014-03-25 18:09:32 -070088 # TODO: make this a simple copy
Andreas Gampe2fe07922014-04-21 07:50:39 -070089$(4)/$(1)-$(2).jar: $(3)/$(1)-$(2).jar $(4)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -070090 cp $$< $(4)/
Andreas Gampe2fe07922014-04-21 07:50:39 -070091 endif
Brian Carlstrom7940e442013-07-12 13:46:57 -070092 endif
93
94 ifeq ($(ART_BUILD_HOST),true)
95 include $(CLEAR_VARS)
96 LOCAL_MODULE := $(1)-$(2)
97 LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
98 LOCAL_JAVA_LIBRARIES := $(HOST_CORE_JARS)
99 LOCAL_NO_STANDARD_LIBRARIES := true
100 LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_OUT)
Brian Carlstrom76c8e592014-01-27 22:56:32 -0800101 LOCAL_DEX_PREOPT := false
Brian Carlstrom7940e442013-07-12 13:46:57 -0700102 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
103 LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
Brian Carlstromd7997eb2013-11-08 16:42:41 -0800104 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Brian Carlstromafb2c322014-01-24 17:43:55 -0800105 ART_TEST_HOST_DEX_FILES += $$(LOCAL_INSTALLED_MODULE)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700106 endif
107endef
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700108$(foreach dir,$(TEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-test-dex,$(dir),$(ART_NATIVETEST_OUT),$(2ND_ART_NATIVETEST_OUT))))
109$(foreach dir,$(TEST_OAT_DIRECTORIES), $(eval $(call build-art-test-dex,oat-test-dex,$(dir),$(ART_TEST_OUT),$(2ND_ART_TEST_OUT))))
Brian Carlstrom7940e442013-07-12 13:46:57 -0700110
Andreas Gampe2fe07922014-04-21 07:50:39 -0700111# Rules to explicitly create 2nd-arch test directories, as we use a "cp" for them
112# instead of BUILD_JAVA_LIBRARY
113ifneq ($(2ND_ART_NATIVETEST_OUT),)
114$(2ND_ART_NATIVETEST_OUT):
115 $(hide) mkdir -p $@
116endif
117
118ifneq ($(2ND_ART_TEST_OUT),)
119$(2ND_ART_TEST_OUT):
120 $(hide) mkdir -p $@
121endif
122
Brian Carlstrom7940e442013-07-12 13:46:57 -0700123########################################################################
124
Andreas Gampe2fe07922014-04-21 07:50:39 -0700125ART_TEST_TARGET_OAT_TARGETS$(ART_PHONY_TEST_TARGET_SUFFIX) :=
126ART_TEST_TARGET_OAT_TARGETS$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) :=
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700127ART_TEST_HOST_OAT_DEFAULT_TARGETS :=
128ART_TEST_HOST_OAT_INTERPRETER_TARGETS :=
Brian Carlstrom7940e442013-07-12 13:46:57 -0700129
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700130define declare-test-art-oat-targets-impl
131.PHONY: test-art-target-oat-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX)
132test-art-target-oat-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX): $($(2)ART_TEST_OUT)/oat-test-dex-$(1).jar test-art-target-sync
133 adb shell touch $($(2)ART_TEST_DIR)/test-art-target-oat-$(1)
134 adb shell rm $($(2)ART_TEST_DIR)/test-art-target-oat-$(1)
135 adb shell sh -c "/system/bin/dalvikvm$($(2)ART_TARGET_BINARY_SUFFIX) $(DALVIKVM_FLAGS) -XXlib:libartd.so -Ximage:$($(2)ART_TEST_DIR)/core.art -classpath $($(2)ART_TEST_DIR)/oat-test-dex-$(1).jar -Djava.library.path=$($(2)ART_TEST_DIR) $(1) && touch $($(2)ART_TEST_DIR)/test-art-target-oat-$(1)"
136 $(hide) (adb pull $($(2)ART_TEST_DIR)/test-art-target-oat-$(1) /tmp/ && echo test-art-target-oat-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX) PASSED) || (echo test-art-target-oat-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX) FAILED && exit 1)
137 $(hide) rm /tmp/test-art-target-oat-$(1)
138endef
139
Brian Carlstrom7940e442013-07-12 13:46:57 -0700140# $(1): directory
141# $(2): arguments
142define declare-test-art-oat-targets
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700143 ifdef TARGET_2ND_ARCH
144 $(call declare-test-art-oat-targets-impl,$(1),2ND_)
145
146 # Bind the primary to the non-suffix rule
147 ifneq ($(ART_PHONY_TEST_TARGET_SUFFIX),)
148test-art-target-oat-$(1): test-art-target-oat-$(1)$(ART_PHONY_TEST_TARGET_SUFFIX)
149 endif
150 endif
151 $(call declare-test-art-oat-targets-impl,$(1),)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700152
Nicolas Geoffray1db132d2014-03-26 10:56:24 +0000153$(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex: $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar $(HOST_CORE_IMG_OUT) | $(DEX2OATD)
154 $(DEX2OATD) $(DEX2OAT_FLAGS) --runtime-arg -Xms16m --runtime-arg -Xmx16m --boot-image=$(HOST_CORE_IMG_OUT) --dex-file=$(PWD)/$$< --oat-file=$(PWD)/$$@ --instruction-set=$(ART_HOST_ARCH) --host --android-root=$(HOST_OUT)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700155
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700156.PHONY: test-art-host-oat-default-$(1)
157test-art-host-oat-default-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies
158 mkdir -p /tmp/android-data/test-art-host-oat-default-$(1)
159 ANDROID_DATA=/tmp/android-data/test-art-host-oat-default-$(1) \
Brian Carlstrom7940e442013-07-12 13:46:57 -0700160 ANDROID_ROOT=$(HOST_OUT) \
161 LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +0000162 $(HOST_OUT_EXECUTABLES)/dalvikvm $(DALVIKVM_FLAGS) -XXlib:libartd.so -Ximage:$(shell pwd)/$(HOST_CORE_IMG_OUT) -classpath $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar -Djava.library.path=$(HOST_OUT_SHARED_LIBRARIES) $(1) $(2) \
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700163 && echo test-art-host-oat-default-$(1) PASSED || (echo test-art-host-oat-default-$(1) FAILED && exit 1)
164 $(hide) rm -r /tmp/android-data/test-art-host-oat-default-$(1)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700165
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700166.PHONY: test-art-host-oat-interpreter-$(1)
167test-art-host-oat-interpreter-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies
168 mkdir -p /tmp/android-data/test-art-host-oat-interpreter-$(1)
169 ANDROID_DATA=/tmp/android-data/test-art-host-oat-interpreter-$(1) \
Brian Carlstrom7940e442013-07-12 13:46:57 -0700170 ANDROID_ROOT=$(HOST_OUT) \
171 LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \
Brian Carlstrom43534862014-02-19 01:13:52 -0800172 $(HOST_OUT_EXECUTABLES)/dalvikvm -XXlib:libartd.so -Ximage:$(shell pwd)/$(HOST_CORE_IMG_OUT) -Xint -classpath $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar -Djava.library.path=$(HOST_OUT_SHARED_LIBRARIES) $(1) $(2) \
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700173 && echo test-art-host-oat-interpreter-$(1) PASSED || (echo test-art-host-oat-interpreter-$(1) FAILED && exit 1)
174 $(hide) rm -r /tmp/android-data/test-art-host-oat-interpreter-$(1)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700175
Brian Carlstroma404db02013-08-28 09:37:40 -0700176.PHONY: test-art-host-oat-$(1)
177test-art-host-oat-$(1): test-art-host-oat-default-$(1) test-art-host-oat-interpreter-$(1)
178
179.PHONY: test-art-oat-$(1)
180test-art-oat-$(1): test-art-host-oat-$(1) test-art-target-oat-$(1)
181
Andreas Gampe2fe07922014-04-21 07:50:39 -0700182ART_TEST_TARGET_OAT_TARGETS$(ART_PHONY_TEST_TARGET_SUFFIX) += test-art-target-oat-$(1)$(ART_PHONY_TEST_TARGET_SUFFIX)
183ifdef TARGET_2ND_ARCH
184 ART_TEST_TARGET_OAT_TARGETS$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) += test-art-target-oat-$(1)$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
185endif
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700186ART_TEST_HOST_OAT_DEFAULT_TARGETS += test-art-host-oat-default-$(1)
187ART_TEST_HOST_OAT_INTERPRETER_TARGETS += test-art-host-oat-interpreter-$(1)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700188endef
189$(foreach dir,$(TEST_OAT_DIRECTORIES), $(eval $(call declare-test-art-oat-targets,$(dir))))
190
191########################################################################
192
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700193TEST_ART_RUN_TEST_MAKE_TARGETS :=
194
195# Helper to create individual build targets for tests.
196# Must be called with $(eval)
197# $(1): the test number
198define declare-make-art-run-test
199dmart_target := $(TARGET_OUT_DATA)/art-run-tests/$(1)/touch
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -0800200$$(dmart_target): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700201 $(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -0800202 $(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1)
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700203 $(hide) touch $$@
204
Brian Carlstrom7940e442013-07-12 13:46:57 -0700205
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700206TEST_ART_RUN_TEST_MAKE_TARGETS += $$(dmart_target)
207dmart_target :=
208endef
209
210# Expand all tests.
Brian Carlstrome4d159a2014-03-31 14:00:52 -0700211TEST_ART_RUN_TESTS := $(wildcard $(LOCAL_PATH)/[0-9]*)
212TEST_ART_RUN_TESTS := $(subst $(LOCAL_PATH)/,, $(TEST_ART_RUN_TESTS))
Brian Carlstrom6b5123f2014-04-16 15:12:45 -0700213TEST_ART_TIMING_SENSITIVE_RUN_TESTS := 053-wait-some 055-enum-performance
Brian Carlstrome4d159a2014-03-31 14:00:52 -0700214ifdef dist_goal # disable timing sensitive tests on "dist" builds.
Brian Carlstrom934ce802014-04-01 18:09:33 -0700215 $(foreach test, $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), \
216 $(info Skipping $(test)) \
217 $(eval TEST_ART_RUN_TESTS := $(filter-out $(test), $(TEST_ART_RUN_TESTS))))
Brian Carlstrome4d159a2014-03-31 14:00:52 -0700218endif
219$(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call declare-make-art-run-test,$(test))))
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700220
221include $(CLEAR_VARS)
222LOCAL_MODULE_TAGS := tests
223LOCAL_MODULE := art-run-tests
224LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_MAKE_TARGETS)
225include $(BUILD_PHONY_PACKAGE)
226
227# clear temp vars
228TEST_ART_RUN_TEST_MAKE_TARGETS :=
229declare-make-art-run-test :=
Brian Carlstrom7940e442013-07-12 13:46:57 -0700230
231########################################################################