blob: 34a0f7a6f75c87380ff3522365d54c14d5e3375a [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 := \
Brian Carlstrom7940e442013-07-12 13:46:57 -070020 runtime/barrier_test.cc \
Brian Carlstromba150c32013-08-27 17:31:03 -070021 runtime/base/bit_vector_test.cc \
Ian Rogers43b2e0f2014-01-30 16:58:39 -080022 runtime/base/hex_dump_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070023 runtime/base/histogram_test.cc \
24 runtime/base/mutex_test.cc \
Anwar Ghuloum4446ab92013-08-09 21:17:25 -070025 runtime/base/timing_logger_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070026 runtime/base/unix_file/fd_file_test.cc \
27 runtime/base/unix_file/mapped_file_test.cc \
28 runtime/base/unix_file/null_file_test.cc \
29 runtime/base/unix_file/random_access_file_utils_test.cc \
30 runtime/base/unix_file/string_file_test.cc \
31 runtime/class_linker_test.cc \
32 runtime/dex_file_test.cc \
33 runtime/dex_instruction_visitor_test.cc \
34 runtime/dex_method_iterator_test.cc \
Ian Rogers7655f292013-07-29 11:07:13 -070035 runtime/entrypoints/math_entrypoints_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070036 runtime/exception_test.cc \
37 runtime/gc/accounting/space_bitmap_test.cc \
38 runtime/gc/heap_test.cc \
Andreas Gampea7433512014-02-21 13:19:23 -080039 runtime/gc/space/dlmalloc_space_test.cc \
40 runtime/gc/space/rosalloc_space_test.cc \
41 runtime/gc/space/large_object_space_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070042 runtime/gtest_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070043 runtime/indenter_test.cc \
44 runtime/indirect_reference_table_test.cc \
45 runtime/intern_table_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080046 runtime/leb128_test.cc \
Brian Carlstrom9004cb62013-07-26 15:48:31 -070047 runtime/mem_map_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070048 runtime/mirror/dex_cache_test.cc \
49 runtime/mirror/object_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070050 runtime/reference_table_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070051 runtime/runtime_test.cc \
52 runtime/thread_pool_test.cc \
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010053 runtime/transaction_test.cc \
Brian Carlstrom7940e442013-07-12 13:46:57 -070054 runtime/utils_test.cc \
55 runtime/verifier/method_verifier_test.cc \
56 runtime/verifier/reg_type_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080057 runtime/zip_archive_test.cc \
58
59COMPILER_GTEST_COMMON_SRC_FILES := \
60 runtime/jni_internal_test.cc \
61 compiler/dex/local_value_numbering_test.cc \
62 compiler/driver/compiler_driver_test.cc \
63 compiler/elf_writer_test.cc \
64 compiler/image_test.cc \
65 compiler/jni/jni_compiler_test.cc \
66 compiler/oat_test.cc \
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000067 compiler/optimizing/codegen_test.cc \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080068 compiler/optimizing/dominator_test.cc \
69 compiler/optimizing/pretty_printer_test.cc \
70 compiler/output_stream_test.cc \
71 compiler/utils/arena_allocator_test.cc \
72 compiler/utils/dedupe_set_test.cc \
73 compiler/utils/arm/managed_register_arm_test.cc \
74 compiler/utils/x86/managed_register_x86_test.cc \
Brian Carlstrom51c24672013-07-11 16:00:56 -070075
Dragos Sbirlea8cc51622013-06-21 09:20:34 -070076ifeq ($(ART_SEA_IR_MODE),true)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080077COMPILER_GTEST_COMMON_SRC_FILES += \
Dragos Sbirlea423fb4d2013-08-05 18:33:30 -070078 compiler/utils/scoped_hashtable_test.cc \
79 compiler/sea_ir/types/type_data_test.cc \
Dragos Sbirlea597e46b2013-08-07 18:15:44 -070080 compiler/sea_ir/types/type_inference_visitor_test.cc \
81 compiler/sea_ir/ir/regions_test.cc
Dragos Sbirlea8cc51622013-06-21 09:20:34 -070082endif
83
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080084RUNTIME_GTEST_TARGET_SRC_FILES := \
85 $(RUNTIME_GTEST_COMMON_SRC_FILES)
Brian Carlstrom51c24672013-07-11 16:00:56 -070086
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080087RUNTIME_GTEST_HOST_SRC_FILES := \
88 $(RUNTIME_GTEST_COMMON_SRC_FILES)
89
90COMPILER_GTEST_TARGET_SRC_FILES := \
91 $(COMPILER_GTEST_COMMON_SRC_FILES)
92
93COMPILER_GTEST_HOST_SRC_FILES := \
94 $(COMPILER_GTEST_COMMON_SRC_FILES) \
Ian Rogers166db042013-07-26 12:05:57 -070095 compiler/utils/x86/assembler_x86_test.cc
Brian Carlstrom51c24672013-07-11 16:00:56 -070096
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080097ART_HOST_GTEST_EXECUTABLES :=
98ART_TARGET_GTEST_EXECUTABLES :=
99ART_HOST_GTEST_TARGETS :=
100ART_HOST_VALGRIND_GTEST_TARGETS :=
101ART_TARGET_GTEST_TARGETS :=
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -0700102
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800103ART_TEST_CFLAGS :=
buzbeec531cef2012-10-18 07:09:20 -0700104ifeq ($(ART_USE_PORTABLE_COMPILER),true)
105 ART_TEST_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
buzbee2cfc6392012-05-07 14:51:40 -0700106endif
107
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700108# $(1): target or host
Brian Carlstrom0796af02011-10-12 14:31:45 -0700109# $(2): file name
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800110# $(3): extra C includes
111# $(4): extra shared libraries
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700112define build-art-test
Brian Carlstrom0796af02011-10-12 14:31:45 -0700113 ifneq ($(1),target)
114 ifneq ($(1),host)
115 $$(error expected target or host for argument 1, received $(1))
116 endif
117 endif
118
119 art_target_or_host := $(1)
120 art_gtest_filename := $(2)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800121 art_gtest_extra_c_includes := $(3)
122 art_gtest_extra_shared_libraries := $(4)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700123
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700124 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
125
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700126 include $(CLEAR_VARS)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700127 ifeq ($$(art_target_or_host),target)
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700128 include external/stlport/libstlport.mk
129 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -0700130
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700131 LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700132 LOCAL_MODULE := $$(art_gtest_name)
Brian Carlstrom871599a2012-09-06 13:27:49 -0700133 ifeq ($$(art_target_or_host),target)
134 LOCAL_MODULE_TAGS := tests
135 endif
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800136 LOCAL_SRC_FILES := $$(art_gtest_filename) runtime/common_runtime_test.cc
137 LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime $(3)
138 LOCAL_SHARED_LIBRARIES += libartd $(4)
139 # dex2oatd is needed to go with libartd
Elliott Hughes025218c2013-07-30 17:13:06 -0700140 LOCAL_REQUIRED_MODULES := dex2oatd
Brian Carlstrom4478eb02013-07-14 21:05:57 -0700141
Brian Carlstrom17bfe262013-07-16 17:31:22 -0700142 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
Brian Carlstrom7940e442013-07-12 13:46:57 -0700143 LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -0800144
Elliott Hughes0f096762012-01-31 10:32:46 -0800145 # Mac OS linker doesn't understand --export-dynamic.
146 ifneq ($(HOST_OS)-$$(art_target_or_host),darwin-host)
Elliott Hughesb264f082012-04-06 17:10:10 -0700147 # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...).
148 LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar
Brian Carlstromcfede662012-01-29 17:25:54 -0800149 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -0700150
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800151 LOCAL_CFLAGS := $(ART_TEST_CFLAGS)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700152 ifeq ($$(art_target_or_host),target)
Ian Rogerscd5d0422013-05-17 15:54:01 -0700153 LOCAL_CLANG := $(ART_TARGET_CLANG)
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800154 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
Colin Crossdc781a12014-02-04 16:22:03 -0800155 LOCAL_CFLAGS_x86 := $(ART_TARGET_CFLAGS_x86)
Elliott Hughes025218c2013-07-30 17:13:06 -0700156 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libz libcutils
Elliott Hugheseb02a122012-06-12 11:35:40 -0700157 LOCAL_STATIC_LIBRARIES += libgtest
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -0800158 LOCAL_MODULE_PATH := $(ART_NATIVETEST_OUT)
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800159 include $(LLVM_DEVICE_BUILD_MK)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700160 include $(BUILD_EXECUTABLE)
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -0800161 art_gtest_exe := $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800162 ART_TARGET_GTEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700163 else # host
Ian Rogerscd5d0422013-05-17 15:54:01 -0700164 LOCAL_CLANG := $(ART_HOST_CLANG)
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800165 LOCAL_CFLAGS += $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -0700166 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
Mathieu Chartier0e4627e2012-10-23 16:13:36 -0700167 LOCAL_STATIC_LIBRARIES += libcutils
Elliott Hugheseb02a122012-06-12 11:35:40 -0700168 ifeq ($(HOST_OS),darwin)
169 # Mac OS complains about unresolved symbols if you don't include this.
170 LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host
Elliott Hughes34cf5142012-01-20 16:39:13 -0800171 endif
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800172 include $(LLVM_HOST_BUILD_MK)
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700173 include $(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700174 art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800175 ART_HOST_GTEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -0700176 endif
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700177art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
178ifeq ($$(art_target_or_host),target)
179.PHONY: $$(art_gtest_target)
180$$(art_gtest_target): $$(art_gtest_exe) test-art-target-sync
181 adb shell touch $(ART_TEST_DIR)/$$@
182 adb shell rm $(ART_TEST_DIR)/$$@
Brian Carlstromeaec3ae2012-06-17 23:30:57 -0700183 adb shell chmod 755 $(ART_NATIVETEST_DIR)/$$(notdir $$<)
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -0800184 adb shell sh -c "$(ART_NATIVETEST_DIR)/$$(notdir $$<) && touch $(ART_TEST_DIR)/$$@"
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700185 $(hide) (adb pull $(ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1)
186 $(hide) rm /tmp/$$@
187
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800188ART_TARGET_GTEST_TARGETS += $$(art_gtest_target)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700189else
190.PHONY: $$(art_gtest_target)
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700191$$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700192 $$<
193 @echo $$@ PASSED
194
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800195ART_HOST_GTEST_TARGETS += $$(art_gtest_target)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800196
197.PHONY: valgrind-$$(art_gtest_target)
198valgrind-$$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies
Ian Rogers86aed2a2013-11-13 15:56:44 -0800199 valgrind --leak-check=full --error-exitcode=1 $$<
Ian Rogersd912e5c2013-11-13 12:40:11 -0800200 @echo $$@ PASSED
201
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800202ART_HOST_VALGRIND_GTEST_TARGETS += valgrind-$$(art_gtest_target)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700203endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700204endef
Carl Shapiro008e4122011-06-23 17:27:46 -0700205
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700206ifeq ($(ART_BUILD_TARGET),true)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800207 $(foreach file,$(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file),,)))
208 $(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 -0700209endif
Brian Carlstrom19e776c2013-07-23 12:16:44 -0700210ifeq ($(WITH_HOST_DALVIK),true)
211 ifeq ($(ART_BUILD_HOST),true)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800212 $(foreach file,$(RUNTIME_GTEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file),,)))
213 $(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 -0700214 endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700215endif