• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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$(AHAT_RI_TEST_DUMP_HPROF): PRIVATE_AHAT_RI_TEST_DUMP_JAR := $(AHAT_RI_TEST_DUMP_JAR)
95$(AHAT_RI_TEST_DUMP_HPROF): $(AHAT_RI_TEST_DUMP_JAR)
96	rm -rf $@
97	java -cp $(PRIVATE_AHAT_RI_TEST_DUMP_JAR) Main $@
98
99# --- ahat-tests.jar --------------
100# To run these tests, use: atest ahat-tests --host
101include $(CLEAR_VARS)
102LOCAL_SRC_FILES := $(call all-java-files-under, src/test)
103LOCAL_JAR_MANIFEST := etc/ahat-tests.mf
104LOCAL_JAVA_RESOURCE_FILES := \
105  $(AHAT_TEST_DUMP_HPROF) \
106  $(AHAT_TEST_DUMP_BASE_HPROF) \
107  $(AHAT_TEST_DUMP_PROGUARD_MAP) \
108  $(AHAT_RI_TEST_DUMP_HPROF) \
109  $(LOCAL_PATH)/etc/L.hprof \
110  $(LOCAL_PATH)/etc/O.hprof \
111  $(LOCAL_PATH)/etc/RI.hprof
112LOCAL_STATIC_JAVA_LIBRARIES := ahat junit-host
113LOCAL_IS_HOST_MODULE := true
114LOCAL_MODULE_TAGS := tests
115LOCAL_MODULE := ahat-tests
116LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
117LOCAL_LICENSE_CONDITIONS := notice
118LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../NOTICE
119LOCAL_TEST_CONFIG := ahat-tests.xml
120LOCAL_COMPATIBILITY_SUITE := general-tests
121include $(BUILD_HOST_JAVA_LIBRARY)
122AHAT_TEST_JAR := $(LOCAL_BUILT_MODULE)
123
124endif # EMMA_INSTRUMENT
125endif # linux
126
127# Clean up local variables.
128AHAT_TEST_JAR :=
129AHAT_TEST_DUMP_JAR :=
130AHAT_TEST_DUMP_COMMON :=
131AHAT_TEST_DUMP_HPROF :=
132AHAT_TEST_DUMP_BASE_HPROF :=
133AHAT_TEST_DUMP_PROGUARD_MAP :=
134AHAT_TEST_DUMP_DEPENDENCIES :=
135AHAT_TEST_DUMP_ANDROID_DATA :=
136AHAT_TEST_DUMP_BASE_ANDROID_DATA :=
137
138AHAT_RI_TEST_DUMP_JAR :=
139AHAT_RI_TEST_DUMP_COMMON :=
140AHAT_RI_TEST_DUMP_HPROF :=
141