1# 2# Copyright (C) 2015 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 17LOCAL_PATH := $(call my-dir) 18 19include art/build/Android.common_path.mk 20 21# The ahat tests rely on running ART to generate a heap dump for test, but ART 22# doesn't run on darwin. Only build and run the tests for linux. 23# There are also issues with running under instrumentation. 24ifeq ($(HOST_OS),linux) 25ifneq ($(EMMA_INSTRUMENT),true) 26 27# Determine the location of the test-dump.jar, test-dump.hprof, and proguard 28AHAT_TEST_DUMP_JAR := $(call intermediates-dir-for,JAVA_LIBRARIES,ahat-test-dump)/javalib.jar 29AHAT_TEST_DUMP_COMMON := $(call intermediates-dir-for,JAVA_LIBRARIES,ahat-test-dump,,COMMON) 30AHAT_TEST_DUMP_HPROF := $(AHAT_TEST_DUMP_COMMON)/test-dump.hprof 31AHAT_TEST_DUMP_BASE_HPROF := $(AHAT_TEST_DUMP_COMMON)/test-dump-base.hprof 32AHAT_TEST_DUMP_PROGUARD_MAP := $(AHAT_TEST_DUMP_COMMON)/test-dump.map 33AHAT_TEST_DUMP_PROGUARD_DICTIONARY := $(AHAT_TEST_DUMP_COMMON)/proguard_dictionary 34 35# Directories to use for ANDROID_DATA when generating the test dumps to 36# ensure we don't pollute the source tree with any artifacts from running 37# dalvikvm. 38AHAT_TEST_DUMP_ANDROID_DATA := $(AHAT_TEST_DUMP_COMMON)/test-dump-android_data 39AHAT_TEST_DUMP_BASE_ANDROID_DATA := $(AHAT_TEST_DUMP_COMMON)/test-dump-base-android_data 40 41# Generate the proguard map in the desired location by copying it from 42# wherever the build system generates it by default. 43$(AHAT_TEST_DUMP_PROGUARD_MAP): PRIVATE_AHAT_SOURCE_PROGUARD_MAP := $(AHAT_TEST_DUMP_PROGUARD_DICTIONARY) 44$(AHAT_TEST_DUMP_PROGUARD_MAP): $(AHAT_TEST_DUMP_PROGUARD_DICTIONARY) 45 cp $(PRIVATE_AHAT_SOURCE_PROGUARD_MAP) $@ 46 47ifeq (true,$(HOST_PREFER_32_BIT)) 48 AHAT_TEST_DALVIKVM_DEP := $(HOST_OUT_EXECUTABLES)/dalvikvm32 49 AHAT_TEST_DALVIKVM_ARG := --32 50else 51 AHAT_TEST_DALVIKVM_DEP := $(HOST_OUT_EXECUTABLES)/dalvikvm64 52 AHAT_TEST_DALVIKVM_ARG := --64 53endif 54 55# Run ahat-test-dump.jar to generate test-dump.hprof and test-dump-base.hprof 56# The scripts below are run with --no-compile to avoid dependency on dex2oat. 57AHAT_TEST_DUMP_DEPENDENCIES := \ 58 $(AHAT_TEST_DALVIKVM_DEP) \ 59 $(ART_HOST_SHARED_LIBRARY_DEPENDENCIES) \ 60 $(ART_HOST_SHARED_LIBRARY_DEBUG_DEPENDENCIES) \ 61 $(ART_HOST_DEX_DEPENDENCIES) \ 62 $(HOST_OUT_EXECUTABLES)/art \ 63 $(HOST_CORE_IMG_OUTS) 64 65$(AHAT_TEST_DUMP_HPROF): PRIVATE_AHAT_TEST_ART := $(HOST_OUT_EXECUTABLES)/art 66$(AHAT_TEST_DUMP_HPROF): PRIVATE_AHAT_TEST_DUMP_JAR := $(AHAT_TEST_DUMP_JAR) 67$(AHAT_TEST_DUMP_HPROF): PRIVATE_AHAT_TEST_ANDROID_DATA := $(AHAT_TEST_DUMP_ANDROID_DATA) 68$(AHAT_TEST_DUMP_HPROF): PRIVATE_AHAT_TEST_DALVIKVM_ARG := $(AHAT_TEST_DALVIKVM_ARG) 69$(AHAT_TEST_DUMP_HPROF): $(AHAT_TEST_DUMP_JAR) $(AHAT_TEST_DUMP_DEPENDENCIES) 70 rm -rf $(PRIVATE_AHAT_TEST_ANDROID_DATA) 71 mkdir -p $(PRIVATE_AHAT_TEST_ANDROID_DATA) 72 ANDROID_DATA=$(PRIVATE_AHAT_TEST_ANDROID_DATA) \ 73 $(PRIVATE_AHAT_TEST_ART) --no-compile -d $(PRIVATE_AHAT_TEST_DALVIKVM_ARG) \ 74 -cp $(PRIVATE_AHAT_TEST_DUMP_JAR) Main $@ 75 76$(AHAT_TEST_DUMP_BASE_HPROF): PRIVATE_AHAT_TEST_ART := $(HOST_OUT_EXECUTABLES)/art 77$(AHAT_TEST_DUMP_BASE_HPROF): PRIVATE_AHAT_TEST_DUMP_JAR := $(AHAT_TEST_DUMP_JAR) 78$(AHAT_TEST_DUMP_BASE_HPROF): PRIVATE_AHAT_TEST_ANDROID_DATA := $(AHAT_TEST_DUMP_BASE_ANDROID_DATA) 79$(AHAT_TEST_DUMP_BASE_HPROF): PRIVATE_AHAT_TEST_DALVIKVM_ARG := $(AHAT_TEST_DALVIKVM_ARG) 80$(AHAT_TEST_DUMP_BASE_HPROF): $(AHAT_TEST_DUMP_JAR) $(AHAT_TEST_DUMP_DEPENDENCIES) 81 rm -rf $(PRIVATE_AHAT_TEST_ANDROID_DATA) 82 mkdir -p $(PRIVATE_AHAT_TEST_ANDROID_DATA) 83 ANDROID_DATA=$(PRIVATE_AHAT_TEST_ANDROID_DATA) \ 84 $(PRIVATE_AHAT_TEST_ART) --no-compile -d $(PRIVATE_AHAT_TEST_DALVIKVM_ARG) \ 85 -cp $(PRIVATE_AHAT_TEST_DUMP_JAR) Main $@ --base 86 87 88# Determine the location of the ri-test-dump.jar and ri-test-dump.hprof. 89AHAT_RI_TEST_DUMP_JAR := $(call intermediates-dir-for,JAVA_LIBRARIES,ahat-ri-test-dump,HOST)/javalib.jar 90AHAT_RI_TEST_DUMP_COMMON := $(call intermediates-dir-for,JAVA_LIBRARIES,ahat-ri-test-dump,HOST,COMMON) 91AHAT_RI_TEST_DUMP_HPROF := $(AHAT_RI_TEST_DUMP_COMMON)/ri-test-dump.hprof 92 93# Run ahat-ri-test-dump.jar to generate ri-test-dump.hprof 94# b/329817005: Hardcode JDK 17 for running the test dump 95$(AHAT_RI_TEST_DUMP_HPROF): PRIVATE_AHAT_RI_TEST_DUMP_JAR := $(AHAT_RI_TEST_DUMP_JAR) 96$(AHAT_RI_TEST_DUMP_HPROF): $(AHAT_RI_TEST_DUMP_JAR) 97 rm -rf $@ 98 ./prebuilts/jdk/jdk17/linux-x86/bin/java -cp $(PRIVATE_AHAT_RI_TEST_DUMP_JAR) Main $@ 99 100# --- ahat-tests.jar -------------- 101# To run these tests, use: atest ahat-tests --host 102include $(CLEAR_VARS) 103LOCAL_SRC_FILES := $(call all-java-files-under, src/test) 104LOCAL_JAR_MANIFEST := etc/ahat-tests.mf 105LOCAL_JAVA_RESOURCE_FILES := \ 106 $(AHAT_TEST_DUMP_HPROF) \ 107 $(AHAT_TEST_DUMP_BASE_HPROF) \ 108 $(AHAT_TEST_DUMP_PROGUARD_MAP) \ 109 $(AHAT_RI_TEST_DUMP_HPROF) \ 110 $(LOCAL_PATH)/etc/L.hprof \ 111 $(LOCAL_PATH)/etc/O.hprof \ 112 $(LOCAL_PATH)/etc/RI.hprof 113LOCAL_STATIC_JAVA_LIBRARIES := ahat junit-host 114LOCAL_IS_HOST_MODULE := true 115LOCAL_MODULE_TAGS := tests 116LOCAL_MODULE := ahat-tests 117LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 118LOCAL_LICENSE_CONDITIONS := notice 119LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../NOTICE 120LOCAL_TEST_CONFIG := ahat-tests.xml 121LOCAL_COMPATIBILITY_SUITE := general-tests 122include $(BUILD_HOST_JAVA_LIBRARY) 123AHAT_TEST_JAR := $(LOCAL_BUILT_MODULE) 124 125endif # EMMA_INSTRUMENT 126endif # linux 127 128# Clean up local variables. 129AHAT_TEST_JAR := 130AHAT_TEST_DUMP_JAR := 131AHAT_TEST_DUMP_COMMON := 132AHAT_TEST_DUMP_HPROF := 133AHAT_TEST_DUMP_BASE_HPROF := 134AHAT_TEST_DUMP_PROGUARD_MAP := 135AHAT_TEST_DUMP_DEPENDENCIES := 136AHAT_TEST_DUMP_ANDROID_DATA := 137AHAT_TEST_DUMP_BASE_ANDROID_DATA := 138 139AHAT_RI_TEST_DUMP_JAR := 140AHAT_RI_TEST_DUMP_COMMON := 141AHAT_RI_TEST_DUMP_HPROF := 142