blob: 73310339b2a87be478fee0ceac5264961a496226 [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) \
Nicolas Geoffrayc69b3f82020-06-22 12:33:38 +0000179 $$(HOST_OUT)/$$(I18N_APEX)/etc \
David Srbecky0c0f3022020-02-13 15:53:01 +0000180 $$(HOST_BOOT_IMAGE_JARS) \
Victor Chang65ae6692019-10-11 14:17:21 +0100181 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libicu_jni$$(ART_HOST_SHLIB_EXTENSION) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700182 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION) \
183 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100184 $$(gtest_exe) \
185 $$(ART_GTEST_$(1)_HOST_DEPS) \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800186 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) \
Andreas Gampe148c1602019-06-10 16:47:46 -0700187 $(HOST_OUT_EXECUTABLES)/signal_dumper
Ian Rogers665de8a2014-06-24 21:34:09 -0700188
David Srbecky403384e2020-03-27 12:24:36 +0000189 # Note: The "host arch" Make variables defined in build/make/core/envsetup.mk
190 # and art/build/Android.common.mk have different meanings:
191 #
192 # * In build/make/core/envsetup.mk:
193 # * HOST_ARCH := x86_64
194 # * HOST_2ND_ARCH := x86
195 #
196 # * In art/build/Android.common.mk:
197 # * When `HOST_PREFER_32_BIT` is `true`:
198 # * ART_HOST_ARCH := x86
199 # * 2ND_ART_HOST_ARCH :=
200 # * 2ND_HOST_ARCH :=
201 # * Otherwise:
202 # * ART_HOST_ARCH := x86_64
203 # * 2ND_ART_HOST_ARCH := x86
204 # * 2ND_HOST_ARCH := x86
205 ifeq ($(HOST_PREFER_32_BIT),true)
206 gtest_deps += $$(2ND_HOST_BOOT_IMAGE) # Depend on the 32-bit boot image.
207 else
208 gtest_deps += $$($(3)HOST_BOOT_IMAGE)
209 endif
210
Andreas Gampe6acebf42018-01-22 22:15:43 -0800211.PHONY: $$(gtest_rule)
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700212$$(gtest_rule): $$(gtest_output)
213
214# Re-run the tests, even if nothing changed. Until the build system has a dedicated "no cache"
215# option, claim to write a file that is never produced.
216$$(gtest_output): .KATI_IMPLICIT_OUTPUTS := $$(gtest_output)-nocache
David Srbecky883c1342020-05-11 23:30:29 +0000217# Limit concurrent runs. Each test itself is already highly parallel (and thus memory hungry).
218$$(gtest_output): .KATI_NINJA_POOL := highmem_pool
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700219$$(gtest_output): NAME := $$(gtest_rule)
Andreas Gampe6acebf42018-01-22 22:15:43 -0800220ifeq (,$(SANITIZE_HOST))
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700221$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800222 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700223 timeout --foreground -k 120s 2400s $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Christopher Ferrisfc5e2ef2020-05-08 00:08:42 +0000224 $$< --gtest_output=xml:$$@ && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700225 $$(call ART_TEST_PASSED,$$(NAME))) || $$(call ART_TEST_FAILED,$$(NAME))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800226else
Andreas Gampe03858052017-05-01 08:17:24 -0700227# Note: envsetup currently exports ASAN_OPTIONS=detect_leaks=0 to suppress leak detection, as some
228# build tools (e.g., ninja) intentionally leak. We want leak checks when we run our tests, so
229# override ASAN_OPTIONS. b/37751350
Andreas Gampe6acebf42018-01-22 22:15:43 -0800230# Note 2: Under sanitization, also capture the output, and run it through the stack tool on failure
231# (with the x86-64 ABI, as this allows symbolization of both x86 and x86-64). We don't do this in
232# general as it loses all the color output, and we have our own symbolization step when not running
233# under ASAN.
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700234$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
235 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && set -o pipefail && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700236 ASAN_OPTIONS=detect_leaks=1 timeout --foreground -k 120s 3600s \
237 $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800238 $$< --gtest_output=xml:$$@ 2>&1 | tee $$<.tmp.out >&2 && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700239 { $$(call ART_TEST_PASSED,$$(NAME)) ; rm $$<.tmp.out ; }) || \
Andreas Gampec05fd3f2018-01-23 14:22:07 -0800240 ( grep -q AddressSanitizer $$<.tmp.out && export ANDROID_BUILD_TOP=`pwd` && \
Andreas Gampe6acebf42018-01-22 22:15:43 -0800241 { echo "ABI: 'x86_64'" | cat - $$<.tmp.out | development/scripts/stack | tail -n 3000 ; } ; \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700242 rm $$<.tmp.out ; $$(call ART_TEST_FAILED,$$(NAME)))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800243endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700244
Colin Cross6e95dd52016-09-12 15:37:10 -0700245 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700246 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
247 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
248
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800249
Ian Rogersafd9acc2014-06-17 08:21:54 -0700250 # Clear locally defined variables.
Ian Rogers665de8a2014-06-24 21:34:09 -0700251 gtest_deps :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000252 gtest_exe :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700253 gtest_output :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000254 gtest_rule :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700255 gtest_suffix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700256endef # define-art-gtest-rule-host
257
Nicolas Geoffrayc69b3f82020-06-22 12:33:38 +0000258ART_TEST_HOST_GTEST_DEPENDENCIES := $(host-i18n-data-file)
David Srbecky4a88a5a2020-05-05 16:21:57 +0100259ART_TEST_TARGET_GTEST_DEPENDENCIES := $(TESTING_ART_APEX)
David Srbecky883c1342020-05-11 23:30:29 +0000260
Jiyong Parkeac38a12020-01-03 17:56:33 +0900261# Add the additional dependencies for the specified test
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000262# $(1): test name
Jiyong Parkeac38a12020-01-03 17:56:33 +0900263define add-art-gtest-dependencies
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000264 # Note that, both the primary and the secondary arches of the libs are built by depending
265 # on the module name.
266 gtest_deps := \
267 $$(ART_GTEST_$(1)_TARGET_DEPS) \
268 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Brian Carlstrom0796af02011-10-12 14:31:45 -0700269
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000270 ART_TEST_TARGET_GTEST_DEPENDENCIES += $$(gtest_deps)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100271
272 # Clear locally defined variables.
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000273 gtest_deps :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900274endef # add-art-gtest-dependencies
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100275
276# $(1): file name
277# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
278define define-art-gtest-host
279 art_gtest_filename := $(1)
280
281 include $$(CLEAR_VARS)
282 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
283 ifndef ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES
284 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100285 endif
286 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),$$(art_gtest_filename),$(2)))
287
288 # Clear locally defined variables.
289 art_gtest_filename :=
290 art_gtest_name :=
291endef # define-art-gtest-host
292
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100293# Define the rules to build and run gtests for both archs on host.
294# $(1): test name
295define define-art-gtest-host-both
296 art_gtest_name := $(1)
297
Ian Rogersafd9acc2014-06-17 08:21:54 -0700298.PHONY: test-art-host-gtest-$$(art_gtest_name)
299test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
300 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800301
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100302 # Clear now unused variables.
303 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700304 art_gtest_name :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100305endef # define-art-gtest-host-both
Alex Light50fa9932015-08-10 15:30:07 -0700306
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700307ifeq ($(ART_BUILD_TARGET),true)
Jiyong Parkeac38a12020-01-03 17:56:33 +0900308 $(foreach name,$(ART_TARGET_GTEST_NAMES), $(eval $(call add-art-gtest-dependencies,$(name),)))
309 ART_TEST_TARGET_GTEST_DEPENDENCIES += \
Nicolas Geoffrayc69b3f82020-06-22 12:33:38 +0000310 com.android.i18n \
Nicolas Geoffrayec64f202020-04-20 15:05:54 +0100311 libjavacore.com.android.art.testing \
312 libopenjdkd.com.android.art.testing \
Nicolas Geoffray31e0dc22020-03-20 15:48:09 +0000313 com.android.art.testing \
314 com.android.conscrypt
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700315endif
Ian Rogersc5f17732014-06-05 20:48:42 -0700316ifeq ($(ART_BUILD_HOST),true)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100317 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),)))
318 ifneq ($(HOST_PREFER_32_BIT),true)
319 $(foreach file,$(2ND_ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),2ND_)))
320 endif
321 # Rules to run the different architecture versions of the gtest.
322 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700323endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700324
325# Used outside the art project to get a list of the current tests
326RUNTIME_TARGET_GTEST_MAKE_TARGETS :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900327art_target_gtest_files := $(foreach m,$(ART_TEST_MODULES),$(ART_TEST_LIST_device_$(TARGET_ARCH)_$(m)))
Dan Willemsen7955f5e2020-01-28 12:18:49 -0800328# If testdir == testfile, assume this is not a test_per_src module
Jiyong Parkeac38a12020-01-03 17:56:33 +0900329$(foreach file,$(art_target_gtest_files),\
Dan Willemsen7955f5e2020-01-28 12:18:49 -0800330 $(eval testdir := $$(notdir $$(patsubst %/,%,$$(dir $$(file)))))\
331 $(eval testfile := $$(notdir $$(basename $$(file))))\
332 $(if $(call streq,$(testdir),$(testfile)),,\
333 $(eval testfile := $(testdir)_$(testfile)))\
334 $(eval RUNTIME_TARGET_GTEST_MAKE_TARGETS += $(testfile))\
Jiyong Parkeac38a12020-01-03 17:56:33 +0900335)
Dan Willemsen7955f5e2020-01-28 12:18:49 -0800336testdir :=
337testfile :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900338art_target_gtest_files :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700339
Roland Levillain05e34f42018-05-24 13:19:05 +0000340# Define all the combinations of host/target and suffix such as:
341# test-art-host-gtest or test-art-host-gtest64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700342# $(1): host or target
343# $(2): HOST or TARGET
Roland Levillain05e34f42018-05-24 13:19:05 +0000344# $(3): undefined, 32 or 64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700345define define-test-art-gtest-combination
346 ifeq ($(1),host)
347 ifneq ($(2),HOST)
348 $$(error argument mismatch $(1) and ($2))
349 endif
350 else
351 ifneq ($(1),target)
352 $$(error found $(1) expected host or target)
353 endif
354 ifneq ($(2),TARGET)
355 $$(error argument mismatch $(1) and ($2))
356 endif
357 endif
358
Roland Levillain05e34f42018-05-24 13:19:05 +0000359 rule_name := test-art-$(1)-gtest$(3)
360 dependencies := $$(ART_TEST_$(2)_GTEST$(3)_RULES)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700361
362.PHONY: $$(rule_name)
Søren Gjesse46845f62019-12-10 09:14:16 +0100363$$(rule_name): $$(dependencies) d8
Ian Rogersafd9acc2014-06-17 08:21:54 -0700364 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
365
366 # Clear locally defined variables.
367 rule_name :=
368 dependencies :=
369endef # define-test-art-gtest-combination
370
Roland Levillain05e34f42018-05-24 13:19:05 +0000371$(eval $(call define-test-art-gtest-combination,target,TARGET,))
372$(eval $(call define-test-art-gtest-combination,target,TARGET,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Dan Willemsen5d2dbf82018-04-11 12:31:11 -0700373ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX
Roland Levillain05e34f42018-05-24 13:19:05 +0000374$(eval $(call define-test-art-gtest-combination,target,TARGET,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700375endif
Roland Levillain05e34f42018-05-24 13:19:05 +0000376$(eval $(call define-test-art-gtest-combination,host,HOST,))
377$(eval $(call define-test-art-gtest-combination,host,HOST,$(ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700378ifneq ($(HOST_PREFER_32_BIT),true)
Roland Levillain05e34f42018-05-24 13:19:05 +0000379$(eval $(call define-test-art-gtest-combination,host,HOST,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700380endif
381
382# Clear locally defined variables.
383define-art-gtest-rule-target :=
384define-art-gtest-rule-host :=
385define-art-gtest :=
386define-test-art-gtest-combination :=
387RUNTIME_GTEST_COMMON_SRC_FILES :=
388COMPILER_GTEST_COMMON_SRC_FILES :=
389RUNTIME_GTEST_TARGET_SRC_FILES :=
390RUNTIME_GTEST_HOST_SRC_FILES :=
391COMPILER_GTEST_TARGET_SRC_FILES :=
392COMPILER_GTEST_HOST_SRC_FILES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700393ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
394ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
395ART_TEST_HOST_GTEST_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700396ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
397ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
398ART_TEST_TARGET_GTEST_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000399ART_GTEST_TARGET_ANDROID_ROOT :=
Victor Chang64611242019-07-05 16:32:41 +0100400ART_GTEST_TARGET_ANDROID_I18N_ROOT :=
Martin Stjernholme58624f2019-09-20 15:53:40 +0100401ART_GTEST_TARGET_ANDROID_ART_ROOT :=
Neil Fuller26a5dd62019-03-13 15:16:35 +0000402ART_GTEST_TARGET_ANDROID_TZDATA_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700403ART_GTEST_class_linker_test_DEX_DEPS :=
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800404ART_GTEST_class_table_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700405ART_GTEST_compiler_driver_test_DEX_DEPS :=
406ART_GTEST_dex_file_test_DEX_DEPS :=
407ART_GTEST_exception_test_DEX_DEPS :=
408ART_GTEST_elf_writer_test_HOST_DEPS :=
409ART_GTEST_elf_writer_test_TARGET_DEPS :=
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700410ART_GTEST_imtable_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700411ART_GTEST_jni_compiler_test_DEX_DEPS :=
412ART_GTEST_jni_internal_test_DEX_DEPS :=
Richard Uhler66d874d2015-01-15 09:37:19 -0800413ART_GTEST_oat_file_assistant_test_DEX_DEPS :=
414ART_GTEST_oat_file_assistant_test_HOST_DEPS :=
415ART_GTEST_oat_file_assistant_test_TARGET_DEPS :=
Mathieu Chartier0be7fa72018-04-12 10:13:29 -0700416ART_GTEST_dexanalyze_test_DEX_DEPS :=
Calin Juravle36eb3132017-01-13 16:32:38 -0800417ART_GTEST_dexoptanalyzer_test_DEX_DEPS :=
418ART_GTEST_dexoptanalyzer_test_HOST_DEPS :=
419ART_GTEST_dexoptanalyzer_test_TARGET_DEPS :=
Richard Uhler84f50ae2017-02-06 15:12:45 +0000420ART_GTEST_image_space_test_DEX_DEPS :=
421ART_GTEST_image_space_test_HOST_DEPS :=
422ART_GTEST_image_space_test_TARGET_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700423ART_GTEST_dex2oat_test_DEX_DEPS :=
424ART_GTEST_dex2oat_test_HOST_DEPS :=
425ART_GTEST_dex2oat_test_TARGET_DEPS :=
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700426ART_GTEST_dex2oat_image_test_DEX_DEPS :=
427ART_GTEST_dex2oat_image_test_HOST_DEPS :=
428ART_GTEST_dex2oat_image_test_TARGET_DEPS :=
Vladimir Markod1f73512020-04-02 10:50:35 +0100429ART_GTEST_module_exclusion_test_HOST_DEPS :=
430ART_GTEST_module_exclusion_test_TARGET_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700431ART_GTEST_object_test_DEX_DEPS :=
432ART_GTEST_proxy_test_DEX_DEPS :=
433ART_GTEST_reflection_test_DEX_DEPS :=
434ART_GTEST_stub_test_DEX_DEPS :=
435ART_GTEST_transaction_test_DEX_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700436ART_GTEST_dex2oat_environment_tests_DEX_DEPS :=
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700437ART_GTEST_heap_verification_test_DEX_DEPS :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100438ART_GTEST_verifier_deps_test_DEX_DEPS :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700439$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
440$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Richard Uhler66d874d2015-01-15 09:37:19 -0800441ART_TEST_HOST_GTEST_MainStripped_DEX :=
442ART_TEST_TARGET_GTEST_MainStripped_DEX :=
David Srbecky8c8f1482020-02-05 20:17:10 +0000443ART_TEST_HOST_GTEST_MainUncompressedAligned_DEX :=
444ART_TEST_TARGET_GTEST_MainUncompressedAligned_DEX :=
Mathieu Chartier700a9852018-02-06 18:27:38 -0800445ART_TEST_HOST_GTEST_EmptyUncompressed_DEX :=
446ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100447ART_TEST_GTEST_VerifierDeps_SRC :=
448ART_TEST_HOST_GTEST_VerifierDeps_DEX :=
David Brazdilf906f122016-09-16 16:33:31 +0100449ART_TEST_TARGET_GTEST_VerifierDeps_DEX :=
Vladimir Markod79b37b2018-11-02 13:06:22 +0000450ART_TEST_GTEST_VerifySoftFailDuringClinit_SRC :=
451ART_TEST_HOST_GTEST_VerifySoftFailDuringClinit_DEX :=
452ART_TEST_TARGET_GTEST_VerifySoftFailDuringClinit_DEX :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700453GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700454LOCAL_PATH :=
David Srbecky883c1342020-05-11 23:30:29 +0000455
456endif # ifneq ($(HOST_OS),darwin)