blob: 1815f50c971308307fae17518618e999167a2865 [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
22# List of known broken tests that we won't attempt to execute. The test name must be the full
23# rule name such as test-art-host-oat-optimizing-HelloWorld64.
24ART_TEST_KNOWN_BROKEN :=
25
26# List of known failing tests that when executed won't cause test execution to finish. The test name
27# must be the full rule name such as test-art-host-oat-optimizing-HelloWorld64.
28ART_TEST_KNOWN_FAILING := $(ART_TEST_KNOWN_BROKEN)
29
30# Keep going after encountering a test failure?
31ART_TEST_KEEP_GOING ?= false
32
33# Define the command run on test failure. $(1) is the name of the test. Executed by the shell.
34define ART_TEST_FAILED
35 ( [ -f $(ART_HOST_TEST_DIR)/skipped/$(1) ] || \
36 (mkdir -p $(ART_HOST_TEST_DIR)/failed/ && touch $(ART_HOST_TEST_DIR)/failed/$(1) && \
37 echo $(ART_TEST_KNOWN_FAILING) | grep -q $(1) \
38 && (echo -e "$(1) \e[91mKNOWN FAILURE\e[0m") \
39 || (echo -e "$(1) \e[91mFAILED\e[0m")))
40endef
41
42# Define the command run on test success. $(1) is the name of the test. Executed by the shell.
43# The command checks prints "PASSED" then checks to see if this was a top-level make target (e.g.
44# "mm test-art-host-oat-HelloWorld32"), if it was then it does nothing, otherwise it creates a file
45# to be printed in the passing test summary.
46define ART_TEST_PASSED
47 ( echo -e "$(1) \e[92mPASSED\e[0m" && \
48 (echo $(MAKECMDGOALS) | grep -q $(1) || \
49 (mkdir -p $(ART_HOST_TEST_DIR)/passed/ && touch $(ART_HOST_TEST_DIR)/passed/$(1))))
50endef
51
52# Define the command run on test success of multiple prerequisites. $(1) is the name of the test.
53# When the test is a top-level make target then a summary of the ran tests is produced. Executed by
54# the shell.
55define ART_TEST_PREREQ_FINISHED
56 (echo -e "$(1) \e[32mCOMPLETE\e[0m" && \
57 (echo $(MAKECMDGOALS) | grep -q -v $(1) || \
58 (([ -d $(ART_HOST_TEST_DIR)/passed/ ] \
59 && (echo -e "\e[92mPASSING TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/passed/) \
60 || (echo -e "\e[91mNO TESTS PASSED\e[0m")) && \
61 ([ -d $(ART_HOST_TEST_DIR)/skipped/ ] \
62 && (echo -e "\e[93mSKIPPED TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/skipped/) \
63 || (echo -e "\e[92mNO TESTS SKIPPED\e[0m")) && \
64 ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
65 && (echo -e "\e[91mFAILING TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/failed/) \
66 || (echo -e "\e[92mNO TESTS FAILED\e[0m")) \
67 && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] && rm -r $(ART_HOST_TEST_DIR) \
68 || (rm -r $(ART_HOST_TEST_DIR) && false)))))
69endef
70
71# Define the command executed by the shell ahead of running an art test. $(1) is the name of the
72# test.
73define ART_TEST_SKIP
74 ((echo $(ART_TEST_KNOWN_BROKEN) | grep -q -v $(1) \
75 && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] || [ $(ART_TEST_KEEP_GOING) = true ])\
76 && echo -e "$(1) \e[95mRUNNING\e[0m") \
77 || ((mkdir -p $(ART_HOST_TEST_DIR)/skipped/ && touch $(ART_HOST_TEST_DIR)/skipped/$(1) \
78 && ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
79 && echo -e "$(1) \e[93mSKIPPING DUE TO EARLIER FAILURE\e[0m") \
80 || echo -e "$(1) \e[93mSKIPPING BROKEN TEST\e[0m") && false))
81endef
82
83# Create a build rule to create the dex file for a test.
84# $(1): module prefix, e.g. art-test-dex
85# $(2): input test directory in art/test, e.g. HelloWorld
86# $(3): target output module path (default module path is used on host)
87# $(4): additional dependencies
88# $(5): a make variable used to collate dependencies
89define build-art-test-dex
90 ifeq ($(ART_BUILD_TARGET),true)
91 include $(CLEAR_VARS)
92 LOCAL_MODULE := $(1)-$(2)
93 LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
94 LOCAL_NO_STANDARD_LIBRARIES := true
95 LOCAL_DEX_PREOPT := false
96 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
97 LOCAL_MODULE_TAGS := tests
98 LOCAL_JAVA_LIBRARIES := $(TARGET_CORE_JARS)
99 LOCAL_MODULE_PATH := $(3)
100 LOCAL_DEX_PREOPT_IMAGE_LOCATION := $(TARGET_CORE_IMG_OUT)
101 include $(BUILD_JAVA_LIBRARY)
102 endif
103 ifeq ($(ART_BUILD_HOST),true)
104 include $(CLEAR_VARS)
105 LOCAL_MODULE := $(1)-$(2)
106 LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
107 LOCAL_NO_STANDARD_LIBRARIES := true
108 LOCAL_DEX_PREOPT := false
109 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
110 LOCAL_JAVA_LIBRARIES := $(HOST_CORE_JARS)
111 LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_LOCATION)
112 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
113 endif
114 $(5) := $$(LOCAL_INSTALLED_MODULE)
115endef
116
117endif # ANDROID_COMMON_TEST_MK