blob: a71ce41c503bb4c7e5e704c8c580a68531db3dd9 [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
David Srbecky883c1342020-05-11 23:30:29 +000017# Build rules are excluded from Mac, since we can not run ART tests there in the first place.
18ifneq ($(HOST_OS),darwin)
19
David Srbecky1cf46a32020-06-22 15:39:00 +010020###################################################################################################
21# Create module in testcases to hold all common data and tools needed for ART host tests.
22
23# ART binary tools and libraries (automatic list of all art_cc_binary/art_cc_library modules).
24my_files := $(ART_TESTCASES_CONTENT)
25
26# Manually add system libraries that we need to run the host ART tools.
27my_files += \
David Srbecky22872da2020-06-25 15:23:15 +010028 $(foreach lib, libbacktrace libbase libc++ libicu_jni liblog libsigchain libunwindstack \
29 libziparchive libjavacore libandroidio libopenjdkd, \
30 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST)/$(lib).so:lib64/$(lib).so \
31 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST,,2ND)/$(lib).so:lib/$(lib).so) \
32 $(foreach lib, libcrypto libz libicuuc libicui18n libandroidicu libexpat, \
33 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST)/$(lib).so:lib64/$(lib)-host.so \
34 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST,,2ND)/$(lib).so:lib/$(lib)-host.so)
David Srbecky1cf46a32020-06-22 15:39:00 +010035
36# Add apex directories for art, conscrypt and i18n.
37my_files += $(foreach infix,_ _VDEX_,$(foreach suffix,$(HOST_ARCH) $(HOST_2ND_ARCH), \
38 $(DEXPREOPT_IMAGE$(infix)BUILT_INSTALLED_art_host_$(suffix))))
39my_files += \
40 $(foreach jar,$(CORE_IMG_JARS),\
41 $(HOST_OUT_JAVA_LIBRARIES)/$(jar)-hostdex.jar:apex/com.android.art/javalib/$(jar).jar) \
42 $(HOST_OUT_JAVA_LIBRARIES)/conscrypt-hostdex.jar:apex/com.android.conscrypt/javalib/conscrypt.jar\
David Srbecky22872da2020-06-25 15:23:15 +010043 $(HOST_OUT_JAVA_LIBRARIES)/core-icu4j-hostdex.jar:apex/com.android.i18n/javalib/core-icu4j.jar \
44 $(HOST_OUT)/com.android.i18n/etc/icu/icudt66l.dat:com.android.i18n/etc/icu/icudt66l.dat
David Srbecky1cf46a32020-06-22 15:39:00 +010045
46# Create dummy module that will copy all the data files into testcases directory.
47# For now, this copies everything to "out/host/linux-x86/" subdirectory, since it
48# is hard-coded in many places. TODO: Refactor tests to remove the need for this.
49include $(CLEAR_VARS)
50LOCAL_IS_HOST_MODULE := true
51LOCAL_MODULE := art_common
52LOCAL_MODULE_TAGS := tests
53LOCAL_MODULE_CLASS := NATIVE_TESTS
54LOCAL_MODULE_SUFFIX := .txt
55LOCAL_COMPATIBILITY_SUITE := general-tests
David Srbecky22872da2020-06-25 15:23:15 +010056LOCAL_COMPATIBILITY_SUPPORT_FILES := $(ART_TESTCASES_PREBUILT_CONTENT) \
David Srbecky1cf46a32020-06-22 15:39:00 +010057 $(foreach f,$(my_files),$(call word-colon,1,$f):out/host/linux-x86/$(call word-colon,2,$f))
58include $(BUILD_SYSTEM)/base_rules.mk
59
60$(LOCAL_BUILT_MODULE):
61 @mkdir -p $(dir $@)
62 echo "This directory contains common data and tools needed for ART host tests" > $@
63
64my_files :=
65include $(CLEAR_VARS)
66###################################################################################################
67
Ian Rogersafd9acc2014-06-17 08:21:54 -070068# The path for which all the dex files are relative, not actually the current directory.
69LOCAL_PATH := art/test
70
71include art/build/Android.common_test.mk
72include art/build/Android.common_path.mk
Alex Light50fa9932015-08-10 15:30:07 -070073include art/build/Android.common_build.mk
Ian Rogersafd9acc2014-06-17 08:21:54 -070074
David Srbecky928d28e2020-04-01 17:50:51 +010075# Deprecated core.art dependencies.
76HOST_CORE_IMAGE_DEFAULT_32 :=
77HOST_CORE_IMAGE_DEFAULT_64 :=
78TARGET_CORE_IMAGE_DEFAULT_32 :=
79TARGET_CORE_IMAGE_DEFAULT_64 :=
80
Ian Rogersafd9acc2014-06-17 08:21:54 -070081# The elf writer test has dependencies on core.oat.
Richard Uhler67e1dc52017-02-06 16:50:17 +000082ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
83ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
Brian Carlstrom53463ea2014-11-09 14:11:51 -080084
Nicolas Geoffray975b7742019-03-21 17:37:38 +000085# The two_runtimes_test test has dependencies on core.oat.
86ART_GTEST_two_runtimes_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
87ART_GTEST_two_runtimes_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
88
Vladimir Marko672c0802019-07-26 13:03:13 +010089# The transaction test has dependencies on core.oat.
90ART_GTEST_transaction_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
91ART_GTEST_transaction_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
92
Ian Rogersafd9acc2014-06-17 08:21:54 -070093# The path for which all the source files are relative, not actually the current directory.
Brian Carlstrom7940e442013-07-12 13:46:57 -070094LOCAL_PATH := art
95
Colin Cross6e95dd52016-09-12 15:37:10 -070096ART_TEST_MODULES := \
97 art_cmdline_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -070098 art_compiler_host_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +000099 art_compiler_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700100 art_dex2oat_tests \
Mathieu Chartier2e0478a2018-04-06 14:33:25 -0700101 art_dexanalyze_tests \
David Sehr55232f12017-04-19 14:06:49 -0700102 art_dexdiag_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700103 art_dexdump_tests \
104 art_dexlayout_tests \
105 art_dexlist_tests \
Calin Juravle36eb3132017-01-13 16:32:38 -0800106 art_dexoptanalyzer_tests \
David Brazdil2b9c35b2018-01-12 15:44:43 +0000107 art_hiddenapi_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700108 art_imgdiag_tests \
David Sehr67bf42e2018-02-26 16:43:04 -0800109 art_libartbase_tests \
Orion Hodson119733d2019-01-30 15:14:41 +0000110 art_libartpalette_tests \
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000111 art_libdexfile_external_tests \
Martin Stjernholm70ae00d2019-02-15 22:41:14 +0000112 art_libdexfile_support_static_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +0000113 art_libdexfile_support_tests \
David Sehr334b9d72018-02-12 18:27:56 -0800114 art_libdexfile_tests \
David Sehrd5f8de82018-04-27 14:12:03 -0700115 art_libprofile_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700116 art_oatdump_tests \
117 art_profman_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700118 art_runtime_compiler_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +0000119 art_runtime_tests \
Josh Gao1eac77e2018-02-26 15:54:41 -0800120 art_sigchain_tests \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800121
Jiyong Parka5992522020-01-07 16:55:09 +0900122ART_TARGET_GTEST_NAMES := $(foreach tm,$(ART_TEST_MODULES),\
123 $(foreach path,$(ART_TEST_LIST_device_$(TARGET_ARCH)_$(tm)),\
124 $(notdir $(path))\
125 )\
126)
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000127
Colin Cross6e95dd52016-09-12 15:37:10 -0700128ART_HOST_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES),\
Colin Cross124f8812016-09-15 20:57:47 -0700129 $(ART_TEST_LIST_host_$(ART_HOST_ARCH)_$(m)))
Alex Light50fa9932015-08-10 15:30:07 -0700130
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100131ifneq ($(HOST_PREFER_32_BIT),true)
1322ND_ART_HOST_GTEST_FILES += $(foreach m,$(ART_TEST_MODULES),\
133 $(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_$(m)))
134endif
135
Ian Rogersafd9acc2014-06-17 08:21:54 -0700136# Variables holding collections of gtest pre-requisits used to run a number of gtests.
137ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
138ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
139ART_TEST_HOST_GTEST_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700140ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
141ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
142ART_TEST_TARGET_GTEST_RULES :=
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100143ART_TEST_HOST_GTEST_DEPENDENCIES :=
Nicolas Geoffray17b1dcb2018-10-12 15:09:42 +0100144ART_TEST_TARGET_GTEST_DEPENDENCIES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700145
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000146ART_GTEST_TARGET_ANDROID_ROOT := '/system'
147ifneq ($(ART_TEST_ANDROID_ROOT),)
148 ART_GTEST_TARGET_ANDROID_ROOT := $(ART_TEST_ANDROID_ROOT)
149endif
150
Victor Chang64611242019-07-05 16:32:41 +0100151ART_GTEST_TARGET_ANDROID_I18N_ROOT := '/apex/com.android.i18n'
152ifneq ($(ART_TEST_ANDROID_I18N_ROOT),)
153 ART_GTEST_TARGET_ANDROID_I18N_ROOT := $(ART_TEST_ANDROID_I18N_ROOT)
154endif
155
Martin Stjernholme58624f2019-09-20 15:53:40 +0100156ART_GTEST_TARGET_ANDROID_ART_ROOT := '/apex/com.android.art'
157ifneq ($(ART_TEST_ANDROID_ART_ROOT),)
158 ART_GTEST_TARGET_ANDROID_ART_ROOT := $(ART_TEST_ANDROID_ART_ROOT)
Roland Levillain7c777f82019-01-10 18:00:37 +0000159endif
Neil Fuller26c43772018-11-23 17:56:43 +0000160
Neil Fuller26a5dd62019-03-13 15:16:35 +0000161ART_GTEST_TARGET_ANDROID_TZDATA_ROOT := '/apex/com.android.tzdata'
162ifneq ($(ART_TEST_ANDROID_TZDATA_ROOT),)
163 ART_GTEST_TARGET_ANDROID_TZDATA_ROOT := $(ART_TEST_ANDROID_TZDATA_ROOT)
164endif
165
Ian Rogersafd9acc2014-06-17 08:21:54 -0700166# Define make rules for a host gtests.
167# $(1): gtest name - the name of the test we're building such as leb128_test.
Colin Cross6e95dd52016-09-12 15:37:10 -0700168# $(2): path relative to $OUT to the test binary
169# $(3): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700170define define-art-gtest-rule-host
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700171 gtest_suffix := $(1)$$($(3)ART_PHONY_TEST_HOST_SUFFIX)
172 gtest_rule := test-art-host-gtest-$$(gtest_suffix)
173 gtest_output := $(call intermediates-dir-for,PACKAGING,art-host-gtest,HOST)/$$(gtest_suffix).xml
Dan Willemsen0ef94572018-10-21 19:00:56 +0000174 $$(call dist-for-goals,$$(gtest_rule),$$(gtest_output):gtest/$$(gtest_suffix))
Colin Cross83072062019-10-02 16:06:58 -0700175 gtest_exe := $(2)
Ian Rogers665de8a2014-06-24 21:34:09 -0700176 # Dependencies for all host gtests.
Nicolas Geoffrayd31cff12020-03-27 14:29:45 +0000177 gtest_deps := $$(ART_HOST_DEX_DEPENDENCIES) \
David Srbecky883c1342020-05-11 23:30:29 +0000178 $$(ART_TEST_HOST_GTEST_DEPENDENCIES) \
David Srbecky0c0f3022020-02-13 15:53:01 +0000179 $$(HOST_BOOT_IMAGE_JARS) \
Victor Chang65ae6692019-10-11 14:17:21 +0100180 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libicu_jni$$(ART_HOST_SHLIB_EXTENSION) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700181 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION) \
182 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100183 $$(gtest_exe) \
184 $$(ART_GTEST_$(1)_HOST_DEPS) \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800185 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) \
Andreas Gampe148c1602019-06-10 16:47:46 -0700186 $(HOST_OUT_EXECUTABLES)/signal_dumper
Ian Rogers665de8a2014-06-24 21:34:09 -0700187
David Srbecky403384e2020-03-27 12:24:36 +0000188 # Note: The "host arch" Make variables defined in build/make/core/envsetup.mk
189 # and art/build/Android.common.mk have different meanings:
190 #
191 # * In build/make/core/envsetup.mk:
192 # * HOST_ARCH := x86_64
193 # * HOST_2ND_ARCH := x86
194 #
195 # * In art/build/Android.common.mk:
196 # * When `HOST_PREFER_32_BIT` is `true`:
197 # * ART_HOST_ARCH := x86
198 # * 2ND_ART_HOST_ARCH :=
199 # * 2ND_HOST_ARCH :=
200 # * Otherwise:
201 # * ART_HOST_ARCH := x86_64
202 # * 2ND_ART_HOST_ARCH := x86
203 # * 2ND_HOST_ARCH := x86
204 ifeq ($(HOST_PREFER_32_BIT),true)
205 gtest_deps += $$(2ND_HOST_BOOT_IMAGE) # Depend on the 32-bit boot image.
206 else
207 gtest_deps += $$($(3)HOST_BOOT_IMAGE)
208 endif
209
Andreas Gampe6acebf42018-01-22 22:15:43 -0800210.PHONY: $$(gtest_rule)
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700211$$(gtest_rule): $$(gtest_output)
212
213# Re-run the tests, even if nothing changed. Until the build system has a dedicated "no cache"
214# option, claim to write a file that is never produced.
215$$(gtest_output): .KATI_IMPLICIT_OUTPUTS := $$(gtest_output)-nocache
David Srbecky883c1342020-05-11 23:30:29 +0000216# Limit concurrent runs. Each test itself is already highly parallel (and thus memory hungry).
217$$(gtest_output): .KATI_NINJA_POOL := highmem_pool
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700218$$(gtest_output): NAME := $$(gtest_rule)
Andreas Gampe6acebf42018-01-22 22:15:43 -0800219ifeq (,$(SANITIZE_HOST))
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700220$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800221 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700222 timeout --foreground -k 120s 2400s $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Christopher Ferrisfc5e2ef2020-05-08 00:08:42 +0000223 $$< --gtest_output=xml:$$@ && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700224 $$(call ART_TEST_PASSED,$$(NAME))) || $$(call ART_TEST_FAILED,$$(NAME))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800225else
Andreas Gampe03858052017-05-01 08:17:24 -0700226# Note: envsetup currently exports ASAN_OPTIONS=detect_leaks=0 to suppress leak detection, as some
227# build tools (e.g., ninja) intentionally leak. We want leak checks when we run our tests, so
228# override ASAN_OPTIONS. b/37751350
Andreas Gampe6acebf42018-01-22 22:15:43 -0800229# Note 2: Under sanitization, also capture the output, and run it through the stack tool on failure
230# (with the x86-64 ABI, as this allows symbolization of both x86 and x86-64). We don't do this in
231# general as it loses all the color output, and we have our own symbolization step when not running
232# under ASAN.
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700233$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
234 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && set -o pipefail && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700235 ASAN_OPTIONS=detect_leaks=1 timeout --foreground -k 120s 3600s \
236 $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800237 $$< --gtest_output=xml:$$@ 2>&1 | tee $$<.tmp.out >&2 && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700238 { $$(call ART_TEST_PASSED,$$(NAME)) ; rm $$<.tmp.out ; }) || \
Andreas Gampec05fd3f2018-01-23 14:22:07 -0800239 ( grep -q AddressSanitizer $$<.tmp.out && export ANDROID_BUILD_TOP=`pwd` && \
Andreas Gampe6acebf42018-01-22 22:15:43 -0800240 { echo "ABI: 'x86_64'" | cat - $$<.tmp.out | development/scripts/stack | tail -n 3000 ; } ; \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700241 rm $$<.tmp.out ; $$(call ART_TEST_FAILED,$$(NAME)))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800242endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700243
Colin Cross6e95dd52016-09-12 15:37:10 -0700244 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700245 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
246 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
247
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800248
Ian Rogersafd9acc2014-06-17 08:21:54 -0700249 # Clear locally defined variables.
Ian Rogers665de8a2014-06-24 21:34:09 -0700250 gtest_deps :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000251 gtest_exe :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700252 gtest_output :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000253 gtest_rule :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700254 gtest_suffix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700255endef # define-art-gtest-rule-host
256
David Srbecky4a88a5a2020-05-05 16:21:57 +0100257ART_TEST_HOST_GTEST_DEPENDENCIES :=
258ART_TEST_TARGET_GTEST_DEPENDENCIES := $(TESTING_ART_APEX)
David Srbecky883c1342020-05-11 23:30:29 +0000259
Jiyong Parkeac38a12020-01-03 17:56:33 +0900260# Add the additional dependencies for the specified test
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000261# $(1): test name
Jiyong Parkeac38a12020-01-03 17:56:33 +0900262define add-art-gtest-dependencies
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000263 # Note that, both the primary and the secondary arches of the libs are built by depending
264 # on the module name.
265 gtest_deps := \
266 $$(ART_GTEST_$(1)_TARGET_DEPS) \
267 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Brian Carlstrom0796af02011-10-12 14:31:45 -0700268
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000269 ART_TEST_TARGET_GTEST_DEPENDENCIES += $$(gtest_deps)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100270
271 # Clear locally defined variables.
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000272 gtest_deps :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900273endef # add-art-gtest-dependencies
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100274
275# $(1): file name
276# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
277define define-art-gtest-host
278 art_gtest_filename := $(1)
279
280 include $$(CLEAR_VARS)
281 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
282 ifndef ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES
283 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100284 endif
285 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),$$(art_gtest_filename),$(2)))
286
287 # Clear locally defined variables.
288 art_gtest_filename :=
289 art_gtest_name :=
290endef # define-art-gtest-host
291
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100292# Define the rules to build and run gtests for both archs on host.
293# $(1): test name
294define define-art-gtest-host-both
295 art_gtest_name := $(1)
296
Ian Rogersafd9acc2014-06-17 08:21:54 -0700297.PHONY: test-art-host-gtest-$$(art_gtest_name)
298test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
299 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800300
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100301 # Clear now unused variables.
302 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700303 art_gtest_name :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100304endef # define-art-gtest-host-both
Alex Light50fa9932015-08-10 15:30:07 -0700305
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700306ifeq ($(ART_BUILD_TARGET),true)
Jiyong Parkeac38a12020-01-03 17:56:33 +0900307 $(foreach name,$(ART_TARGET_GTEST_NAMES), $(eval $(call add-art-gtest-dependencies,$(name),)))
308 ART_TEST_TARGET_GTEST_DEPENDENCIES += \
Nicolas Geoffrayb2d4a7e2020-06-22 12:27:33 +0000309 libicu_jni.com.android.i18n \
Nicolas Geoffrayec64f202020-04-20 15:05:54 +0100310 libjavacore.com.android.art.testing \
311 libopenjdkd.com.android.art.testing \
Nicolas Geoffray31e0dc22020-03-20 15:48:09 +0000312 com.android.art.testing \
313 com.android.conscrypt
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700314endif
Ian Rogersc5f17732014-06-05 20:48:42 -0700315ifeq ($(ART_BUILD_HOST),true)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100316 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),)))
317 ifneq ($(HOST_PREFER_32_BIT),true)
318 $(foreach file,$(2ND_ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),2ND_)))
319 endif
320 # Rules to run the different architecture versions of the gtest.
321 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700322endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700323
324# Used outside the art project to get a list of the current tests
325RUNTIME_TARGET_GTEST_MAKE_TARGETS :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900326art_target_gtest_files := $(foreach m,$(ART_TEST_MODULES),$(ART_TEST_LIST_device_$(TARGET_ARCH)_$(m)))
Dan Willemsen7955f5e2020-01-28 12:18:49 -0800327# If testdir == testfile, assume this is not a test_per_src module
Jiyong Parkeac38a12020-01-03 17:56:33 +0900328$(foreach file,$(art_target_gtest_files),\
Dan Willemsen7955f5e2020-01-28 12:18:49 -0800329 $(eval testdir := $$(notdir $$(patsubst %/,%,$$(dir $$(file)))))\
330 $(eval testfile := $$(notdir $$(basename $$(file))))\
331 $(if $(call streq,$(testdir),$(testfile)),,\
332 $(eval testfile := $(testdir)_$(testfile)))\
333 $(eval RUNTIME_TARGET_GTEST_MAKE_TARGETS += $(testfile))\
Jiyong Parkeac38a12020-01-03 17:56:33 +0900334)
Dan Willemsen7955f5e2020-01-28 12:18:49 -0800335testdir :=
336testfile :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900337art_target_gtest_files :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700338
Roland Levillain05e34f42018-05-24 13:19:05 +0000339# Define all the combinations of host/target and suffix such as:
340# test-art-host-gtest or test-art-host-gtest64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700341# $(1): host or target
342# $(2): HOST or TARGET
Roland Levillain05e34f42018-05-24 13:19:05 +0000343# $(3): undefined, 32 or 64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700344define define-test-art-gtest-combination
345 ifeq ($(1),host)
346 ifneq ($(2),HOST)
347 $$(error argument mismatch $(1) and ($2))
348 endif
349 else
350 ifneq ($(1),target)
351 $$(error found $(1) expected host or target)
352 endif
353 ifneq ($(2),TARGET)
354 $$(error argument mismatch $(1) and ($2))
355 endif
356 endif
357
Roland Levillain05e34f42018-05-24 13:19:05 +0000358 rule_name := test-art-$(1)-gtest$(3)
359 dependencies := $$(ART_TEST_$(2)_GTEST$(3)_RULES)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700360
361.PHONY: $$(rule_name)
Søren Gjesse46845f62019-12-10 09:14:16 +0100362$$(rule_name): $$(dependencies) d8
Ian Rogersafd9acc2014-06-17 08:21:54 -0700363 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
364
365 # Clear locally defined variables.
366 rule_name :=
367 dependencies :=
368endef # define-test-art-gtest-combination
369
Roland Levillain05e34f42018-05-24 13:19:05 +0000370$(eval $(call define-test-art-gtest-combination,target,TARGET,))
371$(eval $(call define-test-art-gtest-combination,target,TARGET,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Dan Willemsen5d2dbf82018-04-11 12:31:11 -0700372ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX
Roland Levillain05e34f42018-05-24 13:19:05 +0000373$(eval $(call define-test-art-gtest-combination,target,TARGET,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700374endif
Roland Levillain05e34f42018-05-24 13:19:05 +0000375$(eval $(call define-test-art-gtest-combination,host,HOST,))
376$(eval $(call define-test-art-gtest-combination,host,HOST,$(ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700377ifneq ($(HOST_PREFER_32_BIT),true)
Roland Levillain05e34f42018-05-24 13:19:05 +0000378$(eval $(call define-test-art-gtest-combination,host,HOST,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700379endif
380
381# Clear locally defined variables.
382define-art-gtest-rule-target :=
383define-art-gtest-rule-host :=
384define-art-gtest :=
385define-test-art-gtest-combination :=
386RUNTIME_GTEST_COMMON_SRC_FILES :=
387COMPILER_GTEST_COMMON_SRC_FILES :=
388RUNTIME_GTEST_TARGET_SRC_FILES :=
389RUNTIME_GTEST_HOST_SRC_FILES :=
390COMPILER_GTEST_TARGET_SRC_FILES :=
391COMPILER_GTEST_HOST_SRC_FILES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700392ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
393ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
394ART_TEST_HOST_GTEST_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700395ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
396ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
397ART_TEST_TARGET_GTEST_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000398ART_GTEST_TARGET_ANDROID_ROOT :=
Victor Chang64611242019-07-05 16:32:41 +0100399ART_GTEST_TARGET_ANDROID_I18N_ROOT :=
Martin Stjernholme58624f2019-09-20 15:53:40 +0100400ART_GTEST_TARGET_ANDROID_ART_ROOT :=
Neil Fuller26a5dd62019-03-13 15:16:35 +0000401ART_GTEST_TARGET_ANDROID_TZDATA_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700402ART_GTEST_class_linker_test_DEX_DEPS :=
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800403ART_GTEST_class_table_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700404ART_GTEST_compiler_driver_test_DEX_DEPS :=
405ART_GTEST_dex_file_test_DEX_DEPS :=
406ART_GTEST_exception_test_DEX_DEPS :=
407ART_GTEST_elf_writer_test_HOST_DEPS :=
408ART_GTEST_elf_writer_test_TARGET_DEPS :=
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700409ART_GTEST_imtable_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700410ART_GTEST_jni_compiler_test_DEX_DEPS :=
411ART_GTEST_jni_internal_test_DEX_DEPS :=
Richard Uhler66d874d2015-01-15 09:37:19 -0800412ART_GTEST_oat_file_assistant_test_DEX_DEPS :=
413ART_GTEST_oat_file_assistant_test_HOST_DEPS :=
414ART_GTEST_oat_file_assistant_test_TARGET_DEPS :=
Mathieu Chartier0be7fa72018-04-12 10:13:29 -0700415ART_GTEST_dexanalyze_test_DEX_DEPS :=
Calin Juravle36eb3132017-01-13 16:32:38 -0800416ART_GTEST_dexoptanalyzer_test_DEX_DEPS :=
417ART_GTEST_dexoptanalyzer_test_HOST_DEPS :=
418ART_GTEST_dexoptanalyzer_test_TARGET_DEPS :=
Richard Uhler84f50ae2017-02-06 15:12:45 +0000419ART_GTEST_image_space_test_DEX_DEPS :=
420ART_GTEST_image_space_test_HOST_DEPS :=
421ART_GTEST_image_space_test_TARGET_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700422ART_GTEST_dex2oat_test_DEX_DEPS :=
423ART_GTEST_dex2oat_test_HOST_DEPS :=
424ART_GTEST_dex2oat_test_TARGET_DEPS :=
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700425ART_GTEST_dex2oat_image_test_DEX_DEPS :=
426ART_GTEST_dex2oat_image_test_HOST_DEPS :=
427ART_GTEST_dex2oat_image_test_TARGET_DEPS :=
Vladimir Markod1f73512020-04-02 10:50:35 +0100428ART_GTEST_module_exclusion_test_HOST_DEPS :=
429ART_GTEST_module_exclusion_test_TARGET_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700430ART_GTEST_object_test_DEX_DEPS :=
431ART_GTEST_proxy_test_DEX_DEPS :=
432ART_GTEST_reflection_test_DEX_DEPS :=
433ART_GTEST_stub_test_DEX_DEPS :=
434ART_GTEST_transaction_test_DEX_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700435ART_GTEST_dex2oat_environment_tests_DEX_DEPS :=
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700436ART_GTEST_heap_verification_test_DEX_DEPS :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100437ART_GTEST_verifier_deps_test_DEX_DEPS :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700438$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
439$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Richard Uhler66d874d2015-01-15 09:37:19 -0800440ART_TEST_HOST_GTEST_MainStripped_DEX :=
441ART_TEST_TARGET_GTEST_MainStripped_DEX :=
David Srbecky8c8f1482020-02-05 20:17:10 +0000442ART_TEST_HOST_GTEST_MainUncompressedAligned_DEX :=
443ART_TEST_TARGET_GTEST_MainUncompressedAligned_DEX :=
Mathieu Chartier700a9852018-02-06 18:27:38 -0800444ART_TEST_HOST_GTEST_EmptyUncompressed_DEX :=
445ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100446ART_TEST_GTEST_VerifierDeps_SRC :=
447ART_TEST_HOST_GTEST_VerifierDeps_DEX :=
David Brazdilf906f122016-09-16 16:33:31 +0100448ART_TEST_TARGET_GTEST_VerifierDeps_DEX :=
Vladimir Markod79b37b2018-11-02 13:06:22 +0000449ART_TEST_GTEST_VerifySoftFailDuringClinit_SRC :=
450ART_TEST_HOST_GTEST_VerifySoftFailDuringClinit_DEX :=
451ART_TEST_TARGET_GTEST_VerifySoftFailDuringClinit_DEX :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700452GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700453LOCAL_PATH :=
David Srbecky883c1342020-05-11 23:30:29 +0000454
455endif # ifneq ($(HOST_OS),darwin)