blob: 406c2a187f1a93895894c0583605df71895e31fe [file] [log] [blame]
Carl Shapiro008e4122011-06-23 17:27:46 -07001#
2# Copyright (C) 2011 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
Brian Carlstrom7940e442013-07-12 13:46:57 -070017LOCAL_PATH := art
18
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080019RUNTIME_GTEST_COMMON_SRC_FILES := \
Andreas Gampe5c1e4352014-04-21 19:28:24 -070020 runtime/arch/arch_test.cc \
Andreas Gampe525cde22014-04-22 15:44:50 -070021 runtime/arch/stub_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070022 runtime/barrier_test.cc \
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +010023 runtime/base/bit_field_test.cc \
Brian Carlstromba150c32013-08-27 17:31:03 -070024 runtime/base/bit_vector_test.cc \
Ian Rogers43b2e0f2014-01-30 16:58:39 -080025 runtime/base/hex_dump_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070026 runtime/base/histogram_test.cc \
27 runtime/base/mutex_test.cc \
Anwar Ghuloum4446ab92013-08-09 21:17:25 -070028 runtime/base/timing_logger_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070029 runtime/base/unix_file/fd_file_test.cc \
30 runtime/base/unix_file/mapped_file_test.cc \
31 runtime/base/unix_file/null_file_test.cc \
32 runtime/base/unix_file/random_access_file_utils_test.cc \
33 runtime/base/unix_file/string_file_test.cc \
34 runtime/class_linker_test.cc \
35 runtime/dex_file_test.cc \
36 runtime/dex_instruction_visitor_test.cc \
37 runtime/dex_method_iterator_test.cc \
Ian Rogers7655f292013-07-29 11:07:13 -070038 runtime/entrypoints/math_entrypoints_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070039 runtime/exception_test.cc \
40 runtime/gc/accounting/space_bitmap_test.cc \
41 runtime/gc/heap_test.cc \
Andreas Gampe24651ec2014-02-27 13:26:16 -080042 runtime/gc/space/dlmalloc_space_base_test.cc \
43 runtime/gc/space/dlmalloc_space_static_test.cc \
44 runtime/gc/space/dlmalloc_space_random_test.cc \
45 runtime/gc/space/rosalloc_space_base_test.cc \
46 runtime/gc/space/rosalloc_space_static_test.cc \
47 runtime/gc/space/rosalloc_space_random_test.cc \
Andreas Gampea7433512014-02-21 13:19:23 -080048 runtime/gc/space/large_object_space_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070049 runtime/gtest_test.cc \
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070050 runtime/handle_scope_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070051 runtime/indenter_test.cc \
52 runtime/indirect_reference_table_test.cc \
Narayan Kamath11d9f062014-04-23 20:24:57 +010053 runtime/instruction_set_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070054 runtime/intern_table_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080055 runtime/leb128_test.cc \
Brian Carlstrom9004cb62013-07-26 15:48:31 -070056 runtime/mem_map_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070057 runtime/mirror/dex_cache_test.cc \
58 runtime/mirror/object_test.cc \
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080059 runtime/parsed_options_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070060 runtime/reference_table_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070061 runtime/thread_pool_test.cc \
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010062 runtime/transaction_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070063 runtime/utils_test.cc \
64 runtime/verifier/method_verifier_test.cc \
65 runtime/verifier/reg_type_test.cc \
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070066 runtime/zip_archive_test.cc
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080067
68COMPILER_GTEST_COMMON_SRC_FILES := \
69 runtime/jni_internal_test.cc \
Sebastien Hertzb7054ba2014-03-13 11:52:31 +010070 runtime/proxy_test.cc \
Ian Rogers53b8b092014-03-13 23:45:53 -070071 runtime/reflection_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080072 compiler/dex/local_value_numbering_test.cc \
Vladimir Markobfea9c22014-01-17 17:49:33 +000073 compiler/dex/mir_optimization_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080074 compiler/driver/compiler_driver_test.cc \
75 compiler/elf_writer_test.cc \
76 compiler/image_test.cc \
77 compiler/jni/jni_compiler_test.cc \
78 compiler/oat_test.cc \
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000079 compiler/optimizing/codegen_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080080 compiler/optimizing/dominator_test.cc \
Nicolas Geoffray622d9c32014-05-12 16:11:02 +010081 compiler/optimizing/find_loops_test.cc \
Nicolas Geoffray804d0932014-05-02 08:46:00 +010082 compiler/optimizing/liveness_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080083 compiler/optimizing/pretty_printer_test.cc \
Nicolas Geoffrayc32e7702014-04-24 12:43:16 +010084 compiler/optimizing/ssa_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080085 compiler/output_stream_test.cc \
86 compiler/utils/arena_allocator_test.cc \
87 compiler/utils/dedupe_set_test.cc \
88 compiler/utils/arm/managed_register_arm_test.cc \
Serban Constantinescued8dd492014-02-11 14:15:10 +000089 compiler/utils/arm64/managed_register_arm64_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080090 compiler/utils/x86/managed_register_x86_test.cc \
Brian Carlstrom51c24672013-07-11 16:00:56 -070091
Dragos Sbirlea8cc51622013-06-21 09:20:34 -070092ifeq ($(ART_SEA_IR_MODE),true)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080093COMPILER_GTEST_COMMON_SRC_FILES += \
Dragos Sbirlea423fb4d2013-08-05 18:33:30 -070094 compiler/utils/scoped_hashtable_test.cc \
95 compiler/sea_ir/types/type_data_test.cc \
Dragos Sbirlea597e46b2013-08-07 18:15:44 -070096 compiler/sea_ir/types/type_inference_visitor_test.cc \
97 compiler/sea_ir/ir/regions_test.cc
Dragos Sbirlea8cc51622013-06-21 09:20:34 -070098endif
99
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800100RUNTIME_GTEST_TARGET_SRC_FILES := \
101 $(RUNTIME_GTEST_COMMON_SRC_FILES)
Brian Carlstrom51c24672013-07-11 16:00:56 -0700102
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800103RUNTIME_GTEST_HOST_SRC_FILES := \
104 $(RUNTIME_GTEST_COMMON_SRC_FILES)
105
106COMPILER_GTEST_TARGET_SRC_FILES := \
107 $(COMPILER_GTEST_COMMON_SRC_FILES)
108
109COMPILER_GTEST_HOST_SRC_FILES := \
110 $(COMPILER_GTEST_COMMON_SRC_FILES) \
Andreas Gampe5a4fa822014-03-31 16:50:12 -0700111 compiler/utils/x86/assembler_x86_test.cc \
112 compiler/utils/x86_64/assembler_x86_64_test.cc
Brian Carlstrom51c24672013-07-11 16:00:56 -0700113
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800114ART_HOST_GTEST_EXECUTABLES :=
Andreas Gampe2fe07922014-04-21 07:50:39 -0700115ART_TARGET_GTEST_EXECUTABLES$(ART_PHONY_TEST_TARGET_SUFFIX) :=
116ART_TARGET_GTEST_EXECUTABLES$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) :=
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800117ART_HOST_GTEST_TARGETS :=
118ART_HOST_VALGRIND_GTEST_TARGETS :=
Andreas Gampe2fe07922014-04-21 07:50:39 -0700119ART_TARGET_GTEST_TARGETS$(ART_PHONY_TEST_TARGET_SUFFIX) :=
120ART_TARGET_GTEST_TARGETS$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) :=
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -0700121
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800122ART_TEST_CFLAGS :=
buzbeec531cef2012-10-18 07:09:20 -0700123ifeq ($(ART_USE_PORTABLE_COMPILER),true)
124 ART_TEST_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
buzbee2cfc6392012-05-07 14:51:40 -0700125endif
126
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700127# Build a make target for a target test.
128# (1) Prefix for variables
129define build-art-test-make-target
130.PHONY: $$(art_gtest_target)$($(1)ART_PHONY_TEST_TARGET_SUFFIX)
131$$(art_gtest_target)$($(1)ART_PHONY_TEST_TARGET_SUFFIX): $($(1)ART_NATIVETEST_OUT)/$$(LOCAL_MODULE) test-art-target-sync
132 adb shell touch $($(1)ART_TEST_DIR)/$$@
133 adb shell rm $($(1)ART_TEST_DIR)/$$@
134 adb shell chmod 755 $($(1)ART_NATIVETEST_DIR)/$$(notdir $$<)
135 adb shell sh -c "$($(1)ART_NATIVETEST_DIR)/$$(notdir $$<) && touch $($(1)ART_TEST_DIR)/$$@"
136 $(hide) (adb pull $($(1)ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1)
137 $(hide) rm /tmp/$$@
138
Andreas Gampe2fe07922014-04-21 07:50:39 -0700139 ART_TARGET_GTEST_TARGETS$($(1)ART_PHONY_TEST_TARGET_SUFFIX) += $$(art_gtest_target)$($(1)ART_PHONY_TEST_TARGET_SUFFIX)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700140endef
141
142
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700143# $(1): target or host
Brian Carlstrom0796af02011-10-12 14:31:45 -0700144# $(2): file name
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800145# $(3): extra C includes
146# $(4): extra shared libraries
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700147define build-art-test
Brian Carlstrom0796af02011-10-12 14:31:45 -0700148 ifneq ($(1),target)
149 ifneq ($(1),host)
150 $$(error expected target or host for argument 1, received $(1))
151 endif
152 endif
153
154 art_target_or_host := $(1)
155 art_gtest_filename := $(2)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800156 art_gtest_extra_c_includes := $(3)
157 art_gtest_extra_shared_libraries := $(4)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700158
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700159 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
160
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700161 include $(CLEAR_VARS)
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700162 LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700163 LOCAL_MODULE := $$(art_gtest_name)
Brian Carlstrom871599a2012-09-06 13:27:49 -0700164 ifeq ($$(art_target_or_host),target)
165 LOCAL_MODULE_TAGS := tests
166 endif
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800167 LOCAL_SRC_FILES := $$(art_gtest_filename) runtime/common_runtime_test.cc
168 LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime $(3)
169 LOCAL_SHARED_LIBRARIES += libartd $(4)
170 # dex2oatd is needed to go with libartd
Elliott Hughes025218c2013-07-30 17:13:06 -0700171 LOCAL_REQUIRED_MODULES := dex2oatd
Brian Carlstrom4478eb02013-07-14 21:05:57 -0700172
Brian Carlstrom17bfe262013-07-16 17:31:22 -0700173 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
Brian Carlstrom7940e442013-07-12 13:46:57 -0700174 LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -0800175
Elliott Hughes0f096762012-01-31 10:32:46 -0800176 # Mac OS linker doesn't understand --export-dynamic.
177 ifneq ($(HOST_OS)-$$(art_target_or_host),darwin-host)
Elliott Hughesb264f082012-04-06 17:10:10 -0700178 # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...).
179 LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar
Brian Carlstromcfede662012-01-29 17:25:54 -0800180 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -0700181
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800182 LOCAL_CFLAGS := $(ART_TEST_CFLAGS)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700183 ifeq ($$(art_target_or_host),target)
Ian Rogerscd5d0422013-05-17 15:54:01 -0700184 LOCAL_CLANG := $(ART_TARGET_CLANG)
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800185 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
Colin Crossdc781a12014-02-04 16:22:03 -0800186 LOCAL_CFLAGS_x86 := $(ART_TARGET_CFLAGS_x86)
Serban Constantinescu15523732014-04-02 13:18:05 +0100187 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libz libcutils libvixl
Elliott Hugheseb02a122012-06-12 11:35:40 -0700188 LOCAL_STATIC_LIBRARIES += libgtest
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700189 LOCAL_MODULE_PATH_32 := $(ART_BASE_NATIVETEST_OUT)
190 LOCAL_MODULE_PATH_64 := $(ART_BASE_NATIVETEST_OUT)64
191 LOCAL_MULTILIB := both
Ian Rogersbd5ea6a2014-04-16 16:34:44 -0700192 include art/build/Android.libcxx.mk
Brian Carlstrom0796af02011-10-12 14:31:45 -0700193 include $(BUILD_EXECUTABLE)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700194
195 ART_TARGET_GTEST_EXECUTABLES$(ART_PHONY_TEST_TARGET_SUFFIX) += $(ART_NATIVETEST_OUT)/$$(LOCAL_MODULE)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700196 art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
197
198 ifdef TARGET_2ND_ARCH
199 $(call build-art-test-make-target,2ND_)
200
Andreas Gampe2fe07922014-04-21 07:50:39 -0700201 ART_TARGET_GTEST_EXECUTABLES$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) += $(2ND_ART_NATIVETEST_OUT)/$$(LOCAL_MODULE)
202
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700203 # Bind the primary to the non-suffix rule
204 ifneq ($(ART_PHONY_TEST_TARGET_SUFFIX),)
205$$(art_gtest_target): $$(art_gtest_target)$(ART_PHONY_TEST_TARGET_SUFFIX)
206 endif
207 endif
208 $(call build-art-test-make-target,)
209
Brian Carlstrom0796af02011-10-12 14:31:45 -0700210 else # host
Ian Rogerscd5d0422013-05-17 15:54:01 -0700211 LOCAL_CLANG := $(ART_HOST_CLANG)
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800212 LOCAL_CFLAGS += $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -0700213 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
Serban Constantinescu15523732014-04-02 13:18:05 +0100214 LOCAL_STATIC_LIBRARIES += libcutils libvixl
Brian Carlstrom7f2e3da2014-03-25 16:23:56 -0700215 ifneq ($(WITHOUT_HOST_CLANG),true)
216 # GCC host compiled tests fail with this linked, presumably due to destructors that run.
217 LOCAL_STATIC_LIBRARIES += libgtest_host
218 endif
Andrew Hsiehcae10f72014-04-01 11:52:01 +0800219 LOCAL_LDLIBS += -lpthread -ldl
Ian Rogersbd5ea6a2014-04-16 16:34:44 -0700220 LOCAL_IS_HOST_MODULE := true
221 include art/build/Android.libcxx.mk
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700222 include $(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700223 art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800224 ART_HOST_GTEST_EXECUTABLES += $$(art_gtest_exe)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700225 art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700226.PHONY: $$(art_gtest_target)
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700227$$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700228 $$<
229 @echo $$@ PASSED
230
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700231 ART_HOST_GTEST_TARGETS += $$(art_gtest_target)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800232
233.PHONY: valgrind-$$(art_gtest_target)
234valgrind-$$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies
Ian Rogers86aed2a2013-11-13 15:56:44 -0800235 valgrind --leak-check=full --error-exitcode=1 $$<
Ian Rogersd912e5c2013-11-13 12:40:11 -0800236 @echo $$@ PASSED
237
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700238 ART_HOST_VALGRIND_GTEST_TARGETS += valgrind-$$(art_gtest_target)
239 endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700240endef
Carl Shapiro008e4122011-06-23 17:27:46 -0700241
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700242ifeq ($(ART_BUILD_TARGET),true)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800243 $(foreach file,$(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file),,)))
244 $(foreach file,$(COMPILER_GTEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file),art/compiler,libartd-compiler)))
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700245endif
Brian Carlstrom19e776c2013-07-23 12:16:44 -0700246ifeq ($(WITH_HOST_DALVIK),true)
247 ifeq ($(ART_BUILD_HOST),true)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800248 $(foreach file,$(RUNTIME_GTEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file),,)))
249 $(foreach file,$(COMPILER_GTEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file),art/compiler,libartd-compiler)))
Brian Carlstrom19e776c2013-07-23 12:16:44 -0700250 endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700251endif