• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
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
17ifndef ART_ANDROID_COMMON_TEST_MK
18ART_ANDROID_COMMON_TEST_MK = true
19
20include art/build/Android.common_path.mk
21
22# Directory used for temporary test files on the host.
23ifneq ($(TMPDIR),)
24ART_HOST_TEST_DIR := $(TMPDIR)/test-art-$(shell echo $$PPID)
25else
26# Use a BSD checksum calculated from ANDROID_BUILD_TOP and USER as one of the
27# path components for the test output. This should allow us to run tests from multiple
28# repositories at the same time.
29ART_HOST_TEST_DIR := /tmp/test-art-$(shell echo ${ANDROID_BUILD_TOP}-${USER} | sum | cut -d ' ' -f1)
30endif
31
32# List of known broken tests that we won't attempt to execute. The test name must be the full
33# rule name such as test-art-host-oat-optimizing-HelloWorld64.
34ART_TEST_KNOWN_BROKEN :=
35
36# List of run-tests to skip running in any configuration. This needs to be the full name of the
37# run-test such as '457-regs'.
38ART_TEST_RUN_TEST_SKIP ?=
39
40# Failing valgrind tests.
41# Note: *all* 64b tests involving the runtime do not work currently. b/15170219.
42
43# List of known failing tests that when executed won't cause test execution to not finish.
44# The test name must be the full rule name such as test-art-host-oat-optimizing-HelloWorld64.
45ART_TEST_KNOWN_FAILING :=
46
47# Keep going after encountering a test failure?
48ART_TEST_KEEP_GOING ?= true
49
50# Do you want all tests, even those that are time consuming?
51ART_TEST_FULL ?= false
52
53# Do you want run-test to be quieter? run-tests will only show output if they fail.
54ART_TEST_QUIET ?= true
55
56# Do you want interpreter tests run?
57ART_TEST_INTERPRETER ?= true
58ART_TEST_INTERPRETER_ACCESS_CHECKS ?= true
59
60# Do you want JIT tests run?
61ART_TEST_JIT ?= true
62
63# Do you want optimizing compiler tests run?
64ART_TEST_OPTIMIZING ?= true
65
66# Do you want to test the optimizing compiler with graph coloring register allocation?
67ART_TEST_OPTIMIZING_GRAPH_COLOR ?= $(ART_TEST_FULL)
68
69# Do you want to do run-tests with profiles?
70ART_TEST_SPEED_PROFILE ?= $(ART_TEST_FULL)
71
72# Do we want to test PIC-compiled tests ("apps")?
73ART_TEST_PIC_TEST ?= $(ART_TEST_FULL)
74
75# Do you want tracing tests run?
76ART_TEST_TRACE ?= $(ART_TEST_FULL)
77
78# Do you want tracing tests (streaming mode) run?
79ART_TEST_TRACE_STREAM ?= $(ART_TEST_FULL)
80
81# Do you want tests with GC verification enabled run?
82ART_TEST_GC_VERIFY ?= $(ART_TEST_FULL)
83
84# Do you want tests with the GC stress mode enabled run?
85ART_TEST_GC_STRESS ?= $(ART_TEST_FULL)
86
87# Do you want tests with the JNI forcecopy mode enabled run?
88ART_TEST_JNI_FORCECOPY ?= $(ART_TEST_FULL)
89
90# Do you want run-tests with relocation enabled run?
91ART_TEST_RUN_TEST_RELOCATE ?= $(ART_TEST_FULL)
92
93# Do you want run-tests with prebuilding?
94ART_TEST_RUN_TEST_PREBUILD ?= true
95
96# Do you want run-tests with no prebuilding enabled run?
97ART_TEST_RUN_TEST_NO_PREBUILD ?= $(ART_TEST_FULL)
98
99# Do you want run-tests with a pregenerated core.art?
100ART_TEST_RUN_TEST_IMAGE ?= true
101
102# Do you want run-tests without a pregenerated core.art?
103ART_TEST_RUN_TEST_NO_IMAGE ?= $(ART_TEST_FULL)
104
105# Do you want run-tests with relocation enabled but patchoat failing?
106ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT ?= $(ART_TEST_FULL)
107
108# Do you want run-tests without a dex2oat?
109ART_TEST_RUN_TEST_NO_DEX2OAT ?= $(ART_TEST_FULL)
110
111# Do you want run-tests with libartd.so?
112ART_TEST_RUN_TEST_DEBUG ?= true
113
114# Do you want run-tests with libart.so?
115ART_TEST_RUN_TEST_NDEBUG ?= $(ART_TEST_FULL)
116
117# Do you want run-tests with the host/target's second arch?
118ART_TEST_RUN_TEST_2ND_ARCH ?= true
119
120# Do you want failed tests to have their artifacts cleaned up?
121ART_TEST_RUN_TEST_ALWAYS_CLEAN ?= true
122
123# Do you want run-tests with the --debuggable flag
124ART_TEST_RUN_TEST_DEBUGGABLE ?= $(ART_TEST_FULL)
125
126# Do you want to test multi-part boot-image functionality?
127ART_TEST_RUN_TEST_MULTI_IMAGE ?= $(ART_TEST_FULL)
128
129# Define the command run on test failure. $(1) is the name of the test. Executed by the shell.
130# If the test was a top-level make target (e.g. `test-art-host-gtest-codegen_test64`), the command
131# fails with exit status 1 (returned by the last `grep` statement below).
132# Otherwise (e.g., if the test was run as a prerequisite of a compound test command, such as
133# `test-art-host-gtest-codegen_test`), the command does not fail, as this would break rules running
134# ART_TEST_PREREQ_FINISHED as one of their actions, which expects *all* prerequisites *not* to fail.
135define ART_TEST_FAILED
136  ( [ -f $(ART_HOST_TEST_DIR)/skipped/$(1) ] || \
137    (mkdir -p $(ART_HOST_TEST_DIR)/failed/ && touch $(ART_HOST_TEST_DIR)/failed/$(1) && \
138      echo $(ART_TEST_KNOWN_FAILING) | grep -q $(1) \
139        && (echo -e "$(1) \e[91mKNOWN FAILURE\e[0m") \
140        || (echo -e "$(1) \e[91mFAILED\e[0m" >&2; echo $(MAKECMDGOALS) | grep -q -v $(1))))
141endef
142
143ifeq ($(ART_TEST_QUIET),true)
144  ART_TEST_ANNOUNCE_PASS := ( true )
145  ART_TEST_ANNOUNCE_RUN := ( true )
146  ART_TEST_ANNOUNCE_SKIP_FAILURE := ( true )
147  ART_TEST_ANNOUNCE_SKIP_BROKEN := ( true )
148else
149  # Note the use of '=' and not ':=' is intentional since these are actually functions.
150  ART_TEST_ANNOUNCE_PASS = ( echo -e "$(1) \e[92mPASSED\e[0m" )
151  ART_TEST_ANNOUNCE_RUN = ( echo -e "$(1) \e[95mRUNNING\e[0m")
152  ART_TEST_ANNOUNCE_SKIP_FAILURE = ( echo -e "$(1) \e[93mSKIPPING DUE TO EARLIER FAILURE\e[0m" )
153  ART_TEST_ANNOUNCE_SKIP_BROKEN = ( echo -e "$(1) \e[93mSKIPPING BROKEN TEST\e[0m" )
154endif
155
156# Define the command run on test success. $(1) is the name of the test. Executed by the shell.
157# The command checks prints "PASSED" then checks to see if this was a top-level make target (e.g.
158# "mm test-art-host-oat-HelloWorld32"), if it was then it does nothing, otherwise it creates a file
159# to be printed in the passing test summary.
160define ART_TEST_PASSED
161  ( $(call ART_TEST_ANNOUNCE_PASS,$(1)) && \
162    (echo $(MAKECMDGOALS) | grep -q $(1) || \
163      (mkdir -p $(ART_HOST_TEST_DIR)/passed/ && touch $(ART_HOST_TEST_DIR)/passed/$(1))))
164endef
165
166# Define the command run on test success of multiple prerequisites. $(1) is the name of the test.
167# When the test is a top-level make target then a summary of the ran tests is produced. Executed by
168# the shell.
169define ART_TEST_PREREQ_FINISHED
170  (echo -e "$(1) \e[32mCOMPLETE\e[0m" && \
171    (echo $(MAKECMDGOALS) | grep -q -v $(1) || \
172      (([ -d $(ART_HOST_TEST_DIR)/passed/ ] \
173        && (echo -e "\e[92mPASSING TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/passed/) \
174        || (echo -e "\e[91mNO TESTS PASSED\e[0m")) && \
175      ([ -d $(ART_HOST_TEST_DIR)/skipped/ ] \
176        && (echo -e "\e[93mSKIPPED TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/skipped/) \
177        || (echo -e "\e[92mNO TESTS SKIPPED\e[0m")) && \
178      ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
179        && (echo -e "\e[91mFAILING TESTS\e[0m" >&2 && ls -1 $(ART_HOST_TEST_DIR)/failed/ >&2) \
180        || (echo -e "\e[92mNO TESTS FAILED\e[0m")) \
181      && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] && rm -r $(ART_HOST_TEST_DIR) \
182          || (rm -r $(ART_HOST_TEST_DIR) && false)))))
183endef
184
185# Define the command executed by the shell ahead of running an art test. $(1) is the name of the
186# test.
187define ART_TEST_SKIP
188  ((echo $(ART_TEST_KNOWN_BROKEN) | grep -q -v $(1) \
189     && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] || [ $(ART_TEST_KEEP_GOING) = true ])\
190     && $(call ART_TEST_ANNOUNCE_RUN,$(1)) ) \
191   || ((mkdir -p $(ART_HOST_TEST_DIR)/skipped/ && touch $(ART_HOST_TEST_DIR)/skipped/$(1) \
192     && ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
193       && $(call ART_TEST_ANNOUNCE_SKIP_FAILURE,$(1)) ) \
194     || $(call ART_TEST_ANNOUNCE_SKIP_BROKEN,$(1)) ) && false))
195endef
196
197# Create a build rule to create the dex file for a test.
198# $(1): module prefix, e.g. art-test-dex
199# $(2): input test directory in art/test, e.g. HelloWorld
200# $(3): target output module path (default module path is used on host)
201# $(4): additional dependencies
202# $(5): a make variable used to collate target dependencies, e.g ART_TEST_TARGET_OAT_HelloWorld_DEX
203# $(6): a make variable used to collate host dependencies, e.g ART_TEST_HOST_OAT_HelloWorld_DEX
204#
205# If the input test directory contains a file called main.list and main.jpp,
206# then a multi-dex file is created passing main.list as the --main-dex-list
207# argument to dx and main.jpp for Jack.
208define build-art-test-dex
209  ifeq ($(ART_BUILD_TARGET),true)
210    include $(CLEAR_VARS)
211    LOCAL_MODULE := $(1)-$(2)
212    LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
213    LOCAL_NO_STANDARD_LIBRARIES := true
214    LOCAL_DEX_PREOPT := false
215    LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
216    LOCAL_MODULE_TAGS := tests
217    LOCAL_JAVA_LIBRARIES := $(TARGET_CORE_JARS)
218    LOCAL_MODULE_PATH := $(3)
219    LOCAL_DEX_PREOPT_IMAGE_LOCATION := $(TARGET_CORE_IMG_OUT)
220    ifneq ($(wildcard $(LOCAL_PATH)/$(2)/main.list),)
221      LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(LOCAL_PATH)/$(2)/main.list --minimal-main-dex
222      LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.preprocessor=true -D jack.preprocessor.file=$(LOCAL_PATH)/$(2)/main.jpp
223    endif
224    include $(BUILD_JAVA_LIBRARY)
225    $(5) := $$(LOCAL_INSTALLED_MODULE)
226  endif
227  ifeq ($(ART_BUILD_HOST),true)
228    include $(CLEAR_VARS)
229    LOCAL_MODULE := $(1)-$(2)
230    LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
231    LOCAL_NO_STANDARD_LIBRARIES := true
232    LOCAL_DEX_PREOPT := false
233    LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
234    LOCAL_JAVA_LIBRARIES := $(HOST_CORE_JARS)
235    LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_LOCATION)
236    ifneq ($(wildcard $(LOCAL_PATH)/$(2)/main.list),)
237      LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(LOCAL_PATH)/$(2)/main.list --minimal-main-dex
238      LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.preprocessor=true -D jack.preprocessor.file=$(LOCAL_PATH)/$(2)/main.jpp
239    endif
240    include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
241    $(6) := $$(LOCAL_INSTALLED_MODULE)
242  endif
243endef
244
245endif # ART_ANDROID_COMMON_TEST_MK
246