blob: c87abe5664af3ad0a39f753cb36b86a44c9e92f3 [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
Ian Rogersafd9acc2014-06-17 08:21:54 -070017# The path for which all the dex files are relative, not actually the current directory.
18LOCAL_PATH := art/test
19
20include art/build/Android.common_test.mk
21include art/build/Android.common_path.mk
Alex Light50fa9932015-08-10 15:30:07 -070022include art/build/Android.common_build.mk
Ian Rogersafd9acc2014-06-17 08:21:54 -070023
24# Subdirectories in art/test which contain dex files used as inputs for gtests.
25GTEST_DEX_DIRECTORIES := \
26 AbstractMethod \
27 AllFields \
Artem Udovichenkob3f2b5c2017-01-31 11:49:33 +030028 DefaultMethods \
Nicolas Geoffray01b70e82016-11-17 10:58:36 +000029 DexToDexDecompiler \
Mathieu Chartier1e4841e2016-12-15 14:21:04 -080030 ErroneousA \
31 ErroneousB \
Vladimir Marko72ab6842017-01-20 19:32:50 +000032 ErroneousInit \
Ian Rogersafd9acc2014-06-17 08:21:54 -070033 ExceptionHandle \
34 GetMethodSignature \
Mathieu Chartier496577f2016-09-20 15:33:31 -070035 ImageLayoutA \
36 ImageLayoutB \
Andreas Gampea1ff30f2016-09-27 12:19:45 -070037 IMTA \
38 IMTB \
Sebastien Hertz0462c4c2015-04-01 16:34:17 +020039 Instrumentation \
Ian Rogersafd9acc2014-06-17 08:21:54 -070040 Interfaces \
Artem Udovichenkod9786b02015-10-14 16:36:55 +030041 Lookup \
Ian Rogersafd9acc2014-06-17 08:21:54 -070042 Main \
Mathieu Chartierd00e02b2017-05-24 12:04:13 -070043 ManyMethods \
Narayan Kamath25352fc2016-08-03 12:46:58 +010044 MethodTypes \
Richard Uhler66d874d2015-01-15 09:37:19 -080045 MultiDex \
Richard Uhler67ff7d12015-05-14 13:21:13 -070046 MultiDexModifiedSecondary \
Ian Rogersafd9acc2014-06-17 08:21:54 -070047 MyClass \
48 MyClassNatives \
49 Nested \
50 NonStaticLeafMethods \
Mathieu Chartier279ac5c2016-09-08 17:34:25 -070051 Packages \
Ian Rogersafd9acc2014-06-17 08:21:54 -070052 ProtoCompare \
53 ProtoCompare2 \
Calin Juravle877fd962016-01-05 14:29:29 +000054 ProfileTestMultiDex \
Ian Rogersafd9acc2014-06-17 08:21:54 -070055 StaticLeafMethods \
56 Statics \
57 StaticsFromCode \
58 Transaction \
59 XandY
60
61# Create build rules for each dex file recording the dependency.
62$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-gtest,$(dir), \
Ian Rogers1a2f84e2014-07-07 16:05:18 -070063 $(ART_TARGET_NATIVETEST_OUT),art/build/Android.gtest.mk,ART_TEST_TARGET_GTEST_$(dir)_DEX, \
64 ART_TEST_HOST_GTEST_$(dir)_DEX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -070065
Richard Uhler66d874d2015-01-15 09:37:19 -080066# Create rules for MainStripped, a copy of Main with the classes.dex stripped
67# for the oat file assistant tests.
68ART_TEST_HOST_GTEST_MainStripped_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))Stripped$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
69ART_TEST_TARGET_GTEST_MainStripped_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))Stripped$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
70
71$(ART_TEST_HOST_GTEST_MainStripped_DEX): $(ART_TEST_HOST_GTEST_Main_DEX)
72 cp $< $@
73 $(call dexpreopt-remove-classes.dex,$@)
74
75$(ART_TEST_TARGET_GTEST_MainStripped_DEX): $(ART_TEST_TARGET_GTEST_Main_DEX)
76 cp $< $@
77 $(call dexpreopt-remove-classes.dex,$@)
78
David Brazdilca3c8c32016-09-06 14:04:48 +010079ART_TEST_GTEST_VerifierDeps_SRC := $(abspath $(wildcard $(LOCAL_PATH)/VerifierDeps/*.smali))
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +000080ART_TEST_GTEST_VerifierDepsMulti_SRC := $(abspath $(wildcard $(LOCAL_PATH)/VerifierDepsMulti/*.smali))
David Brazdilca3c8c32016-09-06 14:04:48 +010081ART_TEST_HOST_GTEST_VerifierDeps_DEX := $(dir $(ART_TEST_HOST_GTEST_Main_DEX))$(subst Main,VerifierDeps,$(basename $(notdir $(ART_TEST_HOST_GTEST_Main_DEX))))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
David Brazdilf906f122016-09-16 16:33:31 +010082ART_TEST_TARGET_GTEST_VerifierDeps_DEX := $(dir $(ART_TEST_TARGET_GTEST_Main_DEX))$(subst Main,VerifierDeps,$(basename $(notdir $(ART_TEST_TARGET_GTEST_Main_DEX))))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +000083ART_TEST_HOST_GTEST_VerifierDepsMulti_DEX := $(dir $(ART_TEST_HOST_GTEST_Main_DEX))$(subst Main,VerifierDepsMulti,$(basename $(notdir $(ART_TEST_HOST_GTEST_Main_DEX))))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
84ART_TEST_TARGET_GTEST_VerifierDepsMulti_DEX := $(dir $(ART_TEST_TARGET_GTEST_Main_DEX))$(subst Main,VerifierDepsMulti,$(basename $(notdir $(ART_TEST_TARGET_GTEST_Main_DEX))))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
David Brazdilca3c8c32016-09-06 14:04:48 +010085
86$(ART_TEST_HOST_GTEST_VerifierDeps_DEX): $(ART_TEST_GTEST_VerifierDeps_SRC) $(HOST_OUT_EXECUTABLES)/smali
Ben Gruver14fc9db2017-04-28 15:30:49 -070087 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
David Brazdilca3c8c32016-09-06 14:04:48 +010088
David Brazdilf906f122016-09-16 16:33:31 +010089$(ART_TEST_TARGET_GTEST_VerifierDeps_DEX): $(ART_TEST_GTEST_VerifierDeps_SRC) $(HOST_OUT_EXECUTABLES)/smali
Ben Gruver14fc9db2017-04-28 15:30:49 -070090 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
David Brazdilf906f122016-09-16 16:33:31 +010091
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +000092$(ART_TEST_HOST_GTEST_VerifierDepsMulti_DEX): $(ART_TEST_GTEST_VerifierDepsMulti_SRC) $(HOST_OUT_EXECUTABLES)/smali
Ben Gruver14fc9db2017-04-28 15:30:49 -070093 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +000094
95$(ART_TEST_TARGET_GTEST_VerifierDepsMulti_DEX): $(ART_TEST_GTEST_VerifierDepsMulti_SRC) $(HOST_OUT_EXECUTABLES)/smali
Ben Gruver14fc9db2017-04-28 15:30:49 -070096 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +000097
Ian Rogersafd9acc2014-06-17 08:21:54 -070098# Dex file dependencies for each gtest.
Andreas Gampee1459ae2016-06-29 09:36:30 -070099ART_GTEST_dex2oat_environment_tests_DEX_DEPS := Main MainStripped MultiDex MultiDexModifiedSecondary Nested
100
Mathieu Chartier9df89312016-11-23 13:28:16 -0800101ART_GTEST_atomic_method_ref_map_test_DEX_DEPS := Interfaces
Vladimir Marko72ab6842017-01-20 19:32:50 +0000102ART_GTEST_class_linker_test_DEX_DEPS := AllFields ErroneousA ErroneousB ErroneousInit Interfaces MethodTypes MultiDex MyClass Nested Statics StaticsFromCode
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800103ART_GTEST_class_table_test_DEX_DEPS := XandY
Calin Juravle877fd962016-01-05 14:29:29 +0000104ART_GTEST_compiler_driver_test_DEX_DEPS := AbstractMethod StaticLeafMethods ProfileTestMultiDex
Narayan Kamath25352fc2016-08-03 12:46:58 +0100105ART_GTEST_dex_cache_test_DEX_DEPS := Main Packages MethodTypes
Richard Uhler69bcf2c2017-01-24 10:25:21 +0000106ART_GTEST_dex_file_test_DEX_DEPS := GetMethodSignature Main Nested MultiDex
Mathieu Chartierd00e02b2017-05-24 12:04:13 -0700107ART_GTEST_dexlayout_test_DEX_DEPS := ManyMethods
Vladimir Marko15357702017-02-09 10:37:31 +0000108ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics VerifierDeps
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700109ART_GTEST_dex2oat_image_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics VerifierDeps
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700110ART_GTEST_exception_test_DEX_DEPS := ExceptionHandle
Artem Udovichenkob3f2b5c2017-01-31 11:49:33 +0300111ART_GTEST_image_test_DEX_DEPS := ImageLayoutA ImageLayoutB DefaultMethods
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700112ART_GTEST_imtable_test_DEX_DEPS := IMTA IMTB
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200113ART_GTEST_instrumentation_test_DEX_DEPS := Instrumentation
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700114ART_GTEST_jni_compiler_test_DEX_DEPS := MyClassNatives
115ART_GTEST_jni_internal_test_DEX_DEPS := AllFields StaticLeafMethods
Andreas Gampee1459ae2016-06-29 09:36:30 -0700116ART_GTEST_oat_file_assistant_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
Calin Juravle36eb3132017-01-13 16:32:38 -0800117ART_GTEST_dexoptanalyzer_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
Richard Uhler84f50ae2017-02-06 15:12:45 +0000118ART_GTEST_image_space_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
Andreas Gampe7848da42015-04-09 11:15:04 -0700119ART_GTEST_oat_file_test_DEX_DEPS := Main MultiDex
Mathieu Chartier07ddb6f2015-11-05 11:16:34 -0800120ART_GTEST_oat_test_DEX_DEPS := Main
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700121ART_GTEST_object_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
122ART_GTEST_proxy_test_DEX_DEPS := Interfaces
123ART_GTEST_reflection_test_DEX_DEPS := Main NonStaticLeafMethods StaticLeafMethods
Calin Juravle877fd962016-01-05 14:29:29 +0000124ART_GTEST_profile_assistant_test_DEX_DEPS := ProfileTestMultiDex
Mathieu Chartierdb40eac2017-06-09 18:34:11 -0700125ART_GTEST_profile_compilation_info_test_DEX_DEPS := ManyMethods ProfileTestMultiDex
Andreas Gampe0f01b582017-01-18 15:22:37 -0800126ART_GTEST_runtime_callbacks_test_DEX_DEPS := XandY
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700127ART_GTEST_stub_test_DEX_DEPS := AllFields
128ART_GTEST_transaction_test_DEX_DEPS := Transaction
Artem Udovichenkod9786b02015-10-14 16:36:55 +0300129ART_GTEST_type_lookup_table_test_DEX_DEPS := Lookup
Andreas Gampeae78c262017-02-01 20:40:44 -0800130ART_GTEST_unstarted_runtime_test_DEX_DEPS := Nested
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700131ART_GTEST_heap_verification_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000132ART_GTEST_verifier_deps_test_DEX_DEPS := VerifierDeps VerifierDepsMulti MultiDex
Nicolas Geoffray01b70e82016-11-17 10:58:36 +0000133ART_GTEST_dex_to_dex_decompiler_test_DEX_DEPS := VerifierDeps DexToDexDecompiler
Ian Rogersafd9acc2014-06-17 08:21:54 -0700134
135# The elf writer test has dependencies on core.oat.
Richard Uhler67e1dc52017-02-06 16:50:17 +0000136ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
137ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
Brian Carlstrom53463ea2014-11-09 14:11:51 -0800138
Andreas Gampee1459ae2016-06-29 09:36:30 -0700139ART_GTEST_dex2oat_environment_tests_HOST_DEPS := \
Richard Uhlerbb00f812017-02-16 14:21:10 +0000140 $(HOST_CORE_IMAGE_optimizing_64) \
141 $(HOST_CORE_IMAGE_optimizing_32) \
142 $(HOST_CORE_IMAGE_interpreter_64) \
143 $(HOST_CORE_IMAGE_interpreter_32) \
Richard Uhlerf51ac422016-07-08 09:22:33 -0700144 $(HOST_OUT_EXECUTABLES)/patchoatd
Andreas Gampee1459ae2016-06-29 09:36:30 -0700145ART_GTEST_dex2oat_environment_tests_TARGET_DEPS := \
Richard Uhlerbb00f812017-02-16 14:21:10 +0000146 $(TARGET_CORE_IMAGE_optimizing_64) \
147 $(TARGET_CORE_IMAGE_optimizing_32) \
148 $(TARGET_CORE_IMAGE_interpreter_64) \
149 $(TARGET_CORE_IMAGE_interpreter_32) \
Richard Uhlerf51ac422016-07-08 09:22:33 -0700150 $(TARGET_OUT_EXECUTABLES)/patchoatd
Andreas Gampee1459ae2016-06-29 09:36:30 -0700151
152ART_GTEST_oat_file_assistant_test_HOST_DEPS := \
Richard Uhlerf51ac422016-07-08 09:22:33 -0700153 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
Andreas Gampee1459ae2016-06-29 09:36:30 -0700154ART_GTEST_oat_file_assistant_test_TARGET_DEPS := \
Richard Uhlerf51ac422016-07-08 09:22:33 -0700155 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
Andreas Gampee1459ae2016-06-29 09:36:30 -0700156
Calin Juravle36eb3132017-01-13 16:32:38 -0800157ART_GTEST_dexoptanalyzer_test_HOST_DEPS := \
158 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS) \
159 $(HOST_OUT_EXECUTABLES)/dexoptanalyzerd
160ART_GTEST_dexoptanalyzer_test_TARGET_DEPS := \
161 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS) \
162 dexoptanalyzerd
Andreas Gampee1459ae2016-06-29 09:36:30 -0700163
Richard Uhler84f50ae2017-02-06 15:12:45 +0000164ART_GTEST_image_space_test_HOST_DEPS := \
165 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
166ART_GTEST_image_space_test_TARGET_DEPS := \
167 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
168
Andreas Gampee1459ae2016-06-29 09:36:30 -0700169ART_GTEST_dex2oat_test_HOST_DEPS := \
170 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
171ART_GTEST_dex2oat_test_TARGET_DEPS := \
172 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
Richard Uhler66d874d2015-01-15 09:37:19 -0800173
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700174ART_GTEST_dex2oat_image_test_HOST_DEPS := \
175 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
176ART_GTEST_dex2oat_image_test_TARGET_DEPS := \
177 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
178
Brian Carlstrom53463ea2014-11-09 14:11:51 -0800179# TODO: document why this is needed.
Richard Uhler67e1dc52017-02-06 16:50:17 +0000180ART_GTEST_proxy_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700181
David Sehr55232f12017-04-19 14:06:49 -0700182# The dexdiag test requires the dexdiag utility.
183ART_GTEST_dexdiag_test_HOST_DEPS := \
184 $(HOST_OUT_EXECUTABLES)/dexdiag
185ART_GTEST_dexdiag_test_TARGET_DEPS := \
186 dexdiag
187
Aart Bikcfbe53c2015-07-06 14:27:27 -0700188# The dexdump test requires an image and the dexdump utility.
Aart Bik22c26f52015-07-08 21:20:13 +0000189# TODO: rename into dexdump when migration completes
Aart Bikcfbe53c2015-07-06 14:27:27 -0700190ART_GTEST_dexdump_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000191 $(HOST_CORE_IMAGE_DEFAULT_64) \
192 $(HOST_CORE_IMAGE_DEFAULT_32) \
Aart Bik22c26f52015-07-08 21:20:13 +0000193 $(HOST_OUT_EXECUTABLES)/dexdump2
Aart Bikcfbe53c2015-07-06 14:27:27 -0700194ART_GTEST_dexdump_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000195 $(TARGET_CORE_IMAGE_DEFAULT_64) \
196 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Aart Bik22c26f52015-07-08 21:20:13 +0000197 dexdump2
Aart Bikcfbe53c2015-07-06 14:27:27 -0700198
Jeff Haoc3acfc52016-08-29 14:18:26 -0700199# The dexlayout test requires an image and the dexlayout utility.
200# TODO: rename into dexdump when migration completes
201ART_GTEST_dexlayout_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000202 $(HOST_CORE_IMAGE_DEFAULT_64) \
203 $(HOST_CORE_IMAGE_DEFAULT_32) \
Jeff Haoc3acfc52016-08-29 14:18:26 -0700204 $(HOST_OUT_EXECUTABLES)/dexlayout \
205 $(HOST_OUT_EXECUTABLES)/dexdump2
206ART_GTEST_dexlayout_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000207 $(TARGET_CORE_IMAGE_DEFAULT_64) \
208 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Jeff Haoc3acfc52016-08-29 14:18:26 -0700209 dexlayout \
210 dexdump2
211
Aart Bik3e40f4a2015-07-07 17:09:41 -0700212# The dexlist test requires an image and the dexlist utility.
Aart Bik3e40f4a2015-07-07 17:09:41 -0700213ART_GTEST_dexlist_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000214 $(HOST_CORE_IMAGE_DEFAULT_64) \
215 $(HOST_CORE_IMAGE_DEFAULT_32) \
Aart Bikb1b45be2015-08-28 11:09:29 -0700216 $(HOST_OUT_EXECUTABLES)/dexlist
Aart Bik3e40f4a2015-07-07 17:09:41 -0700217ART_GTEST_dexlist_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000218 $(TARGET_CORE_IMAGE_DEFAULT_64) \
219 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Aart Bikb1b45be2015-08-28 11:09:29 -0700220 dexlist
Aart Bik3e40f4a2015-07-07 17:09:41 -0700221
Igor Murashkin37743352014-11-13 14:38:00 -0800222# The imgdiag test has dependencies on core.oat since it needs to load it during the test.
Andreas Gampec93b8b52014-12-19 23:12:25 -0800223# For the host, also add the installed tool (in the base size, that should suffice). For the
224# target, just the module is fine, the sync will happen late enough.
225ART_GTEST_imgdiag_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000226 $(HOST_CORE_IMAGE_DEFAULT_64) \
227 $(HOST_CORE_IMAGE_DEFAULT_32) \
Andreas Gampec93b8b52014-12-19 23:12:25 -0800228 $(HOST_OUT_EXECUTABLES)/imgdiagd
229ART_GTEST_imgdiag_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000230 $(TARGET_CORE_IMAGE_DEFAULT_64) \
231 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Andreas Gampec93b8b52014-12-19 23:12:25 -0800232 imgdiagd
Igor Murashkin37743352014-11-13 14:38:00 -0800233
Mathieu Chartierea216b32015-05-26 19:48:16 -0700234# Oatdump test requires an image and oatfile to dump.
235ART_GTEST_oatdump_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000236 $(HOST_CORE_IMAGE_DEFAULT_64) \
237 $(HOST_CORE_IMAGE_DEFAULT_32) \
Colin Crossb20be212016-09-19 13:02:47 -0700238 $(HOST_OUT_EXECUTABLES)/oatdumpd \
239 $(HOST_OUT_EXECUTABLES)/oatdumpds
Mathieu Chartierea216b32015-05-26 19:48:16 -0700240ART_GTEST_oatdump_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000241 $(TARGET_CORE_IMAGE_DEFAULT_64) \
242 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Mathieu Chartierea216b32015-05-26 19:48:16 -0700243 oatdump
Vladimir Marko1352f132017-04-28 15:28:29 +0100244ART_GTEST_oatdump_image_test_HOST_DEPS := $(ART_GTEST_oatdump_test_HOST_DEPS)
245ART_GTEST_oatdump_image_test_TARGET_DEPS := $(ART_GTEST_oatdump_test_TARGET_DEPS)
Mathieu Chartierea216b32015-05-26 19:48:16 -0700246
Calin Juravle2e2db782016-02-23 12:00:03 +0000247# Profile assistant tests requires profman utility.
248ART_GTEST_profile_assistant_test_HOST_DEPS := \
249 $(HOST_OUT_EXECUTABLES)/profmand
250ART_GTEST_profile_assistant_test_TARGET_DEPS := \
251 profman
252
Ian Rogersafd9acc2014-06-17 08:21:54 -0700253# The path for which all the source files are relative, not actually the current directory.
Brian Carlstrom7940e442013-07-12 13:46:57 -0700254LOCAL_PATH := art
255
Colin Cross6e95dd52016-09-12 15:37:10 -0700256ART_TEST_MODULES := \
257 art_cmdline_tests \
258 art_compiler_tests \
259 art_compiler_host_tests \
260 art_dex2oat_tests \
David Sehr55232f12017-04-19 14:06:49 -0700261 art_dexdiag_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700262 art_dexdump_tests \
263 art_dexlayout_tests \
264 art_dexlist_tests \
Calin Juravle36eb3132017-01-13 16:32:38 -0800265 art_dexoptanalyzer_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700266 art_imgdiag_tests \
267 art_oatdump_tests \
268 art_profman_tests \
269 art_runtime_tests \
270 art_runtime_compiler_tests \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800271
Colin Cross6e95dd52016-09-12 15:37:10 -0700272ART_TARGET_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES),\
273 $(ART_TEST_LIST_device_$(TARGET_ARCH)_$(m)))
Alex Light50fa9932015-08-10 15:30:07 -0700274
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100275ifdef TARGET_2ND_ARCH
2762ND_ART_TARGET_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES),\
277 $(ART_TEST_LIST_device_$(2ND_TARGET_ARCH)_$(m)))
278endif
279
Colin Cross6e95dd52016-09-12 15:37:10 -0700280ART_HOST_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES),\
Colin Cross124f8812016-09-15 20:57:47 -0700281 $(ART_TEST_LIST_host_$(ART_HOST_ARCH)_$(m)))
Alex Light50fa9932015-08-10 15:30:07 -0700282
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100283ifneq ($(HOST_PREFER_32_BIT),true)
2842ND_ART_HOST_GTEST_FILES += $(foreach m,$(ART_TEST_MODULES),\
285 $(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_$(m)))
286endif
287
Ian Rogersafd9acc2014-06-17 08:21:54 -0700288# Variables holding collections of gtest pre-requisits used to run a number of gtests.
289ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
290ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
291ART_TEST_HOST_GTEST_RULES :=
292ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
293ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
294ART_TEST_HOST_VALGRIND_GTEST_RULES :=
295ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
296ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
297ART_TEST_TARGET_GTEST_RULES :=
Anton Kirilove5e76f42016-05-03 16:15:36 +0100298ART_TEST_TARGET_VALGRIND_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
299ART_TEST_TARGET_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
300ART_TEST_TARGET_VALGRIND_GTEST_RULES :=
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100301ART_TEST_HOST_GTEST_DEPENDENCIES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700302
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000303ART_GTEST_TARGET_ANDROID_ROOT := '/system'
304ifneq ($(ART_TEST_ANDROID_ROOT),)
305 ART_GTEST_TARGET_ANDROID_ROOT := $(ART_TEST_ANDROID_ROOT)
306endif
307
Anton Kirilove5e76f42016-05-03 16:15:36 +0100308ART_VALGRIND_TARGET_DEPENDENCIES := \
309 $(TARGET_OUT_EXECUTABLES)/valgrind \
310 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/memcheck-$(TARGET_ARCH)-linux \
311 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/vgpreload_core-$(TARGET_ARCH)-linux.so \
312 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/vgpreload_memcheck-$(TARGET_ARCH)-linux.so \
313 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/default.supp
314
315ifdef TARGET_2ND_ARCH
316ART_VALGRIND_TARGET_DEPENDENCIES += \
317 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/memcheck-$(TARGET_2ND_ARCH)-linux \
318 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/vgpreload_core-$(TARGET_2ND_ARCH)-linux.so \
319 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/vgpreload_memcheck-$(TARGET_2ND_ARCH)-linux.so
320endif
321
322include $(CLEAR_VARS)
323LOCAL_MODULE := valgrind-target-suppressions.txt
324LOCAL_MODULE_CLASS := ETC
325LOCAL_MODULE_TAGS := optional
326LOCAL_SRC_FILES := test/valgrind-target-suppressions.txt
327LOCAL_MODULE_PATH := $(ART_TARGET_TEST_OUT)
328include $(BUILD_PREBUILT)
329
Ian Rogersafd9acc2014-06-17 08:21:54 -0700330# Define a make rule for a target device gtest.
331# $(1): gtest name - the name of the test we're building such as leb128_test.
Colin Cross6e95dd52016-09-12 15:37:10 -0700332# $(2): path relative to $OUT to the test binary
333# $(3): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
334# $(4): LD_LIBRARY_PATH or undefined - used in case libartd.so is not in /system/lib/
Ian Rogersafd9acc2014-06-17 08:21:54 -0700335define define-art-gtest-rule-target
Colin Cross6e95dd52016-09-12 15:37:10 -0700336 gtest_rule := test-art-target-gtest-$(1)$$($(3)ART_PHONY_TEST_TARGET_SUFFIX)
337 gtest_exe := $(OUT_DIR)/$(2)
338 gtest_target_exe := $$(patsubst $(PRODUCT_OUT)/%,/%,$$(gtest_exe))
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700339
Brian Carlstrom532714a2014-06-25 02:15:31 -0700340 # Add the test dependencies to test-art-target-sync, which will be a prerequisite for the test
Ian Rogersafd9acc2014-06-17 08:21:54 -0700341 # to ensure files are pushed to the device.
342 TEST_ART_TARGET_SYNC_DEPS += \
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700343 $$(ART_GTEST_$(1)_TARGET_DEPS) \
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700344 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700345 $$(gtest_exe) \
346 $$($(3)TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so \
347 $$($(3)TARGET_OUT_SHARED_LIBRARIES)/libopenjdkd.so \
Andreas Gampec7d4a582015-09-30 11:52:02 -0700348 $$(TARGET_OUT_JAVA_LIBRARIES)/core-libart-testdex.jar \
Anton Kirilove5e76f42016-05-03 16:15:36 +0100349 $$(TARGET_OUT_JAVA_LIBRARIES)/core-oj-testdex.jar \
350 $$(ART_TARGET_TEST_OUT)/valgrind-target-suppressions.txt
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700351
Colin Cross6e95dd52016-09-12 15:37:10 -0700352$$(gtest_rule) valgrind-$$(gtest_rule): PRIVATE_TARGET_EXE := $$(gtest_target_exe)
353
Ian Rogersafd9acc2014-06-17 08:21:54 -0700354.PHONY: $$(gtest_rule)
355$$(gtest_rule): test-art-target-sync
Colin Cross6e95dd52016-09-12 15:37:10 -0700356 $(hide) adb shell touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID
357 $(hide) adb shell rm $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID
358 $(hide) adb shell chmod 755 $$(PRIVATE_TARGET_EXE)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700359 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Colin Cross6e95dd52016-09-12 15:37:10 -0700360 (adb shell "$(GCOV_ENV) LD_LIBRARY_PATH=$(4) ANDROID_ROOT=$(ART_GTEST_TARGET_ANDROID_ROOT) \
361 $$(PRIVATE_TARGET_EXE) && touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID" \
362 && (adb pull $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID /tmp/ \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700363 && $$(call ART_TEST_PASSED,$$@)) \
364 || $$(call ART_TEST_FAILED,$$@))
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700365 $(hide) rm -f /tmp/$$@-$$$$PPID
Ian Rogersafd9acc2014-06-17 08:21:54 -0700366
Colin Cross6e95dd52016-09-12 15:37:10 -0700367 ART_TEST_TARGET_GTEST$($(3)ART_PHONY_TEST_TARGET_SUFFIX)_RULES += $$(gtest_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700368 ART_TEST_TARGET_GTEST_RULES += $$(gtest_rule)
369 ART_TEST_TARGET_GTEST_$(1)_RULES += $$(gtest_rule)
370
Anton Kirilove5e76f42016-05-03 16:15:36 +0100371.PHONY: valgrind-$$(gtest_rule)
372valgrind-$$(gtest_rule): $(ART_VALGRIND_TARGET_DEPENDENCIES) test-art-target-sync
Colin Cross6e95dd52016-09-12 15:37:10 -0700373 $(hide) adb shell touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID
374 $(hide) adb shell rm $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID
375 $(hide) adb shell chmod 755 $$(PRIVATE_TARGET_EXE)
Anton Kirilove5e76f42016-05-03 16:15:36 +0100376 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Colin Cross6e95dd52016-09-12 15:37:10 -0700377 (adb shell "$(GCOV_ENV) LD_LIBRARY_PATH=$(4) ANDROID_ROOT=$(ART_GTEST_TARGET_ANDROID_ROOT) \
Anton Kirilove5e76f42016-05-03 16:15:36 +0100378 valgrind --leak-check=full --error-exitcode=1 --workaround-gcc296-bugs=yes \
379 --suppressions=$(ART_TARGET_TEST_DIR)/valgrind-target-suppressions.txt \
Anton Kirilov3a2e78e2017-01-06 13:33:42 +0000380 --num-callers=50 --show-mismatched-frees=no \
Colin Cross6e95dd52016-09-12 15:37:10 -0700381 $$(PRIVATE_TARGET_EXE) && touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID" \
382 && (adb pull $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID /tmp/ \
Anton Kirilove5e76f42016-05-03 16:15:36 +0100383 && $$(call ART_TEST_PASSED,$$@)) \
384 || $$(call ART_TEST_FAILED,$$@))
385 $(hide) rm -f /tmp/$$@-$$$$PPID
386
Colin Cross6e95dd52016-09-12 15:37:10 -0700387 ART_TEST_TARGET_VALGRIND_GTEST$$($(3)ART_PHONY_TEST_TARGET_SUFFIX)_RULES += valgrind-$$(gtest_rule)
Anton Kirilove5e76f42016-05-03 16:15:36 +0100388 ART_TEST_TARGET_VALGRIND_GTEST_RULES += valgrind-$$(gtest_rule)
389 ART_TEST_TARGET_VALGRIND_GTEST_$(1)_RULES += valgrind-$$(gtest_rule)
390
Ian Rogersafd9acc2014-06-17 08:21:54 -0700391 # Clear locally defined variables.
Anton Kirilove5e76f42016-05-03 16:15:36 +0100392 valgrind_gtest_rule :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700393 gtest_rule :=
Colin Cross6e95dd52016-09-12 15:37:10 -0700394 gtest_exe :=
395 gtest_target_exe :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700396endef # define-art-gtest-rule-target
397
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800398ART_VALGRIND_DEPENDENCIES := \
399 $(HOST_OUT_EXECUTABLES)/valgrind \
400 $(HOST_OUT)/lib64/valgrind/memcheck-amd64-linux \
401 $(HOST_OUT)/lib64/valgrind/memcheck-x86-linux \
402 $(HOST_OUT)/lib64/valgrind/default.supp \
403 $(HOST_OUT)/lib64/valgrind/vgpreload_core-amd64-linux.so \
404 $(HOST_OUT)/lib64/valgrind/vgpreload_core-x86-linux.so \
405 $(HOST_OUT)/lib64/valgrind/vgpreload_memcheck-amd64-linux.so \
406 $(HOST_OUT)/lib64/valgrind/vgpreload_memcheck-x86-linux.so
407
Ian Rogersafd9acc2014-06-17 08:21:54 -0700408# Define make rules for a host gtests.
409# $(1): gtest name - the name of the test we're building such as leb128_test.
Colin Cross6e95dd52016-09-12 15:37:10 -0700410# $(2): path relative to $OUT to the test binary
411# $(3): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700412define define-art-gtest-rule-host
Colin Cross6e95dd52016-09-12 15:37:10 -0700413 gtest_rule := test-art-host-gtest-$(1)$$($(3)ART_PHONY_TEST_HOST_SUFFIX)
414 gtest_exe := $(OUT_DIR)/$(2)
Ian Rogers665de8a2014-06-24 21:34:09 -0700415 # Dependencies for all host gtests.
416 gtest_deps := $$(HOST_CORE_DEX_LOCATIONS) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700417 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION) \
418 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100419 $$(gtest_exe) \
420 $$(ART_GTEST_$(1)_HOST_DEPS) \
421 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX))
Ian Rogers665de8a2014-06-24 21:34:09 -0700422
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100423 ART_TEST_HOST_GTEST_DEPENDENCIES += $$(gtest_deps)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700424
Andreas Gampe03858052017-05-01 08:17:24 -0700425# Note: envsetup currently exports ASAN_OPTIONS=detect_leaks=0 to suppress leak detection, as some
426# build tools (e.g., ninja) intentionally leak. We want leak checks when we run our tests, so
427# override ASAN_OPTIONS. b/37751350
Ian Rogersafd9acc2014-06-17 08:21:54 -0700428.PHONY: $$(gtest_rule)
Nicolas Geoffray0f7c06d2015-05-28 10:21:03 +0100429$$(gtest_rule): $$(gtest_exe) $$(gtest_deps)
Andreas Gampe03858052017-05-01 08:17:24 -0700430 $(hide) ($$(call ART_TEST_SKIP,$$@) && ASAN_OPTIONS=detect_leaks=1 $$< && \
431 $$(call ART_TEST_PASSED,$$@)) || $$(call ART_TEST_FAILED,$$@)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700432
Colin Cross6e95dd52016-09-12 15:37:10 -0700433 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700434 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
435 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
436
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800437
Ian Rogersafd9acc2014-06-17 08:21:54 -0700438.PHONY: valgrind-$$(gtest_rule)
Andreas Gampe3db36002015-05-28 20:17:09 -0700439valgrind-$$(gtest_rule): $$(gtest_exe) $$(gtest_deps) $(ART_VALGRIND_DEPENDENCIES)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700440 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Andreas Gampe8df91ac2015-02-20 13:15:15 -0800441 VALGRIND_LIB=$(HOST_OUT)/lib64/valgrind \
Hiroshi Yamauchidc15e892016-03-10 13:49:14 -0800442 $(HOST_OUT_EXECUTABLES)/valgrind --leak-check=full --error-exitcode=1 \
Andreas Gampebf13e802016-09-02 19:43:09 -0700443 --suppressions=art/test/valgrind-suppressions.txt --num-callers=50 \
444 $$< && \
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800445 $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700446
Colin Cross6e95dd52016-09-12 15:37:10 -0700447 ART_TEST_HOST_VALGRIND_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += valgrind-$$(gtest_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700448 ART_TEST_HOST_VALGRIND_GTEST_RULES += valgrind-$$(gtest_rule)
449 ART_TEST_HOST_VALGRIND_GTEST_$(1)_RULES += valgrind-$$(gtest_rule)
450
451 # Clear locally defined variables.
452 valgrind_gtest_rule :=
453 gtest_rule :=
454 gtest_exe :=
Ian Rogers665de8a2014-06-24 21:34:09 -0700455 gtest_deps :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700456endef # define-art-gtest-rule-host
457
458# Define the rules to build and run host and target gtests.
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100459# $(1): file name
460# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
461define define-art-gtest-target
462 art_gtest_filename := $(1)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700463
Ian Rogersafd9acc2014-06-17 08:21:54 -0700464 include $$(CLEAR_VARS)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700465 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
Colin Cross6e95dd52016-09-12 15:37:10 -0700466
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100467 library_path :=
468 2ND_library_path :=
469 ifneq ($$(ART_TEST_ANDROID_ROOT),)
470 ifdef TARGET_2ND_ARCH
471 2ND_library_path := $$(ART_TEST_ANDROID_ROOT)/lib
472 library_path := $$(ART_TEST_ANDROID_ROOT)/lib64
473 else
474 ifneq ($(filter %64,$(TARGET_ARCH)),)
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000475 library_path := $$(ART_TEST_ANDROID_ROOT)/lib64
476 else
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100477 library_path := $$(ART_TEST_ANDROID_ROOT)/lib
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000478 endif
479 endif
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100480 endif
Andreas Gampe5ca4eaa2014-05-29 02:09:33 -0700481
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100482 ifndef ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES
Ian Rogersafd9acc2014-06-17 08:21:54 -0700483 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
Anton Kirilove5e76f42016-05-03 16:15:36 +0100484 ART_TEST_TARGET_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100485 endif
486 $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),$$(art_gtest_filename),$(2),$$($(2)library_path)))
487
488 # Clear locally defined variables.
489 art_gtest_filename :=
490 art_gtest_name :=
491 library_path :=
492 2ND_library_path :=
493endef # define-art-gtest-target
494
495# $(1): file name
496# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
497define define-art-gtest-host
498 art_gtest_filename := $(1)
499
500 include $$(CLEAR_VARS)
501 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
502 ifndef ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES
503 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
504 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
505 endif
506 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),$$(art_gtest_filename),$(2)))
507
508 # Clear locally defined variables.
509 art_gtest_filename :=
510 art_gtest_name :=
511endef # define-art-gtest-host
512
513# Define the rules to build and run gtests for both archs on target.
514# $(1): test name
515define define-art-gtest-target-both
516 art_gtest_name := $(1)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700517
Ian Rogersafd9acc2014-06-17 08:21:54 -0700518 # A rule to run the different architecture versions of the gtest.
519.PHONY: test-art-target-gtest-$$(art_gtest_name)
520test-art-target-gtest-$$(art_gtest_name): $$(ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES)
521 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
522
Anton Kirilove5e76f42016-05-03 16:15:36 +0100523.PHONY: valgrind-test-art-target-gtest-$$(art_gtest_name)
524valgrind-test-art-target-gtest-$$(art_gtest_name): $$(ART_TEST_TARGET_VALGRIND_GTEST_$$(art_gtest_name)_RULES)
525 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
526
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100527 # Clear now unused variables.
528 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
529 ART_TEST_TARGET_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
530 art_gtest_name :=
531endef # define-art-gtest-target-both
Ian Rogersd912e5c2013-11-13 12:40:11 -0800532
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100533# Define the rules to build and run gtests for both archs on host.
534# $(1): test name
535define define-art-gtest-host-both
536 art_gtest_name := $(1)
537
Ian Rogersafd9acc2014-06-17 08:21:54 -0700538.PHONY: test-art-host-gtest-$$(art_gtest_name)
539test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
540 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800541
Ian Rogersafd9acc2014-06-17 08:21:54 -0700542.PHONY: valgrind-test-art-host-gtest-$$(art_gtest_name)
543valgrind-test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES)
544 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
545
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100546 # Clear now unused variables.
547 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
548 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700549 art_gtest_name :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100550endef # define-art-gtest-host-both
Alex Light50fa9932015-08-10 15:30:07 -0700551
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700552ifeq ($(ART_BUILD_TARGET),true)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100553 $(foreach file,$(ART_TARGET_GTEST_FILES), $(eval $(call define-art-gtest-target,$(file),)))
554 ifdef TARGET_2ND_ARCH
555 $(foreach file,$(2ND_ART_TARGET_GTEST_FILES), $(eval $(call define-art-gtest-target,$(file),2ND_)))
556 endif
557 # Rules to run the different architecture versions of the gtest.
558 $(foreach file,$(ART_TARGET_GTEST_FILES), $(eval $(call define-art-gtest-target-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700559endif
Ian Rogersc5f17732014-06-05 20:48:42 -0700560ifeq ($(ART_BUILD_HOST),true)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100561 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),)))
562 ifneq ($(HOST_PREFER_32_BIT),true)
563 $(foreach file,$(2ND_ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),2ND_)))
564 endif
565 # Rules to run the different architecture versions of the gtest.
566 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700567endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700568
569# Used outside the art project to get a list of the current tests
570RUNTIME_TARGET_GTEST_MAKE_TARGETS :=
Colin Cross6e95dd52016-09-12 15:37:10 -0700571$(foreach file, $(ART_TARGET_GTEST_FILES), $(eval RUNTIME_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700572COMPILER_TARGET_GTEST_MAKE_TARGETS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700573
574# Define all the combinations of host/target, valgrind and suffix such as:
575# test-art-host-gtest or valgrind-test-art-host-gtest64
576# $(1): host or target
577# $(2): HOST or TARGET
578# $(3): valgrind- or undefined
579# $(4): undefined, 32 or 64
580define define-test-art-gtest-combination
581 ifeq ($(1),host)
582 ifneq ($(2),HOST)
583 $$(error argument mismatch $(1) and ($2))
584 endif
585 else
586 ifneq ($(1),target)
587 $$(error found $(1) expected host or target)
588 endif
589 ifneq ($(2),TARGET)
590 $$(error argument mismatch $(1) and ($2))
591 endif
592 endif
593
594 rule_name := $(3)test-art-$(1)-gtest$(4)
Andreas Gampe928f72b2014-09-09 19:53:48 -0700595 ifeq ($(3),valgrind-)
Andreas Gampe928f72b2014-09-09 19:53:48 -0700596 dependencies := $$(ART_TEST_$(2)_VALGRIND_GTEST$(4)_RULES)
597 else
598 dependencies := $$(ART_TEST_$(2)_GTEST$(4)_RULES)
599 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700600
601.PHONY: $$(rule_name)
602$$(rule_name): $$(dependencies)
603 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
604
605 # Clear locally defined variables.
606 rule_name :=
607 dependencies :=
608endef # define-test-art-gtest-combination
609
610$(eval $(call define-test-art-gtest-combination,target,TARGET,,))
Anton Kirilove5e76f42016-05-03 16:15:36 +0100611$(eval $(call define-test-art-gtest-combination,target,TARGET,valgrind-,))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700612$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Anton Kirilove5e76f42016-05-03 16:15:36 +0100613$(eval $(call define-test-art-gtest-combination,target,TARGET,valgrind-,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700614ifdef TARGET_2ND_ARCH
615$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Anton Kirilove5e76f42016-05-03 16:15:36 +0100616$(eval $(call define-test-art-gtest-combination,target,TARGET,valgrind-,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700617endif
618$(eval $(call define-test-art-gtest-combination,host,HOST,,))
619$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,))
620$(eval $(call define-test-art-gtest-combination,host,HOST,,$(ART_PHONY_TEST_HOST_SUFFIX)))
621$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(ART_PHONY_TEST_HOST_SUFFIX)))
622ifneq ($(HOST_PREFER_32_BIT),true)
623$(eval $(call define-test-art-gtest-combination,host,HOST,,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
624$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
625endif
626
627# Clear locally defined variables.
628define-art-gtest-rule-target :=
629define-art-gtest-rule-host :=
630define-art-gtest :=
631define-test-art-gtest-combination :=
632RUNTIME_GTEST_COMMON_SRC_FILES :=
633COMPILER_GTEST_COMMON_SRC_FILES :=
634RUNTIME_GTEST_TARGET_SRC_FILES :=
635RUNTIME_GTEST_HOST_SRC_FILES :=
636COMPILER_GTEST_TARGET_SRC_FILES :=
637COMPILER_GTEST_HOST_SRC_FILES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700638ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
639ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
640ART_TEST_HOST_GTEST_RULES :=
641ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
642ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
643ART_TEST_HOST_VALGRIND_GTEST_RULES :=
644ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
645ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
646ART_TEST_TARGET_GTEST_RULES :=
Anton Kirilove5e76f42016-05-03 16:15:36 +0100647ART_TEST_TARGET_VALGRIND_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
648ART_TEST_TARGET_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
649ART_TEST_TARGET_VALGRIND_GTEST_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000650ART_GTEST_TARGET_ANDROID_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700651ART_GTEST_class_linker_test_DEX_DEPS :=
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800652ART_GTEST_class_table_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700653ART_GTEST_compiler_driver_test_DEX_DEPS :=
654ART_GTEST_dex_file_test_DEX_DEPS :=
655ART_GTEST_exception_test_DEX_DEPS :=
656ART_GTEST_elf_writer_test_HOST_DEPS :=
657ART_GTEST_elf_writer_test_TARGET_DEPS :=
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700658ART_GTEST_imtable_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700659ART_GTEST_jni_compiler_test_DEX_DEPS :=
660ART_GTEST_jni_internal_test_DEX_DEPS :=
Richard Uhler66d874d2015-01-15 09:37:19 -0800661ART_GTEST_oat_file_assistant_test_DEX_DEPS :=
662ART_GTEST_oat_file_assistant_test_HOST_DEPS :=
663ART_GTEST_oat_file_assistant_test_TARGET_DEPS :=
Calin Juravle36eb3132017-01-13 16:32:38 -0800664ART_GTEST_dexoptanalyzer_test_DEX_DEPS :=
665ART_GTEST_dexoptanalyzer_test_HOST_DEPS :=
666ART_GTEST_dexoptanalyzer_test_TARGET_DEPS :=
Richard Uhler84f50ae2017-02-06 15:12:45 +0000667ART_GTEST_image_space_test_DEX_DEPS :=
668ART_GTEST_image_space_test_HOST_DEPS :=
669ART_GTEST_image_space_test_TARGET_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700670ART_GTEST_dex2oat_test_DEX_DEPS :=
671ART_GTEST_dex2oat_test_HOST_DEPS :=
672ART_GTEST_dex2oat_test_TARGET_DEPS :=
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700673ART_GTEST_dex2oat_image_test_DEX_DEPS :=
674ART_GTEST_dex2oat_image_test_HOST_DEPS :=
675ART_GTEST_dex2oat_image_test_TARGET_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700676ART_GTEST_object_test_DEX_DEPS :=
677ART_GTEST_proxy_test_DEX_DEPS :=
678ART_GTEST_reflection_test_DEX_DEPS :=
679ART_GTEST_stub_test_DEX_DEPS :=
680ART_GTEST_transaction_test_DEX_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700681ART_GTEST_dex2oat_environment_tests_DEX_DEPS :=
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700682ART_GTEST_heap_verification_test_DEX_DEPS :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100683ART_GTEST_verifier_deps_test_DEX_DEPS :=
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800684ART_VALGRIND_DEPENDENCIES :=
Anton Kirilove5e76f42016-05-03 16:15:36 +0100685ART_VALGRIND_TARGET_DEPENDENCIES :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700686$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
687$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Richard Uhler66d874d2015-01-15 09:37:19 -0800688ART_TEST_HOST_GTEST_MainStripped_DEX :=
689ART_TEST_TARGET_GTEST_MainStripped_DEX :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100690ART_TEST_GTEST_VerifierDeps_SRC :=
691ART_TEST_HOST_GTEST_VerifierDeps_DEX :=
David Brazdilf906f122016-09-16 16:33:31 +0100692ART_TEST_TARGET_GTEST_VerifierDeps_DEX :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700693GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700694LOCAL_PATH :=