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