blob: 52d1ee31a5d1dcb84dd3a5e0e0f901816a7b3373 [file] [log] [blame]
Ian Rogersafd9acc2014-06-17 08:21:54 -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
17ifndef ANDROID_COMMON_TEST_MK
18ANDROID_COMMON_TEST_MK = true
19
20include art/build/Android.common_path.mk
21
Andreas Gampe1fe5e5c2014-07-11 21:14:35 -070022# We need to set a define for the nativetest dir so that common_runtime_test will know the right
23# path. (The problem is being a 32b test on 64b device, which is still located in nativetest64).
24ART_TARGET_CFLAGS += -DART_TARGET_NATIVETEST_DIR=${ART_TARGET_NATIVETEST_DIR}
25
Ian Rogersafd9acc2014-06-17 08:21:54 -070026# List of known broken tests that we won't attempt to execute. The test name must be the full
27# rule name such as test-art-host-oat-optimizing-HelloWorld64.
Andreas Gampe1c83cbc2014-07-22 18:52:29 -070028ART_TEST_KNOWN_BROKEN := \
Andreas Gampe1c83cbc2014-07-22 18:52:29 -070029 test-art-target-run-test-gcstress-optimizing-prebuild-004-SignalTest32 \
30 test-art-target-run-test-gcstress-optimizing-norelocate-004-SignalTest32 \
31 test-art-target-run-test-gcstress-default-prebuild-004-SignalTest32 \
32 test-art-target-run-test-gcstress-default-norelocate-004-SignalTest32 \
33 test-art-target-run-test-gcstress-optimizing-relocate-004-SignalTest32 \
34 test-art-target-run-test-gcstress-default-relocate-004-SignalTest32 \
35 test-art-target-run-test-gcstress-optimizing-no-prebuild-004-SignalTest32 \
36 test-art-target-run-test-gcstress-default-no-prebuild-004-SignalTest32
Ian Rogersafd9acc2014-06-17 08:21:54 -070037
Nicolas Geoffrayf61b5372014-06-25 14:35:34 +010038# List of known failing tests that when executed won't cause test execution to not finish.
39# The test name must be the full rule name such as test-art-host-oat-optimizing-HelloWorld64.
40ART_TEST_KNOWN_FAILING :=
Ian Rogersafd9acc2014-06-17 08:21:54 -070041
42# Keep going after encountering a test failure?
Andreas Gampee7655c52014-07-24 21:41:06 -070043ART_TEST_KEEP_GOING ?= true
Ian Rogersafd9acc2014-06-17 08:21:54 -070044
Ian Rogers5242c0a2014-07-18 11:02:19 -070045# Do you want all tests, even those that are time consuming?
46ART_TEST_FULL ?= true
47
48# Do you want optimizing compiler tests run?
49ART_TEST_OPTIMIZING ?= $(ART_TEST_FULL)
50
51# Do you want tracing tests run?
52ART_TEST_TRACE ?= $(ART_TEST_FULL)
53
Ian Rogers701aa642014-07-18 11:38:13 -070054# Do you want tests with GC verification enabled run?
55ART_TEST_GC_VERIFY ?= $(ART_TEST_FULL)
56
Ian Rogers8a14b752014-07-18 15:06:53 -070057# Do you want tests with the GC stress mode enabled run?
58ART_TEST_GC_STRESS ?= $(ART_TEST_FULL)
59
Alex Lighta59dd802014-07-02 16:28:08 -070060# Do you want run-tests with relocation enabled?
61ART_TEST_RUN_TEST_RELOCATE ?= $(ART_TEST_FULL)
62
63# Do you want run-tests with relocation disabled?
64ART_TEST_RUN_TEST_NO_RELOCATE ?= $(ART_TEST_FULL)
65
Alex Light9d722532014-07-22 18:07:12 -070066# Do you want run-tests with prebuild disabled?
67ART_TEST_RUN_TEST_NO_PREBUILD ?= $(ART_TEST_FULL)
Alex Lighta59dd802014-07-02 16:28:08 -070068
Nicolas Geoffray3bb12b92014-07-28 22:56:07 +010069# Do you want run-tests with prebuild enabled?
70ART_TEST_RUN_TEST_PREBUILD ?= true
71
Alex Lightbfac14a2014-07-30 09:41:21 -070072# Do you want failed tests to have their artifacts cleaned up?
73ART_TEST_RUN_TEST_ALWAYS_CLEAN ?= true
74
Ian Rogersafd9acc2014-06-17 08:21:54 -070075# Define the command run on test failure. $(1) is the name of the test. Executed by the shell.
76define ART_TEST_FAILED
77 ( [ -f $(ART_HOST_TEST_DIR)/skipped/$(1) ] || \
78 (mkdir -p $(ART_HOST_TEST_DIR)/failed/ && touch $(ART_HOST_TEST_DIR)/failed/$(1) && \
79 echo $(ART_TEST_KNOWN_FAILING) | grep -q $(1) \
80 && (echo -e "$(1) \e[91mKNOWN FAILURE\e[0m") \
Ian Rogersd2c0b092014-07-22 14:22:22 -070081 || (echo -e "$(1) \e[91mFAILED\e[0m" >&2 )))
Ian Rogersafd9acc2014-06-17 08:21:54 -070082endef
83
84# Define the command run on test success. $(1) is the name of the test. Executed by the shell.
85# The command checks prints "PASSED" then checks to see if this was a top-level make target (e.g.
86# "mm test-art-host-oat-HelloWorld32"), if it was then it does nothing, otherwise it creates a file
87# to be printed in the passing test summary.
88define ART_TEST_PASSED
89 ( echo -e "$(1) \e[92mPASSED\e[0m" && \
90 (echo $(MAKECMDGOALS) | grep -q $(1) || \
91 (mkdir -p $(ART_HOST_TEST_DIR)/passed/ && touch $(ART_HOST_TEST_DIR)/passed/$(1))))
92endef
93
94# Define the command run on test success of multiple prerequisites. $(1) is the name of the test.
95# When the test is a top-level make target then a summary of the ran tests is produced. Executed by
96# the shell.
97define ART_TEST_PREREQ_FINISHED
98 (echo -e "$(1) \e[32mCOMPLETE\e[0m" && \
99 (echo $(MAKECMDGOALS) | grep -q -v $(1) || \
100 (([ -d $(ART_HOST_TEST_DIR)/passed/ ] \
101 && (echo -e "\e[92mPASSING TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/passed/) \
102 || (echo -e "\e[91mNO TESTS PASSED\e[0m")) && \
103 ([ -d $(ART_HOST_TEST_DIR)/skipped/ ] \
104 && (echo -e "\e[93mSKIPPED TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/skipped/) \
105 || (echo -e "\e[92mNO TESTS SKIPPED\e[0m")) && \
106 ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
Ian Rogers51829152014-07-21 20:28:31 -0700107 && (echo -e "\e[91mFAILING TESTS\e[0m" >&2 && ls -1 $(ART_HOST_TEST_DIR)/failed/ >&2) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700108 || (echo -e "\e[92mNO TESTS FAILED\e[0m")) \
109 && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] && rm -r $(ART_HOST_TEST_DIR) \
110 || (rm -r $(ART_HOST_TEST_DIR) && false)))))
111endef
112
113# Define the command executed by the shell ahead of running an art test. $(1) is the name of the
114# test.
115define ART_TEST_SKIP
116 ((echo $(ART_TEST_KNOWN_BROKEN) | grep -q -v $(1) \
117 && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] || [ $(ART_TEST_KEEP_GOING) = true ])\
118 && echo -e "$(1) \e[95mRUNNING\e[0m") \
119 || ((mkdir -p $(ART_HOST_TEST_DIR)/skipped/ && touch $(ART_HOST_TEST_DIR)/skipped/$(1) \
120 && ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
121 && echo -e "$(1) \e[93mSKIPPING DUE TO EARLIER FAILURE\e[0m") \
122 || echo -e "$(1) \e[93mSKIPPING BROKEN TEST\e[0m") && false))
123endef
124
125# Create a build rule to create the dex file for a test.
126# $(1): module prefix, e.g. art-test-dex
127# $(2): input test directory in art/test, e.g. HelloWorld
128# $(3): target output module path (default module path is used on host)
129# $(4): additional dependencies
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700130# $(5): a make variable used to collate target dependencies, e.g ART_TEST_TARGET_OAT_HelloWorld_DEX
131# $(6): a make variable used to collate host dependencies, e.g ART_TEST_HOST_OAT_HelloWorld_DEX
Ian Rogersafd9acc2014-06-17 08:21:54 -0700132define build-art-test-dex
133 ifeq ($(ART_BUILD_TARGET),true)
134 include $(CLEAR_VARS)
135 LOCAL_MODULE := $(1)-$(2)
136 LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
137 LOCAL_NO_STANDARD_LIBRARIES := true
138 LOCAL_DEX_PREOPT := false
139 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
140 LOCAL_MODULE_TAGS := tests
141 LOCAL_JAVA_LIBRARIES := $(TARGET_CORE_JARS)
142 LOCAL_MODULE_PATH := $(3)
143 LOCAL_DEX_PREOPT_IMAGE_LOCATION := $(TARGET_CORE_IMG_OUT)
144 include $(BUILD_JAVA_LIBRARY)
Brian Carlstrom532714a2014-06-25 02:15:31 -0700145 $(5) := $$(LOCAL_INSTALLED_MODULE)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700146 endif
147 ifeq ($(ART_BUILD_HOST),true)
148 include $(CLEAR_VARS)
149 LOCAL_MODULE := $(1)-$(2)
150 LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
151 LOCAL_NO_STANDARD_LIBRARIES := true
152 LOCAL_DEX_PREOPT := false
153 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
154 LOCAL_JAVA_LIBRARIES := $(HOST_CORE_JARS)
155 LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_LOCATION)
156 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700157 $(6) := $$(LOCAL_INSTALLED_MODULE)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700158 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700159endef
160
161endif # ANDROID_COMMON_TEST_MK