PageRenderTime 22ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/build/Android.common_test.mk

https://gitlab.com/androidopensourceproject/platform-art
Makefile | 154 lines | 90 code | 14 blank | 50 comment | 34 complexity | eb74e2969a48a5ce3eaa3bbfae584c49 MD5 | raw file
  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. ifndef ART_ANDROID_COMMON_TEST_MK
  17. ART_ANDROID_COMMON_TEST_MK = true
  18. include art/build/Android.common_path.mk
  19. # Directory used for temporary test files on the host.
  20. # TMPDIR is always provided by the build system as $OUT_DIR-unique temporary directory.
  21. ART_HOST_TEST_DIR := $(TMPDIR)/test-art
  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.
  24. ART_TEST_KNOWN_BROKEN :=
  25. # List of known failing tests that when executed won't cause test execution to not finish.
  26. # The test name must be the full rule name such as test-art-host-oat-optimizing-HelloWorld64.
  27. ART_TEST_KNOWN_FAILING :=
  28. # Keep going after encountering a test failure?
  29. ART_TEST_KEEP_GOING ?= true
  30. # Do you want run-test to be quieter? run-tests will only show output if they fail.
  31. ART_TEST_QUIET ?= true
  32. # Define the command run on test failure. $(1) is the name of the test. Executed by the shell.
  33. # If the test was a top-level make target (e.g. `test-art-host-gtest-codegen_test64`), the command
  34. # fails with exit status 1 (returned by the last `grep` statement below).
  35. # Otherwise (e.g., if the test was run as a prerequisite of a compound test command, such as
  36. # `test-art-host-gtest-codegen_test`), the command does not fail, as this would break rules running
  37. # ART_TEST_PREREQ_FINISHED as one of their actions, which expects *all* prerequisites *not* to fail.
  38. define ART_TEST_FAILED
  39. ( [ -f $(ART_HOST_TEST_DIR)/skipped/$(1) ] || \
  40. (mkdir -p $(ART_HOST_TEST_DIR)/failed/ && touch $(ART_HOST_TEST_DIR)/failed/$(1) && \
  41. echo $(ART_TEST_KNOWN_FAILING) | grep -q $(1) \
  42. && (echo -e "$(1) \e[91mKNOWN FAILURE\e[0m") \
  43. || (echo -e "$(1) \e[91mFAILED\e[0m" >&2; echo $(MAKECMDGOALS) | grep -q -v $(1))))
  44. endef
  45. ifeq ($(ART_TEST_QUIET),true)
  46. ART_TEST_ANNOUNCE_PASS := ( true )
  47. ART_TEST_ANNOUNCE_RUN := ( true )
  48. ART_TEST_ANNOUNCE_SKIP_FAILURE := ( true )
  49. ART_TEST_ANNOUNCE_SKIP_BROKEN := ( true )
  50. else
  51. # Note the use of '=' and not ':=' is intentional since these are actually functions.
  52. ART_TEST_ANNOUNCE_PASS = ( echo -e "$(1) \e[92mPASSED\e[0m" )
  53. ART_TEST_ANNOUNCE_RUN = ( echo -e "$(1) \e[95mRUNNING\e[0m")
  54. ART_TEST_ANNOUNCE_SKIP_FAILURE = ( echo -e "$(1) \e[93mSKIPPING DUE TO EARLIER FAILURE\e[0m" )
  55. ART_TEST_ANNOUNCE_SKIP_BROKEN = ( echo -e "$(1) \e[93mSKIPPING BROKEN TEST\e[0m" )
  56. endif
  57. # Define the command run on test success. $(1) is the name of the test. Executed by the shell.
  58. # The command checks prints "PASSED" then checks to see if this was a top-level make target (e.g.
  59. # "mm test-art-host-oat-HelloWorld32"), if it was then it does nothing, otherwise it creates a file
  60. # to be printed in the passing test summary.
  61. define ART_TEST_PASSED
  62. ( $(call ART_TEST_ANNOUNCE_PASS,$(1)) && \
  63. (echo $(MAKECMDGOALS) | grep -q $(1) || \
  64. (mkdir -p $(ART_HOST_TEST_DIR)/passed/ && touch $(ART_HOST_TEST_DIR)/passed/$(1))))
  65. endef
  66. # Define the command run on test success of multiple prerequisites. $(1) is the name of the test.
  67. # When the test is a top-level make target then a summary of the ran tests is produced. Executed by
  68. # the shell.
  69. define ART_TEST_PREREQ_FINISHED
  70. (echo -e "$(1) \e[32mCOMPLETE\e[0m" && \
  71. (echo $(MAKECMDGOALS) | grep -q -v $(1) || \
  72. (([ -d $(ART_HOST_TEST_DIR)/passed/ ] \
  73. && (echo -e "\e[92mPASSING TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/passed/) \
  74. || (echo -e "\e[91mNO TESTS PASSED\e[0m")) && \
  75. ([ -d $(ART_HOST_TEST_DIR)/skipped/ ] \
  76. && (echo -e "\e[93mSKIPPED TESTS\e[0m" && ls -1 $(ART_HOST_TEST_DIR)/skipped/) \
  77. || (echo -e "\e[92mNO TESTS SKIPPED\e[0m")) && \
  78. ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
  79. && (echo -e "\e[91mFAILING TESTS\e[0m" >&2 && ls -1 $(ART_HOST_TEST_DIR)/failed/ >&2) \
  80. || (echo -e "\e[92mNO TESTS FAILED\e[0m")) \
  81. && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] && rm -r $(ART_HOST_TEST_DIR) \
  82. || (rm -r $(ART_HOST_TEST_DIR) && false)))))
  83. endef
  84. # Define the command executed by the shell ahead of running an art test. $(1) is the name of the
  85. # test.
  86. define ART_TEST_SKIP
  87. ((echo $(ART_TEST_KNOWN_BROKEN) | grep -q -v $(1) \
  88. && ([ ! -d $(ART_HOST_TEST_DIR)/failed/ ] || [ $(ART_TEST_KEEP_GOING) = true ])\
  89. && $(call ART_TEST_ANNOUNCE_RUN,$(1)) ) \
  90. || ((mkdir -p $(ART_HOST_TEST_DIR)/skipped/ && touch $(ART_HOST_TEST_DIR)/skipped/$(1) \
  91. && ([ -d $(ART_HOST_TEST_DIR)/failed/ ] \
  92. && $(call ART_TEST_ANNOUNCE_SKIP_FAILURE,$(1)) ) \
  93. || $(call ART_TEST_ANNOUNCE_SKIP_BROKEN,$(1)) ) && false))
  94. endef
  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
  100. # $(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
  102. #
  103. # If the input test directory contains a file called main.list,
  104. # then a multi-dex file is created passing main.list as the --main-dex-list
  105. # argument to dx.
  106. define build-art-test-dex
  107. ifeq ($(ART_BUILD_TARGET),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_MODULE_TAGS := tests
  115. LOCAL_JAVA_LIBRARIES := $(TARGET_TEST_CORE_JARS)
  116. LOCAL_MODULE_PATH := $(3)
  117. ifneq ($(wildcard $(LOCAL_PATH)/$(2)/main.list),)
  118. LOCAL_MIN_SDK_VERSION := 19
  119. LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(LOCAL_PATH)/$(2)/main.list --minimal-main-dex
  120. endif
  121. include $(BUILD_JAVA_LIBRARY)
  122. $(5) := $$(LOCAL_INSTALLED_MODULE)
  123. endif
  124. ifeq ($(ART_BUILD_HOST),true)
  125. include $(CLEAR_VARS)
  126. LOCAL_MODULE := $(1)-$(2)
  127. LOCAL_SRC_FILES := $(call all-java-files-under, $(2))
  128. LOCAL_NO_STANDARD_LIBRARIES := true
  129. LOCAL_DEX_PREOPT := false
  130. LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_test.mk $(4)
  131. LOCAL_JAVA_LIBRARIES := $(HOST_TEST_CORE_JARS)
  132. ifneq ($(wildcard $(LOCAL_PATH)/$(2)/main.list),)
  133. LOCAL_MIN_SDK_VERSION := 19
  134. LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(LOCAL_PATH)/$(2)/main.list --minimal-main-dex
  135. endif
  136. include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
  137. $(6) := $$(LOCAL_INSTALLED_MODULE)
  138. endif
  139. endef
  140. endif # ART_ANDROID_COMMON_TEST_MK