blob: e28fb737cd8b148ad5ec898c9140264a5799760c [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))
Colin Cross83072062019-10-02 16:06:58 -0700197 gtest_exe := $(2)
Ian Rogers665de8a2014-06-24 21:34:09 -0700198 # Dependencies for all host gtests.
Nicolas Geoffrayd31cff12020-03-27 14:29:45 +0000199 gtest_deps := $$(ART_HOST_DEX_DEPENDENCIES) \
David Srbecky883c1342020-05-11 23:30:29 +0000200 $$(ART_TEST_HOST_GTEST_DEPENDENCIES) \
Martin Stjernholm76228ff2020-07-16 22:17:09 +0100201 $$(HOST_OUT)/$$(I18N_APEX)/timestamp \
David Srbecky0c0f3022020-02-13 15:53:01 +0000202 $$(HOST_BOOT_IMAGE_JARS) \
Victor Chang65ae6692019-10-11 14:17:21 +0100203 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libicu_jni$$(ART_HOST_SHLIB_EXTENSION) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700204 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION) \
205 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100206 $$(gtest_exe) \
207 $$(ART_GTEST_$(1)_HOST_DEPS) \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800208 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX)) \
Andreas Gampe148c1602019-06-10 16:47:46 -0700209 $(HOST_OUT_EXECUTABLES)/signal_dumper
Ian Rogers665de8a2014-06-24 21:34:09 -0700210
David Srbecky403384e2020-03-27 12:24:36 +0000211 # Note: The "host arch" Make variables defined in build/make/core/envsetup.mk
212 # and art/build/Android.common.mk have different meanings:
213 #
214 # * In build/make/core/envsetup.mk:
215 # * HOST_ARCH := x86_64
216 # * HOST_2ND_ARCH := x86
217 #
218 # * In art/build/Android.common.mk:
219 # * When `HOST_PREFER_32_BIT` is `true`:
220 # * ART_HOST_ARCH := x86
221 # * 2ND_ART_HOST_ARCH :=
222 # * 2ND_HOST_ARCH :=
223 # * Otherwise:
224 # * ART_HOST_ARCH := x86_64
225 # * 2ND_ART_HOST_ARCH := x86
226 # * 2ND_HOST_ARCH := x86
227 ifeq ($(HOST_PREFER_32_BIT),true)
228 gtest_deps += $$(2ND_HOST_BOOT_IMAGE) # Depend on the 32-bit boot image.
229 else
230 gtest_deps += $$($(3)HOST_BOOT_IMAGE)
231 endif
232
Alex Lightd78be002020-09-01 07:49:21 -0700233.PHONY: $$(gtest_build_rule)
234$$(gtest_build_rule) : $$(gtest_exe) $$(gtest_deps)
235
236
Andreas Gampe6acebf42018-01-22 22:15:43 -0800237.PHONY: $$(gtest_rule)
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700238$$(gtest_rule): $$(gtest_output)
239
240# Re-run the tests, even if nothing changed. Until the build system has a dedicated "no cache"
241# option, claim to write a file that is never produced.
242$$(gtest_output): .KATI_IMPLICIT_OUTPUTS := $$(gtest_output)-nocache
David Srbecky883c1342020-05-11 23:30:29 +0000243# Limit concurrent runs. Each test itself is already highly parallel (and thus memory hungry).
244$$(gtest_output): .KATI_NINJA_POOL := highmem_pool
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700245$$(gtest_output): NAME := $$(gtest_rule)
Andreas Gampe6acebf42018-01-22 22:15:43 -0800246ifeq (,$(SANITIZE_HOST))
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700247$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800248 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700249 timeout --foreground -k 120s 2400s $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Christopher Ferrisfc5e2ef2020-05-08 00:08:42 +0000250 $$< --gtest_output=xml:$$@ && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700251 $$(call ART_TEST_PASSED,$$(NAME))) || $$(call ART_TEST_FAILED,$$(NAME))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800252else
Andreas Gampe03858052017-05-01 08:17:24 -0700253# Note: envsetup currently exports ASAN_OPTIONS=detect_leaks=0 to suppress leak detection, as some
254# build tools (e.g., ninja) intentionally leak. We want leak checks when we run our tests, so
255# override ASAN_OPTIONS. b/37751350
Andreas Gampe6acebf42018-01-22 22:15:43 -0800256# Note 2: Under sanitization, also capture the output, and run it through the stack tool on failure
257# (with the x86-64 ABI, as this allows symbolization of both x86 and x86-64). We don't do this in
258# general as it loses all the color output, and we have our own symbolization step when not running
259# under ASAN.
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700260$$(gtest_output): $$(gtest_exe) $$(gtest_deps)
261 $(hide) ($$(call ART_TEST_SKIP,$$(NAME)) && set -o pipefail && \
Andreas Gampe0df2aba2019-06-10 16:53:55 -0700262 ASAN_OPTIONS=detect_leaks=1 timeout --foreground -k 120s 3600s \
263 $(HOST_OUT_EXECUTABLES)/signal_dumper -s 15 \
Andreas Gampe28fd62a2018-12-12 15:15:22 -0800264 $$< --gtest_output=xml:$$@ 2>&1 | tee $$<.tmp.out >&2 && \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700265 { $$(call ART_TEST_PASSED,$$(NAME)) ; rm $$<.tmp.out ; }) || \
Andreas Gampec05fd3f2018-01-23 14:22:07 -0800266 ( grep -q AddressSanitizer $$<.tmp.out && export ANDROID_BUILD_TOP=`pwd` && \
Andreas Gampe6acebf42018-01-22 22:15:43 -0800267 { echo "ABI: 'x86_64'" | cat - $$<.tmp.out | development/scripts/stack | tail -n 3000 ; } ; \
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700268 rm $$<.tmp.out ; $$(call ART_TEST_FAILED,$$(NAME)))
Andreas Gampe6acebf42018-01-22 22:15:43 -0800269endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700270
Colin Cross6e95dd52016-09-12 15:37:10 -0700271 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
Alex Lightd78be002020-09-01 07:49:21 -0700272 ART_TEST_HOST_GTEST_BUILD_RULES += $$(gtest_build_rule)
273 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES += $$(gtest_build_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700274 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
275 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
276
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800277
Ian Rogersafd9acc2014-06-17 08:21:54 -0700278 # Clear locally defined variables.
Ian Rogers665de8a2014-06-24 21:34:09 -0700279 gtest_deps :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000280 gtest_exe :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700281 gtest_output :=
Roland Levillain76cfe612017-10-30 13:14:28 +0000282 gtest_rule :=
Dan Willemsendb72e5e2018-10-02 14:09:21 -0700283 gtest_suffix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700284endef # define-art-gtest-rule-host
285
Nicolas Geoffray15259602020-07-30 09:31:15 +0100286ART_TEST_HOST_GTEST_DEPENDENCIES := $(HOST_I18N_DATA)
David Srbecky4a88a5a2020-05-05 16:21:57 +0100287ART_TEST_TARGET_GTEST_DEPENDENCIES := $(TESTING_ART_APEX)
David Srbecky883c1342020-05-11 23:30:29 +0000288
Jiyong Parkeac38a12020-01-03 17:56:33 +0900289# Add the additional dependencies for the specified test
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000290# $(1): test name
Jiyong Parkeac38a12020-01-03 17:56:33 +0900291define add-art-gtest-dependencies
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000292 # Note that, both the primary and the secondary arches of the libs are built by depending
293 # on the module name.
294 gtest_deps := \
295 $$(ART_GTEST_$(1)_TARGET_DEPS) \
296 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Brian Carlstrom0796af02011-10-12 14:31:45 -0700297
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000298 ART_TEST_TARGET_GTEST_DEPENDENCIES += $$(gtest_deps)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100299
300 # Clear locally defined variables.
Nicolas Geoffray340fb0b2019-12-30 10:36:22 +0000301 gtest_deps :=
Jiyong Parkeac38a12020-01-03 17:56:33 +0900302endef # add-art-gtest-dependencies
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100303
304# $(1): file name
305# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
306define define-art-gtest-host
307 art_gtest_filename := $(1)
308
309 include $$(CLEAR_VARS)
310 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
311 ifndef ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES
312 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100313 endif
314 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),$$(art_gtest_filename),$(2)))
315
316 # Clear locally defined variables.
317 art_gtest_filename :=
318 art_gtest_name :=
319endef # define-art-gtest-host
320
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100321# Define the rules to build and run gtests for both archs on host.
322# $(1): test name
323define define-art-gtest-host-both
324 art_gtest_name := $(1)
325
Ian Rogersafd9acc2014-06-17 08:21:54 -0700326.PHONY: test-art-host-gtest-$$(art_gtest_name)
327test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
328 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800329
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100330 # Clear now unused variables.
331 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700332 art_gtest_name :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100333endef # define-art-gtest-host-both
Alex Light50fa9932015-08-10 15:30:07 -0700334
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700335ifeq ($(ART_BUILD_TARGET),true)
Jiyong Parkeac38a12020-01-03 17:56:33 +0900336 $(foreach name,$(ART_TARGET_GTEST_NAMES), $(eval $(call add-art-gtest-dependencies,$(name),)))
337 ART_TEST_TARGET_GTEST_DEPENDENCIES += \
Nicolas Geoffrayc69b3f82020-06-22 12:33:38 +0000338 com.android.i18n \
Nicolas Geoffrayec64f202020-04-20 15:05:54 +0100339 libjavacore.com.android.art.testing \
340 libopenjdkd.com.android.art.testing \
Nicolas Geoffray31e0dc22020-03-20 15:48:09 +0000341 com.android.art.testing \
342 com.android.conscrypt
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700343endif
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100344ifeq ($(ART_BUILD_HOST),true)
345 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),)))
346 ifneq ($(HOST_PREFER_32_BIT),true)
347 $(foreach file,$(2ND_ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),2ND_)))
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100348 endif
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100349 # Rules to run the different architecture versions of the gtest.
350 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700351endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700352
Roland Levillain05e34f42018-05-24 13:19:05 +0000353# Define all the combinations of host/target and suffix such as:
354# test-art-host-gtest or test-art-host-gtest64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700355# $(1): host or target
356# $(2): HOST or TARGET
Roland Levillain05e34f42018-05-24 13:19:05 +0000357# $(3): undefined, 32 or 64
Ian Rogersafd9acc2014-06-17 08:21:54 -0700358define define-test-art-gtest-combination
359 ifeq ($(1),host)
360 ifneq ($(2),HOST)
361 $$(error argument mismatch $(1) and ($2))
362 endif
363 else
364 ifneq ($(1),target)
365 $$(error found $(1) expected host or target)
366 endif
367 ifneq ($(2),TARGET)
368 $$(error argument mismatch $(1) and ($2))
369 endif
370 endif
371
Roland Levillain05e34f42018-05-24 13:19:05 +0000372 rule_name := test-art-$(1)-gtest$(3)
373 dependencies := $$(ART_TEST_$(2)_GTEST$(3)_RULES)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700374
375.PHONY: $$(rule_name)
Søren Gjesse46845f62019-12-10 09:14:16 +0100376$$(rule_name): $$(dependencies) d8
Ian Rogersafd9acc2014-06-17 08:21:54 -0700377 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
378
379 # Clear locally defined variables.
380 rule_name :=
381 dependencies :=
382endef # define-test-art-gtest-combination
383
Roland Levillain05e34f42018-05-24 13:19:05 +0000384$(eval $(call define-test-art-gtest-combination,target,TARGET,))
385$(eval $(call define-test-art-gtest-combination,target,TARGET,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Dan Willemsen5d2dbf82018-04-11 12:31:11 -0700386ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX
Roland Levillain05e34f42018-05-24 13:19:05 +0000387$(eval $(call define-test-art-gtest-combination,target,TARGET,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700388endif
Roland Levillain05e34f42018-05-24 13:19:05 +0000389$(eval $(call define-test-art-gtest-combination,host,HOST,))
390$(eval $(call define-test-art-gtest-combination,host,HOST,$(ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700391ifneq ($(HOST_PREFER_32_BIT),true)
Roland Levillain05e34f42018-05-24 13:19:05 +0000392$(eval $(call define-test-art-gtest-combination,host,HOST,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700393endif
394
Alex Lightd78be002020-09-01 07:49:21 -0700395# Define all the combinations of host/target and suffix such as:
396# test-art-host-gtest-dependencies or test-art-host-gtest-dependencies64
397# $(1): host or target
398# $(2): HOST or TARGET
399# $(3): undefined, 32 or 64
400define define-test-art-gtest-dependency-combination
401 ifeq ($(1),host)
402 ifneq ($(2),HOST)
403 $$(error argument mismatch $(1) and ($2))
404 endif
405 else
406 ifneq ($(1),target)
407 $$(error found $(1) expected host or target)
408 endif
409 ifneq ($(2),TARGET)
410 $$(error argument mismatch $(1) and ($2))
411 endif
412 endif
413
414 rule_name := test-art-$(1)-gtest-dependencies$(3)
415 dependencies := $$(ART_TEST_$(2)_GTEST$(3)_BUILD_RULES)
416
417.PHONY: $$(rule_name)
418$$(rule_name): $$(dependencies) d8
419
420 # Clear locally defined variables.
421 rule_name :=
422 dependencies :=
423endef # define-test-art-gtest-dependency-combination
424
425# TODO Get target-deps working too
426# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,))
427# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,$(ART_PHONY_TEST_TARGET_SUFFIX)))
428# ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX
429# $(eval $(call define-test-art-gtest-dependency-combination,target,TARGET,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
430# endif
431$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,))
432$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,$(ART_PHONY_TEST_HOST_SUFFIX)))
433ifneq ($(HOST_PREFER_32_BIT),true)
434$(eval $(call define-test-art-gtest-dependency-combination,host,HOST,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
435endif
436
Ian Rogersafd9acc2014-06-17 08:21:54 -0700437# Clear locally defined variables.
438define-art-gtest-rule-target :=
439define-art-gtest-rule-host :=
440define-art-gtest :=
441define-test-art-gtest-combination :=
442RUNTIME_GTEST_COMMON_SRC_FILES :=
443COMPILER_GTEST_COMMON_SRC_FILES :=
444RUNTIME_GTEST_TARGET_SRC_FILES :=
445RUNTIME_GTEST_HOST_SRC_FILES :=
446COMPILER_GTEST_TARGET_SRC_FILES :=
447COMPILER_GTEST_HOST_SRC_FILES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700448ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
449ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
450ART_TEST_HOST_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700451ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
452ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_BUILD_RULES :=
453ART_TEST_HOST_GTEST_BUILD_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700454ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
455ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
456ART_TEST_TARGET_GTEST_RULES :=
Alex Lightd78be002020-09-01 07:49:21 -0700457ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
458ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_BUILD_RULES :=
459ART_TEST_TARGET_GTEST_BUILD_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000460ART_GTEST_TARGET_ANDROID_ROOT :=
Victor Chang64611242019-07-05 16:32:41 +0100461ART_GTEST_TARGET_ANDROID_I18N_ROOT :=
Martin Stjernholme58624f2019-09-20 15:53:40 +0100462ART_GTEST_TARGET_ANDROID_ART_ROOT :=
Neil Fuller26a5dd62019-03-13 15:16:35 +0000463ART_GTEST_TARGET_ANDROID_TZDATA_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700464ART_GTEST_class_linker_test_DEX_DEPS :=
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800465ART_GTEST_class_table_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700466ART_GTEST_compiler_driver_test_DEX_DEPS :=
467ART_GTEST_dex_file_test_DEX_DEPS :=
468ART_GTEST_exception_test_DEX_DEPS :=
469ART_GTEST_elf_writer_test_HOST_DEPS :=
470ART_GTEST_elf_writer_test_TARGET_DEPS :=
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700471ART_GTEST_imtable_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700472ART_GTEST_jni_compiler_test_DEX_DEPS :=
473ART_GTEST_jni_internal_test_DEX_DEPS :=
Richard Uhler66d874d2015-01-15 09:37:19 -0800474ART_GTEST_oat_file_assistant_test_DEX_DEPS :=
475ART_GTEST_oat_file_assistant_test_HOST_DEPS :=
476ART_GTEST_oat_file_assistant_test_TARGET_DEPS :=
Mathieu Chartier0be7fa72018-04-12 10:13:29 -0700477ART_GTEST_dexanalyze_test_DEX_DEPS :=
Calin Juravle36eb3132017-01-13 16:32:38 -0800478ART_GTEST_dexoptanalyzer_test_DEX_DEPS :=
479ART_GTEST_dexoptanalyzer_test_HOST_DEPS :=
480ART_GTEST_dexoptanalyzer_test_TARGET_DEPS :=
Richard Uhler84f50ae2017-02-06 15:12:45 +0000481ART_GTEST_image_space_test_DEX_DEPS :=
482ART_GTEST_image_space_test_HOST_DEPS :=
483ART_GTEST_image_space_test_TARGET_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700484ART_GTEST_dex2oat_test_DEX_DEPS :=
485ART_GTEST_dex2oat_test_HOST_DEPS :=
486ART_GTEST_dex2oat_test_TARGET_DEPS :=
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700487ART_GTEST_dex2oat_image_test_DEX_DEPS :=
488ART_GTEST_dex2oat_image_test_HOST_DEPS :=
489ART_GTEST_dex2oat_image_test_TARGET_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700490ART_GTEST_object_test_DEX_DEPS :=
491ART_GTEST_proxy_test_DEX_DEPS :=
492ART_GTEST_reflection_test_DEX_DEPS :=
493ART_GTEST_stub_test_DEX_DEPS :=
494ART_GTEST_transaction_test_DEX_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700495ART_GTEST_dex2oat_environment_tests_DEX_DEPS :=
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700496ART_GTEST_heap_verification_test_DEX_DEPS :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100497ART_GTEST_verifier_deps_test_DEX_DEPS :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700498$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
499$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Richard Uhler66d874d2015-01-15 09:37:19 -0800500ART_TEST_HOST_GTEST_MainStripped_DEX :=
501ART_TEST_TARGET_GTEST_MainStripped_DEX :=
David Srbecky8c8f1482020-02-05 20:17:10 +0000502ART_TEST_HOST_GTEST_MainUncompressedAligned_DEX :=
503ART_TEST_TARGET_GTEST_MainUncompressedAligned_DEX :=
Mathieu Chartier700a9852018-02-06 18:27:38 -0800504ART_TEST_HOST_GTEST_EmptyUncompressed_DEX :=
505ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100506ART_TEST_GTEST_VerifierDeps_SRC :=
507ART_TEST_HOST_GTEST_VerifierDeps_DEX :=
David Brazdilf906f122016-09-16 16:33:31 +0100508ART_TEST_TARGET_GTEST_VerifierDeps_DEX :=
Vladimir Markod79b37b2018-11-02 13:06:22 +0000509ART_TEST_GTEST_VerifySoftFailDuringClinit_SRC :=
510ART_TEST_HOST_GTEST_VerifySoftFailDuringClinit_DEX :=
511ART_TEST_TARGET_GTEST_VerifySoftFailDuringClinit_DEX :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700512GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700513LOCAL_PATH :=
David Srbecky883c1342020-05-11 23:30:29 +0000514
515endif # ifneq ($(HOST_OS),darwin)