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