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