blob: 00fbd6933b6a085507fd4947fa6325793cd24c43 [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
Ian Rogersafd9acc2014-06-17 08:21:54 -070017# The path for which all the dex files are relative, not actually the current directory.
18LOCAL_PATH := art/test
19
20include art/build/Android.common_test.mk
21include art/build/Android.common_path.mk
22
23# Subdirectories in art/test which contain dex files used as inputs for gtests.
24GTEST_DEX_DIRECTORIES := \
25 AbstractMethod \
26 AllFields \
27 ExceptionHandle \
28 GetMethodSignature \
29 Interfaces \
30 Main \
31 MyClass \
32 MyClassNatives \
33 Nested \
34 NonStaticLeafMethods \
35 ProtoCompare \
36 ProtoCompare2 \
37 StaticLeafMethods \
38 Statics \
39 StaticsFromCode \
40 Transaction \
41 XandY
42
43# Create build rules for each dex file recording the dependency.
44$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-gtest,$(dir), \
Ian Rogers1a2f84e2014-07-07 16:05:18 -070045 $(ART_TARGET_NATIVETEST_OUT),art/build/Android.gtest.mk,ART_TEST_TARGET_GTEST_$(dir)_DEX, \
46 ART_TEST_HOST_GTEST_$(dir)_DEX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -070047
48# Dex file dependencies for each gtest.
Brian Carlstromeb85f2b2014-06-25 13:23:00 -070049ART_GTEST_class_linker_test_DEX_DEPS := Interfaces MyClass Nested Statics StaticsFromCode
50ART_GTEST_compiler_driver_test_DEX_DEPS := AbstractMethod
Andreas Gampeda823442014-11-03 15:36:53 -080051ART_GTEST_dex_file_test_DEX_DEPS := GetMethodSignature Main Nested
Brian Carlstromeb85f2b2014-06-25 13:23:00 -070052ART_GTEST_exception_test_DEX_DEPS := ExceptionHandle
53ART_GTEST_jni_compiler_test_DEX_DEPS := MyClassNatives
54ART_GTEST_jni_internal_test_DEX_DEPS := AllFields StaticLeafMethods
55ART_GTEST_object_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
56ART_GTEST_proxy_test_DEX_DEPS := Interfaces
57ART_GTEST_reflection_test_DEX_DEPS := Main NonStaticLeafMethods StaticLeafMethods
58ART_GTEST_stub_test_DEX_DEPS := AllFields
59ART_GTEST_transaction_test_DEX_DEPS := Transaction
Ian Rogersafd9acc2014-06-17 08:21:54 -070060
61# The elf writer test has dependencies on core.oat.
Andreas Gampec23c9c92014-10-28 14:47:25 -070062ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_IMAGE_default_no-pic_64) $(HOST_CORE_IMAGE_default_no-pic_32)
63ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_default_no-pic_64) $(TARGET_CORE_IMAGE_default_no-pic_32)
Brian Carlstromdeb6fe22014-08-18 16:07:10 -070064ART_GTEST_jni_internal_test_TARGET_DEPS := $(TARGET_CORE_DEX_FILES)
65ART_GTEST_proxy_test_TARGET_DEPS := $(TARGET_CORE_DEX_FILES)
Andreas Gampec23c9c92014-10-28 14:47:25 -070066ART_GTEST_proxy_test_HOST_DEPS := $(HOST_CORE_IMAGE_default_no-pic_64) $(HOST_CORE_IMAGE_default_no-pic_32)
Nicolas Geoffray96a63452014-10-30 12:13:17 +000067ART_GTEST_dex_method_iterator_test_TARGET_DEPS := $(TARGET_CORE_JARS)
Ian Rogersafd9acc2014-06-17 08:21:54 -070068
69# The path for which all the source files are relative, not actually the current directory.
Brian Carlstrom7940e442013-07-12 13:46:57 -070070LOCAL_PATH := art
71
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080072RUNTIME_GTEST_COMMON_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -070073 runtime/arch/arch_test.cc \
Serban Constantinescu86797a72014-06-19 16:17:56 +010074 runtime/arch/memcmp16_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -070075 runtime/arch/stub_test.cc \
76 runtime/barrier_test.cc \
77 runtime/base/bit_field_test.cc \
78 runtime/base/bit_vector_test.cc \
79 runtime/base/hex_dump_test.cc \
80 runtime/base/histogram_test.cc \
81 runtime/base/mutex_test.cc \
82 runtime/base/scoped_flock_test.cc \
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070083 runtime/base/stringprintf_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -070084 runtime/base/timing_logger_test.cc \
85 runtime/base/unix_file/fd_file_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -070086 runtime/base/unix_file/null_file_test.cc \
87 runtime/base/unix_file/random_access_file_utils_test.cc \
88 runtime/base/unix_file/string_file_test.cc \
89 runtime/class_linker_test.cc \
90 runtime/dex_file_test.cc \
91 runtime/dex_file_verifier_test.cc \
92 runtime/dex_instruction_visitor_test.cc \
93 runtime/dex_method_iterator_test.cc \
94 runtime/entrypoints/math_entrypoints_test.cc \
95 runtime/entrypoints/quick/quick_trampoline_entrypoints_test.cc \
96 runtime/entrypoints_order_test.cc \
97 runtime/exception_test.cc \
Mathieu Chartier2c265012014-08-05 18:15:56 -070098 runtime/gc/accounting/card_table_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -070099 runtime/gc/accounting/space_bitmap_test.cc \
100 runtime/gc/heap_test.cc \
101 runtime/gc/space/dlmalloc_space_base_test.cc \
102 runtime/gc/space/dlmalloc_space_static_test.cc \
103 runtime/gc/space/dlmalloc_space_random_test.cc \
104 runtime/gc/space/rosalloc_space_base_test.cc \
105 runtime/gc/space/rosalloc_space_static_test.cc \
106 runtime/gc/space/rosalloc_space_random_test.cc \
107 runtime/gc/space/large_object_space_test.cc \
108 runtime/gtest_test.cc \
109 runtime/handle_scope_test.cc \
110 runtime/indenter_test.cc \
111 runtime/indirect_reference_table_test.cc \
112 runtime/instruction_set_test.cc \
113 runtime/intern_table_test.cc \
Ian Rogers5ac814a2014-11-04 16:39:32 -0800114 runtime/interpreter/safe_math_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700115 runtime/leb128_test.cc \
116 runtime/mem_map_test.cc \
117 runtime/mirror/dex_cache_test.cc \
118 runtime/mirror/object_test.cc \
Andreas Gampe74240812014-04-17 10:35:09 -0700119 runtime/monitor_pool_test.cc \
Elena Sayapina1af6a1f2014-06-20 16:58:37 +0700120 runtime/monitor_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700121 runtime/parsed_options_test.cc \
122 runtime/reference_table_test.cc \
123 runtime/thread_pool_test.cc \
124 runtime/transaction_test.cc \
125 runtime/utils_test.cc \
126 runtime/verifier/method_verifier_test.cc \
127 runtime/verifier/reg_type_test.cc \
128 runtime/zip_archive_test.cc
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800129
130COMPILER_GTEST_COMMON_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700131 runtime/jni_internal_test.cc \
Jeff Haodb8a6642014-08-14 17:18:52 -0700132 runtime/proxy_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700133 runtime/reflection_test.cc \
Vladimir Marko95a05972014-05-30 10:01:32 +0100134 compiler/dex/global_value_numbering_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700135 compiler/dex/local_value_numbering_test.cc \
Vladimir Marko55fff042014-07-10 12:42:52 +0100136 compiler/dex/mir_graph_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700137 compiler/dex/mir_optimization_test.cc \
138 compiler/driver/compiler_driver_test.cc \
139 compiler/elf_writer_test.cc \
140 compiler/image_test.cc \
141 compiler/jni/jni_compiler_test.cc \
142 compiler/oat_test.cc \
143 compiler/optimizing/codegen_test.cc \
Roland Levillain72bceff2014-09-15 18:29:00 +0100144 compiler/optimizing/dead_code_elimination_test.cc \
Roland Levillain75be2832014-10-17 17:02:00 +0100145 compiler/optimizing/constant_folding_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700146 compiler/optimizing/dominator_test.cc \
147 compiler/optimizing/find_loops_test.cc \
Roland Levillainccc07a92014-09-16 14:48:16 +0100148 compiler/optimizing/graph_checker_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700149 compiler/optimizing/graph_test.cc \
Nicolas Geoffrayd31cf3d2014-09-08 17:30:24 +0100150 compiler/optimizing/gvn_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700151 compiler/optimizing/linearize_test.cc \
152 compiler/optimizing/liveness_test.cc \
153 compiler/optimizing/live_interval_test.cc \
154 compiler/optimizing/live_ranges_test.cc \
Nicolas Geoffray724c9632014-09-22 12:27:27 +0100155 compiler/optimizing/nodes_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700156 compiler/optimizing/parallel_move_test.cc \
157 compiler/optimizing/pretty_printer_test.cc \
158 compiler/optimizing/register_allocator_test.cc \
159 compiler/optimizing/ssa_test.cc \
Nicolas Geoffray99ea58c2014-07-02 15:08:17 +0100160 compiler/optimizing/stack_map_test.cc \
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000161 compiler/optimizing/suspend_check_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700162 compiler/output_stream_test.cc \
163 compiler/utils/arena_allocator_test.cc \
164 compiler/utils/dedupe_set_test.cc \
165 compiler/utils/arm/managed_register_arm_test.cc \
166 compiler/utils/arm64/managed_register_arm64_test.cc \
167 compiler/utils/x86/managed_register_x86_test.cc \
Brian Carlstrom51c24672013-07-11 16:00:56 -0700168
Dragos Sbirlea8cc51622013-06-21 09:20:34 -0700169ifeq ($(ART_SEA_IR_MODE),true)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800170COMPILER_GTEST_COMMON_SRC_FILES += \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700171 compiler/utils/scoped_hashtable_test.cc \
172 compiler/sea_ir/types/type_data_test.cc \
173 compiler/sea_ir/types/type_inference_visitor_test.cc \
174 compiler/sea_ir/ir/regions_test.cc
Dragos Sbirlea8cc51622013-06-21 09:20:34 -0700175endif
176
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800177RUNTIME_GTEST_TARGET_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700178 $(RUNTIME_GTEST_COMMON_SRC_FILES)
Brian Carlstrom51c24672013-07-11 16:00:56 -0700179
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800180RUNTIME_GTEST_HOST_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700181 $(RUNTIME_GTEST_COMMON_SRC_FILES)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800182
183COMPILER_GTEST_TARGET_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700184 $(COMPILER_GTEST_COMMON_SRC_FILES)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800185
186COMPILER_GTEST_HOST_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700187 $(COMPILER_GTEST_COMMON_SRC_FILES) \
Nicolas Geoffray1a43dd72014-07-17 15:15:34 +0100188 compiler/utils//assembler_thumb_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700189 compiler/utils/x86/assembler_x86_test.cc \
190 compiler/utils/x86_64/assembler_x86_64_test.cc
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -0700191
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800192ART_TEST_CFLAGS :=
buzbeec531cef2012-10-18 07:09:20 -0700193ifeq ($(ART_USE_PORTABLE_COMPILER),true)
194 ART_TEST_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
buzbee2cfc6392012-05-07 14:51:40 -0700195endif
196
Ian Rogerse63db272014-07-15 15:36:11 -0700197include $(CLEAR_VARS)
198LOCAL_MODULE := libart-gtest
199LOCAL_MODULE_TAGS := optional
200LOCAL_CPP_EXTENSION := cc
201LOCAL_CFLAGS := $(ART_TARGET_CFLAGS)
202LOCAL_SRC_FILES := runtime/common_runtime_test.cc compiler/common_compiler_test.cc
203LOCAL_C_INCLUDES := $(ART_C_INCLUDES) art/runtime art/compiler
Ian Rogers872dd822014-10-30 11:19:14 -0700204LOCAL_SHARED_LIBRARIES := libartd libartd-compiler libdl
Ian Rogerse63db272014-07-15 15:36:11 -0700205LOCAL_STATIC_LIBRARIES += libgtest_libc++
206LOCAL_CLANG := $(ART_TARGET_CLANG)
207LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
208LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
209include external/libcxx/libcxx.mk
210include $(BUILD_SHARED_LIBRARY)
211
212include $(CLEAR_VARS)
213LOCAL_MODULE := libart-gtest
214LOCAL_MODULE_TAGS := optional
215LOCAL_CPP_EXTENSION := cc
216LOCAL_CFLAGS := $(ART_HOST_CFLAGS)
217LOCAL_SRC_FILES := runtime/common_runtime_test.cc compiler/common_compiler_test.cc
218LOCAL_C_INCLUDES := $(ART_C_INCLUDES) art/runtime art/compiler
219LOCAL_SHARED_LIBRARIES := libartd libartd-compiler
Ian Rogers872dd822014-10-30 11:19:14 -0700220LOCAL_STATIC_LIBRARIES := libgtest_libc++_host
Ian Rogerse63db272014-07-15 15:36:11 -0700221LOCAL_LDLIBS += -ldl -lpthread
222LOCAL_MULTILIB := both
223LOCAL_CLANG := $(ART_HOST_CLANG)
224LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
225LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
226include external/libcxx/libcxx.mk
227include $(BUILD_HOST_SHARED_LIBRARY)
228
Ian Rogersafd9acc2014-06-17 08:21:54 -0700229# Variables holding collections of gtest pre-requisits used to run a number of gtests.
230ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
231ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
232ART_TEST_HOST_GTEST_RULES :=
233ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
234ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
235ART_TEST_HOST_VALGRIND_GTEST_RULES :=
236ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
237ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
238ART_TEST_TARGET_GTEST_RULES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700239
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000240ART_GTEST_TARGET_ANDROID_ROOT := '/system'
241ifneq ($(ART_TEST_ANDROID_ROOT),)
242 ART_GTEST_TARGET_ANDROID_ROOT := $(ART_TEST_ANDROID_ROOT)
243endif
244
Ian Rogersafd9acc2014-06-17 08:21:54 -0700245# Define a make rule for a target device gtest.
246# $(1): gtest name - the name of the test we're building such as leb128_test.
247# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000248# $(3): LD_LIBRARY_PATH or undefined - used in case libartd.so is not in /system/lib/
Ian Rogersafd9acc2014-06-17 08:21:54 -0700249define define-art-gtest-rule-target
250 gtest_rule := test-art-target-gtest-$(1)$$($(2)ART_PHONY_TEST_TARGET_SUFFIX)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700251
Brian Carlstrom532714a2014-06-25 02:15:31 -0700252 # Add the test dependencies to test-art-target-sync, which will be a prerequisite for the test
Ian Rogersafd9acc2014-06-17 08:21:54 -0700253 # to ensure files are pushed to the device.
254 TEST_ART_TARGET_SYNC_DEPS += \
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700255 $$(ART_GTEST_$(1)_TARGET_DEPS) \
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700256 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700257 $$(ART_TARGET_NATIVETEST_OUT)/$$(TARGET_$(2)ARCH)/$(1) \
Nicolas Geoffray96a63452014-10-30 12:13:17 +0000258 $$($(2)TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so \
259 $$(TARGET_OUT_JAVA_LIBRARIES)/core-libart.jar
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700260
Ian Rogersafd9acc2014-06-17 08:21:54 -0700261.PHONY: $$(gtest_rule)
262$$(gtest_rule): test-art-target-sync
263 $(hide) adb shell touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID
264 $(hide) adb shell rm $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID
265 $(hide) adb shell chmod 755 $(ART_TARGET_NATIVETEST_DIR)/$(TARGET_$(2)ARCH)/$(1)
266 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000267 (adb shell "LD_LIBRARY_PATH=$(3) ANDROID_ROOT=$(ART_GTEST_TARGET_ANDROID_ROOT) \
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000268 $(ART_TARGET_NATIVETEST_DIR)/$(TARGET_$(2)ARCH)/$(1) && touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID" \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700269 && (adb pull $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID /tmp/ \
270 && $$(call ART_TEST_PASSED,$$@)) \
271 || $$(call ART_TEST_FAILED,$$@))
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700272 $(hide) rm -f /tmp/$$@-$$$$PPID
Ian Rogersafd9acc2014-06-17 08:21:54 -0700273
274 ART_TEST_TARGET_GTEST$($(2)ART_PHONY_TEST_TARGET_SUFFIX)_RULES += $$(gtest_rule)
275 ART_TEST_TARGET_GTEST_RULES += $$(gtest_rule)
276 ART_TEST_TARGET_GTEST_$(1)_RULES += $$(gtest_rule)
277
278 # Clear locally defined variables.
279 gtest_rule :=
280endef # define-art-gtest-rule-target
281
282# Define make rules for a host gtests.
283# $(1): gtest name - the name of the test we're building such as leb128_test.
284# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
285define define-art-gtest-rule-host
286 gtest_rule := test-art-host-gtest-$(1)$$($(2)ART_PHONY_TEST_HOST_SUFFIX)
287 gtest_exe := $$(HOST_OUT_EXECUTABLES)/$(1)$$($(2)ART_PHONY_TEST_HOST_SUFFIX)
Ian Rogers665de8a2014-06-24 21:34:09 -0700288 # Dependencies for all host gtests.
289 gtest_deps := $$(HOST_CORE_DEX_LOCATIONS) \
Nicolas Geoffray4d1231d2014-07-01 10:46:31 +0100290 $$($(2)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION)
Ian Rogers665de8a2014-06-24 21:34:09 -0700291
Ian Rogersafd9acc2014-06-17 08:21:54 -0700292
293.PHONY: $$(gtest_rule)
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700294$$(gtest_rule): $$(gtest_exe) $$(ART_GTEST_$(1)_HOST_DEPS) $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) $$(gtest_deps)
Dmitriy Ivanov8508a432014-10-14 11:38:46 -0700295 $(hide) ($$(call ART_TEST_SKIP,$$@) && $$< && $$(call ART_TEST_PASSED,$$@)) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700296 || $$(call ART_TEST_FAILED,$$@)
297
298 ART_TEST_HOST_GTEST$$($(2)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
299 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
300 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
301
302.PHONY: valgrind-$$(gtest_rule)
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700303valgrind-$$(gtest_rule): $$(gtest_exe) $$(ART_GTEST_$(1)_HOST_DEPS) $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) $$(gtest_deps)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700304 $(hide) $$(call ART_TEST_SKIP,$$@) && \
305 valgrind --leak-check=full --error-exitcode=1 $$< && $$(call ART_TEST_PASSED,$$@) \
306 || $$(call ART_TEST_FAILED,$$@)
307
308 ART_TEST_HOST_VALGRIND_GTEST$$($(2)ART_PHONY_TEST_HOST_SUFFIX)_RULES += valgrind-$$(gtest_rule)
309 ART_TEST_HOST_VALGRIND_GTEST_RULES += valgrind-$$(gtest_rule)
310 ART_TEST_HOST_VALGRIND_GTEST_$(1)_RULES += valgrind-$$(gtest_rule)
311
312 # Clear locally defined variables.
313 valgrind_gtest_rule :=
314 gtest_rule :=
315 gtest_exe :=
Ian Rogers665de8a2014-06-24 21:34:09 -0700316 gtest_deps :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700317endef # define-art-gtest-rule-host
318
319# Define the rules to build and run host and target gtests.
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700320# $(1): target or host
Brian Carlstrom0796af02011-10-12 14:31:45 -0700321# $(2): file name
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800322# $(3): extra C includes
323# $(4): extra shared libraries
Ian Rogersafd9acc2014-06-17 08:21:54 -0700324define define-art-gtest
Brian Carlstrom0796af02011-10-12 14:31:45 -0700325 ifneq ($(1),target)
326 ifneq ($(1),host)
327 $$(error expected target or host for argument 1, received $(1))
328 endif
329 endif
330
331 art_target_or_host := $(1)
332 art_gtest_filename := $(2)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800333 art_gtest_extra_c_includes := $(3)
334 art_gtest_extra_shared_libraries := $(4)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700335
Ian Rogersafd9acc2014-06-17 08:21:54 -0700336 include $$(CLEAR_VARS)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700337 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700338 LOCAL_MODULE := $$(art_gtest_name)
Brian Carlstrom871599a2012-09-06 13:27:49 -0700339 ifeq ($$(art_target_or_host),target)
340 LOCAL_MODULE_TAGS := tests
341 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700342 LOCAL_CPP_EXTENSION := $$(ART_CPP_EXTENSION)
Dmitriy Ivanove49a4f62014-10-20 14:11:00 -0700343 LOCAL_SRC_FILES := $$(art_gtest_filename)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700344 LOCAL_C_INCLUDES += $$(ART_C_INCLUDES) art/runtime $$(art_gtest_extra_c_includes)
Ian Rogerse63db272014-07-15 15:36:11 -0700345 LOCAL_SHARED_LIBRARIES += libartd $$(art_gtest_extra_shared_libraries) libart-gtest
Dmitriy Ivanove49a4f62014-10-20 14:11:00 -0700346 LOCAL_WHOLE_STATIC_LIBRARIES += libsigchain
Brian Carlstrom4478eb02013-07-14 21:05:57 -0700347
Ian Rogerse63db272014-07-15 15:36:11 -0700348 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
349 LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -0800350
Elliott Hughes0f096762012-01-31 10:32:46 -0800351 # Mac OS linker doesn't understand --export-dynamic.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700352 ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host)
Elliott Hughesb264f082012-04-06 17:10:10 -0700353 # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...).
354 LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar
Brian Carlstromcfede662012-01-29 17:25:54 -0800355 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -0700356
Ian Rogersafd9acc2014-06-17 08:21:54 -0700357 LOCAL_CFLAGS := $$(ART_TEST_CFLAGS)
Dan Albert2a0e9542014-05-21 14:55:02 -0700358 include external/libcxx/libcxx.mk
Brian Carlstrom0796af02011-10-12 14:31:45 -0700359 ifeq ($$(art_target_or_host),target)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700360 $$(eval $$(call set-target-local-clang-vars))
361 $$(eval $$(call set-target-local-cflags-vars,debug))
Serban Constantinescu15523732014-04-02 13:18:05 +0100362 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libz libcutils libvixl
Ian Rogersafd9acc2014-06-17 08:21:54 -0700363 LOCAL_MODULE_PATH_32 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_32)
364 LOCAL_MODULE_PATH_64 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_64)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700365 LOCAL_MULTILIB := both
Ian Rogersafd9acc2014-06-17 08:21:54 -0700366 include $$(BUILD_EXECUTABLE)
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000367 library_path :=
368 2nd_library_path :=
369 ifneq ($$(ART_TEST_ANDROID_ROOT),)
370 ifdef TARGET_2ND_ARCH
371 2nd_library_path := $$(ART_TEST_ANDROID_ROOT)/lib
372 library_path := $$(ART_TEST_ANDROID_ROOT)/lib64
373 else
374 library_path := $$(ART_TEST_ANDROID_ROOT)/lib
375 endif
376 endif
Andreas Gampe5ca4eaa2014-05-29 02:09:33 -0700377
Ian Rogersafd9acc2014-06-17 08:21:54 -0700378 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700379 ifdef TARGET_2ND_ARCH
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000380 $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),2ND_,$$(2nd_library_path)))
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700381 endif
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000382 $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),,$$(library_path)))
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700383
Ian Rogersafd9acc2014-06-17 08:21:54 -0700384 # A rule to run the different architecture versions of the gtest.
385.PHONY: test-art-target-gtest-$$(art_gtest_name)
386test-art-target-gtest-$$(art_gtest_name): $$(ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES)
387 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
388
389 # Clear locally defined variables.
390 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
Brian Carlstrom0796af02011-10-12 14:31:45 -0700391 else # host
Ian Rogersafd9acc2014-06-17 08:21:54 -0700392 LOCAL_CLANG := $$(ART_HOST_CLANG)
393 LOCAL_CFLAGS += $$(ART_HOST_CFLAGS) $$(ART_HOST_DEBUG_CFLAGS)
Ian Rogers872dd822014-10-30 11:19:14 -0700394 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libziparchive-host libz-host libvixl
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700395 LOCAL_LDLIBS := $(ART_HOST_LDLIBS) -lpthread -ldl
Ian Rogersbd5ea6a2014-04-16 16:34:44 -0700396 LOCAL_IS_HOST_MODULE := true
Ian Rogersafd9acc2014-06-17 08:21:54 -0700397 LOCAL_MULTILIB := both
398 LOCAL_MODULE_STEM_32 := $$(art_gtest_name)32
399 LOCAL_MODULE_STEM_64 := $$(art_gtest_name)64
400 include $$(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700401
Ian Rogersafd9acc2014-06-17 08:21:54 -0700402 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
403 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
404 ifneq ($$(HOST_PREFER_32_BIT),true)
405 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),2ND_))
406 endif
407 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),))
Ian Rogersd912e5c2013-11-13 12:40:11 -0800408
Ian Rogersafd9acc2014-06-17 08:21:54 -0700409 # Rules to run the different architecture versions of the gtest.
410.PHONY: test-art-host-gtest-$$(art_gtest_name)
411test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
412 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800413
Ian Rogersafd9acc2014-06-17 08:21:54 -0700414.PHONY: valgrind-test-art-host-gtest-$$(art_gtest_name)
415valgrind-test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES)
416 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
417
418 # Clear locally defined variables.
419 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
420 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
421 endif # host_or_target
422
423 # Clear locally defined variables.
424 art_target_or_host :=
425 art_gtest_filename :=
426 art_gtest_extra_c_includes :=
427 art_gtest_extra_shared_libraries :=
428 art_gtest_name :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000429 library_path :=
430 2nd_library_path :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700431endef # define-art-gtest
Carl Shapiro008e4122011-06-23 17:27:46 -0700432
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700433ifeq ($(ART_BUILD_TARGET),true)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700434 $(foreach file,$(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval $(call define-art-gtest,target,$(file),,)))
435 $(foreach file,$(COMPILER_GTEST_TARGET_SRC_FILES), $(eval $(call define-art-gtest,target,$(file),art/compiler,libartd-compiler)))
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700436endif
Ian Rogersc5f17732014-06-05 20:48:42 -0700437ifeq ($(ART_BUILD_HOST),true)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700438 $(foreach file,$(RUNTIME_GTEST_HOST_SRC_FILES), $(eval $(call define-art-gtest,host,$(file),,)))
439 $(foreach file,$(COMPILER_GTEST_HOST_SRC_FILES), $(eval $(call define-art-gtest,host,$(file),art/compiler,libartd-compiler)))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700440endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700441
442# Used outside the art project to get a list of the current tests
443RUNTIME_TARGET_GTEST_MAKE_TARGETS :=
444$(foreach file, $(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval RUNTIME_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
445COMPILER_TARGET_GTEST_MAKE_TARGETS :=
446$(foreach file, $(COMPILER_GTEST_TARGET_SRC_FILES), $(eval COMPILER_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700447
448# Define all the combinations of host/target, valgrind and suffix such as:
449# test-art-host-gtest or valgrind-test-art-host-gtest64
450# $(1): host or target
451# $(2): HOST or TARGET
452# $(3): valgrind- or undefined
453# $(4): undefined, 32 or 64
454define define-test-art-gtest-combination
455 ifeq ($(1),host)
456 ifneq ($(2),HOST)
457 $$(error argument mismatch $(1) and ($2))
458 endif
459 else
460 ifneq ($(1),target)
461 $$(error found $(1) expected host or target)
462 endif
463 ifneq ($(2),TARGET)
464 $$(error argument mismatch $(1) and ($2))
465 endif
466 endif
467
468 rule_name := $(3)test-art-$(1)-gtest$(4)
Andreas Gampe928f72b2014-09-09 19:53:48 -0700469 ifeq ($(3),valgrind-)
470 ifneq ($(1),host)
471 $$(error valgrind tests only wired up for the host)
472 endif
473 dependencies := $$(ART_TEST_$(2)_VALGRIND_GTEST$(4)_RULES)
474 else
475 dependencies := $$(ART_TEST_$(2)_GTEST$(4)_RULES)
476 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700477
478.PHONY: $$(rule_name)
479$$(rule_name): $$(dependencies)
480 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
481
482 # Clear locally defined variables.
483 rule_name :=
484 dependencies :=
485endef # define-test-art-gtest-combination
486
487$(eval $(call define-test-art-gtest-combination,target,TARGET,,))
488$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(ART_PHONY_TEST_TARGET_SUFFIX)))
489ifdef TARGET_2ND_ARCH
490$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
491endif
492$(eval $(call define-test-art-gtest-combination,host,HOST,,))
493$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,))
494$(eval $(call define-test-art-gtest-combination,host,HOST,,$(ART_PHONY_TEST_HOST_SUFFIX)))
495$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(ART_PHONY_TEST_HOST_SUFFIX)))
496ifneq ($(HOST_PREFER_32_BIT),true)
497$(eval $(call define-test-art-gtest-combination,host,HOST,,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
498$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
499endif
500
501# Clear locally defined variables.
502define-art-gtest-rule-target :=
503define-art-gtest-rule-host :=
504define-art-gtest :=
505define-test-art-gtest-combination :=
506RUNTIME_GTEST_COMMON_SRC_FILES :=
507COMPILER_GTEST_COMMON_SRC_FILES :=
508RUNTIME_GTEST_TARGET_SRC_FILES :=
509RUNTIME_GTEST_HOST_SRC_FILES :=
510COMPILER_GTEST_TARGET_SRC_FILES :=
511COMPILER_GTEST_HOST_SRC_FILES :=
512ART_TEST_CFLAGS :=
513ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
514ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
515ART_TEST_HOST_GTEST_RULES :=
516ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
517ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
518ART_TEST_HOST_VALGRIND_GTEST_RULES :=
519ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
520ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
521ART_TEST_TARGET_GTEST_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000522ART_GTEST_TARGET_ANDROID_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700523ART_GTEST_class_linker_test_DEX_DEPS :=
524ART_GTEST_compiler_driver_test_DEX_DEPS :=
525ART_GTEST_dex_file_test_DEX_DEPS :=
526ART_GTEST_exception_test_DEX_DEPS :=
527ART_GTEST_elf_writer_test_HOST_DEPS :=
528ART_GTEST_elf_writer_test_TARGET_DEPS :=
529ART_GTEST_jni_compiler_test_DEX_DEPS :=
530ART_GTEST_jni_internal_test_DEX_DEPS :=
531ART_GTEST_object_test_DEX_DEPS :=
532ART_GTEST_proxy_test_DEX_DEPS :=
533ART_GTEST_reflection_test_DEX_DEPS :=
534ART_GTEST_stub_test_DEX_DEPS :=
535ART_GTEST_transaction_test_DEX_DEPS :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700536$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
537$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700538GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700539LOCAL_PATH :=