blob: 9b79abf71d61a0664fe8613ded85ac62b9e45254 [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)
Tsu Chiang Chuang430e3772014-05-13 15:27:13 -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)/
Tsu Chiang Chuang430e3772014-05-13 15:27:13 -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
Tsu Chiang Chuang430e3772014-05-13 15:27:13 -0700111# Used outside the art project to get a list of the current tests
112ART_TEST_DEX_MAKE_TARGETS := $(addprefix art-test-dex-, $(TEST_DEX_DIRECTORIES))
Tsu Chiang Chuang1694e022014-05-15 09:59:33 -0700113ART_TEST_OAT_MAKE_TARGETS := $(addprefix oat-test-dex-, $(TEST_OAT_DIRECTORIES))
Tsu Chiang Chuang430e3772014-05-13 15:27:13 -0700114
Andreas Gampe2fe07922014-04-21 07:50:39 -0700115# Rules to explicitly create 2nd-arch test directories, as we use a "cp" for them
116# instead of BUILD_JAVA_LIBRARY
117ifneq ($(2ND_ART_NATIVETEST_OUT),)
118$(2ND_ART_NATIVETEST_OUT):
119 $(hide) mkdir -p $@
120endif
121
122ifneq ($(2ND_ART_TEST_OUT),)
123$(2ND_ART_TEST_OUT):
124 $(hide) mkdir -p $@
125endif
126
Brian Carlstrom7940e442013-07-12 13:46:57 -0700127########################################################################
128
Andreas Gampe2fe07922014-04-21 07:50:39 -0700129ART_TEST_TARGET_OAT_TARGETS$(ART_PHONY_TEST_TARGET_SUFFIX) :=
130ART_TEST_TARGET_OAT_TARGETS$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) :=
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700131ART_TEST_HOST_OAT_DEFAULT_TARGETS :=
132ART_TEST_HOST_OAT_INTERPRETER_TARGETS :=
Brian Carlstrom7940e442013-07-12 13:46:57 -0700133
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700134define declare-test-art-oat-targets-impl
135.PHONY: test-art-target-oat-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX)
136test-art-target-oat-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX): $($(2)ART_TEST_OUT)/oat-test-dex-$(1).jar test-art-target-sync
137 adb shell touch $($(2)ART_TEST_DIR)/test-art-target-oat-$(1)
138 adb shell rm $($(2)ART_TEST_DIR)/test-art-target-oat-$(1)
139 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)"
140 $(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)
141 $(hide) rm /tmp/test-art-target-oat-$(1)
142endef
143
Brian Carlstrom7940e442013-07-12 13:46:57 -0700144# $(1): directory
145# $(2): arguments
146define declare-test-art-oat-targets
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700147 ifdef TARGET_2ND_ARCH
148 $(call declare-test-art-oat-targets-impl,$(1),2ND_)
149
150 # Bind the primary to the non-suffix rule
151 ifneq ($(ART_PHONY_TEST_TARGET_SUFFIX),)
152test-art-target-oat-$(1): test-art-target-oat-$(1)$(ART_PHONY_TEST_TARGET_SUFFIX)
153 endif
154 endif
155 $(call declare-test-art-oat-targets-impl,$(1),)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700156
Nicolas Geoffray1db132d2014-03-26 10:56:24 +0000157$(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex: $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar $(HOST_CORE_IMG_OUT) | $(DEX2OATD)
Andreas Gamped5ca7b32014-05-14 15:33:03 -0700158 $(DEX2OATD) $(DEX2OAT_FLAGS) --runtime-arg -Xms16m --runtime-arg -Xmx16m --boot-image=$(HOST_CORE_IMG_OUT) --dex-file=$$(realpath $$<) --oat-file=$$(realpath $(HOST_OUT_JAVA_LIBRARIES))/oat-test-dex-$(1).odex --instruction-set=$(ART_HOST_ARCH) --host --android-root=$(HOST_OUT)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700159
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700160.PHONY: test-art-host-oat-default-$(1)
161test-art-host-oat-default-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies
162 mkdir -p /tmp/android-data/test-art-host-oat-default-$(1)
163 ANDROID_DATA=/tmp/android-data/test-art-host-oat-default-$(1) \
Brian Carlstrom7940e442013-07-12 13:46:57 -0700164 ANDROID_ROOT=$(HOST_OUT) \
165 LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \
Andreas Gamped5ca7b32014-05-14 15:33:03 -0700166 $(HOST_OUT_EXECUTABLES)/dalvikvm $(DALVIKVM_FLAGS) -XXlib:libartd.so -Ximage:$$(realpath $(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 -0700167 && echo test-art-host-oat-default-$(1) PASSED || (echo test-art-host-oat-default-$(1) FAILED && exit 1)
168 $(hide) rm -r /tmp/android-data/test-art-host-oat-default-$(1)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700169
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700170.PHONY: test-art-host-oat-interpreter-$(1)
171test-art-host-oat-interpreter-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies
172 mkdir -p /tmp/android-data/test-art-host-oat-interpreter-$(1)
173 ANDROID_DATA=/tmp/android-data/test-art-host-oat-interpreter-$(1) \
Brian Carlstrom7940e442013-07-12 13:46:57 -0700174 ANDROID_ROOT=$(HOST_OUT) \
175 LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \
Andreas Gamped5ca7b32014-05-14 15:33:03 -0700176 $(HOST_OUT_EXECUTABLES)/dalvikvm -XXlib:libartd.so -Ximage:$$(realpath $(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 -0700177 && echo test-art-host-oat-interpreter-$(1) PASSED || (echo test-art-host-oat-interpreter-$(1) FAILED && exit 1)
178 $(hide) rm -r /tmp/android-data/test-art-host-oat-interpreter-$(1)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700179
Brian Carlstroma404db02013-08-28 09:37:40 -0700180.PHONY: test-art-host-oat-$(1)
181test-art-host-oat-$(1): test-art-host-oat-default-$(1) test-art-host-oat-interpreter-$(1)
182
183.PHONY: test-art-oat-$(1)
184test-art-oat-$(1): test-art-host-oat-$(1) test-art-target-oat-$(1)
185
Andreas Gampe2fe07922014-04-21 07:50:39 -0700186ART_TEST_TARGET_OAT_TARGETS$(ART_PHONY_TEST_TARGET_SUFFIX) += test-art-target-oat-$(1)$(ART_PHONY_TEST_TARGET_SUFFIX)
187ifdef TARGET_2ND_ARCH
188 ART_TEST_TARGET_OAT_TARGETS$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) += test-art-target-oat-$(1)$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
189endif
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700190ART_TEST_HOST_OAT_DEFAULT_TARGETS += test-art-host-oat-default-$(1)
191ART_TEST_HOST_OAT_INTERPRETER_TARGETS += test-art-host-oat-interpreter-$(1)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700192endef
193$(foreach dir,$(TEST_OAT_DIRECTORIES), $(eval $(call declare-test-art-oat-targets,$(dir))))
194
195########################################################################
196
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700197TEST_ART_RUN_TEST_MAKE_TARGETS :=
Ying Wangfea356f2014-05-05 16:50:14 -0700198art_run_tests_dir := $(call intermediates-dir-for,PACKAGING,art-run-tests)/DATA
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700199
200# Helper to create individual build targets for tests.
201# Must be called with $(eval)
202# $(1): the test number
203define declare-make-art-run-test
Ying Wangfea356f2014-05-05 16:50:14 -0700204dmart_target := $(art_run_tests_dir)/art-run-tests/$(1)/touch
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -0800205$$(dmart_target): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700206 $(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -0800207 $(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 -0700208 $(hide) touch $$@
209
Brian Carlstrom7940e442013-07-12 13:46:57 -0700210
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700211TEST_ART_RUN_TEST_MAKE_TARGETS += $$(dmart_target)
212dmart_target :=
213endef
214
215# Expand all tests.
Brian Carlstrome4d159a2014-03-31 14:00:52 -0700216TEST_ART_RUN_TESTS := $(wildcard $(LOCAL_PATH)/[0-9]*)
217TEST_ART_RUN_TESTS := $(subst $(LOCAL_PATH)/,, $(TEST_ART_RUN_TESTS))
Brian Carlstrom6b5123f2014-04-16 15:12:45 -0700218TEST_ART_TIMING_SENSITIVE_RUN_TESTS := 053-wait-some 055-enum-performance
Brian Carlstrome4d159a2014-03-31 14:00:52 -0700219ifdef dist_goal # disable timing sensitive tests on "dist" builds.
Brian Carlstrom934ce802014-04-01 18:09:33 -0700220 $(foreach test, $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), \
221 $(info Skipping $(test)) \
222 $(eval TEST_ART_RUN_TESTS := $(filter-out $(test), $(TEST_ART_RUN_TESTS))))
Brian Carlstrome4d159a2014-03-31 14:00:52 -0700223endif
224$(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call declare-make-art-run-test,$(test))))
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700225
226include $(CLEAR_VARS)
227LOCAL_MODULE_TAGS := tests
228LOCAL_MODULE := art-run-tests
229LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_MAKE_TARGETS)
Ying Wangfea356f2014-05-05 16:50:14 -0700230# The build system use this flag to pick up files generated by declare-make-art-run-test.
231LOCAL_PICKUP_FILES := $(art_run_tests_dir)
232
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700233include $(BUILD_PHONY_PACKAGE)
234
235# clear temp vars
236TEST_ART_RUN_TEST_MAKE_TARGETS :=
237declare-make-art-run-test :=
Brian Carlstrom7940e442013-07-12 13:46:57 -0700238
239########################################################################