1#
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
17# 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), \
45  $(ART_TARGET_NATIVETEST_OUT),art/build/Android.gtest.mk,ART_TEST_TARGET_GTEST_$(dir)_DEX, \
46  ART_TEST_HOST_GTEST_$(dir)_DEX)))
47
48# Dex file dependencies for each gtest.
49ART_GTEST_class_linker_test_DEX_DEPS := Interfaces MyClass Nested Statics StaticsFromCode
50ART_GTEST_compiler_driver_test_DEX_DEPS := AbstractMethod
51ART_GTEST_dex_file_test_DEX_DEPS := GetMethodSignature
52ART_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
60
61# The elf writer test has dependencies on core.oat.
62ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_OAT_OUT) $(2ND_HOST_CORE_OAT_OUT)
63ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_OAT_OUT) $(2ND_TARGET_CORE_OAT_OUT)
64
65# The path for which all the source files are relative, not actually the current directory.
66LOCAL_PATH := art
67
68RUNTIME_GTEST_COMMON_SRC_FILES := \
69  runtime/arch/arch_test.cc \
70  runtime/arch/memcmp16_test.cc \
71  runtime/arch/stub_test.cc \
72  runtime/barrier_test.cc \
73  runtime/base/bit_field_test.cc \
74  runtime/base/bit_vector_test.cc \
75  runtime/base/hash_set_test.cc \
76  runtime/base/hex_dump_test.cc \
77  runtime/base/histogram_test.cc \
78  runtime/base/mutex_test.cc \
79  runtime/base/scoped_flock_test.cc \
80  runtime/base/stringprintf_test.cc \
81  runtime/base/timing_logger_test.cc \
82  runtime/base/unix_file/fd_file_test.cc \
83  runtime/base/unix_file/mapped_file_test.cc \
84  runtime/base/unix_file/null_file_test.cc \
85  runtime/base/unix_file/random_access_file_utils_test.cc \
86  runtime/base/unix_file/string_file_test.cc \
87  runtime/class_linker_test.cc \
88  runtime/dex_file_test.cc \
89  runtime/dex_file_verifier_test.cc \
90  runtime/dex_instruction_visitor_test.cc \
91  runtime/dex_method_iterator_test.cc \
92  runtime/entrypoints/math_entrypoints_test.cc \
93  runtime/entrypoints/quick/quick_trampoline_entrypoints_test.cc \
94  runtime/entrypoints_order_test.cc \
95  runtime/exception_test.cc \
96  runtime/gc/accounting/card_table_test.cc \
97  runtime/gc/accounting/space_bitmap_test.cc \
98  runtime/gc/heap_test.cc \
99  runtime/gc/space/dlmalloc_space_base_test.cc \
100  runtime/gc/space/dlmalloc_space_static_test.cc \
101  runtime/gc/space/dlmalloc_space_random_test.cc \
102  runtime/gc/space/rosalloc_space_base_test.cc \
103  runtime/gc/space/rosalloc_space_static_test.cc \
104  runtime/gc/space/rosalloc_space_random_test.cc \
105  runtime/gc/space/large_object_space_test.cc \
106  runtime/gtest_test.cc \
107  runtime/handle_scope_test.cc \
108  runtime/indenter_test.cc \
109  runtime/indirect_reference_table_test.cc \
110  runtime/instruction_set_test.cc \
111  runtime/intern_table_test.cc \
112  runtime/leb128_test.cc \
113  runtime/mem_map_test.cc \
114  runtime/mirror/dex_cache_test.cc \
115  runtime/mirror/object_test.cc \
116  runtime/monitor_pool_test.cc \
117  runtime/monitor_test.cc \
118  runtime/parsed_options_test.cc \
119  runtime/reference_table_test.cc \
120  runtime/thread_pool_test.cc \
121  runtime/transaction_test.cc \
122  runtime/utils_test.cc \
123  runtime/verifier/method_verifier_test.cc \
124  runtime/verifier/reg_type_test.cc \
125  runtime/zip_archive_test.cc
126
127COMPILER_GTEST_COMMON_SRC_FILES := \
128  runtime/jni_internal_test.cc \
129  runtime/proxy_test.cc \
130  runtime/reflection_test.cc \
131  compiler/dex/global_value_numbering_test.cc \
132  compiler/dex/local_value_numbering_test.cc \
133  compiler/dex/mir_graph_test.cc \
134  compiler/dex/mir_optimization_test.cc \
135  compiler/driver/compiler_driver_test.cc \
136  compiler/elf_writer_test.cc \
137  compiler/image_test.cc \
138  compiler/jni/jni_compiler_test.cc \
139  compiler/oat_test.cc \
140  compiler/optimizing/codegen_test.cc \
141  compiler/optimizing/dominator_test.cc \
142  compiler/optimizing/find_loops_test.cc \
143  compiler/optimizing/graph_test.cc \
144  compiler/optimizing/linearize_test.cc \
145  compiler/optimizing/liveness_test.cc \
146  compiler/optimizing/live_interval_test.cc \
147  compiler/optimizing/live_ranges_test.cc \
148  compiler/optimizing/parallel_move_test.cc \
149  compiler/optimizing/pretty_printer_test.cc \
150  compiler/optimizing/register_allocator_test.cc \
151  compiler/optimizing/ssa_test.cc \
152  compiler/optimizing/stack_map_test.cc \
153  compiler/output_stream_test.cc \
154  compiler/utils/arena_allocator_test.cc \
155  compiler/utils/dedupe_set_test.cc \
156  compiler/utils/swap_space_test.cc \
157  compiler/utils/arm/managed_register_arm_test.cc \
158  compiler/utils/arm64/managed_register_arm64_test.cc \
159  compiler/utils/x86/managed_register_x86_test.cc \
160
161ifeq ($(ART_SEA_IR_MODE),true)
162COMPILER_GTEST_COMMON_SRC_FILES += \
163  compiler/utils/scoped_hashtable_test.cc \
164  compiler/sea_ir/types/type_data_test.cc \
165  compiler/sea_ir/types/type_inference_visitor_test.cc \
166  compiler/sea_ir/ir/regions_test.cc
167endif
168
169RUNTIME_GTEST_TARGET_SRC_FILES := \
170  $(RUNTIME_GTEST_COMMON_SRC_FILES)
171
172RUNTIME_GTEST_HOST_SRC_FILES := \
173  $(RUNTIME_GTEST_COMMON_SRC_FILES)
174
175COMPILER_GTEST_TARGET_SRC_FILES := \
176  $(COMPILER_GTEST_COMMON_SRC_FILES)
177
178COMPILER_GTEST_HOST_SRC_FILES := \
179  $(COMPILER_GTEST_COMMON_SRC_FILES) \
180  compiler/utils//assembler_thumb_test.cc \
181  compiler/utils/x86/assembler_x86_test.cc \
182  compiler/utils/x86_64/assembler_x86_64_test.cc
183
184ART_TEST_CFLAGS :=
185ifeq ($(ART_USE_PORTABLE_COMPILER),true)
186  ART_TEST_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
187endif
188
189include $(CLEAR_VARS)
190LOCAL_MODULE := libart-gtest
191LOCAL_MODULE_TAGS := optional
192LOCAL_CPP_EXTENSION := cc
193LOCAL_CFLAGS := $(ART_TARGET_CFLAGS)
194LOCAL_SRC_FILES := runtime/common_runtime_test.cc compiler/common_compiler_test.cc
195LOCAL_C_INCLUDES := $(ART_C_INCLUDES) art/runtime art/compiler
196LOCAL_SHARED_LIBRARIES := libcutils libartd libartd-compiler libdl
197LOCAL_STATIC_LIBRARIES += libgtest_libc++
198LOCAL_CLANG := $(ART_TARGET_CLANG)
199LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
200LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
201include external/libcxx/libcxx.mk
202include $(BUILD_SHARED_LIBRARY)
203
204include $(CLEAR_VARS)
205LOCAL_MODULE := libart-gtest
206LOCAL_MODULE_TAGS := optional
207LOCAL_CPP_EXTENSION := cc
208LOCAL_CFLAGS := $(ART_HOST_CFLAGS)
209LOCAL_SRC_FILES := runtime/common_runtime_test.cc compiler/common_compiler_test.cc
210LOCAL_C_INCLUDES := $(ART_C_INCLUDES) art/runtime art/compiler
211LOCAL_SHARED_LIBRARIES := libartd libartd-compiler
212LOCAL_STATIC_LIBRARIES := libcutils
213ifneq ($(WITHOUT_HOST_CLANG),true)
214  # GCC host compiled tests fail with this linked, presumably due to destructors that run.
215  LOCAL_STATIC_LIBRARIES += libgtest_libc++_host
216endif
217LOCAL_LDLIBS += -ldl -lpthread
218LOCAL_MULTILIB := both
219LOCAL_CLANG := $(ART_HOST_CLANG)
220LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
221LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
222include external/libcxx/libcxx.mk
223include $(BUILD_HOST_SHARED_LIBRARY)
224
225# Variables holding collections of gtest pre-requisits used to run a number of gtests.
226ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
227ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
228ART_TEST_HOST_GTEST_RULES :=
229ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
230ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
231ART_TEST_HOST_VALGRIND_GTEST_RULES :=
232ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
233ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
234ART_TEST_TARGET_GTEST_RULES :=
235
236# Define a make rule for a target device gtest.
237# $(1): gtest name - the name of the test we're building such as leb128_test.
238# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
239define define-art-gtest-rule-target
240  gtest_rule := test-art-target-gtest-$(1)$$($(2)ART_PHONY_TEST_TARGET_SUFFIX)
241
242  # Add the test dependencies to test-art-target-sync, which will be a prerequisite for the test
243  # to ensure files are pushed to the device.
244  TEST_ART_TARGET_SYNC_DEPS += \
245    $$(ART_GTEST_$(1)_TARGET_DEPS) \
246    $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
247    $$(ART_TARGET_NATIVETEST_OUT)/$$(TARGET_$(2)ARCH)/$(1) \
248    $$($(2)TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so
249
250.PHONY: $$(gtest_rule)
251$$(gtest_rule): test-art-target-sync
252	$(hide) adb shell touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID
253	$(hide) adb shell rm $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID
254	$(hide) adb shell chmod 755 $(ART_TARGET_NATIVETEST_DIR)/$(TARGET_$(2)ARCH)/$(1)
255	$(hide) $$(call ART_TEST_SKIP,$$@) && \
256	  (adb shell "$(ART_TARGET_NATIVETEST_DIR)/$(TARGET_$(2)ARCH)/$(1) && touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID" \
257	  && (adb pull $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID /tmp/ \
258	      && $$(call ART_TEST_PASSED,$$@)) \
259	  || $$(call ART_TEST_FAILED,$$@))
260	$(hide) rm /tmp/$$@-$$$$PPID
261
262  ART_TEST_TARGET_GTEST$($(2)ART_PHONY_TEST_TARGET_SUFFIX)_RULES += $$(gtest_rule)
263  ART_TEST_TARGET_GTEST_RULES += $$(gtest_rule)
264  ART_TEST_TARGET_GTEST_$(1)_RULES += $$(gtest_rule)
265
266  # Clear locally defined variables.
267  gtest_rule :=
268endef  # define-art-gtest-rule-target
269
270# Define make rules for a host gtests.
271# $(1): gtest name - the name of the test we're building such as leb128_test.
272# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
273define define-art-gtest-rule-host
274  gtest_rule := test-art-host-gtest-$(1)$$($(2)ART_PHONY_TEST_HOST_SUFFIX)
275  gtest_exe := $$(HOST_OUT_EXECUTABLES)/$(1)$$($(2)ART_PHONY_TEST_HOST_SUFFIX)
276  # Dependencies for all host gtests.
277  gtest_deps := $$(HOST_CORE_DEX_LOCATIONS) \
278    $$($(2)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION)
279
280
281.PHONY: $$(gtest_rule)
282$$(gtest_rule): $$(gtest_exe) $$(ART_GTEST_$(1)_HOST_DEPS) $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) $$(gtest_deps)
283	$(hide) ($$(call ART_TEST_SKIP,$$@) && $$< && $$(call ART_TEST_PASSED,$$@)) \
284	  || $$(call ART_TEST_FAILED,$$@)
285
286  ART_TEST_HOST_GTEST$$($(2)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
287  ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
288  ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
289
290.PHONY: valgrind-$$(gtest_rule)
291valgrind-$$(gtest_rule): $$(gtest_exe) $$(ART_GTEST_$(1)_HOST_DEPS) $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) $$(gtest_deps)
292	$(hide) $$(call ART_TEST_SKIP,$$@) && \
293	  valgrind --leak-check=full --error-exitcode=1 $$< && $$(call ART_TEST_PASSED,$$@) \
294	    || $$(call ART_TEST_FAILED,$$@)
295
296  ART_TEST_HOST_VALGRIND_GTEST$$($(2)ART_PHONY_TEST_HOST_SUFFIX)_RULES += valgrind-$$(gtest_rule)
297  ART_TEST_HOST_VALGRIND_GTEST_RULES += valgrind-$$(gtest_rule)
298  ART_TEST_HOST_VALGRIND_GTEST_$(1)_RULES += valgrind-$$(gtest_rule)
299
300  # Clear locally defined variables.
301  valgrind_gtest_rule :=
302  gtest_rule :=
303  gtest_exe :=
304  gtest_deps :=
305endef  # define-art-gtest-rule-host
306
307# Define the rules to build and run host and target gtests.
308# $(1): target or host
309# $(2): file name
310# $(3): extra C includes
311# $(4): extra shared libraries
312define define-art-gtest
313  ifneq ($(1),target)
314    ifneq ($(1),host)
315      $$(error expected target or host for argument 1, received $(1))
316    endif
317  endif
318
319  art_target_or_host := $(1)
320  art_gtest_filename := $(2)
321  art_gtest_extra_c_includes := $(3)
322  art_gtest_extra_shared_libraries := $(4)
323
324  include $$(CLEAR_VARS)
325  art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
326  LOCAL_MODULE := $$(art_gtest_name)
327  ifeq ($$(art_target_or_host),target)
328    LOCAL_MODULE_TAGS := tests
329  endif
330  LOCAL_CPP_EXTENSION := $$(ART_CPP_EXTENSION)
331  LOCAL_SRC_FILES := $$(art_gtest_filename)
332  LOCAL_C_INCLUDES += $$(ART_C_INCLUDES) art/runtime $$(art_gtest_extra_c_includes)
333  LOCAL_SHARED_LIBRARIES += libartd $$(art_gtest_extra_shared_libraries) libart-gtest
334  LOCAL_WHOLE_STATIC_LIBRARIES += libsigchain
335
336  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
337  LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
338
339  # Mac OS linker doesn't understand --export-dynamic.
340  ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host)
341    # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...).
342    LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar
343  endif
344
345  LOCAL_CFLAGS := $$(ART_TEST_CFLAGS)
346  include external/libcxx/libcxx.mk
347  ifeq ($$(art_target_or_host),target)
348    $$(eval $$(call set-target-local-clang-vars))
349    $$(eval $$(call set-target-local-cflags-vars,debug))
350    LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libz libcutils libvixl
351    LOCAL_MODULE_PATH_32 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_32)
352    LOCAL_MODULE_PATH_64 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_64)
353    LOCAL_MULTILIB := both
354    include $$(BUILD_EXECUTABLE)
355
356    ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
357    ifdef TARGET_2ND_ARCH
358      $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),2ND_))
359    endif
360    $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),))
361
362    # A rule to run the different architecture versions of the gtest.
363.PHONY: test-art-target-gtest-$$(art_gtest_name)
364test-art-target-gtest-$$(art_gtest_name): $$(ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES)
365	$$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
366
367    # Clear locally defined variables.
368    ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
369  else # host
370    LOCAL_CLANG := $$(ART_HOST_CLANG)
371    LOCAL_CFLAGS += $$(ART_HOST_CFLAGS) $$(ART_HOST_DEBUG_CFLAGS)
372    LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
373    LOCAL_STATIC_LIBRARIES += libcutils libvixl
374    LOCAL_LDLIBS += -lpthread -ldl
375    LOCAL_IS_HOST_MODULE := true
376    LOCAL_MULTILIB := both
377    LOCAL_MODULE_STEM_32 := $$(art_gtest_name)32
378    LOCAL_MODULE_STEM_64 := $$(art_gtest_name)64
379    include $$(BUILD_HOST_EXECUTABLE)
380
381    ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
382    ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
383    ifneq ($$(HOST_PREFER_32_BIT),true)
384      $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),2ND_))
385    endif
386    $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),))
387
388    # Rules to run the different architecture versions of the gtest.
389.PHONY: test-art-host-gtest-$$(art_gtest_name)
390test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
391	$$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
392
393.PHONY: valgrind-test-art-host-gtest-$$(art_gtest_name)
394valgrind-test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES)
395	$$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
396
397    # Clear locally defined variables.
398    ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
399    ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
400  endif  # host_or_target
401
402  # Clear locally defined variables.
403  art_target_or_host :=
404  art_gtest_filename :=
405  art_gtest_extra_c_includes :=
406  art_gtest_extra_shared_libraries :=
407  art_gtest_name :=
408endef  # define-art-gtest
409
410ifeq ($(ART_BUILD_TARGET),true)
411  $(foreach file,$(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval $(call define-art-gtest,target,$(file),,)))
412  $(foreach file,$(COMPILER_GTEST_TARGET_SRC_FILES), $(eval $(call define-art-gtest,target,$(file),art/compiler,libartd-compiler)))
413endif
414ifeq ($(ART_BUILD_HOST),true)
415  $(foreach file,$(RUNTIME_GTEST_HOST_SRC_FILES), $(eval $(call define-art-gtest,host,$(file),,)))
416  $(foreach file,$(COMPILER_GTEST_HOST_SRC_FILES), $(eval $(call define-art-gtest,host,$(file),art/compiler,libartd-compiler)))
417endif
418
419# Used outside the art project to get a list of the current tests
420RUNTIME_TARGET_GTEST_MAKE_TARGETS :=
421$(foreach file, $(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval RUNTIME_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
422COMPILER_TARGET_GTEST_MAKE_TARGETS :=
423$(foreach file, $(COMPILER_GTEST_TARGET_SRC_FILES), $(eval COMPILER_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
424
425# Define all the combinations of host/target, valgrind and suffix such as:
426# test-art-host-gtest or valgrind-test-art-host-gtest64
427# $(1): host or target
428# $(2): HOST or TARGET
429# $(3): valgrind- or undefined
430# $(4): undefined, 32 or 64
431define define-test-art-gtest-combination
432  ifeq ($(1),host)
433    ifneq ($(2),HOST)
434      $$(error argument mismatch $(1) and ($2))
435    endif
436  else
437    ifneq ($(1),target)
438      $$(error found $(1) expected host or target)
439    endif
440    ifneq ($(2),TARGET)
441      $$(error argument mismatch $(1) and ($2))
442    endif
443  endif
444
445  rule_name := $(3)test-art-$(1)-gtest$(4)
446  dependencies := $$(ART_TEST_$(2)_GTEST$(4)_RULES)
447
448.PHONY: $$(rule_name)
449$$(rule_name): $$(dependencies)
450	$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
451
452  # Clear locally defined variables.
453  rule_name :=
454  dependencies :=
455endef  # define-test-art-gtest-combination
456
457$(eval $(call define-test-art-gtest-combination,target,TARGET,,))
458$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(ART_PHONY_TEST_TARGET_SUFFIX)))
459ifdef TARGET_2ND_ARCH
460$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
461endif
462$(eval $(call define-test-art-gtest-combination,host,HOST,,))
463$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,))
464$(eval $(call define-test-art-gtest-combination,host,HOST,,$(ART_PHONY_TEST_HOST_SUFFIX)))
465$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(ART_PHONY_TEST_HOST_SUFFIX)))
466ifneq ($(HOST_PREFER_32_BIT),true)
467$(eval $(call define-test-art-gtest-combination,host,HOST,,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
468$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
469endif
470
471# Clear locally defined variables.
472define-art-gtest-rule-target :=
473define-art-gtest-rule-host :=
474define-art-gtest :=
475define-test-art-gtest-combination :=
476RUNTIME_GTEST_COMMON_SRC_FILES :=
477COMPILER_GTEST_COMMON_SRC_FILES :=
478RUNTIME_GTEST_TARGET_SRC_FILES :=
479RUNTIME_GTEST_HOST_SRC_FILES :=
480COMPILER_GTEST_TARGET_SRC_FILES :=
481COMPILER_GTEST_HOST_SRC_FILES :=
482ART_TEST_CFLAGS :=
483ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
484ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
485ART_TEST_HOST_GTEST_RULES :=
486ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
487ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
488ART_TEST_HOST_VALGRIND_GTEST_RULES :=
489ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
490ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
491ART_TEST_TARGET_GTEST_RULES :=
492ART_GTEST_class_linker_test_DEX_DEPS :=
493ART_GTEST_compiler_driver_test_DEX_DEPS :=
494ART_GTEST_dex_file_test_DEX_DEPS :=
495ART_GTEST_exception_test_DEX_DEPS :=
496ART_GTEST_elf_writer_test_HOST_DEPS :=
497ART_GTEST_elf_writer_test_TARGET_DEPS :=
498ART_GTEST_jni_compiler_test_DEX_DEPS :=
499ART_GTEST_jni_internal_test_DEX_DEPS :=
500ART_GTEST_object_test_DEX_DEPS :=
501ART_GTEST_proxy_test_DEX_DEPS :=
502ART_GTEST_reflection_test_DEX_DEPS :=
503ART_GTEST_stub_test_DEX_DEPS :=
504ART_GTEST_transaction_test_DEX_DEPS :=
505$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
506$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
507GTEST_DEX_DIRECTORIES :=
508LOCAL_PATH :=
509