• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.mk
19
20########################################################################
21
22# subdirectories which are used as inputs for gtests
23TEST_DEX_DIRECTORIES := \
24	AbstractMethod \
25	AllFields \
26	CreateMethodSignature \
27	ExceptionHandle \
28	Interfaces \
29	Main \
30	MyClass \
31	MyClassNatives \
32	Nested \
33	NonStaticLeafMethods \
34	ProtoCompare \
35	ProtoCompare2 \
36	StaticLeafMethods \
37	Statics \
38	StaticsFromCode \
39	XandY
40
41# subdirectories of which are used with test-art-target-oat
42# Declare the simplest tests (Main, HelloWorld) first, the rest are alphabetical
43TEST_OAT_DIRECTORIES := \
44	Main \
45	HelloWorld \
46	\
47	JniTest \
48	NativeAllocations \
49	ParallelGC \
50	ReferenceMap \
51	StackWalk \
52	ThreadStress
53
54# TODO: Enable when the StackWalk2 tests are passing
55#	StackWalk2 \
56
57ART_TEST_TARGET_DEX_FILES :=
58ART_TEST_HOST_DEX_FILES :=
59
60# $(1): module prefix
61# $(2): input test directory
62# $(3): target output module path (default module path is used on host)
63define build-art-test-dex
64  ifeq ($(ART_BUILD_TARGET),true)
65    include $(CLEAR_VARS)
66    LOCAL_MODULE := $(1)-$(2)
67    LOCAL_MODULE_TAGS := tests
68    LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
69    LOCAL_JAVA_LIBRARIES := $(TARGET_CORE_JARS)
70    LOCAL_NO_STANDARD_LIBRARIES := true
71    LOCAL_MODULE_PATH := $(3)
72    LOCAL_DEX_PREOPT_IMAGE := $(TARGET_CORE_IMG_OUT)
73    LOCAL_DEX_PREOPT := false
74    LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
75    LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
76    include $(BUILD_JAVA_LIBRARY)
77    ART_TEST_TARGET_DEX_FILES += $(3)/$$(LOCAL_MODULE).jar
78  endif
79
80  ifeq ($(ART_BUILD_HOST),true)
81    include $(CLEAR_VARS)
82    LOCAL_MODULE := $(1)-$(2)
83    LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
84    LOCAL_JAVA_LIBRARIES := $(HOST_CORE_JARS)
85    LOCAL_NO_STANDARD_LIBRARIES := true
86    LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_OUT)
87    LOCAL_BUILD_HOST_DEX := true
88    LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
89    LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
90    include $(BUILD_HOST_JAVA_LIBRARY)
91    ART_TEST_HOST_DEX_FILES += $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE).jar
92  endif
93endef
94$(foreach dir,$(TEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-test-dex,$(dir),$(ART_NATIVETEST_OUT))))
95$(foreach dir,$(TEST_OAT_DIRECTORIES), $(eval $(call build-art-test-dex,oat-test-dex,$(dir),$(ART_TEST_OUT))))
96
97########################################################################
98
99ART_TEST_TARGET_OAT_TARGETS :=
100ART_TEST_HOST_OAT_DEFAULT_TARGETS :=
101ART_TEST_HOST_OAT_INTERPRETER_TARGETS :=
102
103# $(1): directory
104# $(2): arguments
105define declare-test-art-oat-targets
106.PHONY: test-art-target-oat-$(1)
107test-art-target-oat-$(1): $(ART_TEST_OUT)/oat-test-dex-$(1).jar test-art-target-sync
108	adb shell touch $(ART_TEST_DIR)/test-art-target-oat-$(1)
109	adb shell rm $(ART_TEST_DIR)/test-art-target-oat-$(1)
110	adb shell sh -c "dalvikvm -XXlib:libartd.so -Ximage:$(ART_TEST_DIR)/core.art -classpath $(ART_TEST_DIR)/oat-test-dex-$(1).jar -Djava.library.path=$(ART_TEST_DIR) $(1) $(2) && touch $(ART_TEST_DIR)/test-art-target-oat-$(1)"
111	$(hide) (adb pull $(ART_TEST_DIR)/test-art-target-oat-$(1) /tmp/ && echo test-art-target-oat-$(1) PASSED) || (echo test-art-target-oat-$(1) FAILED && exit 1)
112	$(hide) rm /tmp/test-art-target-oat-$(1)
113
114$(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex: $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar $(HOST_CORE_IMG_OUT) | $(DEX2OAT)
115	$(DEX2OAT) --runtime-arg -Xms16m --runtime-arg -Xmx16m --boot-image=$(HOST_CORE_IMG_OUT) --dex-file=$(PWD)/$$< --oat-file=$(PWD)/$$@ --instruction-set=$(HOST_ARCH) --host --host-prefix="" --android-root=$(HOST_OUT)
116
117.PHONY: test-art-host-oat-default-$(1)
118test-art-host-oat-default-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies
119	mkdir -p /tmp/android-data/test-art-host-oat-default-$(1)
120	ANDROID_DATA=/tmp/android-data/test-art-host-oat-default-$(1) \
121	  ANDROID_ROOT=$(HOST_OUT) \
122	  LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \
123	  dalvikvm -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) \
124          && echo test-art-host-oat-default-$(1) PASSED || (echo test-art-host-oat-default-$(1) FAILED && exit 1)
125	$(hide) rm -r /tmp/android-data/test-art-host-oat-default-$(1)
126
127.PHONY: test-art-host-oat-interpreter-$(1)
128test-art-host-oat-interpreter-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies
129	mkdir -p /tmp/android-data/test-art-host-oat-interpreter-$(1)
130	ANDROID_DATA=/tmp/android-data/test-art-host-oat-interpreter-$(1) \
131	  ANDROID_ROOT=$(HOST_OUT) \
132	  LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \
133	  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) \
134          && echo test-art-host-oat-interpreter-$(1) PASSED || (echo test-art-host-oat-interpreter-$(1) FAILED && exit 1)
135	$(hide) rm -r /tmp/android-data/test-art-host-oat-interpreter-$(1)
136
137.PHONY: test-art-host-oat-$(1)
138test-art-host-oat-$(1): test-art-host-oat-default-$(1) test-art-host-oat-interpreter-$(1)
139
140.PHONY: test-art-oat-$(1)
141test-art-oat-$(1): test-art-host-oat-$(1) test-art-target-oat-$(1)
142
143ART_TEST_TARGET_OAT_TARGETS += test-art-target-oat-$(1)
144ART_TEST_HOST_OAT_DEFAULT_TARGETS += test-art-host-oat-default-$(1)
145ART_TEST_HOST_OAT_INTERPRETER_TARGETS += test-art-host-oat-interpreter-$(1)
146endef
147$(foreach dir,$(TEST_OAT_DIRECTORIES), $(eval $(call declare-test-art-oat-targets,$(dir))))
148
149########################################################################
150
151TEST_ART_RUN_TEST_MAKE_TARGETS :=
152
153# Helper to create individual build targets for tests.
154# Must be called with $(eval)
155# $(1): the test number
156define declare-make-art-run-test
157dmart_target := $(TARGET_OUT_DATA)/art-run-tests/$(1)/touch
158$$(dmart_target): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin
159	$(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
160	$(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1)
161	$(hide) touch $$@
162
163
164TEST_ART_RUN_TEST_MAKE_TARGETS += $$(dmart_target)
165dmart_target :=
166endef
167
168# Expand all tests.
169$(foreach test, $(wildcard $(LOCAL_PATH)/[0-9]*), $(eval $(call declare-make-art-run-test,$(notdir $(test)))))
170
171include $(CLEAR_VARS)
172LOCAL_MODULE_TAGS := tests
173LOCAL_MODULE := art-run-tests
174LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_MAKE_TARGETS)
175include $(BUILD_PHONY_PACKAGE)
176
177# clear temp vars
178TEST_ART_RUN_TEST_MAKE_TARGETS :=
179declare-make-art-run-test :=
180
181########################################################################
182