Android.common_test.mk revision 9d722533b0ef6547ee0ab5286f65af98451c36e4
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 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 not finish.
27# The test name must be the full rule name such as test-art-host-oat-optimizing-HelloWorld64.
28ART_TEST_KNOWN_FAILING :=
29
30# Keep going after encountering a test failure?
31ART_TEST_KEEP_GOING ?= false
32
33# Do you want all tests, even those that are time consuming?
34ART_TEST_FULL ?= true
35
36# Do you want optimizing compiler tests run?
37ART_TEST_OPTIMIZING ?= $(ART_TEST_FULL)
38
39# Do you want tracing tests run?
40ART_TEST_TRACE ?= $(ART_TEST_FULL)
41
42# Do you want tests with GC verification enabled run?
43ART_TEST_GC_VERIFY ?= $(ART_TEST_FULL)
44
45# Do you want tests with the GC stress mode enabled run?
46ART_TEST_GC_STRESS ?= $(ART_TEST_FULL)
47
48# Do you want oat tests with relocation enabled?
49ART_TEST_OAT_RELOCATE ?= true
50
51# Do you want oat tests with relocation disabled?
52ART_TEST_OAT_NO_RELOCATE ?= $(ART_TEST_FULL)
53
54# Do you want run-tests with relocation enabled?
55ART_TEST_RUN_TEST_RELOCATE ?= $(ART_TEST_FULL)
56
57# Do you want run-tests with relocation disabled?
58ART_TEST_RUN_TEST_NO_RELOCATE ?= $(ART_TEST_FULL)
59
60# Do you want run-tests with prebuild disabled?
61ART_TEST_RUN_TEST_NO_PREBUILD ?= $(ART_TEST_FULL)
62
63# Define the command run on test failure. $(1) is the name of the test. Executed by the shell.
64define ART_TEST_FAILED
65  ( [ -f $(ART_HOST_TEST_DIR)/skipped/$(1) ] || \
66    (mkdir -p $(ART_HOST_TEST_DIR)/failed/ && touch $(ART_HOST_TEST_DIR)/failed/$(1) && \
67      echo $(ART_TEST_KNOWN_FAILING) | grep -q $(1) \
68        && (echo -e "$(1) \e[91mKNOWN FAILURE\e[0m") \
69        || (echo -e "$(1) \e[91mFAILED\e[0m")))
70endef
71
72# Define the command run on test success. $(1) is the name of the test. Executed by the shell.
73# The command checks prints "PASSED" then checks to see if this was a top-level make target (e.g.
74# "mm test-art-host-oat-HelloWorld32"), if it was then it does nothing, otherwise it creates a file
75# to be printed in the passing test summary.
76define ART_TEST_PASSED
77  ( echo -e "$(1) \e[92mPASSED\e[0m" && \
78    (echo $(MAKECMDGOALS) | grep -q $(1) || \
79      (mkdir -p $(ART_HOST_TEST_DIR)/passed/ && touch $(ART_HOST_TEST_DIR)/passed/$(1))))
80endef
81
82# Define the command run on test success of multiple prerequisites. $(1) is the name of the test.
83# When the test is a top-level make target then a summary of the ran tests is produced. Executed by
84# the shell.
85define ART_TEST_PREREQ_FINISHED
86  (echo -e "$(1) \e[32mCOMPLETE\e[0m" && \
87    (echo $(MAKECMDGOALS) | grep -q -v $(1) || \
88      (([ -d $(ART_HOST_TEST_DIR)/passed/ ] \
89        && (echo -e "\e[92mPASSING TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/passed/) \
90        || (echo -e "\e[91mNO TESTS PASSED\e[0m")) && \
91      ([ -d $(ART_HOST_TEST_DIR)/skipped/ ] \
92        && (echo -e "\e[93mSKIPPED TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/skipped/) \
93        || (echo -e "\e[92mNO TESTS SKIPPED\e[0m")) && \
94      ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
95        && (echo -e "\e[91mFAILING TESTS\e[0m" >&2 && ls -1 $(ART_HOST_TEST_DIR)/failed/ >&2) \
96        || (echo -e "\e[92mNO TESTS FAILED\e[0m")) \
97      && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] && rm -r $(ART_HOST_TEST_DIR) \
98          || (rm -r $(ART_HOST_TEST_DIR) && false)))))
99endef
100
101# Define the command executed by the shell ahead of running an art test. $(1) is the name of the
102# test.
103define ART_TEST_SKIP
104  ((echo $(ART_TEST_KNOWN_BROKEN) | grep -q -v $(1) \
105     && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] || [ $(ART_TEST_KEEP_GOING) = true ])\
106     && echo -e "$(1) \e[95mRUNNING\e[0m") \
107   || ((mkdir -p $(ART_HOST_TEST_DIR)/skipped/ && touch $(ART_HOST_TEST_DIR)/skipped/$(1) \
108     && ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
109       && echo -e "$(1) \e[93mSKIPPING DUE TO EARLIER FAILURE\e[0m") \
110     || echo -e "$(1) \e[93mSKIPPING BROKEN TEST\e[0m") && false))
111endef
112
113# Create a build rule to create the dex file for a test.
114# $(1): module prefix, e.g. art-test-dex
115# $(2): input test directory in art/test, e.g. HelloWorld
116# $(3): target output module path (default module path is used on host)
117# $(4): additional dependencies
118# $(5): a make variable used to collate target dependencies, e.g ART_TEST_TARGET_OAT_HelloWorld_DEX
119# $(6): a make variable used to collate host dependencies, e.g ART_TEST_HOST_OAT_HelloWorld_DEX
120define build-art-test-dex
121  ifeq ($(ART_BUILD_TARGET),true)
122    include $(CLEAR_VARS)
123    LOCAL_MODULE := $(1)-$(2)
124    LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
125    LOCAL_NO_STANDARD_LIBRARIES := true
126    LOCAL_DEX_PREOPT := false
127    LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
128    LOCAL_MODULE_TAGS := tests
129    LOCAL_JAVA_LIBRARIES := $(TARGET_CORE_JARS)
130    LOCAL_MODULE_PATH := $(3)
131    LOCAL_DEX_PREOPT_IMAGE_LOCATION := $(TARGET_CORE_IMG_OUT)
132    include $(BUILD_JAVA_LIBRARY)
133    $(5) := $$(LOCAL_INSTALLED_MODULE)
134  endif
135  ifeq ($(ART_BUILD_HOST),true)
136    include $(CLEAR_VARS)
137    LOCAL_MODULE := $(1)-$(2)
138    LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
139    LOCAL_NO_STANDARD_LIBRARIES := true
140    LOCAL_DEX_PREOPT := false
141    LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
142    LOCAL_JAVA_LIBRARIES := $(HOST_CORE_JARS)
143    LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_LOCATION)
144    include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
145    $(6) := $$(LOCAL_INSTALLED_MODULE)
146  endif
147endef
148
149endif # ANDROID_COMMON_TEST_MK
150