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