blob: 86ef35ed7ae2e891736c2a08a73a8cd078cd50ca [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.
Nicolas Geoffrayf61b5372014-06-25 14:35:34 +010024ART_TEST_KNOWN_BROKEN := \
25 test-art-host-oat-optimizing-SignalTest64 \
Nicolas Geoffray8d486732014-07-16 16:23:40 +010026 test-art-host-oat-optimizing-SignalTest32 \
27 test-art-target-oat-optimizing-SignalTest32
Ian Rogersafd9acc2014-06-17 08:21:54 -070028
Nicolas Geoffrayf61b5372014-06-25 14:35:34 +010029# List of known failing tests that when executed won't cause test execution to not finish.
30# The test name must be the full rule name such as test-art-host-oat-optimizing-HelloWorld64.
31ART_TEST_KNOWN_FAILING :=
Ian Rogersafd9acc2014-06-17 08:21:54 -070032
33# Keep going after encountering a test failure?
34ART_TEST_KEEP_GOING ?= false
35
Ian Rogers5242c0a2014-07-18 11:02:19 -070036# Do you want all tests, even those that are time consuming?
37ART_TEST_FULL ?= true
38
39# Do you want optimizing compiler tests run?
40ART_TEST_OPTIMIZING ?= $(ART_TEST_FULL)
41
42# Do you want tracing tests run?
43ART_TEST_TRACE ?= $(ART_TEST_FULL)
44
Ian Rogersafd9acc2014-06-17 08:21:54 -070045# Define the command run on test failure. $(1) is the name of the test. Executed by the shell.
46define ART_TEST_FAILED
47 ( [ -f $(ART_HOST_TEST_DIR)/skipped/$(1) ] || \
48 (mkdir -p $(ART_HOST_TEST_DIR)/failed/ && touch $(ART_HOST_TEST_DIR)/failed/$(1) && \
49 echo $(ART_TEST_KNOWN_FAILING) | grep -q $(1) \
50 && (echo -e "$(1) \e[91mKNOWN FAILURE\e[0m") \
51 || (echo -e "$(1) \e[91mFAILED\e[0m")))
52endef
53
54# Define the command run on test success. $(1) is the name of the test. Executed by the shell.
55# The command checks prints "PASSED" then checks to see if this was a top-level make target (e.g.
56# "mm test-art-host-oat-HelloWorld32"), if it was then it does nothing, otherwise it creates a file
57# to be printed in the passing test summary.
58define ART_TEST_PASSED
59 ( echo -e "$(1) \e[92mPASSED\e[0m" && \
60 (echo $(MAKECMDGOALS) | grep -q $(1) || \
61 (mkdir -p $(ART_HOST_TEST_DIR)/passed/ && touch $(ART_HOST_TEST_DIR)/passed/$(1))))
62endef
63
64# Define the command run on test success of multiple prerequisites. $(1) is the name of the test.
65# When the test is a top-level make target then a summary of the ran tests is produced. Executed by
66# the shell.
67define ART_TEST_PREREQ_FINISHED
68 (echo -e "$(1) \e[32mCOMPLETE\e[0m" && \
69 (echo $(MAKECMDGOALS) | grep -q -v $(1) || \
70 (([ -d $(ART_HOST_TEST_DIR)/passed/ ] \
71 && (echo -e "\e[92mPASSING TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/passed/) \
72 || (echo -e "\e[91mNO TESTS PASSED\e[0m")) && \
73 ([ -d $(ART_HOST_TEST_DIR)/skipped/ ] \
74 && (echo -e "\e[93mSKIPPED TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/skipped/) \
75 || (echo -e "\e[92mNO TESTS SKIPPED\e[0m")) && \
76 ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
77 && (echo -e "\e[91mFAILING TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/failed/) \
78 || (echo -e "\e[92mNO TESTS FAILED\e[0m")) \
79 && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] && rm -r $(ART_HOST_TEST_DIR) \
80 || (rm -r $(ART_HOST_TEST_DIR) && false)))))
81endef
82
83# Define the command executed by the shell ahead of running an art test. $(1) is the name of the
84# test.
85define ART_TEST_SKIP
86 ((echo $(ART_TEST_KNOWN_BROKEN) | grep -q -v $(1) \
87 && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] || [ $(ART_TEST_KEEP_GOING) = true ])\
88 && echo -e "$(1) \e[95mRUNNING\e[0m") \
89 || ((mkdir -p $(ART_HOST_TEST_DIR)/skipped/ && touch $(ART_HOST_TEST_DIR)/skipped/$(1) \
90 && ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
91 && echo -e "$(1) \e[93mSKIPPING DUE TO EARLIER FAILURE\e[0m") \
92 || echo -e "$(1) \e[93mSKIPPING BROKEN TEST\e[0m") && false))
93endef
94
95# Create a build rule to create the dex file for a test.
96# $(1): module prefix, e.g. art-test-dex
97# $(2): input test directory in art/test, e.g. HelloWorld
98# $(3): target output module path (default module path is used on host)
99# $(4): additional dependencies
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700100# $(5): a make variable used to collate target dependencies, e.g ART_TEST_TARGET_OAT_HelloWorld_DEX
101# $(6): a make variable used to collate host dependencies, e.g ART_TEST_HOST_OAT_HelloWorld_DEX
Ian Rogersafd9acc2014-06-17 08:21:54 -0700102define build-art-test-dex
103 ifeq ($(ART_BUILD_TARGET),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_MODULE_TAGS := tests
111 LOCAL_JAVA_LIBRARIES := $(TARGET_CORE_JARS)
112 LOCAL_MODULE_PATH := $(3)
113 LOCAL_DEX_PREOPT_IMAGE_LOCATION := $(TARGET_CORE_IMG_OUT)
114 include $(BUILD_JAVA_LIBRARY)
Brian Carlstrom532714a2014-06-25 02:15:31 -0700115 $(5) := $$(LOCAL_INSTALLED_MODULE)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700116 endif
117 ifeq ($(ART_BUILD_HOST),true)
118 include $(CLEAR_VARS)
119 LOCAL_MODULE := $(1)-$(2)
120 LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
121 LOCAL_NO_STANDARD_LIBRARIES := true
122 LOCAL_DEX_PREOPT := false
123 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
124 LOCAL_JAVA_LIBRARIES := $(HOST_CORE_JARS)
125 LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_LOCATION)
126 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers1a2f84e2014-07-07 16:05:18 -0700127 $(6) := $$(LOCAL_INSTALLED_MODULE)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700128 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700129endef
130
131endif # ANDROID_COMMON_TEST_MK