blob: def31909784dce464a0561b3f47f027f1770b52b [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))))
Jiakai Zhangb9784192021-12-13 14:11:43 +000042# `dexpreopt_bootjars.go` uses a single source of input regardless of variants, so we should use the
43# same source for `CORE_IMG_JARS` to avoid checksum mismatches on the oat files. We can still use
44# the host variant of `conscrypt` and `core-icu4j` because they don't go into the primary boot image
45# that is used in host gtests, and hence can't lead to checksum mismatches.
David Srbecky1cf46a32020-06-22 15:39:00 +010046my_files += \
47 $(foreach jar,$(CORE_IMG_JARS),\
Jiakai Zhangb9784192021-12-13 14:11:43 +000048 $(OUT_DIR)/soong/$(PRODUCT_DEVICE)/dex_artjars_input/$(jar).jar:apex/com.android.art/javalib/$(jar).jar) \
David Srbecky1cf46a32020-06-22 15:39:00 +010049 $(HOST_OUT_JAVA_LIBRARIES)/conscrypt-hostdex.jar:apex/com.android.conscrypt/javalib/conscrypt.jar\
David Srbecky671d34d2020-07-02 12:23:28 +010050 $(HOST_OUT_JAVA_LIBRARIES)/core-icu4j-hostdex.jar:apex/com.android.i18n/javalib/core-icu4j.jar \
51 $(icu_data_file):com.android.i18n/etc/icu/$(notdir $(icu_data_file))
David Srbecky1cf46a32020-06-22 15:39:00 +010052
David Srbeckyd3ee9022020-07-27 16:05:38 +010053# Create phony module that will copy all the data files into testcases directory.
David Srbecky1cf46a32020-06-22 15:39:00 +010054# For now, this copies everything to "out/host/linux-x86/" subdirectory, since it
55# is hard-coded in many places. TODO: Refactor tests to remove the need for this.
56include $(CLEAR_VARS)
57LOCAL_IS_HOST_MODULE := true
58LOCAL_MODULE := art_common
Bob Badour9150de62021-02-26 03:22:24 -080059LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
60LOCAL_LICENSE_CONDITIONS := notice
61LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE
David Srbecky1cf46a32020-06-22 15:39:00 +010062LOCAL_MODULE_TAGS := tests
63LOCAL_MODULE_CLASS := NATIVE_TESTS
64LOCAL_MODULE_SUFFIX := .txt
Dan Shi8562f372020-10-19 10:51:40 -070065LOCAL_COMPATIBILITY_SUITE := art-host-tests
David Srbeckyb0713ca2020-07-01 15:04:39 +010066LOCAL_COMPATIBILITY_SUPPORT_FILES := $(ART_TESTCASES_PREBUILT_CONTENT) \
David Srbecky1cf46a32020-06-22 15:39:00 +010067 $(foreach f,$(my_files),$(call word-colon,1,$f):out/host/linux-x86/$(call word-colon,2,$f))
68include $(BUILD_SYSTEM)/base_rules.mk
69
70$(LOCAL_BUILT_MODULE):
71 @mkdir -p $(dir $@)
72 echo "This directory contains common data and tools needed for ART host tests" > $@
73
74my_files :=
75include $(CLEAR_VARS)
76###################################################################################################
77
Ian Rogersafd9acc2014-06-17 08:21:54 -070078# The path for which all the dex files are relative, not actually the current directory.
79LOCAL_PATH := art/test
80
81include art/build/Android.common_test.mk
82include art/build/Android.common_path.mk
Alex Light50fa9932015-08-10 15:30:07 -070083include art/build/Android.common_build.mk
Ian Rogersafd9acc2014-06-17 08:21:54 -070084
David Srbecky928d28e2020-04-01 17:50:51 +010085# Deprecated core.art dependencies.
86HOST_CORE_IMAGE_DEFAULT_32 :=
87HOST_CORE_IMAGE_DEFAULT_64 :=
88TARGET_CORE_IMAGE_DEFAULT_32 :=
89TARGET_CORE_IMAGE_DEFAULT_64 :=
90
Ian Rogersafd9acc2014-06-17 08:21:54 -070091# The elf writer test has dependencies on core.oat.
Richard Uhler67e1dc52017-02-06 16:50:17 +000092ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
93ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
Brian Carlstrom53463ea2014-11-09 14:11:51 -080094
Nicolas Geoffray975b7742019-03-21 17:37:38 +000095# The two_runtimes_test test has dependencies on core.oat.
96ART_GTEST_two_runtimes_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
97ART_GTEST_two_runtimes_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
98
Vladimir Marko672c0802019-07-26 13:03:13 +010099# The transaction test has dependencies on core.oat.
100ART_GTEST_transaction_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
101ART_GTEST_transaction_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
102
Ian Rogersafd9acc2014-06-17 08:21:54 -0700103# The path for which all the source files are relative, not actually the current directory.
Brian Carlstrom7940e442013-07-12 13:46:57 -0700104LOCAL_PATH := art
105
Victor Hsieh7a3ccd02021-09-08 11:59:29 -0700106ART_TEST_MODULES_COMMON := \
Colin Cross6e95dd52016-09-12 15:37:10 -0700107 art_cmdline_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700108 art_compiler_host_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +0000109 art_compiler_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700110 art_dex2oat_tests \
Mathieu Chartier2e0478a2018-04-06 14:33:25 -0700111 art_dexanalyze_tests \
David Sehr55232f12017-04-19 14:06:49 -0700112 art_dexdiag_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700113 art_dexdump_tests \
114 art_dexlayout_tests \
115 art_dexlist_tests \
Calin Juravle36eb3132017-01-13 16:32:38 -0800116 art_dexoptanalyzer_tests \
David Brazdil2b9c35b2018-01-12 15:44:43 +0000117 art_hiddenapi_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700118 art_imgdiag_tests \
David Sehr67bf42e2018-02-26 16:43:04 -0800119 art_libartbase_tests \
Orion Hodson119733d2019-01-30 15:14:41 +0000120 art_libartpalette_tests \
Chris Wailesbfd622a2021-01-13 16:13:41 -0800121 art_libartservice_tests \
122 art_libarttools_tests \
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000123 art_libdexfile_external_tests \
Martin Stjernholm70ae00d2019-02-15 22:41:14 +0000124 art_libdexfile_support_static_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +0000125 art_libdexfile_support_tests \
David Sehr334b9d72018-02-12 18:27:56 -0800126 art_libdexfile_tests \
David Sehrd5f8de82018-04-27 14:12:03 -0700127 art_libprofile_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700128 art_oatdump_tests \
129 art_profman_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700130 art_runtime_compiler_tests \
Martin Stjernholm750bf042019-01-09 22:51:12 +0000131 art_runtime_tests \
Josh Gao1eac77e2018-02-26 15:54:41 -0800132 art_sigchain_tests \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800133
Victor Hsieh7a3ccd02021-09-08 11:59:29 -0700134ART_TEST_MODULES_TARGET := $(ART_TEST_MODULES_COMMON) art_odrefresh_tests
135ART_TEST_MODULES_HOST := $(ART_TEST_MODULES_COMMON)
136
137ART_TARGET_GTEST_NAMES := $(foreach tm,$(ART_TEST_MODULES_TARGET),\
Jiyong Parka5992522020-01-07 16:55:09 +0900138 $(foreach path,$(ART_TEST_LIST_device_$(TARGET_ARCH)_$(tm)),\
139 $(notdir $(path))\
140 )\
141)
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000142
Victor Hsieh7a3ccd02021-09-08 11:59:29 -0700143ART_HOST_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES_HOST),\
Colin Cross124f8812016-09-15 20:57:47 -0700144 $(ART_TEST_LIST_host_$(ART_HOST_ARCH)_$(m)))
Alex Light50fa9932015-08-10 15:30:07 -0700145
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100146ifneq ($(HOST_PREFER_32_BIT),true)
Victor Hsieh7a3ccd02021-09-08 11:59:29 -07001472ND_ART_HOST_GTEST_FILES += $(foreach m,$(ART_TEST_MODULES_HOST),\
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100148 $(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_$(m)))
149endif
150
Ian Rogersafd9acc2014-06-17 08:21:54 -0700151# Variables holding collections of gtest pre-requisits used to run a number of gtests.
152ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
153ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
154ART_TEST_HOST_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700155ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
156ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
157ART_TEST_HOST_GTEST_BUILD_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700158ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
159ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
160ART_TEST_TARGET_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700161ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
162ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
163ART_TEST_TARGET_GTEST_BUILD_RULES :=
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100164ART_TEST_HOST_GTEST_DEPENDENCIES :=
Nicolas Geoffray17b1dcb2018-10-12 15:09:42 +0100165ART_TEST_TARGET_GTEST_DEPENDENCIES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700166
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000167ART_GTEST_TARGET_ANDROID_ROOT := '/system'
168ifneq ($(ART_TEST_ANDROID_ROOT),)
169 ART_GTEST_TARGET_ANDROID_ROOT := $(ART_TEST_ANDROID_ROOT)
170endif
171
Victor Chang64611242019-07-05 16:32:41 +0100172ART_GTEST_TARGET_ANDROID_I18N_ROOT := '/apex/com.android.i18n'
173ifneq ($(ART_TEST_ANDROID_I18N_ROOT),)
174 ART_GTEST_TARGET_ANDROID_I18N_ROOT := $(ART_TEST_ANDROID_I18N_ROOT)
175endif
176
Martin Stjernholme58624f2019-09-20 15:53:40 +0100177ART_GTEST_TARGET_ANDROID_ART_ROOT := '/apex/com.android.art'
178ifneq ($(ART_TEST_ANDROID_ART_ROOT),)
179 ART_GTEST_TARGET_ANDROID_ART_ROOT := $(ART_TEST_ANDROID_ART_ROOT)
Roland Levillain7c777f82019-01-10 18:00:37 +0000180endif
Neil Fuller26c43772018-11-23 17:56:43 +0000181
Neil Fuller26a5dd62019-03-13 15:16:35 +0000182ART_GTEST_TARGET_ANDROID_TZDATA_ROOT := '/apex/com.android.tzdata'
183ifneq ($(ART_TEST_ANDROID_TZDATA_ROOT),)
184 ART_GTEST_TARGET_ANDROID_TZDATA_ROOT := $(ART_TEST_ANDROID_TZDATA_ROOT)
185endif
186
Ian Rogersafd9acc2014-06-17 08:21:54 -0700187# Define make rules for a host gtests.
188# $(1): gtest name - the name of the test we're building such as leb128_test.
Colin Cross6e95dd52016-09-12 15:37:10 -0700189# $(2): path relative to $OUT to the test binary
190# $(3): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700191define define-art-gtest-rule-host
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700192 gtest_suffix := $(1)$$($(3)ART_PHONY_TEST_HOST_SUFFIX)
193 gtest_rule := test-art-host-gtest-$$(gtest_suffix)
Alex Lightd78be002020-09-01 07:49:21 -0700194 gtest_build_rule := test-art-host-gtest-dependencies-$$(gtest_suffix)
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700195 gtest_output := $(call intermediates-dir-for,PACKAGING,art-host-gtest,HOST)/$$(gtest_suffix).xml
Dan Willemsen0ef94572018-10-21 19:00:56 +0000196 $$(call dist-for-goals,$$(gtest_rule),$$(gtest_output):gtest/$$(gtest_suffix))
Bob Badourf0295202022-03-30 15:26:23 -0700197 $$(call declare-1p-target,$$(gtest_output))
Colin Cross83072062019-10-02 16:06:58 -0700198 gtest_exe := $(2)
Ian Rogers665de8a2014-06-24 21:34:09 -0700199 # Dependencies for all host gtests.
Nicolas Geoffrayd31cff12020-03-27 14:29:45 +0000200 gtest_deps := $$(ART_HOST_DEX_DEPENDENCIES) \
David Srbecky883c1342020-05-11 23:30:29 +0000201 $$(ART_TEST_HOST_GTEST_DEPENDENCIES) \
Martin Stjernholm76228ff2020-07-16 22:17:09 +0100202 $$(HOST_OUT)/$$(I18N_APEX)/timestamp \
David Srbecky0c0f3022020-02-13 15:53:01 +0000203 $$(HOST_BOOT_IMAGE_JARS) \
Victor Chang65ae6692019-10-11 14:17:21 +0100204 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libicu_jni$$(ART_HOST_SHLIB_EXTENSION) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700205 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION) \
206 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100207 $$(gtest_exe) \
208 $$(ART_GTEST_$(1)_HOST_DEPS) \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800209 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) \
Andreas Gampe148c1602019-06-10 16:47:46 -0700210 $(HOST_OUT_EXECUTABLES)/signal_dumper
Ian Rogers665de8a2014-06-24 21:34:09 -0700211
David Srbecky403384e2020-03-27 12:24:36 +0000212 # Note: The "host arch" Make variables defined in build/make/core/envsetup.mk
213 # and art/build/Android.common.mk have different meanings:
214 #
215 # * In build/make/core/envsetup.mk:
216 # * HOST_ARCH := x86_64
217 # * HOST_2ND_ARCH := x86
218 #
219 # * In art/build/Android.common.mk:
220 # * When `HOST_PREFER_32_BIT` is `true`:
221 # * ART_HOST_ARCH := x86
222 # * 2ND_ART_HOST_ARCH :=
223 # * 2ND_HOST_ARCH :=
224 # * Otherwise:
225 # * ART_HOST_ARCH := x86_64
226 # * 2ND_ART_HOST_ARCH := x86
227 # * 2ND_HOST_ARCH := x86
228 ifeq ($(HOST_PREFER_32_BIT),true)
229 gtest_deps += $$(2ND_HOST_BOOT_IMAGE) # Depend on the 32-bit boot image.
230 else
231 gtest_deps += $$($(3)HOST_BOOT_IMAGE)
232 endif
233
Alex Lightd78be002020-09-01 07:49:21 -0700234.PHONY: $$(gtest_build_rule)
235$$(gtest_build_rule) : $$(gtest_exe) $$(gtest_deps)
236
237
Andreas Gampe6acebf42018-01-22 22:15:43 -0800238.PHONY: $$(gtest_rule)
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700239$$(gtest_rule): $$(gtest_output)
240
241# Re-run the tests, even if nothing changed. Until the build system has a dedicated "no cache"
242# option, claim to write a file that is never produced.
243$$(gtest_output): .KATI_IMPLICIT_OUTPUTS := $$(gtest_output)-nocache
David Srbecky883c1342020-05-11 23:30:29 +0000244# Limit concurrent runs. Each test itself is already highly parallel (and thus memory hungry).
245$$(gtest_output): .KATI_NINJA_POOL := highmem_pool
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700246$$(gtest_output): NAME := $$(gtest_rule)
Andreas Gampe6acebf42018-01-22 22:15:43 -0800247ifeq (,$(SANITIZE_HOST))
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700248$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800249 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700250 timeout --foreground -k 120s 2400s $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Christopher Ferrisfc5e2ef2020-05-08 00:08:42 +0000251 $$< --gtest_output=xml:$$@ && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700252 $$(call ART_TEST_PASSED,$$(NAME))) || $$(call ART_TEST_FAILED,$$(NAME))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800253else
Andreas Gampe03858052017-05-01 08:17:24 -0700254# Note: envsetup currently exports ASAN_OPTIONS=detect_leaks=0 to suppress leak detection, as some
255# build tools (e.g., ninja) intentionally leak. We want leak checks when we run our tests, so
256# override ASAN_OPTIONS. b/37751350
Andreas Gampe6acebf42018-01-22 22:15:43 -0800257# Note 2: Under sanitization, also capture the output, and run it through the stack tool on failure
258# (with the x86-64 ABI, as this allows symbolization of both x86 and x86-64). We don't do this in
259# general as it loses all the color output, and we have our own symbolization step when not running
260# under ASAN.
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700261$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
262 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && set -o pipefail && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700263 ASAN_OPTIONS=detect_leaks=1 timeout --foreground -k 120s 3600s \
264 $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800265 $$< --gtest_output=xml:$$@ 2>&1 | tee $$<.tmp.out >&2 && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700266 { $$(call ART_TEST_PASSED,$$(NAME)) ; rm $$<.tmp.out ; }) || \
Andreas Gampec05fd3f2018-01-23 14:22:07 -0800267 ( grep -q AddressSanitizer $$<.tmp.out && export ANDROID_BUILD_TOP=`pwd` && \
Andreas Gampe6acebf42018-01-22 22:15:43 -0800268 { echo "ABI: 'x86_64'" | cat - $$<.tmp.out | development/scripts/stack | tail -n 3000 ; } ; \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700269 rm $$<.tmp.out ; $$(call ART_TEST_FAILED,$$(NAME)))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800270endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700271
Colin Cross6e95dd52016-09-12 15:37:10 -0700272 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
Alex Lightd78be002020-09-01 07:49:21 -0700273 ART_TEST_HOST_GTEST_BUILD_RULES += $$(gtest_build_rule)
274 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES += $$(gtest_build_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700275 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
276 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
277
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800278
Ian Rogersafd9acc2014-06-17 08:21:54 -0700279 # Clear locally defined variables.
Ian Rogers665de8a2014-06-24 21:34:09 -0700280 gtest_deps :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000281 gtest_exe :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700282 gtest_output :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000283 gtest_rule :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700284 gtest_suffix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700285endef # define-art-gtest-rule-host
286
Nicolas Geoffray15259602020-07-30 09:31:15 +0100287ART_TEST_HOST_GTEST_DEPENDENCIES := $(HOST_I18N_DATA)
David Srbecky4a88a5a2020-05-05 16:21:57 +0100288ART_TEST_TARGET_GTEST_DEPENDENCIES := $(TESTING_ART_APEX)
David Srbecky883c1342020-05-11 23:30:29 +0000289
Jiyong Parkeac38a12020-01-03 17:56:33 +0900290# Add the additional dependencies for the specified test
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000291# $(1): test name
Jiyong Parkeac38a12020-01-03 17:56:33 +0900292define add-art-gtest-dependencies
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000293 # Note that, both the primary and the secondary arches of the libs are built by depending
294 # on the module name.
295 gtest_deps := \
296 $$(ART_GTEST_$(1)_TARGET_DEPS) \
297 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Brian Carlstrom0796af02011-10-12 14:31:45 -0700298
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000299 ART_TEST_TARGET_GTEST_DEPENDENCIES += $$(gtest_deps)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100300
301 # Clear locally defined variables.
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000302 gtest_deps :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900303endef # add-art-gtest-dependencies
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100304
305# $(1): file name
306# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
307define define-art-gtest-host
308 art_gtest_filename := $(1)
309
310 include $$(CLEAR_VARS)
311 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
312 ifndef ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES
313 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100314 endif
315 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),$$(art_gtest_filename),$(2)))
316
317 # Clear locally defined variables.
318 art_gtest_filename :=
319 art_gtest_name :=
320endef # define-art-gtest-host
321
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100322# Define the rules to build and run gtests for both archs on host.
323# $(1): test name
324define define-art-gtest-host-both
325 art_gtest_name := $(1)
326
Ian Rogersafd9acc2014-06-17 08:21:54 -0700327.PHONY: test-art-host-gtest-$$(art_gtest_name)
328test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
329 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800330
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100331 # Clear now unused variables.
332 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700333 art_gtest_name :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100334endef # define-art-gtest-host-both
Alex Light50fa9932015-08-10 15:30:07 -0700335
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700336ifeq ($(ART_BUILD_TARGET),true)
Jiyong Parkeac38a12020-01-03 17:56:33 +0900337 $(foreach name,$(ART_TARGET_GTEST_NAMES), $(eval $(call add-art-gtest-dependencies,$(name),)))
338 ART_TEST_TARGET_GTEST_DEPENDENCIES += \
Nicolas Geoffrayc69b3f82020-06-22 12:33:38 +0000339 com.android.i18n \
Nicolas Geoffrayec64f202020-04-20 15:05:54 +0100340 libjavacore.com.android.art.testing \
341 libopenjdkd.com.android.art.testing \
Nicolas Geoffray31e0dc22020-03-20 15:48:09 +0000342 com.android.art.testing \
343 com.android.conscrypt
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700344endif
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100345ifeq ($(ART_BUILD_HOST),true)
346 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),)))
347 ifneq ($(HOST_PREFER_32_BIT),true)
348 $(foreach file,$(2ND_ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),2ND_)))
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100349 endif
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100350 # Rules to run the different architecture versions of the gtest.
351 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700352endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700353
Roland Levillain05e34f42018-05-24 13:19:05 +0000354# Define all the combinations of host/target and suffix such as:
355# test-art-host-gtest or test-art-host-gtest64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700356# $(1): host or target
357# $(2): HOST or TARGET
Roland Levillain05e34f42018-05-24 13:19:05 +0000358# $(3): undefined, 32 or 64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700359define define-test-art-gtest-combination
360 ifeq ($(1),host)
361 ifneq ($(2),HOST)
362 $$(error argument mismatch $(1) and ($2))
363 endif
364 else
365 ifneq ($(1),target)
366 $$(error found $(1) expected host or target)
367 endif
368 ifneq ($(2),TARGET)
369 $$(error argument mismatch $(1) and ($2))
370 endif
371 endif
372
Roland Levillain05e34f42018-05-24 13:19:05 +0000373 rule_name := test-art-$(1)-gtest$(3)
374 dependencies := $$(ART_TEST_$(2)_GTEST$(3)_RULES)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700375
376.PHONY: $$(rule_name)
Søren Gjesse46845f62019-12-10 09:14:16 +0100377$$(rule_name): $$(dependencies) d8
Ian Rogersafd9acc2014-06-17 08:21:54 -0700378 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
379
380 # Clear locally defined variables.
381 rule_name :=
382 dependencies :=
383endef # define-test-art-gtest-combination
384
Roland Levillain05e34f42018-05-24 13:19:05 +0000385$(eval $(call define-test-art-gtest-combination,target,TARGET,))
386$(eval $(call define-test-art-gtest-combination,target,TARGET,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Dan Willemsen5d2dbf82018-04-11 12:31:11 -0700387ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX
Roland Levillain05e34f42018-05-24 13:19:05 +0000388$(eval $(call define-test-art-gtest-combination,target,TARGET,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700389endif
Roland Levillain05e34f42018-05-24 13:19:05 +0000390$(eval $(call define-test-art-gtest-combination,host,HOST,))
391$(eval $(call define-test-art-gtest-combination,host,HOST,$(ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700392ifneq ($(HOST_PREFER_32_BIT),true)
Roland Levillain05e34f42018-05-24 13:19:05 +0000393$(eval $(call define-test-art-gtest-combination,host,HOST,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700394endif
395
Alex Lightd78be002020-09-01 07:49:21 -0700396# Define all the combinations of host/target and suffix such as:
397# test-art-host-gtest-dependencies or test-art-host-gtest-dependencies64
398# $(1): host or target
399# $(2): HOST or TARGET
400# $(3): undefined, 32 or 64
401define define-test-art-gtest-dependency-combination
402 ifeq ($(1),host)
403 ifneq ($(2),HOST)
404 $$(error argument mismatch $(1) and ($2))
405 endif
406 else
407 ifneq ($(1),target)
408 $$(error found $(1) expected host or target)
409 endif
410 ifneq ($(2),TARGET)
411 $$(error argument mismatch $(1) and ($2))
412 endif
413 endif
414
415 rule_name := test-art-$(1)-gtest-dependencies$(3)
416 dependencies := $$(ART_TEST_$(2)_GTEST$(3)_BUILD_RULES)
417
418.PHONY: $$(rule_name)
419$$(rule_name): $$(dependencies) d8
420
421 # Clear locally defined variables.
422 rule_name :=
423 dependencies :=
424endef # define-test-art-gtest-dependency-combination
425
426# TODO Get target-deps working too
427# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,))
428# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,$(ART_PHONY_TEST_TARGET_SUFFIX)))
429# ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX
430# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
431# endif
432$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,))
433$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,$(ART_PHONY_TEST_HOST_SUFFIX)))
434ifneq ($(HOST_PREFER_32_BIT),true)
435$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
436endif
437
Ian Rogersafd9acc2014-06-17 08:21:54 -0700438# Clear locally defined variables.
439define-art-gtest-rule-target :=
440define-art-gtest-rule-host :=
441define-art-gtest :=
442define-test-art-gtest-combination :=
443RUNTIME_GTEST_COMMON_SRC_FILES :=
444COMPILER_GTEST_COMMON_SRC_FILES :=
445RUNTIME_GTEST_TARGET_SRC_FILES :=
446RUNTIME_GTEST_HOST_SRC_FILES :=
447COMPILER_GTEST_TARGET_SRC_FILES :=
448COMPILER_GTEST_HOST_SRC_FILES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700449ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
450ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
451ART_TEST_HOST_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700452ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
453ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
454ART_TEST_HOST_GTEST_BUILD_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700455ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
456ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
457ART_TEST_TARGET_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700458ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
459ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
460ART_TEST_TARGET_GTEST_BUILD_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000461ART_GTEST_TARGET_ANDROID_ROOT :=
Victor Chang64611242019-07-05 16:32:41 +0100462ART_GTEST_TARGET_ANDROID_I18N_ROOT :=
Martin Stjernholme58624f2019-09-20 15:53:40 +0100463ART_GTEST_TARGET_ANDROID_ART_ROOT :=
Neil Fuller26a5dd62019-03-13 15:16:35 +0000464ART_GTEST_TARGET_ANDROID_TZDATA_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700465ART_GTEST_class_linker_test_DEX_DEPS :=
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800466ART_GTEST_class_table_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700467ART_GTEST_compiler_driver_test_DEX_DEPS :=
468ART_GTEST_dex_file_test_DEX_DEPS :=
469ART_GTEST_exception_test_DEX_DEPS :=
470ART_GTEST_elf_writer_test_HOST_DEPS :=
471ART_GTEST_elf_writer_test_TARGET_DEPS :=
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700472ART_GTEST_imtable_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700473ART_GTEST_jni_compiler_test_DEX_DEPS :=
474ART_GTEST_jni_internal_test_DEX_DEPS :=
Richard Uhler66d874d2015-01-15 09:37:19 -0800475ART_GTEST_oat_file_assistant_test_DEX_DEPS :=
476ART_GTEST_oat_file_assistant_test_HOST_DEPS :=
477ART_GTEST_oat_file_assistant_test_TARGET_DEPS :=
Mathieu Chartier0be7fa72018-04-12 10:13:29 -0700478ART_GTEST_dexanalyze_test_DEX_DEPS :=
Calin Juravle36eb3132017-01-13 16:32:38 -0800479ART_GTEST_dexoptanalyzer_test_DEX_DEPS :=
480ART_GTEST_dexoptanalyzer_test_HOST_DEPS :=
481ART_GTEST_dexoptanalyzer_test_TARGET_DEPS :=
Richard Uhler84f50ae2017-02-06 15:12:45 +0000482ART_GTEST_image_space_test_DEX_DEPS :=
483ART_GTEST_image_space_test_HOST_DEPS :=
484ART_GTEST_image_space_test_TARGET_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700485ART_GTEST_dex2oat_test_DEX_DEPS :=
486ART_GTEST_dex2oat_test_HOST_DEPS :=
487ART_GTEST_dex2oat_test_TARGET_DEPS :=
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700488ART_GTEST_dex2oat_image_test_DEX_DEPS :=
489ART_GTEST_dex2oat_image_test_HOST_DEPS :=
490ART_GTEST_dex2oat_image_test_TARGET_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700491ART_GTEST_object_test_DEX_DEPS :=
492ART_GTEST_proxy_test_DEX_DEPS :=
493ART_GTEST_reflection_test_DEX_DEPS :=
494ART_GTEST_stub_test_DEX_DEPS :=
495ART_GTEST_transaction_test_DEX_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700496ART_GTEST_dex2oat_environment_tests_DEX_DEPS :=
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700497ART_GTEST_heap_verification_test_DEX_DEPS :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100498ART_GTEST_verifier_deps_test_DEX_DEPS :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700499$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
500$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Richard Uhler66d874d2015-01-15 09:37:19 -0800501ART_TEST_HOST_GTEST_MainStripped_DEX :=
502ART_TEST_TARGET_GTEST_MainStripped_DEX :=
David Srbecky8c8f1482020-02-05 20:17:10 +0000503ART_TEST_HOST_GTEST_MainUncompressedAligned_DEX :=
504ART_TEST_TARGET_GTEST_MainUncompressedAligned_DEX :=
Mathieu Chartier700a9852018-02-06 18:27:38 -0800505ART_TEST_HOST_GTEST_EmptyUncompressed_DEX :=
506ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100507ART_TEST_GTEST_VerifierDeps_SRC :=
508ART_TEST_HOST_GTEST_VerifierDeps_DEX :=
David Brazdilf906f122016-09-16 16:33:31 +0100509ART_TEST_TARGET_GTEST_VerifierDeps_DEX :=
Vladimir Markod79b37b2018-11-02 13:06:22 +0000510ART_TEST_GTEST_VerifySoftFailDuringClinit_SRC :=
511ART_TEST_HOST_GTEST_VerifySoftFailDuringClinit_DEX :=
512ART_TEST_TARGET_GTEST_VerifySoftFailDuringClinit_DEX :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700513GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700514LOCAL_PATH :=
David Srbecky883c1342020-05-11 23:30:29 +0000515
516endif # ifneq ($(HOST_OS),darwin)