blob: 60bcd63cdbf20b0334aa19e922884c6f094addd8 [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 \
Calin Juravlecdd49122017-07-05 20:09:53 -070033 ForClassLoaderA \
34 ForClassLoaderB \
35 ForClassLoaderC \
36 ForClassLoaderD \
Ian Rogersafd9acc2014-06-17 08:21:54 -070037 ExceptionHandle \
38 GetMethodSignature \
Mathieu Chartier496577f2016-09-20 15:33:31 -070039 ImageLayoutA \
40 ImageLayoutB \
Andreas Gampea1ff30f2016-09-27 12:19:45 -070041 IMTA \
42 IMTB \
Sebastien Hertz0462c4c2015-04-01 16:34:17 +020043 Instrumentation \
Ian Rogersafd9acc2014-06-17 08:21:54 -070044 Interfaces \
Artem Udovichenkod9786b02015-10-14 16:36:55 +030045 Lookup \
Ian Rogersafd9acc2014-06-17 08:21:54 -070046 Main \
Mathieu Chartierd00e02b2017-05-24 12:04:13 -070047 ManyMethods \
Narayan Kamath25352fc2016-08-03 12:46:58 +010048 MethodTypes \
Richard Uhler66d874d2015-01-15 09:37:19 -080049 MultiDex \
Richard Uhler67ff7d12015-05-14 13:21:13 -070050 MultiDexModifiedSecondary \
Ian Rogersafd9acc2014-06-17 08:21:54 -070051 MyClass \
52 MyClassNatives \
53 Nested \
54 NonStaticLeafMethods \
Mathieu Chartier279ac5c2016-09-08 17:34:25 -070055 Packages \
Ian Rogersafd9acc2014-06-17 08:21:54 -070056 ProtoCompare \
57 ProtoCompare2 \
Calin Juravle877fd962016-01-05 14:29:29 +000058 ProfileTestMultiDex \
Ian Rogersafd9acc2014-06-17 08:21:54 -070059 StaticLeafMethods \
60 Statics \
61 StaticsFromCode \
62 Transaction \
63 XandY
64
65# Create build rules for each dex file recording the dependency.
66$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-gtest,$(dir), \
Ian Rogers1a2f84e2014-07-07 16:05:18 -070067 $(ART_TARGET_NATIVETEST_OUT),art/build/Android.gtest.mk,ART_TEST_TARGET_GTEST_$(dir)_DEX, \
68 ART_TEST_HOST_GTEST_$(dir)_DEX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -070069
Richard Uhler66d874d2015-01-15 09:37:19 -080070# Create rules for MainStripped, a copy of Main with the classes.dex stripped
71# for the oat file assistant tests.
72ART_TEST_HOST_GTEST_MainStripped_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))Stripped$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
73ART_TEST_TARGET_GTEST_MainStripped_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))Stripped$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
74
Nicolas Geoffrayae7e8382017-11-20 15:10:28 +000075# Create rules for MainUncompressed, a copy of Main with the classes.dex uncompressed
76# for the dex2oat tests.
77ART_TEST_HOST_GTEST_MainUncompressed_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))Uncompressed$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
78ART_TEST_TARGET_GTEST_MainUncompressed_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))Uncompressed$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
79
Richard Uhler66d874d2015-01-15 09:37:19 -080080$(ART_TEST_HOST_GTEST_MainStripped_DEX): $(ART_TEST_HOST_GTEST_Main_DEX)
81 cp $< $@
82 $(call dexpreopt-remove-classes.dex,$@)
83
84$(ART_TEST_TARGET_GTEST_MainStripped_DEX): $(ART_TEST_TARGET_GTEST_Main_DEX)
85 cp $< $@
86 $(call dexpreopt-remove-classes.dex,$@)
87
Nicolas Geoffrayae7e8382017-11-20 15:10:28 +000088$(ART_TEST_HOST_GTEST_MainUncompressed_DEX): $(ART_TEST_HOST_GTEST_Main_DEX) $(ZIPALIGN)
89 cp $< $@
90 $(call uncompress-dexs, $@)
91 $(call align-package, $@)
92
93$(ART_TEST_TARGET_GTEST_MainUncompressed_DEX): $(ART_TEST_TARGET_GTEST_Main_DEX) $(ZIPALIGN)
94 cp $< $@
95 $(call uncompress-dexs, $@)
96 $(call align-package, $@)
97
David Brazdilca3c8c32016-09-06 14:04:48 +010098ART_TEST_GTEST_VerifierDeps_SRC := $(abspath $(wildcard $(LOCAL_PATH)/VerifierDeps/*.smali))
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +000099ART_TEST_GTEST_VerifierDepsMulti_SRC := $(abspath $(wildcard $(LOCAL_PATH)/VerifierDepsMulti/*.smali))
David Brazdilca3c8c32016-09-06 14:04:48 +0100100ART_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 +0100101ART_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 +0000102ART_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))
103ART_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 +0100104
105$(ART_TEST_HOST_GTEST_VerifierDeps_DEX): $(ART_TEST_GTEST_VerifierDeps_SRC) $(HOST_OUT_EXECUTABLES)/smali
Ben Gruver14fc9db2017-04-28 15:30:49 -0700106 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
David Brazdilca3c8c32016-09-06 14:04:48 +0100107
David Brazdilf906f122016-09-16 16:33:31 +0100108$(ART_TEST_TARGET_GTEST_VerifierDeps_DEX): $(ART_TEST_GTEST_VerifierDeps_SRC) $(HOST_OUT_EXECUTABLES)/smali
Ben Gruver14fc9db2017-04-28 15:30:49 -0700109 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
David Brazdilf906f122016-09-16 16:33:31 +0100110
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000111$(ART_TEST_HOST_GTEST_VerifierDepsMulti_DEX): $(ART_TEST_GTEST_VerifierDepsMulti_SRC) $(HOST_OUT_EXECUTABLES)/smali
Ben Gruver14fc9db2017-04-28 15:30:49 -0700112 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000113
114$(ART_TEST_TARGET_GTEST_VerifierDepsMulti_DEX): $(ART_TEST_GTEST_VerifierDepsMulti_SRC) $(HOST_OUT_EXECUTABLES)/smali
Ben Gruver14fc9db2017-04-28 15:30:49 -0700115 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000116
Ian Rogersafd9acc2014-06-17 08:21:54 -0700117# Dex file dependencies for each gtest.
Andreas Gampecac31ad2017-11-06 20:01:17 -0800118ART_GTEST_dex2oat_environment_tests_DEX_DEPS := Main MainStripped MultiDex MultiDexModifiedSecondary MyClassNatives Nested VerifierDeps VerifierDepsMulti
Andreas Gampee1459ae2016-06-29 09:36:30 -0700119
Mathieu Chartier93764b82017-07-17 14:51:53 -0700120ART_GTEST_atomic_dex_ref_map_test_DEX_DEPS := Interfaces
Calin Juravlecdd49122017-07-05 20:09:53 -0700121ART_GTEST_class_linker_test_DEX_DEPS := AllFields ErroneousA ErroneousB ErroneousInit ForClassLoaderA ForClassLoaderB ForClassLoaderC ForClassLoaderD Interfaces MethodTypes MultiDex MyClass Nested Statics StaticsFromCode
Calin Juravle57d0acc2017-07-11 17:41:30 -0700122ART_GTEST_class_loader_context_test_DEX_DEPS := Main MultiDex MyClass ForClassLoaderA ForClassLoaderB ForClassLoaderC ForClassLoaderD
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800123ART_GTEST_class_table_test_DEX_DEPS := XandY
Calin Juravle877fd962016-01-05 14:29:29 +0000124ART_GTEST_compiler_driver_test_DEX_DEPS := AbstractMethod StaticLeafMethods ProfileTestMultiDex
Narayan Kamath25352fc2016-08-03 12:46:58 +0100125ART_GTEST_dex_cache_test_DEX_DEPS := Main Packages MethodTypes
Richard Uhler69bcf2c2017-01-24 10:25:21 +0000126ART_GTEST_dex_file_test_DEX_DEPS := GetMethodSignature Main Nested MultiDex
Mathieu Chartierd00e02b2017-05-24 12:04:13 -0700127ART_GTEST_dexlayout_test_DEX_DEPS := ManyMethods
Nicolas Geoffrayae7e8382017-11-20 15:10:28 +0000128ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) ManyMethods Statics VerifierDeps MainUncompressed
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700129ART_GTEST_dex2oat_image_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics VerifierDeps
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700130ART_GTEST_exception_test_DEX_DEPS := ExceptionHandle
Artem Udovichenkob3f2b5c2017-01-31 11:49:33 +0300131ART_GTEST_image_test_DEX_DEPS := ImageLayoutA ImageLayoutB DefaultMethods
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700132ART_GTEST_imtable_test_DEX_DEPS := IMTA IMTB
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200133ART_GTEST_instrumentation_test_DEX_DEPS := Instrumentation
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700134ART_GTEST_jni_compiler_test_DEX_DEPS := MyClassNatives
135ART_GTEST_jni_internal_test_DEX_DEPS := AllFields StaticLeafMethods
Andreas Gampee1459ae2016-06-29 09:36:30 -0700136ART_GTEST_oat_file_assistant_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
Calin Juravle36eb3132017-01-13 16:32:38 -0800137ART_GTEST_dexoptanalyzer_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
Richard Uhler84f50ae2017-02-06 15:12:45 +0000138ART_GTEST_image_space_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
Andreas Gampe7848da42015-04-09 11:15:04 -0700139ART_GTEST_oat_file_test_DEX_DEPS := Main MultiDex
Mathieu Chartier07ddb6f2015-11-05 11:16:34 -0800140ART_GTEST_oat_test_DEX_DEPS := Main
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700141ART_GTEST_object_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
Alex Klyubind1d5c952017-12-15 12:57:33 -0800142ART_GTEST_patchoat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700143ART_GTEST_proxy_test_DEX_DEPS := Interfaces
144ART_GTEST_reflection_test_DEX_DEPS := Main NonStaticLeafMethods StaticLeafMethods
Calin Juravle877fd962016-01-05 14:29:29 +0000145ART_GTEST_profile_assistant_test_DEX_DEPS := ProfileTestMultiDex
Mathieu Chartierdb40eac2017-06-09 18:34:11 -0700146ART_GTEST_profile_compilation_info_test_DEX_DEPS := ManyMethods ProfileTestMultiDex
Andreas Gampe0f01b582017-01-18 15:22:37 -0800147ART_GTEST_runtime_callbacks_test_DEX_DEPS := XandY
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700148ART_GTEST_stub_test_DEX_DEPS := AllFields
149ART_GTEST_transaction_test_DEX_DEPS := Transaction
Artem Udovichenkod9786b02015-10-14 16:36:55 +0300150ART_GTEST_type_lookup_table_test_DEX_DEPS := Lookup
Andreas Gampeae78c262017-02-01 20:40:44 -0800151ART_GTEST_unstarted_runtime_test_DEX_DEPS := Nested
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700152ART_GTEST_heap_verification_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000153ART_GTEST_verifier_deps_test_DEX_DEPS := VerifierDeps VerifierDepsMulti MultiDex
Nicolas Geoffray01b70e82016-11-17 10:58:36 +0000154ART_GTEST_dex_to_dex_decompiler_test_DEX_DEPS := VerifierDeps DexToDexDecompiler
Ian Rogersafd9acc2014-06-17 08:21:54 -0700155
156# The elf writer test has dependencies on core.oat.
Richard Uhler67e1dc52017-02-06 16:50:17 +0000157ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
158ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_DEFAULT_64) $(TARGET_CORE_IMAGE_DEFAULT_32)
Brian Carlstrom53463ea2014-11-09 14:11:51 -0800159
Andreas Gampee1459ae2016-06-29 09:36:30 -0700160ART_GTEST_dex2oat_environment_tests_HOST_DEPS := \
Richard Uhlerbb00f812017-02-16 14:21:10 +0000161 $(HOST_CORE_IMAGE_optimizing_64) \
162 $(HOST_CORE_IMAGE_optimizing_32) \
163 $(HOST_CORE_IMAGE_interpreter_64) \
164 $(HOST_CORE_IMAGE_interpreter_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800165 patchoatd-host
Andreas Gampee1459ae2016-06-29 09:36:30 -0700166ART_GTEST_dex2oat_environment_tests_TARGET_DEPS := \
Richard Uhlerbb00f812017-02-16 14:21:10 +0000167 $(TARGET_CORE_IMAGE_optimizing_64) \
168 $(TARGET_CORE_IMAGE_optimizing_32) \
169 $(TARGET_CORE_IMAGE_interpreter_64) \
170 $(TARGET_CORE_IMAGE_interpreter_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800171 patchoatd-target
Andreas Gampee1459ae2016-06-29 09:36:30 -0700172
David Srbeckyec2cdf42017-12-08 16:21:25 +0000173ART_GTEST_oat_file_test_HOST_DEPS := \
174 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
175ART_GTEST_oat_file_test_TARGET_DEPS := \
176 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
177
Andreas Gampee1459ae2016-06-29 09:36:30 -0700178ART_GTEST_oat_file_assistant_test_HOST_DEPS := \
Richard Uhlerf51ac422016-07-08 09:22:33 -0700179 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
Andreas Gampee1459ae2016-06-29 09:36:30 -0700180ART_GTEST_oat_file_assistant_test_TARGET_DEPS := \
Richard Uhlerf51ac422016-07-08 09:22:33 -0700181 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
Andreas Gampee1459ae2016-06-29 09:36:30 -0700182
Calin Juravle36eb3132017-01-13 16:32:38 -0800183ART_GTEST_dexoptanalyzer_test_HOST_DEPS := \
184 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS) \
Andreas Gampe47200462017-11-09 11:40:03 -0800185 dexoptanalyzerd-host
Calin Juravle36eb3132017-01-13 16:32:38 -0800186ART_GTEST_dexoptanalyzer_test_TARGET_DEPS := \
187 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS) \
Andreas Gampe47200462017-11-09 11:40:03 -0800188 dexoptanalyzerd-target
Andreas Gampee1459ae2016-06-29 09:36:30 -0700189
Richard Uhler84f50ae2017-02-06 15:12:45 +0000190ART_GTEST_image_space_test_HOST_DEPS := \
191 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
192ART_GTEST_image_space_test_TARGET_DEPS := \
193 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
194
Andreas Gampee1459ae2016-06-29 09:36:30 -0700195ART_GTEST_dex2oat_test_HOST_DEPS := \
Andreas Gampe47200462017-11-09 11:40:03 -0800196 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS) \
197 dex2oatd-host
Andreas Gampee1459ae2016-06-29 09:36:30 -0700198ART_GTEST_dex2oat_test_TARGET_DEPS := \
Andreas Gampe47200462017-11-09 11:40:03 -0800199 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS) \
200 dex2oatd-target
Richard Uhler66d874d2015-01-15 09:37:19 -0800201
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700202ART_GTEST_dex2oat_image_test_HOST_DEPS := \
Andreas Gampe47200462017-11-09 11:40:03 -0800203 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS) \
204 dex2oatd-host
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700205ART_GTEST_dex2oat_image_test_TARGET_DEPS := \
Andreas Gampe47200462017-11-09 11:40:03 -0800206 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS) \
207 dex2oatd-target
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700208
Brian Carlstrom53463ea2014-11-09 14:11:51 -0800209# TODO: document why this is needed.
Richard Uhler67e1dc52017-02-06 16:50:17 +0000210ART_GTEST_proxy_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700211
David Sehr55232f12017-04-19 14:06:49 -0700212# The dexdiag test requires the dexdiag utility.
Andreas Gampe47200462017-11-09 11:40:03 -0800213ART_GTEST_dexdiag_test_HOST_DEPS := dexdiag-host
214ART_GTEST_dexdiag_test_TARGET_DEPS := dexdiag-target
David Sehr55232f12017-04-19 14:06:49 -0700215
Aart Bikcfbe53c2015-07-06 14:27:27 -0700216# The dexdump test requires an image and the dexdump utility.
Aart Bik22c26f52015-07-08 21:20:13 +0000217# TODO: rename into dexdump when migration completes
Aart Bikcfbe53c2015-07-06 14:27:27 -0700218ART_GTEST_dexdump_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000219 $(HOST_CORE_IMAGE_DEFAULT_64) \
220 $(HOST_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800221 dexdump2-host
Aart Bikcfbe53c2015-07-06 14:27:27 -0700222ART_GTEST_dexdump_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000223 $(TARGET_CORE_IMAGE_DEFAULT_64) \
224 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800225 dexdump2-target
Aart Bikcfbe53c2015-07-06 14:27:27 -0700226
Jeff Haoc3acfc52016-08-29 14:18:26 -0700227# The dexlayout test requires an image and the dexlayout utility.
228# TODO: rename into dexdump when migration completes
229ART_GTEST_dexlayout_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000230 $(HOST_CORE_IMAGE_DEFAULT_64) \
231 $(HOST_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe693bfbf2017-11-10 12:23:31 -0800232 dexlayoutd-host \
Andreas Gampe47200462017-11-09 11:40:03 -0800233 dexdump2-host
Jeff Haoc3acfc52016-08-29 14:18:26 -0700234ART_GTEST_dexlayout_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000235 $(TARGET_CORE_IMAGE_DEFAULT_64) \
236 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe693bfbf2017-11-10 12:23:31 -0800237 dexlayoutd-target \
Andreas Gampe47200462017-11-09 11:40:03 -0800238 dexdump2-target
Jeff Haoc3acfc52016-08-29 14:18:26 -0700239
Aart Bik3e40f4a2015-07-07 17:09:41 -0700240# The dexlist test requires an image and the dexlist utility.
Aart Bik3e40f4a2015-07-07 17:09:41 -0700241ART_GTEST_dexlist_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000242 $(HOST_CORE_IMAGE_DEFAULT_64) \
243 $(HOST_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800244 dexlist-host
Aart Bik3e40f4a2015-07-07 17:09:41 -0700245ART_GTEST_dexlist_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000246 $(TARGET_CORE_IMAGE_DEFAULT_64) \
247 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800248 dexlist-target
Aart Bik3e40f4a2015-07-07 17:09:41 -0700249
Igor Murashkin37743352014-11-13 14:38:00 -0800250# The imgdiag test has dependencies on core.oat since it needs to load it during the test.
Andreas Gampec93b8b52014-12-19 23:12:25 -0800251# For the host, also add the installed tool (in the base size, that should suffice). For the
252# target, just the module is fine, the sync will happen late enough.
253ART_GTEST_imgdiag_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000254 $(HOST_CORE_IMAGE_DEFAULT_64) \
255 $(HOST_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800256 imgdiagd-host
Andreas Gampec93b8b52014-12-19 23:12:25 -0800257ART_GTEST_imgdiag_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000258 $(TARGET_CORE_IMAGE_DEFAULT_64) \
259 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800260 imgdiagd-target
Igor Murashkin37743352014-11-13 14:38:00 -0800261
Mathieu Chartierea216b32015-05-26 19:48:16 -0700262# Oatdump test requires an image and oatfile to dump.
263ART_GTEST_oatdump_test_HOST_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000264 $(HOST_CORE_IMAGE_DEFAULT_64) \
265 $(HOST_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800266 oatdumpd-host \
267 oatdumpds-host
Mathieu Chartierea216b32015-05-26 19:48:16 -0700268ART_GTEST_oatdump_test_TARGET_DEPS := \
Richard Uhler67e1dc52017-02-06 16:50:17 +0000269 $(TARGET_CORE_IMAGE_DEFAULT_64) \
270 $(TARGET_CORE_IMAGE_DEFAULT_32) \
Andreas Gampe47200462017-11-09 11:40:03 -0800271 oatdumpd-target
Vladimir Marko1352f132017-04-28 15:28:29 +0100272ART_GTEST_oatdump_image_test_HOST_DEPS := $(ART_GTEST_oatdump_test_HOST_DEPS)
273ART_GTEST_oatdump_image_test_TARGET_DEPS := $(ART_GTEST_oatdump_test_TARGET_DEPS)
Mathieu Chartierea216b32015-05-26 19:48:16 -0700274
Alex Klyubind1d5c952017-12-15 12:57:33 -0800275ART_GTEST_patchoat_test_HOST_DEPS := \
276 $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
277ART_GTEST_patchoat_test_TARGET_DEPS := \
278 $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
279
Calin Juravle2e2db782016-02-23 12:00:03 +0000280# Profile assistant tests requires profman utility.
Andreas Gampe47200462017-11-09 11:40:03 -0800281ART_GTEST_profile_assistant_test_HOST_DEPS := profmand-host
Andreas Gampe693bfbf2017-11-10 12:23:31 -0800282ART_GTEST_profile_assistant_test_TARGET_DEPS := profmand-target
Calin Juravle2e2db782016-02-23 12:00:03 +0000283
Ian Rogersafd9acc2014-06-17 08:21:54 -0700284# The path for which all the source files are relative, not actually the current directory.
Brian Carlstrom7940e442013-07-12 13:46:57 -0700285LOCAL_PATH := art
286
Colin Cross6e95dd52016-09-12 15:37:10 -0700287ART_TEST_MODULES := \
288 art_cmdline_tests \
289 art_compiler_tests \
290 art_compiler_host_tests \
291 art_dex2oat_tests \
David Sehr55232f12017-04-19 14:06:49 -0700292 art_dexdiag_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700293 art_dexdump_tests \
294 art_dexlayout_tests \
295 art_dexlist_tests \
Calin Juravle36eb3132017-01-13 16:32:38 -0800296 art_dexoptanalyzer_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700297 art_imgdiag_tests \
298 art_oatdump_tests \
Alex Klyubind1d5c952017-12-15 12:57:33 -0800299 art_patchoat_tests \
Colin Cross6e95dd52016-09-12 15:37:10 -0700300 art_profman_tests \
301 art_runtime_tests \
302 art_runtime_compiler_tests \
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800303
Colin Cross6e95dd52016-09-12 15:37:10 -0700304ART_TARGET_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES),\
305 $(ART_TEST_LIST_device_$(TARGET_ARCH)_$(m)))
Alex Light50fa9932015-08-10 15:30:07 -0700306
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100307ifdef TARGET_2ND_ARCH
3082ND_ART_TARGET_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES),\
309 $(ART_TEST_LIST_device_$(2ND_TARGET_ARCH)_$(m)))
310endif
311
Colin Cross6e95dd52016-09-12 15:37:10 -0700312ART_HOST_GTEST_FILES := $(foreach m,$(ART_TEST_MODULES),\
Colin Cross124f8812016-09-15 20:57:47 -0700313 $(ART_TEST_LIST_host_$(ART_HOST_ARCH)_$(m)))
Alex Light50fa9932015-08-10 15:30:07 -0700314
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100315ifneq ($(HOST_PREFER_32_BIT),true)
3162ND_ART_HOST_GTEST_FILES += $(foreach m,$(ART_TEST_MODULES),\
317 $(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_$(m)))
318endif
319
Ian Rogersafd9acc2014-06-17 08:21:54 -0700320# Variables holding collections of gtest pre-requisits used to run a number of gtests.
321ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
322ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
323ART_TEST_HOST_GTEST_RULES :=
324ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
325ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
326ART_TEST_HOST_VALGRIND_GTEST_RULES :=
327ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
328ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
329ART_TEST_TARGET_GTEST_RULES :=
Anton Kirilove5e76f42016-05-03 16:15:36 +0100330ART_TEST_TARGET_VALGRIND_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
331ART_TEST_TARGET_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
332ART_TEST_TARGET_VALGRIND_GTEST_RULES :=
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100333ART_TEST_HOST_GTEST_DEPENDENCIES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700334
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000335ART_GTEST_TARGET_ANDROID_ROOT := '/system'
336ifneq ($(ART_TEST_ANDROID_ROOT),)
337 ART_GTEST_TARGET_ANDROID_ROOT := $(ART_TEST_ANDROID_ROOT)
338endif
339
Anton Kirilove5e76f42016-05-03 16:15:36 +0100340ART_VALGRIND_TARGET_DEPENDENCIES := \
341 $(TARGET_OUT_EXECUTABLES)/valgrind \
342 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/memcheck-$(TARGET_ARCH)-linux \
343 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/vgpreload_core-$(TARGET_ARCH)-linux.so \
344 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/vgpreload_memcheck-$(TARGET_ARCH)-linux.so \
345 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/default.supp
346
347ifdef TARGET_2ND_ARCH
348ART_VALGRIND_TARGET_DEPENDENCIES += \
349 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/memcheck-$(TARGET_2ND_ARCH)-linux \
350 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/vgpreload_core-$(TARGET_2ND_ARCH)-linux.so \
351 $(TARGET_OUT_SHARED_LIBRARIES)/valgrind/vgpreload_memcheck-$(TARGET_2ND_ARCH)-linux.so
352endif
353
354include $(CLEAR_VARS)
355LOCAL_MODULE := valgrind-target-suppressions.txt
356LOCAL_MODULE_CLASS := ETC
357LOCAL_MODULE_TAGS := optional
358LOCAL_SRC_FILES := test/valgrind-target-suppressions.txt
359LOCAL_MODULE_PATH := $(ART_TARGET_TEST_OUT)
360include $(BUILD_PREBUILT)
361
Ian Rogersafd9acc2014-06-17 08:21:54 -0700362# Define a make rule for a target device gtest.
363# $(1): gtest name - the name of the test we're building such as leb128_test.
Colin Cross6e95dd52016-09-12 15:37:10 -0700364# $(2): path relative to $OUT to the test binary
365# $(3): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
366# $(4): LD_LIBRARY_PATH or undefined - used in case libartd.so is not in /system/lib/
Ian Rogersafd9acc2014-06-17 08:21:54 -0700367define define-art-gtest-rule-target
Colin Cross6e95dd52016-09-12 15:37:10 -0700368 gtest_rule := test-art-target-gtest-$(1)$$($(3)ART_PHONY_TEST_TARGET_SUFFIX)
369 gtest_exe := $(OUT_DIR)/$(2)
370 gtest_target_exe := $$(patsubst $(PRODUCT_OUT)/%,/%,$$(gtest_exe))
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700371
Brian Carlstrom532714a2014-06-25 02:15:31 -0700372 # Add the test dependencies to test-art-target-sync, which will be a prerequisite for the test
Ian Rogersafd9acc2014-06-17 08:21:54 -0700373 # to ensure files are pushed to the device.
374 TEST_ART_TARGET_SYNC_DEPS += \
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700375 $$(ART_GTEST_$(1)_TARGET_DEPS) \
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700376 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX)) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700377 $$(gtest_exe) \
378 $$($(3)TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so \
379 $$($(3)TARGET_OUT_SHARED_LIBRARIES)/libopenjdkd.so \
Andreas Gampec7d4a582015-09-30 11:52:02 -0700380 $$(TARGET_OUT_JAVA_LIBRARIES)/core-libart-testdex.jar \
Anton Kirilove5e76f42016-05-03 16:15:36 +0100381 $$(TARGET_OUT_JAVA_LIBRARIES)/core-oj-testdex.jar \
382 $$(ART_TARGET_TEST_OUT)/valgrind-target-suppressions.txt
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700383
Colin Cross6e95dd52016-09-12 15:37:10 -0700384$$(gtest_rule) valgrind-$$(gtest_rule): PRIVATE_TARGET_EXE := $$(gtest_target_exe)
385
Ian Rogersafd9acc2014-06-17 08:21:54 -0700386.PHONY: $$(gtest_rule)
387$$(gtest_rule): test-art-target-sync
Colin Cross6e95dd52016-09-12 15:37:10 -0700388 $(hide) adb shell touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID
389 $(hide) adb shell rm $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID
390 $(hide) adb shell chmod 755 $$(PRIVATE_TARGET_EXE)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700391 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Roland Levillaina42e7042017-10-30 17:24:43 +0000392 (adb shell "env $(GCOV_ENV) LD_LIBRARY_PATH=$(4) \
393 ANDROID_ROOT=$(ART_GTEST_TARGET_ANDROID_ROOT) $$(PRIVATE_TARGET_EXE) \
394 && touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID" \
395 && (adb pull $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID /tmp/ \
396 && $$(call ART_TEST_PASSED,$$@)) \
397 || $$(call ART_TEST_FAILED,$$@))
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700398 $(hide) rm -f /tmp/$$@-$$$$PPID
Ian Rogersafd9acc2014-06-17 08:21:54 -0700399
Colin Cross6e95dd52016-09-12 15:37:10 -0700400 ART_TEST_TARGET_GTEST$($(3)ART_PHONY_TEST_TARGET_SUFFIX)_RULES += $$(gtest_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700401 ART_TEST_TARGET_GTEST_RULES += $$(gtest_rule)
402 ART_TEST_TARGET_GTEST_$(1)_RULES += $$(gtest_rule)
403
Anton Kirilove5e76f42016-05-03 16:15:36 +0100404.PHONY: valgrind-$$(gtest_rule)
405valgrind-$$(gtest_rule): $(ART_VALGRIND_TARGET_DEPENDENCIES) test-art-target-sync
Colin Cross6e95dd52016-09-12 15:37:10 -0700406 $(hide) adb shell touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID
407 $(hide) adb shell rm $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID
408 $(hide) adb shell chmod 755 $$(PRIVATE_TARGET_EXE)
Anton Kirilove5e76f42016-05-03 16:15:36 +0100409 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Roland Levillaina42e7042017-10-30 17:24:43 +0000410 (adb shell "env $(GCOV_ENV) LD_LIBRARY_PATH=$(4) \
411 ANDROID_ROOT=$(ART_GTEST_TARGET_ANDROID_ROOT) \
412 $$$$ANDROID_ROOT/bin/valgrind \
413 --leak-check=full --error-exitcode=1 --workaround-gcc296-bugs=yes \
414 --suppressions=$(ART_TARGET_TEST_DIR)/valgrind-target-suppressions.txt \
415 --num-callers=50 --show-mismatched-frees=no $$(PRIVATE_TARGET_EXE) \
416 && touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID" \
417 && (adb pull $(ART_TARGET_TEST_DIR)/$(TARGET_$(3)ARCH)/$$@-$$$$PPID /tmp/ \
418 && $$(call ART_TEST_PASSED,$$@)) \
419 || $$(call ART_TEST_FAILED,$$@))
Anton Kirilove5e76f42016-05-03 16:15:36 +0100420 $(hide) rm -f /tmp/$$@-$$$$PPID
421
Roland Levillaina42e7042017-10-30 17:24:43 +0000422 ART_TEST_TARGET_VALGRIND_GTEST$$($(3)ART_PHONY_TEST_TARGET_SUFFIX)_RULES += \
423 valgrind-$$(gtest_rule)
Anton Kirilove5e76f42016-05-03 16:15:36 +0100424 ART_TEST_TARGET_VALGRIND_GTEST_RULES += valgrind-$$(gtest_rule)
425 ART_TEST_TARGET_VALGRIND_GTEST_$(1)_RULES += valgrind-$$(gtest_rule)
426
Ian Rogersafd9acc2014-06-17 08:21:54 -0700427 # Clear locally defined variables.
Anton Kirilove5e76f42016-05-03 16:15:36 +0100428 valgrind_gtest_rule :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700429 gtest_rule :=
Colin Cross6e95dd52016-09-12 15:37:10 -0700430 gtest_exe :=
431 gtest_target_exe :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700432endef # define-art-gtest-rule-target
433
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800434ART_VALGRIND_DEPENDENCIES := \
435 $(HOST_OUT_EXECUTABLES)/valgrind \
436 $(HOST_OUT)/lib64/valgrind/memcheck-amd64-linux \
437 $(HOST_OUT)/lib64/valgrind/memcheck-x86-linux \
438 $(HOST_OUT)/lib64/valgrind/default.supp \
439 $(HOST_OUT)/lib64/valgrind/vgpreload_core-amd64-linux.so \
440 $(HOST_OUT)/lib64/valgrind/vgpreload_core-x86-linux.so \
441 $(HOST_OUT)/lib64/valgrind/vgpreload_memcheck-amd64-linux.so \
442 $(HOST_OUT)/lib64/valgrind/vgpreload_memcheck-x86-linux.so
443
Ian Rogersafd9acc2014-06-17 08:21:54 -0700444# Define make rules for a host gtests.
445# $(1): gtest name - the name of the test we're building such as leb128_test.
Colin Cross6e95dd52016-09-12 15:37:10 -0700446# $(2): path relative to $OUT to the test binary
447# $(3): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700448define define-art-gtest-rule-host
Colin Cross6e95dd52016-09-12 15:37:10 -0700449 gtest_rule := test-art-host-gtest-$(1)$$($(3)ART_PHONY_TEST_HOST_SUFFIX)
450 gtest_exe := $(OUT_DIR)/$(2)
Ian Rogers665de8a2014-06-24 21:34:09 -0700451 # Dependencies for all host gtests.
452 gtest_deps := $$(HOST_CORE_DEX_LOCATIONS) \
Colin Cross6e95dd52016-09-12 15:37:10 -0700453 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libjavacore$$(ART_HOST_SHLIB_EXTENSION) \
454 $$($(3)ART_HOST_OUT_SHARED_LIBRARIES)/libopenjdkd$$(ART_HOST_SHLIB_EXTENSION) \
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100455 $$(gtest_exe) \
456 $$(ART_GTEST_$(1)_HOST_DEPS) \
457 $(foreach file,$(ART_GTEST_$(1)_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX))
Ian Rogers665de8a2014-06-24 21:34:09 -0700458
Nicolas Geoffray58035ae2015-05-27 19:10:27 +0100459 ART_TEST_HOST_GTEST_DEPENDENCIES += $$(gtest_deps)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700460
Andreas Gampe03858052017-05-01 08:17:24 -0700461# Note: envsetup currently exports ASAN_OPTIONS=detect_leaks=0 to suppress leak detection, as some
462# build tools (e.g., ninja) intentionally leak. We want leak checks when we run our tests, so
463# override ASAN_OPTIONS. b/37751350
Ian Rogersafd9acc2014-06-17 08:21:54 -0700464.PHONY: $$(gtest_rule)
Nicolas Geoffray0f7c06d2015-05-28 10:21:03 +0100465$$(gtest_rule): $$(gtest_exe) $$(gtest_deps)
Andreas Gampe03858052017-05-01 08:17:24 -0700466 $(hide) ($$(call ART_TEST_SKIP,$$@) && ASAN_OPTIONS=detect_leaks=1 $$< && \
467 $$(call ART_TEST_PASSED,$$@)) || $$(call ART_TEST_FAILED,$$@)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700468
Colin Cross6e95dd52016-09-12 15:37:10 -0700469 ART_TEST_HOST_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700470 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
471 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
472
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800473
Ian Rogersafd9acc2014-06-17 08:21:54 -0700474.PHONY: valgrind-$$(gtest_rule)
Andreas Gampe3db36002015-05-28 20:17:09 -0700475valgrind-$$(gtest_rule): $$(gtest_exe) $$(gtest_deps) $(ART_VALGRIND_DEPENDENCIES)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700476 $(hide) $$(call ART_TEST_SKIP,$$@) && \
Andreas Gampe8df91ac2015-02-20 13:15:15 -0800477 VALGRIND_LIB=$(HOST_OUT)/lib64/valgrind \
Hiroshi Yamauchidc15e892016-03-10 13:49:14 -0800478 $(HOST_OUT_EXECUTABLES)/valgrind --leak-check=full --error-exitcode=1 \
Andreas Gampebf13e802016-09-02 19:43:09 -0700479 --suppressions=art/test/valgrind-suppressions.txt --num-callers=50 \
480 $$< && \
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800481 $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700482
Colin Cross6e95dd52016-09-12 15:37:10 -0700483 ART_TEST_HOST_VALGRIND_GTEST$$($(3)ART_PHONY_TEST_HOST_SUFFIX)_RULES += valgrind-$$(gtest_rule)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700484 ART_TEST_HOST_VALGRIND_GTEST_RULES += valgrind-$$(gtest_rule)
485 ART_TEST_HOST_VALGRIND_GTEST_$(1)_RULES += valgrind-$$(gtest_rule)
486
487 # Clear locally defined variables.
488 valgrind_gtest_rule :=
489 gtest_rule :=
490 gtest_exe :=
Ian Rogers665de8a2014-06-24 21:34:09 -0700491 gtest_deps :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700492endef # define-art-gtest-rule-host
493
494# Define the rules to build and run host and target gtests.
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100495# $(1): file name
496# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
497define define-art-gtest-target
498 art_gtest_filename := $(1)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700499
Ian Rogersafd9acc2014-06-17 08:21:54 -0700500 include $$(CLEAR_VARS)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700501 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
Colin Cross6e95dd52016-09-12 15:37:10 -0700502
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100503 library_path :=
504 2ND_library_path :=
505 ifneq ($$(ART_TEST_ANDROID_ROOT),)
506 ifdef TARGET_2ND_ARCH
507 2ND_library_path := $$(ART_TEST_ANDROID_ROOT)/lib
508 library_path := $$(ART_TEST_ANDROID_ROOT)/lib64
509 else
510 ifneq ($(filter %64,$(TARGET_ARCH)),)
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000511 library_path := $$(ART_TEST_ANDROID_ROOT)/lib64
512 else
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100513 library_path := $$(ART_TEST_ANDROID_ROOT)/lib
Nicolas Geoffray9eb40742014-10-29 22:38:53 +0000514 endif
515 endif
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100516 endif
Andreas Gampe5ca4eaa2014-05-29 02:09:33 -0700517
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100518 ifndef ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES
Ian Rogersafd9acc2014-06-17 08:21:54 -0700519 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
Anton Kirilove5e76f42016-05-03 16:15:36 +0100520 ART_TEST_TARGET_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100521 endif
522 $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),$$(art_gtest_filename),$(2),$$($(2)library_path)))
523
524 # Clear locally defined variables.
525 art_gtest_filename :=
526 art_gtest_name :=
527 library_path :=
528 2ND_library_path :=
529endef # define-art-gtest-target
530
531# $(1): file name
532# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
533define define-art-gtest-host
534 art_gtest_filename := $(1)
535
536 include $$(CLEAR_VARS)
537 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
538 ifndef ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES
539 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
540 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
541 endif
542 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),$$(art_gtest_filename),$(2)))
543
544 # Clear locally defined variables.
545 art_gtest_filename :=
546 art_gtest_name :=
547endef # define-art-gtest-host
548
549# Define the rules to build and run gtests for both archs on target.
550# $(1): test name
551define define-art-gtest-target-both
552 art_gtest_name := $(1)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700553
Ian Rogersafd9acc2014-06-17 08:21:54 -0700554 # A rule to run the different architecture versions of the gtest.
555.PHONY: test-art-target-gtest-$$(art_gtest_name)
556test-art-target-gtest-$$(art_gtest_name): $$(ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES)
557 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
558
Anton Kirilove5e76f42016-05-03 16:15:36 +0100559.PHONY: valgrind-test-art-target-gtest-$$(art_gtest_name)
560valgrind-test-art-target-gtest-$$(art_gtest_name): $$(ART_TEST_TARGET_VALGRIND_GTEST_$$(art_gtest_name)_RULES)
561 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
562
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100563 # Clear now unused variables.
564 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
565 ART_TEST_TARGET_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
566 art_gtest_name :=
567endef # define-art-gtest-target-both
Ian Rogersd912e5c2013-11-13 12:40:11 -0800568
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100569# Define the rules to build and run gtests for both archs on host.
570# $(1): test name
571define define-art-gtest-host-both
572 art_gtest_name := $(1)
573
Ian Rogersafd9acc2014-06-17 08:21:54 -0700574.PHONY: test-art-host-gtest-$$(art_gtest_name)
575test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
576 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800577
Ian Rogersafd9acc2014-06-17 08:21:54 -0700578.PHONY: valgrind-test-art-host-gtest-$$(art_gtest_name)
579valgrind-test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES)
580 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
581
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100582 # Clear now unused variables.
583 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
584 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700585 art_gtest_name :=
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100586endef # define-art-gtest-host-both
Alex Light50fa9932015-08-10 15:30:07 -0700587
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700588ifeq ($(ART_BUILD_TARGET),true)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100589 $(foreach file,$(ART_TARGET_GTEST_FILES), $(eval $(call define-art-gtest-target,$(file),)))
590 ifdef TARGET_2ND_ARCH
591 $(foreach file,$(2ND_ART_TARGET_GTEST_FILES), $(eval $(call define-art-gtest-target,$(file),2ND_)))
592 endif
593 # Rules to run the different architecture versions of the gtest.
594 $(foreach file,$(ART_TARGET_GTEST_FILES), $(eval $(call define-art-gtest-target-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700595endif
Ian Rogersc5f17732014-06-05 20:48:42 -0700596ifeq ($(ART_BUILD_HOST),true)
Nicolas Geoffray6bbea4c2016-09-16 16:41:43 +0100597 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),)))
598 ifneq ($(HOST_PREFER_32_BIT),true)
599 $(foreach file,$(2ND_ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host,$(file),2ND_)))
600 endif
601 # Rules to run the different architecture versions of the gtest.
602 $(foreach file,$(ART_HOST_GTEST_FILES), $(eval $(call define-art-gtest-host-both,$$(notdir $$(basename $$(file))))))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700603endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700604
605# Used outside the art project to get a list of the current tests
606RUNTIME_TARGET_GTEST_MAKE_TARGETS :=
Colin Cross6e95dd52016-09-12 15:37:10 -0700607$(foreach file, $(ART_TARGET_GTEST_FILES), $(eval RUNTIME_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700608COMPILER_TARGET_GTEST_MAKE_TARGETS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700609
610# Define all the combinations of host/target, valgrind and suffix such as:
611# test-art-host-gtest or valgrind-test-art-host-gtest64
612# $(1): host or target
613# $(2): HOST or TARGET
614# $(3): valgrind- or undefined
615# $(4): undefined, 32 or 64
616define define-test-art-gtest-combination
617 ifeq ($(1),host)
618 ifneq ($(2),HOST)
619 $$(error argument mismatch $(1) and ($2))
620 endif
621 else
622 ifneq ($(1),target)
623 $$(error found $(1) expected host or target)
624 endif
625 ifneq ($(2),TARGET)
626 $$(error argument mismatch $(1) and ($2))
627 endif
628 endif
629
630 rule_name := $(3)test-art-$(1)-gtest$(4)
Andreas Gampe928f72b2014-09-09 19:53:48 -0700631 ifeq ($(3),valgrind-)
Andreas Gampe928f72b2014-09-09 19:53:48 -0700632 dependencies := $$(ART_TEST_$(2)_VALGRIND_GTEST$(4)_RULES)
633 else
634 dependencies := $$(ART_TEST_$(2)_GTEST$(4)_RULES)
635 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700636
637.PHONY: $$(rule_name)
Alan Leunga4ba9b52017-11-16 00:19:18 -0800638$$(rule_name): $$(dependencies) dx d8-compat-dx
Ian Rogersafd9acc2014-06-17 08:21:54 -0700639 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
640
641 # Clear locally defined variables.
642 rule_name :=
643 dependencies :=
644endef # define-test-art-gtest-combination
645
646$(eval $(call define-test-art-gtest-combination,target,TARGET,,))
Anton Kirilove5e76f42016-05-03 16:15:36 +0100647$(eval $(call define-test-art-gtest-combination,target,TARGET,valgrind-,))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700648$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Anton Kirilove5e76f42016-05-03 16:15:36 +0100649$(eval $(call define-test-art-gtest-combination,target,TARGET,valgrind-,$(ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700650ifdef TARGET_2ND_ARCH
651$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Anton Kirilove5e76f42016-05-03 16:15:36 +0100652$(eval $(call define-test-art-gtest-combination,target,TARGET,valgrind-,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700653endif
654$(eval $(call define-test-art-gtest-combination,host,HOST,,))
655$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,))
656$(eval $(call define-test-art-gtest-combination,host,HOST,,$(ART_PHONY_TEST_HOST_SUFFIX)))
657$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(ART_PHONY_TEST_HOST_SUFFIX)))
658ifneq ($(HOST_PREFER_32_BIT),true)
659$(eval $(call define-test-art-gtest-combination,host,HOST,,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
660$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
661endif
662
663# Clear locally defined variables.
664define-art-gtest-rule-target :=
665define-art-gtest-rule-host :=
666define-art-gtest :=
667define-test-art-gtest-combination :=
668RUNTIME_GTEST_COMMON_SRC_FILES :=
669COMPILER_GTEST_COMMON_SRC_FILES :=
670RUNTIME_GTEST_TARGET_SRC_FILES :=
671RUNTIME_GTEST_HOST_SRC_FILES :=
672COMPILER_GTEST_TARGET_SRC_FILES :=
673COMPILER_GTEST_HOST_SRC_FILES :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700674ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
675ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
676ART_TEST_HOST_GTEST_RULES :=
677ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
678ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
679ART_TEST_HOST_VALGRIND_GTEST_RULES :=
680ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
681ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
682ART_TEST_TARGET_GTEST_RULES :=
Anton Kirilove5e76f42016-05-03 16:15:36 +0100683ART_TEST_TARGET_VALGRIND_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
684ART_TEST_TARGET_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
685ART_TEST_TARGET_VALGRIND_GTEST_RULES :=
Nicolas Geoffray96a37c82014-10-29 23:50:40 +0000686ART_GTEST_TARGET_ANDROID_ROOT :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700687ART_GTEST_class_linker_test_DEX_DEPS :=
Mathieu Chartierdb70ce52016-12-12 11:06:59 -0800688ART_GTEST_class_table_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700689ART_GTEST_compiler_driver_test_DEX_DEPS :=
690ART_GTEST_dex_file_test_DEX_DEPS :=
691ART_GTEST_exception_test_DEX_DEPS :=
692ART_GTEST_elf_writer_test_HOST_DEPS :=
693ART_GTEST_elf_writer_test_TARGET_DEPS :=
Andreas Gampea1ff30f2016-09-27 12:19:45 -0700694ART_GTEST_imtable_test_DEX_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700695ART_GTEST_jni_compiler_test_DEX_DEPS :=
696ART_GTEST_jni_internal_test_DEX_DEPS :=
Richard Uhler66d874d2015-01-15 09:37:19 -0800697ART_GTEST_oat_file_assistant_test_DEX_DEPS :=
698ART_GTEST_oat_file_assistant_test_HOST_DEPS :=
699ART_GTEST_oat_file_assistant_test_TARGET_DEPS :=
Calin Juravle36eb3132017-01-13 16:32:38 -0800700ART_GTEST_dexoptanalyzer_test_DEX_DEPS :=
701ART_GTEST_dexoptanalyzer_test_HOST_DEPS :=
702ART_GTEST_dexoptanalyzer_test_TARGET_DEPS :=
Richard Uhler84f50ae2017-02-06 15:12:45 +0000703ART_GTEST_image_space_test_DEX_DEPS :=
704ART_GTEST_image_space_test_HOST_DEPS :=
705ART_GTEST_image_space_test_TARGET_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700706ART_GTEST_dex2oat_test_DEX_DEPS :=
707ART_GTEST_dex2oat_test_HOST_DEPS :=
708ART_GTEST_dex2oat_test_TARGET_DEPS :=
Mathieu Chartierf70fe3d2017-06-21 15:24:02 -0700709ART_GTEST_dex2oat_image_test_DEX_DEPS :=
710ART_GTEST_dex2oat_image_test_HOST_DEPS :=
711ART_GTEST_dex2oat_image_test_TARGET_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700712ART_GTEST_object_test_DEX_DEPS :=
Alex Klyubind1d5c952017-12-15 12:57:33 -0800713ART_GTEST_patchoat_test_DEX_DEPS :=
714ART_GTEST_patchoat_test_HOST_DEPS :=
715ART_GTEST_patchoat_test_TARGET_DEPS :=
Brian Carlstromeb85f2b2014-06-25 13:23:00 -0700716ART_GTEST_proxy_test_DEX_DEPS :=
717ART_GTEST_reflection_test_DEX_DEPS :=
718ART_GTEST_stub_test_DEX_DEPS :=
719ART_GTEST_transaction_test_DEX_DEPS :=
Andreas Gampee1459ae2016-06-29 09:36:30 -0700720ART_GTEST_dex2oat_environment_tests_DEX_DEPS :=
Mathieu Chartier1ca68902017-04-18 11:26:22 -0700721ART_GTEST_heap_verification_test_DEX_DEPS :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100722ART_GTEST_verifier_deps_test_DEX_DEPS :=
Andreas Gampe3c0bb312015-02-19 10:02:19 -0800723ART_VALGRIND_DEPENDENCIES :=
Anton Kirilove5e76f42016-05-03 16:15:36 +0100724ART_VALGRIND_TARGET_DEPENDENCIES :=
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700725$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_TARGET_GTEST_$(dir)_DEX :=))
726$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_TEST_HOST_GTEST_$(dir)_DEX :=))
Richard Uhler66d874d2015-01-15 09:37:19 -0800727ART_TEST_HOST_GTEST_MainStripped_DEX :=
728ART_TEST_TARGET_GTEST_MainStripped_DEX :=
Nicolas Geoffrayae7e8382017-11-20 15:10:28 +0000729ART_TEST_HOST_GTEST_MainUncompressed_DEX :=
730ART_TEST_TARGET_GTEST_MainUncompressed_DEX :=
David Brazdilca3c8c32016-09-06 14:04:48 +0100731ART_TEST_GTEST_VerifierDeps_SRC :=
732ART_TEST_HOST_GTEST_VerifierDeps_DEX :=
David Brazdilf906f122016-09-16 16:33:31 +0100733ART_TEST_TARGET_GTEST_VerifierDeps_DEX :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700734GTEST_DEX_DIRECTORIES :=
Brian Carlstrom532714a2014-06-25 02:15:31 -0700735LOCAL_PATH :=