blob: 7ab4d64d45c967642f80ff4d1698a695d46eed99 [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 Carlstrom53463ea2014-11-09 14:11:51 -080064
65# TODO: document why this is needed.
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)
Ian Rogersafd9acc2014-06-17 08:21:54 -070067
Igor Murashkin37743352014-11-13 14:38:00 -080068# The imgdiag test has dependencies on core.oat since it needs to load it during the test.
Andreas Gampec93b8b52014-12-19 23:12:25 -080069# For the host, also add the installed tool (in the base size, that should suffice). For the
70# target, just the module is fine, the sync will happen late enough.
71ART_GTEST_imgdiag_test_HOST_DEPS := \
72 $(HOST_CORE_IMAGE_default_no-pic_64) \
73 $(HOST_CORE_IMAGE_default_no-pic_32) \
74 $(HOST_OUT_EXECUTABLES)/imgdiagd
75ART_GTEST_imgdiag_test_TARGET_DEPS := \
76 $(TARGET_CORE_IMAGE_default_no-pic_64) \
77 $(TARGET_CORE_IMAGE_default_no-pic_32) \
78 imgdiagd
Igor Murashkin37743352014-11-13 14:38:00 -080079
Ian Rogersafd9acc2014-06-17 08:21:54 -070080# The path for which all the source files are relative, not actually the current directory.
Brian Carlstrom7940e442013-07-12 13:46:57 -070081LOCAL_PATH := art
82
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080083RUNTIME_GTEST_COMMON_SRC_FILES := \
Igor Murashkinaaebaa02015-01-26 10:55:53 -080084 cmdline/cmdline_parser_test.cc \
Igor Murashkin37743352014-11-13 14:38:00 -080085 imgdiag/imgdiag_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -070086 runtime/arch/arch_test.cc \
Ian Rogersd582fa42014-11-05 23:46:43 -080087 runtime/arch/instruction_set_test.cc \
88 runtime/arch/instruction_set_features_test.cc \
Serban Constantinescu86797a72014-06-19 16:17:56 +010089 runtime/arch/memcmp16_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -070090 runtime/arch/stub_test.cc \
Ian Rogersd582fa42014-11-05 23:46:43 -080091 runtime/arch/arm/instruction_set_features_arm_test.cc \
92 runtime/arch/arm64/instruction_set_features_arm64_test.cc \
93 runtime/arch/mips/instruction_set_features_mips_test.cc \
Andreas Gampe57b34292015-01-14 15:45:59 -080094 runtime/arch/mips64/instruction_set_features_mips64_test.cc \
Ian Rogersd582fa42014-11-05 23:46:43 -080095 runtime/arch/x86/instruction_set_features_x86_test.cc \
96 runtime/arch/x86_64/instruction_set_features_x86_64_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -070097 runtime/barrier_test.cc \
98 runtime/base/bit_field_test.cc \
99 runtime/base/bit_vector_test.cc \
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800100 runtime/base/hash_set_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700101 runtime/base/hex_dump_test.cc \
102 runtime/base/histogram_test.cc \
103 runtime/base/mutex_test.cc \
104 runtime/base/scoped_flock_test.cc \
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700105 runtime/base/stringprintf_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700106 runtime/base/timing_logger_test.cc \
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800107 runtime/base/variant_map_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700108 runtime/base/unix_file/fd_file_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700109 runtime/class_linker_test.cc \
110 runtime/dex_file_test.cc \
111 runtime/dex_file_verifier_test.cc \
112 runtime/dex_instruction_visitor_test.cc \
113 runtime/dex_method_iterator_test.cc \
114 runtime/entrypoints/math_entrypoints_test.cc \
115 runtime/entrypoints/quick/quick_trampoline_entrypoints_test.cc \
116 runtime/entrypoints_order_test.cc \
117 runtime/exception_test.cc \
Mathieu Chartier2c265012014-08-05 18:15:56 -0700118 runtime/gc/accounting/card_table_test.cc \
Mathieu Chartier4858a932015-01-23 13:18:53 -0800119 runtime/gc/accounting/mod_union_table_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700120 runtime/gc/accounting/space_bitmap_test.cc \
121 runtime/gc/heap_test.cc \
Mathieu Chartier9e2094f2014-12-11 18:43:48 -0800122 runtime/gc/reference_queue_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700123 runtime/gc/space/dlmalloc_space_base_test.cc \
124 runtime/gc/space/dlmalloc_space_static_test.cc \
125 runtime/gc/space/dlmalloc_space_random_test.cc \
126 runtime/gc/space/rosalloc_space_base_test.cc \
127 runtime/gc/space/rosalloc_space_static_test.cc \
128 runtime/gc/space/rosalloc_space_random_test.cc \
129 runtime/gc/space/large_object_space_test.cc \
Mathieu Chartiera5eae692014-12-17 17:56:03 -0800130 runtime/gc/task_processor_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700131 runtime/gtest_test.cc \
132 runtime/handle_scope_test.cc \
133 runtime/indenter_test.cc \
134 runtime/indirect_reference_table_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700135 runtime/intern_table_test.cc \
Ian Rogers5ac814a2014-11-04 16:39:32 -0800136 runtime/interpreter/safe_math_test.cc \
Ian Rogersf4d4da12014-11-11 16:10:33 -0800137 runtime/java_vm_ext_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700138 runtime/leb128_test.cc \
139 runtime/mem_map_test.cc \
140 runtime/mirror/dex_cache_test.cc \
141 runtime/mirror/object_test.cc \
Andreas Gampe74240812014-04-17 10:35:09 -0700142 runtime/monitor_pool_test.cc \
Elena Sayapina1af6a1f2014-06-20 16:58:37 +0700143 runtime/monitor_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700144 runtime/parsed_options_test.cc \
145 runtime/reference_table_test.cc \
146 runtime/thread_pool_test.cc \
147 runtime/transaction_test.cc \
Narayan Kamatha5afcfc2015-01-29 20:06:46 +0000148 runtime/utf_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700149 runtime/utils_test.cc \
150 runtime/verifier/method_verifier_test.cc \
151 runtime/verifier/reg_type_test.cc \
152 runtime/zip_archive_test.cc
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800153
154COMPILER_GTEST_COMMON_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700155 runtime/jni_internal_test.cc \
Jeff Haodb8a6642014-08-14 17:18:52 -0700156 runtime/proxy_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700157 runtime/reflection_test.cc \
Vladimir Marko7a01dc22015-01-02 17:00:44 +0000158 compiler/dex/gvn_dead_code_elimination_test.cc \
Vladimir Marko95a05972014-05-30 10:01:32 +0100159 compiler/dex/global_value_numbering_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700160 compiler/dex/local_value_numbering_test.cc \
Vladimir Marko55fff042014-07-10 12:42:52 +0100161 compiler/dex/mir_graph_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700162 compiler/dex/mir_optimization_test.cc \
163 compiler/driver/compiler_driver_test.cc \
164 compiler/elf_writer_test.cc \
165 compiler/image_test.cc \
166 compiler/jni/jni_compiler_test.cc \
167 compiler/oat_test.cc \
Mingyao Yangf384f882014-10-22 16:08:18 -0700168 compiler/optimizing/bounds_check_elimination_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700169 compiler/optimizing/codegen_test.cc \
Roland Levillain72bceff2014-09-15 18:29:00 +0100170 compiler/optimizing/dead_code_elimination_test.cc \
Roland Levillain75be2832014-10-17 17:02:00 +0100171 compiler/optimizing/constant_folding_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700172 compiler/optimizing/dominator_test.cc \
173 compiler/optimizing/find_loops_test.cc \
Roland Levillainccc07a92014-09-16 14:48:16 +0100174 compiler/optimizing/graph_checker_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700175 compiler/optimizing/graph_test.cc \
Nicolas Geoffrayd31cf3d2014-09-08 17:30:24 +0100176 compiler/optimizing/gvn_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700177 compiler/optimizing/linearize_test.cc \
178 compiler/optimizing/liveness_test.cc \
179 compiler/optimizing/live_interval_test.cc \
180 compiler/optimizing/live_ranges_test.cc \
Nicolas Geoffray724c9632014-09-22 12:27:27 +0100181 compiler/optimizing/nodes_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700182 compiler/optimizing/parallel_move_test.cc \
183 compiler/optimizing/pretty_printer_test.cc \
184 compiler/optimizing/register_allocator_test.cc \
185 compiler/optimizing/ssa_test.cc \
Nicolas Geoffray99ea58c2014-07-02 15:08:17 +0100186 compiler/optimizing/stack_map_test.cc \
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000187 compiler/optimizing/suspend_check_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700188 compiler/output_stream_test.cc \
189 compiler/utils/arena_allocator_test.cc \
190 compiler/utils/dedupe_set_test.cc \
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800191 compiler/utils/swap_space_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700192 compiler/utils/arm/managed_register_arm_test.cc \
193 compiler/utils/arm64/managed_register_arm64_test.cc \
194 compiler/utils/x86/managed_register_x86_test.cc \
Brian Carlstrom51c24672013-07-11 16:00:56 -0700195
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800196RUNTIME_GTEST_TARGET_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700197 $(RUNTIME_GTEST_COMMON_SRC_FILES)
Brian Carlstrom51c24672013-07-11 16:00:56 -0700198
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800199RUNTIME_GTEST_HOST_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700200 $(RUNTIME_GTEST_COMMON_SRC_FILES)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800201
202COMPILER_GTEST_TARGET_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700203 $(COMPILER_GTEST_COMMON_SRC_FILES)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800204
205COMPILER_GTEST_HOST_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700206 $(COMPILER_GTEST_COMMON_SRC_FILES) \
Roland Levillain1a28fc42014-11-13 18:03:06 +0000207 compiler/utils/arm/assembler_arm32_test.cc \
208 compiler/utils/arm/assembler_thumb2_test.cc \
209 compiler/utils/assembler_thumb_test.cc \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700210 compiler/utils/x86/assembler_x86_test.cc \
211 compiler/utils/x86_64/assembler_x86_64_test.cc
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -0700212
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800213ART_TEST_CFLAGS :=
buzbee2cfc6392012-05-07 14:51:40 -0700214
Ian Rogerse63db272014-07-15 15:36:11 -0700215include $(CLEAR_VARS)
216LOCAL_MODULE := libart-gtest
217LOCAL_MODULE_TAGS := optional
218LOCAL_CPP_EXTENSION := cc
Ian Rogerse63db272014-07-15 15:36:11 -0700219LOCAL_SRC_FILES := runtime/common_runtime_test.cc compiler/common_compiler_test.cc
220LOCAL_C_INCLUDES := $(ART_C_INCLUDES) art/runtime art/compiler
Ian Rogers872dd822014-10-30 11:19:14 -0700221LOCAL_SHARED_LIBRARIES := libartd libartd-compiler libdl
Dan Albertfd84f662014-11-11 18:53:41 -0800222LOCAL_STATIC_LIBRARIES += libgtest
Ian Rogerse63db272014-07-15 15:36:11 -0700223LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
224LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
Andreas Gampebced67d2015-01-07 14:35:44 -0800225$(eval $(call set-target-local-clang-vars))
226$(eval $(call set-target-local-cflags-vars,debug))
Ian Rogerse63db272014-07-15 15:36:11 -0700227include $(BUILD_SHARED_LIBRARY)
228
229include $(CLEAR_VARS)
230LOCAL_MODULE := libart-gtest
231LOCAL_MODULE_TAGS := optional
232LOCAL_CPP_EXTENSION := cc
233LOCAL_CFLAGS := $(ART_HOST_CFLAGS)
234LOCAL_SRC_FILES := runtime/common_runtime_test.cc compiler/common_compiler_test.cc
235LOCAL_C_INCLUDES := $(ART_C_INCLUDES) art/runtime art/compiler
236LOCAL_SHARED_LIBRARIES := libartd libartd-compiler
Nicolas Geoffray10fc34b2014-11-10 21:38:15 +0000237LOCAL_STATIC_LIBRARIES := libgtest_host
Ian Rogerse63db272014-07-15 15:36:11 -0700238LOCAL_LDLIBS += -ldl -lpthread
239LOCAL_MULTILIB := both
240LOCAL_CLANG := $(ART_HOST_CLANG)
241LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
242LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
Ian Rogerse63db272014-07-15 15:36:11 -0700243include $(BUILD_HOST_SHARED_LIBRARY)
244
Ian Rogersafd9acc2014-06-17 08:21:54 -0700245# Variables holding collections of gtest pre-requisits used to run a number of gtests.
246ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
247ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
248ART_TEST_HOST_GTEST_RULES :=
249ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
250ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
251ART_TEST_HOST_VALGRIND_GTEST_RULES :=
252ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
253ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
254ART_TEST_TARGET_GTEST_RULES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700255
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000256ART_GTEST_TARGET_ANDROID_ROOT := '/system'
257ifneq ($(ART_TEST_ANDROID_ROOT),)
258 ART_GTEST_TARGET_ANDROID_ROOT := $(ART_TEST_ANDROID_ROOT)
259endif
260
Ian Rogersafd9acc2014-06-17 08:21:54 -0700261# Define a make rule for a target device gtest.
262# $(1): gtest name - the name of the test we're building such as leb128_test.
263# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000264# $(3): LD_LIBRARY_PATH or undefined - used in case libartd.so is not in /system/lib/
Ian Rogersafd9acc2014-06-17 08:21:54 -0700265define define-art-gtest-rule-target
266 gtest_rule := test-art-target-gtest-$(1)$$($(2)ART_PHONY_TEST_TARGET_SUFFIX)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700267
Brian Carlstrom532714a2014-06-25 02:15:31 -0700268 # Add the test dependencies to test-art-target-sync, which will be a prerequisite for the test
Ian Rogersafd9acc2014-06-17 08:21:54 -0700269 # to ensure files are pushed to the device.
270 TEST_ART_TARGET_SYNC_DEPS += \
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700271 $$(ART_GTEST_$(1)_TARGET_DEPS) \
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700272 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700273 $$(ART_TARGET_NATIVETEST_OUT)/$$(TARGET_$(2)ARCH)/$(1) \
Nicolas Geoffray96a63452014-10-30 12:13:17 +0000274 $$($(2)TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so \
275 $$(TARGET_OUT_JAVA_LIBRARIES)/core-libart.jar
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700276
Ian Rogersafd9acc2014-06-17 08:21:54 -0700277.PHONY: $$(gtest_rule)
278$$(gtest_rule): test-art-target-sync
279 $(hide) adb shell touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID
280 $(hide) adb shell rm $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID
281 $(hide) adb shell chmod 755 $(ART_TARGET_NATIVETEST_DIR)/$(TARGET_$(2)ARCH)/$(1)
282 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Dan Albert31fb2602014-09-30 22:10:10 -0700283 (adb shell "$(GCOV_ENV) LD_LIBRARY_PATH=$(3) ANDROID_ROOT=$(ART_GTEST_TARGET_ANDROID_ROOT) \
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000284 $(ART_TARGET_NATIVETEST_DIR)/$(TARGET_$(2)ARCH)/$(1) && touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID" \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700285 && (adb pull $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID /tmp/ \
286 && $$(call ART_TEST_PASSED,$$@)) \
287 || $$(call ART_TEST_FAILED,$$@))
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700288 $(hide) rm -f /tmp/$$@-$$$$PPID
Ian Rogersafd9acc2014-06-17 08:21:54 -0700289
290 ART_TEST_TARGET_GTEST$($(2)ART_PHONY_TEST_TARGET_SUFFIX)_RULES += $$(gtest_rule)
291 ART_TEST_TARGET_GTEST_RULES += $$(gtest_rule)
292 ART_TEST_TARGET_GTEST_$(1)_RULES += $$(gtest_rule)
293
294 # Clear locally defined variables.
295 gtest_rule :=
296endef # define-art-gtest-rule-target
297
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800298ART_VALGRIND_DEPENDENCIES := \
299 $(HOST_OUT_EXECUTABLES)/valgrind \
300 $(HOST_OUT)/lib64/valgrind/memcheck-amd64-linux \
301 $(HOST_OUT)/lib64/valgrind/memcheck-x86-linux \
302 $(HOST_OUT)/lib64/valgrind/default.supp \
303 $(HOST_OUT)/lib64/valgrind/vgpreload_core-amd64-linux.so \
304 $(HOST_OUT)/lib64/valgrind/vgpreload_core-x86-linux.so \
305 $(HOST_OUT)/lib64/valgrind/vgpreload_memcheck-amd64-linux.so \
306 $(HOST_OUT)/lib64/valgrind/vgpreload_memcheck-x86-linux.so
307
Ian Rogersafd9acc2014-06-17 08:21:54 -0700308# Define make rules for a host gtests.
309# $(1): gtest name - the name of the test we're building such as leb128_test.
310# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
311define define-art-gtest-rule-host
312 gtest_rule := test-art-host-gtest-$(1)$$($(2)ART_PHONY_TEST_HOST_SUFFIX)
313 gtest_exe := $$(HOST_OUT_EXECUTABLES)/$(1)$$($(2)ART_PHONY_TEST_HOST_SUFFIX)
Ian Rogers665de8a2014-06-24 21:34:09 -0700314 # Dependencies for all host gtests.
315 gtest_deps := $$(HOST_CORE_DEX_LOCATIONS) \
Nicolas Geoffray4d1231d2014-07-01 10:46:31 +0100316 $$($(2)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION)
Ian Rogers665de8a2014-06-24 21:34:09 -0700317
Ian Rogersafd9acc2014-06-17 08:21:54 -0700318
319.PHONY: $$(gtest_rule)
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700320$$(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 -0700321 $(hide) ($$(call ART_TEST_SKIP,$$@) && $$< && $$(call ART_TEST_PASSED,$$@)) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700322 || $$(call ART_TEST_FAILED,$$@)
323
324 ART_TEST_HOST_GTEST$$($(2)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
325 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
326 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
327
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800328
Ian Rogersafd9acc2014-06-17 08:21:54 -0700329.PHONY: valgrind-$$(gtest_rule)
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800330valgrind-$$(gtest_rule): $$(gtest_exe) $$(ART_GTEST_$(1)_HOST_DEPS) $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) $$(gtest_deps) $(ART_VALGRIND_DEPENDENCIES)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700331 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Andreas Gampe8df91ac2015-02-20 13:15:15 -0800332 VALGRIND_LIB=$(HOST_OUT)/lib64/valgrind \
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800333 $(HOST_OUT_EXECUTABLES)/valgrind --leak-check=full --error-exitcode=1 $$< && \
334 $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700335
336 ART_TEST_HOST_VALGRIND_GTEST$$($(2)ART_PHONY_TEST_HOST_SUFFIX)_RULES += valgrind-$$(gtest_rule)
337 ART_TEST_HOST_VALGRIND_GTEST_RULES += valgrind-$$(gtest_rule)
338 ART_TEST_HOST_VALGRIND_GTEST_$(1)_RULES += valgrind-$$(gtest_rule)
339
340 # Clear locally defined variables.
341 valgrind_gtest_rule :=
342 gtest_rule :=
343 gtest_exe :=
Ian Rogers665de8a2014-06-24 21:34:09 -0700344 gtest_deps :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700345endef # define-art-gtest-rule-host
346
347# Define the rules to build and run host and target gtests.
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700348# $(1): target or host
Brian Carlstrom0796af02011-10-12 14:31:45 -0700349# $(2): file name
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800350# $(3): extra C includes
351# $(4): extra shared libraries
Ian Rogersafd9acc2014-06-17 08:21:54 -0700352define define-art-gtest
Brian Carlstrom0796af02011-10-12 14:31:45 -0700353 ifneq ($(1),target)
354 ifneq ($(1),host)
355 $$(error expected target or host for argument 1, received $(1))
356 endif
357 endif
358
359 art_target_or_host := $(1)
360 art_gtest_filename := $(2)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800361 art_gtest_extra_c_includes := $(3)
362 art_gtest_extra_shared_libraries := $(4)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700363
Ian Rogersafd9acc2014-06-17 08:21:54 -0700364 include $$(CLEAR_VARS)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700365 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700366 LOCAL_MODULE := $$(art_gtest_name)
Brian Carlstrom871599a2012-09-06 13:27:49 -0700367 ifeq ($$(art_target_or_host),target)
368 LOCAL_MODULE_TAGS := tests
369 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700370 LOCAL_CPP_EXTENSION := $$(ART_CPP_EXTENSION)
Dmitriy Ivanove49a4f62014-10-20 14:11:00 -0700371 LOCAL_SRC_FILES := $$(art_gtest_filename)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700372 LOCAL_C_INCLUDES += $$(ART_C_INCLUDES) art/runtime $$(art_gtest_extra_c_includes)
Ian Rogerse63db272014-07-15 15:36:11 -0700373 LOCAL_SHARED_LIBRARIES += libartd $$(art_gtest_extra_shared_libraries) libart-gtest
Dmitriy Ivanove49a4f62014-10-20 14:11:00 -0700374 LOCAL_WHOLE_STATIC_LIBRARIES += libsigchain
Brian Carlstrom4478eb02013-07-14 21:05:57 -0700375
Ian Rogerse63db272014-07-15 15:36:11 -0700376 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
377 LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -0800378
Elliott Hughes0f096762012-01-31 10:32:46 -0800379 # Mac OS linker doesn't understand --export-dynamic.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700380 ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host)
Elliott Hughesb264f082012-04-06 17:10:10 -0700381 # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...).
382 LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar
Brian Carlstromcfede662012-01-29 17:25:54 -0800383 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -0700384
Ian Rogersafd9acc2014-06-17 08:21:54 -0700385 LOCAL_CFLAGS := $$(ART_TEST_CFLAGS)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700386 ifeq ($$(art_target_or_host),target)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700387 $$(eval $$(call set-target-local-clang-vars))
388 $$(eval $$(call set-target-local-cflags-vars,debug))
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000389 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libz libcutils libvixld
Ian Rogersafd9acc2014-06-17 08:21:54 -0700390 LOCAL_MODULE_PATH_32 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_32)
391 LOCAL_MODULE_PATH_64 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_64)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700392 LOCAL_MULTILIB := both
Ian Rogersafd9acc2014-06-17 08:21:54 -0700393 include $$(BUILD_EXECUTABLE)
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000394 library_path :=
395 2nd_library_path :=
396 ifneq ($$(ART_TEST_ANDROID_ROOT),)
397 ifdef TARGET_2ND_ARCH
398 2nd_library_path := $$(ART_TEST_ANDROID_ROOT)/lib
399 library_path := $$(ART_TEST_ANDROID_ROOT)/lib64
400 else
Nicolas Geoffrayc1dea4a2014-11-10 08:33:52 +0000401 ifneq ($(filter %64,$(TARGET_ARCH)),)
402 library_path := $$(ART_TEST_ANDROID_ROOT)/lib64
403 else
404 library_path := $$(ART_TEST_ANDROID_ROOT)/lib
405 endif
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000406 endif
407 endif
Andreas Gampe5ca4eaa2014-05-29 02:09:33 -0700408
Ian Rogersafd9acc2014-06-17 08:21:54 -0700409 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700410 ifdef TARGET_2ND_ARCH
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000411 $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),2ND_,$$(2nd_library_path)))
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700412 endif
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000413 $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),,$$(library_path)))
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700414
Ian Rogersafd9acc2014-06-17 08:21:54 -0700415 # A rule to run the different architecture versions of the gtest.
416.PHONY: test-art-target-gtest-$$(art_gtest_name)
417test-art-target-gtest-$$(art_gtest_name): $$(ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES)
418 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
419
420 # Clear locally defined variables.
421 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
Brian Carlstrom0796af02011-10-12 14:31:45 -0700422 else # host
Ian Rogersafd9acc2014-06-17 08:21:54 -0700423 LOCAL_CLANG := $$(ART_HOST_CLANG)
424 LOCAL_CFLAGS += $$(ART_HOST_CFLAGS) $$(ART_HOST_DEBUG_CFLAGS)
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000425 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libziparchive-host libz-host libvixld
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700426 LOCAL_LDLIBS := $(ART_HOST_LDLIBS) -lpthread -ldl
Ian Rogersbd5ea6a2014-04-16 16:34:44 -0700427 LOCAL_IS_HOST_MODULE := true
Ian Rogersafd9acc2014-06-17 08:21:54 -0700428 LOCAL_MULTILIB := both
429 LOCAL_MODULE_STEM_32 := $$(art_gtest_name)32
430 LOCAL_MODULE_STEM_64 := $$(art_gtest_name)64
431 include $$(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700432
Ian Rogersafd9acc2014-06-17 08:21:54 -0700433 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
434 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
435 ifneq ($$(HOST_PREFER_32_BIT),true)
436 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),2ND_))
437 endif
438 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),))
Ian Rogersd912e5c2013-11-13 12:40:11 -0800439
Ian Rogersafd9acc2014-06-17 08:21:54 -0700440 # Rules to run the different architecture versions of the gtest.
441.PHONY: test-art-host-gtest-$$(art_gtest_name)
442test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
443 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800444
Ian Rogersafd9acc2014-06-17 08:21:54 -0700445.PHONY: valgrind-test-art-host-gtest-$$(art_gtest_name)
446valgrind-test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES)
447 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
448
449 # Clear locally defined variables.
450 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
451 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
452 endif # host_or_target
453
454 # Clear locally defined variables.
455 art_target_or_host :=
456 art_gtest_filename :=
457 art_gtest_extra_c_includes :=
458 art_gtest_extra_shared_libraries :=
459 art_gtest_name :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000460 library_path :=
461 2nd_library_path :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700462endef # define-art-gtest
Carl Shapiro008e4122011-06-23 17:27:46 -0700463
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700464ifeq ($(ART_BUILD_TARGET),true)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700465 $(foreach file,$(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval $(call define-art-gtest,target,$(file),,)))
466 $(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 -0700467endif
Ian Rogersc5f17732014-06-05 20:48:42 -0700468ifeq ($(ART_BUILD_HOST),true)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700469 $(foreach file,$(RUNTIME_GTEST_HOST_SRC_FILES), $(eval $(call define-art-gtest,host,$(file),,)))
470 $(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 -0700471endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700472
473# Used outside the art project to get a list of the current tests
474RUNTIME_TARGET_GTEST_MAKE_TARGETS :=
475$(foreach file, $(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval RUNTIME_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
476COMPILER_TARGET_GTEST_MAKE_TARGETS :=
477$(foreach file, $(COMPILER_GTEST_TARGET_SRC_FILES), $(eval COMPILER_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700478
479# Define all the combinations of host/target, valgrind and suffix such as:
480# test-art-host-gtest or valgrind-test-art-host-gtest64
481# $(1): host or target
482# $(2): HOST or TARGET
483# $(3): valgrind- or undefined
484# $(4): undefined, 32 or 64
485define define-test-art-gtest-combination
486 ifeq ($(1),host)
487 ifneq ($(2),HOST)
488 $$(error argument mismatch $(1) and ($2))
489 endif
490 else
491 ifneq ($(1),target)
492 $$(error found $(1) expected host or target)
493 endif
494 ifneq ($(2),TARGET)
495 $$(error argument mismatch $(1) and ($2))
496 endif
497 endif
498
499 rule_name := $(3)test-art-$(1)-gtest$(4)
Andreas Gampe928f72b2014-09-09 19:53:48 -0700500 ifeq ($(3),valgrind-)
501 ifneq ($(1),host)
502 $$(error valgrind tests only wired up for the host)
503 endif
504 dependencies := $$(ART_TEST_$(2)_VALGRIND_GTEST$(4)_RULES)
505 else
506 dependencies := $$(ART_TEST_$(2)_GTEST$(4)_RULES)
507 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700508
509.PHONY: $$(rule_name)
510$$(rule_name): $$(dependencies)
511 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
512
513 # Clear locally defined variables.
514 rule_name :=
515 dependencies :=
516endef # define-test-art-gtest-combination
517
518$(eval $(call define-test-art-gtest-combination,target,TARGET,,))
519$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(ART_PHONY_TEST_TARGET_SUFFIX)))
520ifdef TARGET_2ND_ARCH
521$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
522endif
523$(eval $(call define-test-art-gtest-combination,host,HOST,,))
524$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,))
525$(eval $(call define-test-art-gtest-combination,host,HOST,,$(ART_PHONY_TEST_HOST_SUFFIX)))
526$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(ART_PHONY_TEST_HOST_SUFFIX)))
527ifneq ($(HOST_PREFER_32_BIT),true)
528$(eval $(call define-test-art-gtest-combination,host,HOST,,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
529$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
530endif
531
532# Clear locally defined variables.
533define-art-gtest-rule-target :=
534define-art-gtest-rule-host :=
535define-art-gtest :=
536define-test-art-gtest-combination :=
537RUNTIME_GTEST_COMMON_SRC_FILES :=
538COMPILER_GTEST_COMMON_SRC_FILES :=
539RUNTIME_GTEST_TARGET_SRC_FILES :=
540RUNTIME_GTEST_HOST_SRC_FILES :=
541COMPILER_GTEST_TARGET_SRC_FILES :=
542COMPILER_GTEST_HOST_SRC_FILES :=
543ART_TEST_CFLAGS :=
544ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
545ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
546ART_TEST_HOST_GTEST_RULES :=
547ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
548ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
549ART_TEST_HOST_VALGRIND_GTEST_RULES :=
550ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
551ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
552ART_TEST_TARGET_GTEST_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000553ART_GTEST_TARGET_ANDROID_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700554ART_GTEST_class_linker_test_DEX_DEPS :=
555ART_GTEST_compiler_driver_test_DEX_DEPS :=
556ART_GTEST_dex_file_test_DEX_DEPS :=
557ART_GTEST_exception_test_DEX_DEPS :=
558ART_GTEST_elf_writer_test_HOST_DEPS :=
559ART_GTEST_elf_writer_test_TARGET_DEPS :=
560ART_GTEST_jni_compiler_test_DEX_DEPS :=
561ART_GTEST_jni_internal_test_DEX_DEPS :=
562ART_GTEST_object_test_DEX_DEPS :=
563ART_GTEST_proxy_test_DEX_DEPS :=
564ART_GTEST_reflection_test_DEX_DEPS :=
565ART_GTEST_stub_test_DEX_DEPS :=
566ART_GTEST_transaction_test_DEX_DEPS :=
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800567ART_VALGRIND_DEPENDENCIES :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700568$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
569$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700570GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700571LOCAL_PATH :=