Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1 | # Copyright (C) 2011 The Android Open Source Project |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 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 | |
| 16 | LOCAL_PATH := $(call my-dir) |
| 17 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 18 | include art/build/Android.common.mk |
| 19 | |
| 20 | ######################################################################## |
| 21 | |
| 22 | # subdirectories which are used as inputs for gtests |
| 23 | TEST_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 |
| 43 | TEST_OAT_DIRECTORIES := \ |
| 44 | Main \ |
| 45 | HelloWorld \ |
| 46 | \ |
Brian Carlstrom | 1db9113 | 2013-07-12 18:05:20 -0700 | [diff] [blame] | 47 | NativeAllocations \ |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 48 | ParallelGC \ |
| 49 | ReferenceMap \ |
| 50 | StackWalk \ |
| 51 | ThreadStress |
| 52 | |
| 53 | # TODO: Enable when the StackWalk2 tests are passing |
| 54 | # StackWalk2 \ |
| 55 | |
| 56 | ART_TEST_TARGET_DEX_FILES := |
| 57 | ART_TEST_HOST_DEX_FILES := |
| 58 | |
| 59 | # $(1): module prefix |
| 60 | # $(2): input test directory |
| 61 | # $(3): target output module path (default module path is used on host) |
| 62 | define build-art-test-dex |
| 63 | ifeq ($(ART_BUILD_TARGET),true) |
| 64 | include $(CLEAR_VARS) |
| 65 | LOCAL_MODULE := $(1)-$(2) |
| 66 | LOCAL_MODULE_TAGS := tests |
| 67 | LOCAL_SRC_FILES := $(call all-java-files-under, $(2)) |
| 68 | LOCAL_JAVA_LIBRARIES := $(TARGET_CORE_JARS) |
| 69 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 70 | LOCAL_MODULE_PATH := $(3) |
| 71 | LOCAL_DEX_PREOPT_IMAGE := $(TARGET_CORE_IMG_OUT) |
| 72 | LOCAL_DEX_PREOPT := false |
| 73 | LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk |
| 74 | LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk |
| 75 | include $(BUILD_JAVA_LIBRARY) |
| 76 | ART_TEST_TARGET_DEX_FILES += $(3)/$$(LOCAL_MODULE).jar |
| 77 | endif |
| 78 | |
| 79 | ifeq ($(ART_BUILD_HOST),true) |
| 80 | include $(CLEAR_VARS) |
| 81 | LOCAL_MODULE := $(1)-$(2) |
| 82 | LOCAL_SRC_FILES := $(call all-java-files-under, $(2)) |
| 83 | LOCAL_JAVA_LIBRARIES := $(HOST_CORE_JARS) |
| 84 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 85 | LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_OUT) |
| 86 | LOCAL_BUILD_HOST_DEX := true |
| 87 | LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk |
| 88 | LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk |
| 89 | include $(BUILD_HOST_JAVA_LIBRARY) |
| 90 | ART_TEST_HOST_DEX_FILES += $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE).jar |
| 91 | endif |
| 92 | endef |
| 93 | $(foreach dir,$(TEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-test-dex,$(dir),$(ART_NATIVETEST_OUT)))) |
| 94 | $(foreach dir,$(TEST_OAT_DIRECTORIES), $(eval $(call build-art-test-dex,oat-test-dex,$(dir),$(ART_TEST_OUT)))) |
| 95 | |
| 96 | ######################################################################## |
| 97 | |
| 98 | ART_TEST_TARGET_OAT_TARGETS := |
Brian Carlstrom | dbaa93a | 2013-07-31 15:13:10 -0700 | [diff] [blame] | 99 | ART_TEST_HOST_OAT_DEFAULT_TARGETS := |
| 100 | ART_TEST_HOST_OAT_INTERPRETER_TARGETS := |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 101 | |
| 102 | # $(1): directory |
| 103 | # $(2): arguments |
| 104 | define declare-test-art-oat-targets |
| 105 | .PHONY: test-art-target-oat-$(1) |
| 106 | test-art-target-oat-$(1): $(ART_TEST_OUT)/oat-test-dex-$(1).jar test-art-target-sync |
| 107 | adb shell touch $(ART_TEST_DIR)/test-art-target-oat-$(1) |
| 108 | adb shell rm $(ART_TEST_DIR)/test-art-target-oat-$(1) |
| 109 | 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)" |
| 110 | $(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) |
| 111 | $(hide) rm /tmp/test-art-target-oat-$(1) |
| 112 | |
| 113 | $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex: $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar $(HOST_CORE_IMG_OUT) | $(DEX2OAT) |
Brian Carlstrom | 7571e8b | 2013-08-12 17:04:14 -0700 | [diff] [blame] | 114 | $(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) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 115 | |
Brian Carlstrom | dbaa93a | 2013-07-31 15:13:10 -0700 | [diff] [blame] | 116 | .PHONY: test-art-host-oat-default-$(1) |
| 117 | test-art-host-oat-default-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies |
| 118 | mkdir -p /tmp/android-data/test-art-host-oat-default-$(1) |
| 119 | ANDROID_DATA=/tmp/android-data/test-art-host-oat-default-$(1) \ |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 120 | ANDROID_ROOT=$(HOST_OUT) \ |
| 121 | LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \ |
| 122 | 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) \ |
Brian Carlstrom | dbaa93a | 2013-07-31 15:13:10 -0700 | [diff] [blame] | 123 | && echo test-art-host-oat-default-$(1) PASSED || (echo test-art-host-oat-default-$(1) FAILED && exit 1) |
| 124 | $(hide) rm -r /tmp/android-data/test-art-host-oat-default-$(1) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 125 | |
Brian Carlstrom | dbaa93a | 2013-07-31 15:13:10 -0700 | [diff] [blame] | 126 | .PHONY: test-art-host-oat-interpreter-$(1) |
| 127 | test-art-host-oat-interpreter-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies |
| 128 | mkdir -p /tmp/android-data/test-art-host-oat-interpreter-$(1) |
| 129 | ANDROID_DATA=/tmp/android-data/test-art-host-oat-interpreter-$(1) \ |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 130 | ANDROID_ROOT=$(HOST_OUT) \ |
| 131 | LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \ |
| 132 | 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 Carlstrom | dbaa93a | 2013-07-31 15:13:10 -0700 | [diff] [blame] | 133 | && echo test-art-host-oat-interpreter-$(1) PASSED || (echo test-art-host-oat-interpreter-$(1) FAILED && exit 1) |
| 134 | $(hide) rm -r /tmp/android-data/test-art-host-oat-interpreter-$(1) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 135 | |
Brian Carlstrom | a404db0 | 2013-08-28 09:37:40 -0700 | [diff] [blame] | 136 | .PHONY: test-art-host-oat-$(1) |
| 137 | test-art-host-oat-$(1): test-art-host-oat-default-$(1) test-art-host-oat-interpreter-$(1) |
| 138 | |
| 139 | .PHONY: test-art-oat-$(1) |
| 140 | test-art-oat-$(1): test-art-host-oat-$(1) test-art-target-oat-$(1) |
| 141 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 142 | ART_TEST_TARGET_OAT_TARGETS += test-art-target-oat-$(1) |
Brian Carlstrom | dbaa93a | 2013-07-31 15:13:10 -0700 | [diff] [blame] | 143 | ART_TEST_HOST_OAT_DEFAULT_TARGETS += test-art-host-oat-default-$(1) |
| 144 | ART_TEST_HOST_OAT_INTERPRETER_TARGETS += test-art-host-oat-interpreter-$(1) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 145 | endef |
| 146 | $(foreach dir,$(TEST_OAT_DIRECTORIES), $(eval $(call declare-test-art-oat-targets,$(dir)))) |
| 147 | |
| 148 | ######################################################################## |
| 149 | |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 150 | TEST_ART_RUN_TEST_MAKE_TARGETS := |
| 151 | |
| 152 | # Helper to create individual build targets for tests. |
| 153 | # Must be called with $(eval) |
| 154 | # $(1): the test number |
| 155 | define declare-make-art-run-test |
| 156 | dmart_target := $(TARGET_OUT_DATA)/art-run-tests/$(1)/touch |
Tsu Chiang Chuang | 6674f8a | 2013-01-16 15:41:21 -0800 | [diff] [blame] | 157 | $$(dmart_target): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 158 | $(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@) |
Tsu Chiang Chuang | 6674f8a | 2013-01-16 15:41:21 -0800 | [diff] [blame] | 159 | $(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1) |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 160 | $(hide) touch $$@ |
| 161 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 162 | |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 163 | TEST_ART_RUN_TEST_MAKE_TARGETS += $$(dmart_target) |
| 164 | dmart_target := |
| 165 | endef |
| 166 | |
| 167 | # Expand all tests. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 168 | $(foreach test, $(wildcard $(LOCAL_PATH)/[0-9]*), $(eval $(call declare-make-art-run-test,$(notdir $(test))))) |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 169 | |
| 170 | include $(CLEAR_VARS) |
| 171 | LOCAL_MODULE_TAGS := tests |
| 172 | LOCAL_MODULE := art-run-tests |
| 173 | LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_MAKE_TARGETS) |
| 174 | include $(BUILD_PHONY_PACKAGE) |
| 175 | |
| 176 | # clear temp vars |
| 177 | TEST_ART_RUN_TEST_MAKE_TARGETS := |
| 178 | declare-make-art-run-test := |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 179 | |
| 180 | ######################################################################## |