blob: 0bc93c2254f3fd65f99991b6b628ab55897604e0 [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
Bob Badour8da26142021-03-01 10:14:50 -080020LOCAL_PATH := $(call my-dir)
21
David Srbecky1cf46a32020-06-22 15:39:00 +010022###################################################################################################
23# Create module in testcases to hold all common data and tools needed for ART host tests.
24
25# ART binary tools and libraries (automatic list of all art_cc_binary/art_cc_library modules).
26my_files := $(ART_TESTCASES_CONTENT)
27
28# Manually add system libraries that we need to run the host ART tools.
29my_files += \
Victor Chang9c1c0422020-10-05 13:17:02 +010030 $(foreach lib, libbacktrace libbase libc++ libicu libicu_jni liblog libsigchain libunwindstack \
David Srbeckyd5e776c2020-09-25 10:18:24 +010031 libziparchive libjavacore libandroidio libopenjdkd liblz4 liblzma, \
David Srbeckybeed9222020-07-01 15:01:41 +010032 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST)/$(lib).so:lib64/$(lib).so \
33 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST,,2ND)/$(lib).so:lib/$(lib).so) \
Victor Chang9c1c0422020-10-05 13:17:02 +010034 $(foreach lib, libcrypto libz libicuuc libicui18n libexpat, \
David Srbeckybeed9222020-07-01 15:01:41 +010035 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST)/$(lib).so:lib64/$(lib)-host.so \
36 $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST,,2ND)/$(lib).so:lib/$(lib)-host.so)
David Srbecky1cf46a32020-06-22 15:39:00 +010037
38# Add apex directories for art, conscrypt and i18n.
David Srbecky671d34d2020-07-02 12:23:28 +010039icu_data_file := $(firstword $(wildcard external/icu/icu4c/source/stubdata/icu*.dat))
David Srbecky1cf46a32020-06-22 15:39:00 +010040my_files += $(foreach infix,_ _VDEX_,$(foreach suffix,$(HOST_ARCH) $(HOST_2ND_ARCH), \
41 $(DEXPREOPT_IMAGE$(infix)BUILT_INSTALLED_art_host_$(suffix))))
42my_files += \
43 $(foreach jar,$(CORE_IMG_JARS),\
44 $(HOST_OUT_JAVA_LIBRARIES)/$(jar)-hostdex.jar:apex/com.android.art/javalib/$(jar).jar) \
45 $(HOST_OUT_JAVA_LIBRARIES)/conscrypt-hostdex.jar:apex/com.android.conscrypt/javalib/conscrypt.jar\
David Srbecky671d34d2020-07-02 12:23:28 +010046 $(HOST_OUT_JAVA_LIBRARIES)/core-icu4j-hostdex.jar:apex/com.android.i18n/javalib/core-icu4j.jar \
47 $(icu_data_file):com.android.i18n/etc/icu/$(notdir $(icu_data_file))
David Srbecky1cf46a32020-06-22 15:39:00 +010048
David Srbeckyd3ee9022020-07-27 16:05:38 +010049# Create phony module that will copy all the data files into testcases directory.
David Srbecky1cf46a32020-06-22 15:39:00 +010050# For now, this copies everything to "out/host/linux-x86/" subdirectory, since it
51# is hard-coded in many places. TODO: Refactor tests to remove the need for this.
52include $(CLEAR_VARS)
53LOCAL_IS_HOST_MODULE := true
54LOCAL_MODULE := art_common
Bob Badour9150de62021-02-26 03:22:24 -080055LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
56LOCAL_LICENSE_CONDITIONS := notice
57LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE
David Srbecky1cf46a32020-06-22 15:39:00 +010058LOCAL_MODULE_TAGS := tests
59LOCAL_MODULE_CLASS := NATIVE_TESTS
60LOCAL_MODULE_SUFFIX := .txt
Dan Shi8562f372020-10-19 10:51:40 -070061LOCAL_COMPATIBILITY_SUITE := art-host-tests
David Srbeckyb0713ca2020-07-01 15:04:39 +010062LOCAL_COMPATIBILITY_SUPPORT_FILES := $(ART_TESTCASES_PREBUILT_CONTENT) \
David Srbecky1cf46a32020-06-22 15:39:00 +010063 $(foreach f,$(my_files),$(call word-colon,1,$f):out/host/linux-x86/$(call word-colon,2,$f))
64include $(BUILD_SYSTEM)/base_rules.mk
65
66$(LOCAL_BUILT_MODULE):
67 @mkdir -p $(dir $@)
68 echo "This directory contains common data and tools needed for ART host tests" > $@
69
70my_files :=
71include $(CLEAR_VARS)
72###################################################################################################
73
Ian Rogersafd9acc2014-06-17 08:21:54 -070074# The path for which all the dex files are relative, not actually the current directory.
75LOCAL_PATH := art/test
76
77include art/build/Android.common_test.mk
78include art/build/Android.common_path.mk
Alex Light50fa9932015-08-10 15:30:07 -070079include art/build/Android.common_build.mk
Ian Rogersafd9acc2014-06-17 08:21:54 -070080
David Srbecky928d28e2020-04-01 17:50:51 +010081# Deprecated core.art dependencies.
82HOST_CORE_IMAGE_DEFAULT_32 :=
83HOST_CORE_IMAGE_DEFAULT_64 :=
84TARGET_CORE_IMAGE_DEFAULT_32 :=
85TARGET_CORE_IMAGE_DEFAULT_64 :=
86
Ian Rogersafd9acc2014-06-17 08:21:54 -070087# The elf writer test has dependencies on core.oat.
Richard Uhler67e1dc52017-02-06 16:50:17 +000088ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
89ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
Brian Carlstrom53463ea2014-11-09 14:11:51 -080090
Nicolas Geoffray975b7742019-03-21 17:37:38 +000091# The two_runtimes_test test has dependencies on core.oat.
92ART_GTEST_two_runtimes_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
93ART_GTEST_two_runtimes_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
94
Vladimir Marko672c0802019-07-26 13:03:13 +010095# The transaction test has dependencies on core.oat.
96ART_GTEST_transaction_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
97ART_GTEST_transaction_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
98
Ian Rogersafd9acc2014-06-17 08:21:54 -070099# The path for which all the source files are relative, not actually the current directory.
Brian Carlstrom7940e442013-07-12 13:46:57 -0700100LOCAL_PATH := art
101
Victor Hsieh7a3ccd02021-09-08 11:59:29 -0700102ART_TEST_MODULES_COMMON := \
Colin Cross6e95dd52016-09-12 15:37:10 -0700103 art_cmdline_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700104 art_compiler_host_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +0000105 art_compiler_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700106 art_dex2oat_tests \
Mathieu Chartier2e0478a2018-04-06 14:33:25 -0700107 art_dexanalyze_tests \
David Sehr55232f12017-04-19 14:06:49 -0700108 art_dexdiag_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700109 art_dexdump_tests \
110 art_dexlayout_tests \
111 art_dexlist_tests \
Calin Juravle36eb3132017-01-13 16:32:38 -0800112 art_dexoptanalyzer_tests \
David Brazdil2b9c35b2018-01-12 15:44:43 +0000113 art_hiddenapi_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700114 art_imgdiag_tests \
David Sehr67bf42e2018-02-26 16:43:04 -0800115 art_libartbase_tests \
Orion Hodson119733d2019-01-30 15:14:41 +0000116 art_libartpalette_tests \
Chris Wailesbfd622a2021-01-13 16:13:41 -0800117 art_libartservice_tests \
118 art_libarttools_tests \
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000119 art_libdexfile_external_tests \
Martin Stjernholm70ae00d2019-02-15 22:41:14 +0000120 art_libdexfile_support_static_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +0000121 art_libdexfile_support_tests \
David Sehr334b9d72018-02-12 18:27:56 -0800122 art_libdexfile_tests \
David Sehrd5f8de82018-04-27 14:12:03 -0700123 art_libprofile_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700124 art_oatdump_tests \
125 art_profman_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700126 art_runtime_compiler_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +0000127 art_runtime_tests \
Josh Gao1eac77e2018-02-26 15:54:41 -0800128 art_sigchain_tests \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800129
Victor Hsieh7a3ccd02021-09-08 11:59:29 -0700130ART_TEST_MODULES_TARGET := $(ART_TEST_MODULES_COMMON) art_odrefresh_tests
131ART_TEST_MODULES_HOST := $(ART_TEST_MODULES_COMMON)
132
133ART_TARGET_GTEST_NAMES := $(foreach tm,$(ART_TEST_MODULES_TARGET),\
Jiyong Parka5992522020-01-07 16:55:09 +0900134 $(foreach path,$(ART_TEST_LIST_device_$(TARGET_ARCH)_$(tm)),\
135 $(notdir $(path))\
136 )\
137)
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000138
Victor Hsieh7a3ccd02021-09-08 11:59:29 -0700139ART_HOST_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES_HOST),\
Colin Cross124f8812016-09-15 20:57:47 -0700140 $(ART_TEST_LIST_host_$(ART_HOST_ARCH)_$(m)))
Alex Light50fa9932015-08-10 15:30:07 -0700141
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100142ifneq ($(HOST_PREFER_32_BIT),true)
Victor Hsieh7a3ccd02021-09-08 11:59:29 -07001432ND_ART_HOST_GTEST_FILES += $(foreach m,$(ART_TEST_MODULES_HOST),\
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100144 $(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_$(m)))
145endif
146
Ian Rogersafd9acc2014-06-17 08:21:54 -0700147# Variables holding collections of gtest pre-requisits used to run a number of gtests.
148ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
149ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
150ART_TEST_HOST_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700151ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
152ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
153ART_TEST_HOST_GTEST_BUILD_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700154ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
155ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
156ART_TEST_TARGET_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700157ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
158ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
159ART_TEST_TARGET_GTEST_BUILD_RULES :=
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100160ART_TEST_HOST_GTEST_DEPENDENCIES :=
Nicolas Geoffray17b1dcb2018-10-12 15:09:42 +0100161ART_TEST_TARGET_GTEST_DEPENDENCIES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700162
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000163ART_GTEST_TARGET_ANDROID_ROOT := '/system'
164ifneq ($(ART_TEST_ANDROID_ROOT),)
165 ART_GTEST_TARGET_ANDROID_ROOT := $(ART_TEST_ANDROID_ROOT)
166endif
167
Victor Chang64611242019-07-05 16:32:41 +0100168ART_GTEST_TARGET_ANDROID_I18N_ROOT := '/apex/com.android.i18n'
169ifneq ($(ART_TEST_ANDROID_I18N_ROOT),)
170 ART_GTEST_TARGET_ANDROID_I18N_ROOT := $(ART_TEST_ANDROID_I18N_ROOT)
171endif
172
Martin Stjernholme58624f2019-09-20 15:53:40 +0100173ART_GTEST_TARGET_ANDROID_ART_ROOT := '/apex/com.android.art'
174ifneq ($(ART_TEST_ANDROID_ART_ROOT),)
175 ART_GTEST_TARGET_ANDROID_ART_ROOT := $(ART_TEST_ANDROID_ART_ROOT)
Roland Levillain7c777f82019-01-10 18:00:37 +0000176endif
Neil Fuller26c43772018-11-23 17:56:43 +0000177
Neil Fuller26a5dd62019-03-13 15:16:35 +0000178ART_GTEST_TARGET_ANDROID_TZDATA_ROOT := '/apex/com.android.tzdata'
179ifneq ($(ART_TEST_ANDROID_TZDATA_ROOT),)
180 ART_GTEST_TARGET_ANDROID_TZDATA_ROOT := $(ART_TEST_ANDROID_TZDATA_ROOT)
181endif
182
Ian Rogersafd9acc2014-06-17 08:21:54 -0700183# Define make rules for a host gtests.
184# $(1): gtest name - the name of the test we're building such as leb128_test.
Colin Cross6e95dd52016-09-12 15:37:10 -0700185# $(2): path relative to $OUT to the test binary
186# $(3): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700187define define-art-gtest-rule-host
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700188 gtest_suffix := $(1)$$($(3)ART_PHONY_TEST_HOST_SUFFIX)
189 gtest_rule := test-art-host-gtest-$$(gtest_suffix)
Alex Lightd78be002020-09-01 07:49:21 -0700190 gtest_build_rule := test-art-host-gtest-dependencies-$$(gtest_suffix)
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700191 gtest_output := $(call intermediates-dir-for,PACKAGING,art-host-gtest,HOST)/$$(gtest_suffix).xml
Dan Willemsen0ef94572018-10-21 19:00:56 +0000192 $$(call dist-for-goals,$$(gtest_rule),$$(gtest_output):gtest/$$(gtest_suffix))
Colin Cross83072062019-10-02 16:06:58 -0700193 gtest_exe := $(2)
Ian Rogers665de8a2014-06-24 21:34:09 -0700194 # Dependencies for all host gtests.
Nicolas Geoffrayd31cff12020-03-27 14:29:45 +0000195 gtest_deps := $$(ART_HOST_DEX_DEPENDENCIES) \
David Srbecky883c1342020-05-11 23:30:29 +0000196 $$(ART_TEST_HOST_GTEST_DEPENDENCIES) \
Martin Stjernholm76228ff2020-07-16 22:17:09 +0100197 $$(HOST_OUT)/$$(I18N_APEX)/timestamp \
David Srbecky0c0f3022020-02-13 15:53:01 +0000198 $$(HOST_BOOT_IMAGE_JARS) \
Victor Chang65ae6692019-10-11 14:17:21 +0100199 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libicu_jni$$(ART_HOST_SHLIB_EXTENSION) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700200 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION) \
201 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100202 $$(gtest_exe) \
203 $$(ART_GTEST_$(1)_HOST_DEPS) \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800204 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) \
Andreas Gampe148c1602019-06-10 16:47:46 -0700205 $(HOST_OUT_EXECUTABLES)/signal_dumper
Ian Rogers665de8a2014-06-24 21:34:09 -0700206
David Srbecky403384e2020-03-27 12:24:36 +0000207 # Note: The "host arch" Make variables defined in build/make/core/envsetup.mk
208 # and art/build/Android.common.mk have different meanings:
209 #
210 # * In build/make/core/envsetup.mk:
211 # * HOST_ARCH := x86_64
212 # * HOST_2ND_ARCH := x86
213 #
214 # * In art/build/Android.common.mk:
215 # * When `HOST_PREFER_32_BIT` is `true`:
216 # * ART_HOST_ARCH := x86
217 # * 2ND_ART_HOST_ARCH :=
218 # * 2ND_HOST_ARCH :=
219 # * Otherwise:
220 # * ART_HOST_ARCH := x86_64
221 # * 2ND_ART_HOST_ARCH := x86
222 # * 2ND_HOST_ARCH := x86
223 ifeq ($(HOST_PREFER_32_BIT),true)
224 gtest_deps += $$(2ND_HOST_BOOT_IMAGE) # Depend on the 32-bit boot image.
225 else
226 gtest_deps += $$($(3)HOST_BOOT_IMAGE)
227 endif
228
Alex Lightd78be002020-09-01 07:49:21 -0700229.PHONY: $$(gtest_build_rule)
230$$(gtest_build_rule) : $$(gtest_exe) $$(gtest_deps)
231
232
Andreas Gampe6acebf42018-01-22 22:15:43 -0800233.PHONY: $$(gtest_rule)
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700234$$(gtest_rule): $$(gtest_output)
235
236# Re-run the tests, even if nothing changed. Until the build system has a dedicated "no cache"
237# option, claim to write a file that is never produced.
238$$(gtest_output): .KATI_IMPLICIT_OUTPUTS := $$(gtest_output)-nocache
David Srbecky883c1342020-05-11 23:30:29 +0000239# Limit concurrent runs. Each test itself is already highly parallel (and thus memory hungry).
240$$(gtest_output): .KATI_NINJA_POOL := highmem_pool
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700241$$(gtest_output): NAME := $$(gtest_rule)
Andreas Gampe6acebf42018-01-22 22:15:43 -0800242ifeq (,$(SANITIZE_HOST))
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700243$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800244 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700245 timeout --foreground -k 120s 2400s $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Christopher Ferrisfc5e2ef2020-05-08 00:08:42 +0000246 $$< --gtest_output=xml:$$@ && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700247 $$(call ART_TEST_PASSED,$$(NAME))) || $$(call ART_TEST_FAILED,$$(NAME))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800248else
Andreas Gampe03858052017-05-01 08:17:24 -0700249# Note: envsetup currently exports ASAN_OPTIONS=detect_leaks=0 to suppress leak detection, as some
250# build tools (e.g., ninja) intentionally leak. We want leak checks when we run our tests, so
251# override ASAN_OPTIONS. b/37751350
Andreas Gampe6acebf42018-01-22 22:15:43 -0800252# Note 2: Under sanitization, also capture the output, and run it through the stack tool on failure
253# (with the x86-64 ABI, as this allows symbolization of both x86 and x86-64). We don't do this in
254# general as it loses all the color output, and we have our own symbolization step when not running
255# under ASAN.
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700256$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
257 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && set -o pipefail && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700258 ASAN_OPTIONS=detect_leaks=1 timeout --foreground -k 120s 3600s \
259 $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800260 $$< --gtest_output=xml:$$@ 2>&1 | tee $$<.tmp.out >&2 && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700261 { $$(call ART_TEST_PASSED,$$(NAME)) ; rm $$<.tmp.out ; }) || \
Andreas Gampec05fd3f2018-01-23 14:22:07 -0800262 ( grep -q AddressSanitizer $$<.tmp.out && export ANDROID_BUILD_TOP=`pwd` && \
Andreas Gampe6acebf42018-01-22 22:15:43 -0800263 { echo "ABI: 'x86_64'" | cat - $$<.tmp.out | development/scripts/stack | tail -n 3000 ; } ; \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700264 rm $$<.tmp.out ; $$(call ART_TEST_FAILED,$$(NAME)))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800265endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700266
Colin Cross6e95dd52016-09-12 15:37:10 -0700267 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
Alex Lightd78be002020-09-01 07:49:21 -0700268 ART_TEST_HOST_GTEST_BUILD_RULES += $$(gtest_build_rule)
269 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES += $$(gtest_build_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700270 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
271 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
272
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800273
Ian Rogersafd9acc2014-06-17 08:21:54 -0700274 # Clear locally defined variables.
Ian Rogers665de8a2014-06-24 21:34:09 -0700275 gtest_deps :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000276 gtest_exe :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700277 gtest_output :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000278 gtest_rule :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700279 gtest_suffix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700280endef # define-art-gtest-rule-host
281
Nicolas Geoffray15259602020-07-30 09:31:15 +0100282ART_TEST_HOST_GTEST_DEPENDENCIES := $(HOST_I18N_DATA)
David Srbecky4a88a5a2020-05-05 16:21:57 +0100283ART_TEST_TARGET_GTEST_DEPENDENCIES := $(TESTING_ART_APEX)
David Srbecky883c1342020-05-11 23:30:29 +0000284
Jiyong Parkeac38a12020-01-03 17:56:33 +0900285# Add the additional dependencies for the specified test
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000286# $(1): test name
Jiyong Parkeac38a12020-01-03 17:56:33 +0900287define add-art-gtest-dependencies
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000288 # Note that, both the primary and the secondary arches of the libs are built by depending
289 # on the module name.
290 gtest_deps := \
291 $$(ART_GTEST_$(1)_TARGET_DEPS) \
292 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Brian Carlstrom0796af02011-10-12 14:31:45 -0700293
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000294 ART_TEST_TARGET_GTEST_DEPENDENCIES += $$(gtest_deps)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100295
296 # Clear locally defined variables.
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000297 gtest_deps :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900298endef # add-art-gtest-dependencies
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100299
300# $(1): file name
301# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
302define define-art-gtest-host
303 art_gtest_filename := $(1)
304
305 include $$(CLEAR_VARS)
306 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
307 ifndef ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES
308 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100309 endif
310 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),$$(art_gtest_filename),$(2)))
311
312 # Clear locally defined variables.
313 art_gtest_filename :=
314 art_gtest_name :=
315endef # define-art-gtest-host
316
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100317# Define the rules to build and run gtests for both archs on host.
318# $(1): test name
319define define-art-gtest-host-both
320 art_gtest_name := $(1)
321
Ian Rogersafd9acc2014-06-17 08:21:54 -0700322.PHONY: test-art-host-gtest-$$(art_gtest_name)
323test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
324 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800325
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100326 # Clear now unused variables.
327 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700328 art_gtest_name :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100329endef # define-art-gtest-host-both
Alex Light50fa9932015-08-10 15:30:07 -0700330
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700331ifeq ($(ART_BUILD_TARGET),true)
Jiyong Parkeac38a12020-01-03 17:56:33 +0900332 $(foreach name,$(ART_TARGET_GTEST_NAMES), $(eval $(call add-art-gtest-dependencies,$(name),)))
333 ART_TEST_TARGET_GTEST_DEPENDENCIES += \
Nicolas Geoffrayc69b3f82020-06-22 12:33:38 +0000334 com.android.i18n \
Nicolas Geoffrayec64f202020-04-20 15:05:54 +0100335 libjavacore.com.android.art.testing \
336 libopenjdkd.com.android.art.testing \
Nicolas Geoffray31e0dc22020-03-20 15:48:09 +0000337 com.android.art.testing \
338 com.android.conscrypt
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700339endif
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100340ifeq ($(ART_BUILD_HOST),true)
341 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),)))
342 ifneq ($(HOST_PREFER_32_BIT),true)
343 $(foreach file,$(2ND_ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),2ND_)))
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100344 endif
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100345 # Rules to run the different architecture versions of the gtest.
346 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700347endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700348
Roland Levillain05e34f42018-05-24 13:19:05 +0000349# Define all the combinations of host/target and suffix such as:
350# test-art-host-gtest or test-art-host-gtest64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700351# $(1): host or target
352# $(2): HOST or TARGET
Roland Levillain05e34f42018-05-24 13:19:05 +0000353# $(3): undefined, 32 or 64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700354define define-test-art-gtest-combination
355 ifeq ($(1),host)
356 ifneq ($(2),HOST)
357 $$(error argument mismatch $(1) and ($2))
358 endif
359 else
360 ifneq ($(1),target)
361 $$(error found $(1) expected host or target)
362 endif
363 ifneq ($(2),TARGET)
364 $$(error argument mismatch $(1) and ($2))
365 endif
366 endif
367
Roland Levillain05e34f42018-05-24 13:19:05 +0000368 rule_name := test-art-$(1)-gtest$(3)
369 dependencies := $$(ART_TEST_$(2)_GTEST$(3)_RULES)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700370
371.PHONY: $$(rule_name)
Søren Gjesse46845f62019-12-10 09:14:16 +0100372$$(rule_name): $$(dependencies) d8
Ian Rogersafd9acc2014-06-17 08:21:54 -0700373 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
374
375 # Clear locally defined variables.
376 rule_name :=
377 dependencies :=
378endef # define-test-art-gtest-combination
379
Roland Levillain05e34f42018-05-24 13:19:05 +0000380$(eval $(call define-test-art-gtest-combination,target,TARGET,))
381$(eval $(call define-test-art-gtest-combination,target,TARGET,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Dan Willemsen5d2dbf82018-04-11 12:31:11 -0700382ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX
Roland Levillain05e34f42018-05-24 13:19:05 +0000383$(eval $(call define-test-art-gtest-combination,target,TARGET,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700384endif
Roland Levillain05e34f42018-05-24 13:19:05 +0000385$(eval $(call define-test-art-gtest-combination,host,HOST,))
386$(eval $(call define-test-art-gtest-combination,host,HOST,$(ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700387ifneq ($(HOST_PREFER_32_BIT),true)
Roland Levillain05e34f42018-05-24 13:19:05 +0000388$(eval $(call define-test-art-gtest-combination,host,HOST,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700389endif
390
Alex Lightd78be002020-09-01 07:49:21 -0700391# Define all the combinations of host/target and suffix such as:
392# test-art-host-gtest-dependencies or test-art-host-gtest-dependencies64
393# $(1): host or target
394# $(2): HOST or TARGET
395# $(3): undefined, 32 or 64
396define define-test-art-gtest-dependency-combination
397 ifeq ($(1),host)
398 ifneq ($(2),HOST)
399 $$(error argument mismatch $(1) and ($2))
400 endif
401 else
402 ifneq ($(1),target)
403 $$(error found $(1) expected host or target)
404 endif
405 ifneq ($(2),TARGET)
406 $$(error argument mismatch $(1) and ($2))
407 endif
408 endif
409
410 rule_name := test-art-$(1)-gtest-dependencies$(3)
411 dependencies := $$(ART_TEST_$(2)_GTEST$(3)_BUILD_RULES)
412
413.PHONY: $$(rule_name)
414$$(rule_name): $$(dependencies) d8
415
416 # Clear locally defined variables.
417 rule_name :=
418 dependencies :=
419endef # define-test-art-gtest-dependency-combination
420
421# TODO Get target-deps working too
422# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,))
423# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,$(ART_PHONY_TEST_TARGET_SUFFIX)))
424# ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX
425# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
426# endif
427$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,))
428$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,$(ART_PHONY_TEST_HOST_SUFFIX)))
429ifneq ($(HOST_PREFER_32_BIT),true)
430$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
431endif
432
Ian Rogersafd9acc2014-06-17 08:21:54 -0700433# Clear locally defined variables.
434define-art-gtest-rule-target :=
435define-art-gtest-rule-host :=
436define-art-gtest :=
437define-test-art-gtest-combination :=
438RUNTIME_GTEST_COMMON_SRC_FILES :=
439COMPILER_GTEST_COMMON_SRC_FILES :=
440RUNTIME_GTEST_TARGET_SRC_FILES :=
441RUNTIME_GTEST_HOST_SRC_FILES :=
442COMPILER_GTEST_TARGET_SRC_FILES :=
443COMPILER_GTEST_HOST_SRC_FILES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700444ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
445ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
446ART_TEST_HOST_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700447ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
448ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
449ART_TEST_HOST_GTEST_BUILD_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700450ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
451ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
452ART_TEST_TARGET_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700453ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
454ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
455ART_TEST_TARGET_GTEST_BUILD_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000456ART_GTEST_TARGET_ANDROID_ROOT :=
Victor Chang64611242019-07-05 16:32:41 +0100457ART_GTEST_TARGET_ANDROID_I18N_ROOT :=
Martin Stjernholme58624f2019-09-20 15:53:40 +0100458ART_GTEST_TARGET_ANDROID_ART_ROOT :=
Neil Fuller26a5dd62019-03-13 15:16:35 +0000459ART_GTEST_TARGET_ANDROID_TZDATA_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700460ART_GTEST_class_linker_test_DEX_DEPS :=
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800461ART_GTEST_class_table_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700462ART_GTEST_compiler_driver_test_DEX_DEPS :=
463ART_GTEST_dex_file_test_DEX_DEPS :=
464ART_GTEST_exception_test_DEX_DEPS :=
465ART_GTEST_elf_writer_test_HOST_DEPS :=
466ART_GTEST_elf_writer_test_TARGET_DEPS :=
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700467ART_GTEST_imtable_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700468ART_GTEST_jni_compiler_test_DEX_DEPS :=
469ART_GTEST_jni_internal_test_DEX_DEPS :=
Richard Uhler66d874d2015-01-15 09:37:19 -0800470ART_GTEST_oat_file_assistant_test_DEX_DEPS :=
471ART_GTEST_oat_file_assistant_test_HOST_DEPS :=
472ART_GTEST_oat_file_assistant_test_TARGET_DEPS :=
Mathieu Chartier0be7fa72018-04-12 10:13:29 -0700473ART_GTEST_dexanalyze_test_DEX_DEPS :=
Calin Juravle36eb3132017-01-13 16:32:38 -0800474ART_GTEST_dexoptanalyzer_test_DEX_DEPS :=
475ART_GTEST_dexoptanalyzer_test_HOST_DEPS :=
476ART_GTEST_dexoptanalyzer_test_TARGET_DEPS :=
Richard Uhler84f50ae2017-02-06 15:12:45 +0000477ART_GTEST_image_space_test_DEX_DEPS :=
478ART_GTEST_image_space_test_HOST_DEPS :=
479ART_GTEST_image_space_test_TARGET_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700480ART_GTEST_dex2oat_test_DEX_DEPS :=
481ART_GTEST_dex2oat_test_HOST_DEPS :=
482ART_GTEST_dex2oat_test_TARGET_DEPS :=
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700483ART_GTEST_dex2oat_image_test_DEX_DEPS :=
484ART_GTEST_dex2oat_image_test_HOST_DEPS :=
485ART_GTEST_dex2oat_image_test_TARGET_DEPS :=
Vladimir Markod1f73512020-04-02 10:50:35 +0100486ART_GTEST_module_exclusion_test_HOST_DEPS :=
487ART_GTEST_module_exclusion_test_TARGET_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700488ART_GTEST_object_test_DEX_DEPS :=
489ART_GTEST_proxy_test_DEX_DEPS :=
490ART_GTEST_reflection_test_DEX_DEPS :=
491ART_GTEST_stub_test_DEX_DEPS :=
492ART_GTEST_transaction_test_DEX_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700493ART_GTEST_dex2oat_environment_tests_DEX_DEPS :=
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700494ART_GTEST_heap_verification_test_DEX_DEPS :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100495ART_GTEST_verifier_deps_test_DEX_DEPS :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700496$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
497$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Richard Uhler66d874d2015-01-15 09:37:19 -0800498ART_TEST_HOST_GTEST_MainStripped_DEX :=
499ART_TEST_TARGET_GTEST_MainStripped_DEX :=
David Srbecky8c8f1482020-02-05 20:17:10 +0000500ART_TEST_HOST_GTEST_MainUncompressedAligned_DEX :=
501ART_TEST_TARGET_GTEST_MainUncompressedAligned_DEX :=
Mathieu Chartier700a9852018-02-06 18:27:38 -0800502ART_TEST_HOST_GTEST_EmptyUncompressed_DEX :=
503ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100504ART_TEST_GTEST_VerifierDeps_SRC :=
505ART_TEST_HOST_GTEST_VerifierDeps_DEX :=
David Brazdilf906f122016-09-16 16:33:31 +0100506ART_TEST_TARGET_GTEST_VerifierDeps_DEX :=
Vladimir Markod79b37b2018-11-02 13:06:22 +0000507ART_TEST_GTEST_VerifySoftFailDuringClinit_SRC :=
508ART_TEST_HOST_GTEST_VerifySoftFailDuringClinit_DEX :=
509ART_TEST_TARGET_GTEST_VerifySoftFailDuringClinit_DEX :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700510GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700511LOCAL_PATH :=
David Srbecky883c1342020-05-11 23:30:29 +0000512
513endif # ifneq ($(HOST_OS),darwin)