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