From 26efd3a8d18bd5d12b82f361da5042b7c1a059a4 Mon Sep 17 00:00:00 2001 From: Dan Shi Date: Mon, 13 Nov 2017 13:38:17 -0800 Subject: [PATCH] Add build script to generate TF test XML file with filters Bug: 68270274 Test: run 'atest' in frameworks/base Change-Id: I99b741fae18997caa6aefbd3ab804e5d30e7ae36 --- core/clear_vars.mk | 1 + core/config.mk | 2 ++ core/definitions.mk | 4 ++- core/envsetup.mk | 3 ++ core/host_test_config.mk | 25 +++++++++++++++++ core/target_test_config.mk | 23 ++++++++++++++++ core/test_config_common.mk | 56 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 core/host_test_config.mk create mode 100644 core/target_test_config.mk create mode 100644 core/test_config_common.mk diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 1e64c4f3b..7863c7d57 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -236,6 +236,7 @@ LOCAL_STATIC_LIBRARIES:= LOCAL_STRIP_MODULE:= LOCAL_SYSTEM_SHARED_LIBRARIES:=none LOCAL_TARGET_REQUIRED_MODULES:= +LOCAL_TEST_CONFIG_OPTIONS:= LOCAL_TEST_DATA:= LOCAL_TEST_MODULE_TO_PROGUARD_WITH:= LOCAL_TIDY:= diff --git a/core/config.mk b/core/config.mk index 232f1d057..cbafd5026 100644 --- a/core/config.mk +++ b/core/config.mk @@ -135,6 +135,8 @@ BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk BUILD_HOST_DALVIK_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_java_library.mk BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk +BUILD_HOST_TEST_CONFIG:= $(BUILD_SYSTEM)/host_test_config.mk +BUILD_TARGET_TEST_CONFIG:= $(BUILD_SYSTEM)/target_test_config.mk # ############################################################### # Parse out any modifier targets. diff --git a/core/definitions.mk b/core/definitions.mk index c7799b07a..23d8648bb 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -3018,7 +3018,9 @@ STATS.MODULE_TYPE := \ HOST_DALVIK_JAVA_LIBRARY \ HOST_DALVIK_STATIC_JAVA_LIBRARY \ base_rules \ - HEADER_LIBRARY + HEADER_LIBRARY \ + HOST_TEST_CONFIG \ + TARGET_TEST_CONFIG $(foreach s,$(STATS.MODULE_TYPE),$(eval STATS.MODULE_TYPE.$(s) :=)) define record-module-type diff --git a/core/envsetup.mk b/core/envsetup.mk index ddf903c36..509e7f65c 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -382,6 +382,8 @@ HOST_OUT_COMMON_GEN := $(HOST_COMMON_OUT_ROOT)/gen HOST_CROSS_OUT_GEN := $(HOST_CROSS_OUT)/gen +HOST_OUT_TEST_CONFIG := $(HOST_OUT)/test_config + # Out for HOST_2ND_ARCH HOST_2ND_ARCH_VAR_PREFIX := 2ND_ HOST_2ND_ARCH_MODULE_SUFFIX := _32 @@ -457,6 +459,7 @@ TARGET_OUT_ETC := $(TARGET_OUT)/etc TARGET_OUT_NOTICE_FILES := $(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages TARGET_OUT_TESTCASES := $(PRODUCT_OUT)/testcases +TARGET_OUT_TEST_CONFIG := $(PRODUCT_OUT)/test_config ifeq ($(SANITIZE_LITE),true) # When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not diff --git a/core/host_test_config.mk b/core/host_test_config.mk new file mode 100644 index 000000000..b9975e54e --- /dev/null +++ b/core/host_test_config.mk @@ -0,0 +1,25 @@ +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Common rules for building a TradeFed test XML file for host side tests. +# + +$(call record-module-type,HOST_TEST_CONFIG) + +LOCAL_IS_HOST_MODULE := true + +include $(BUILD_SYSTEM)/test_config_common.mk diff --git a/core/target_test_config.mk b/core/target_test_config.mk new file mode 100644 index 000000000..61f5d2b2e --- /dev/null +++ b/core/target_test_config.mk @@ -0,0 +1,23 @@ +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Common rules for building a TradeFed test XML file for target side tests. +# + +$(call record-module-type,TARGET_TEST_CONFIG) + +include $(BUILD_SYSTEM)/test_config_common.mk diff --git a/core/test_config_common.mk b/core/test_config_common.mk new file mode 100644 index 000000000..487f9f227 --- /dev/null +++ b/core/test_config_common.mk @@ -0,0 +1,56 @@ +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_MODULE_CLASS := TEST_CONFIG + +# Output test config files to testcases directory. +ifeq (,$(filter general-tests, $(LOCAL_COMPATIBILITY_SUITE))) + LOCAL_COMPATIBILITY_SUITE += general-tests +endif + +LOCAL_MODULE_SUFFIX := .config + +my_test_config_file := $(wildcard $(LOCAL_PATH)/$(LOCAL_MODULE).xml) +LOCAL_SRC_FILES := + +include $(BUILD_SYSTEM)/base_rules.mk + +# The test config is not in a standalone XML file. +ifndef my_test_config_file + +ifndef LOCAL_TEST_CONFIG_OPTIONS + $(call pretty-error,LOCAL_TEST_CONFIG_OPTIONS must be set if the test XML file is not provided.) +endif + +my_base_test_config_file := $(LOCAL_PATH)/AndroidTest.xml +my_test_config_file := $(dir $(LOCAL_BUILT_MODULE))AndroidTest.xml + +$(my_test_config_file) : PRIVATE_test_config_options := $(LOCAL_TEST_CONFIG_OPTIONS) +$(my_test_config_file) : $(my_base_test_config_file) + @echo "Create $(notdir $@) with options: $(PRIVATE_test_config_options)." + $(eval _option_xml := \ + $(foreach option,$(PRIVATE_test_config_options), \ + $(eval p := $(subst :,$(space),$(option))) \ +