Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c28ff7b authored by Dan Shi's avatar Dan Shi Committed by Gerrit Code Review
Browse files

Merge "Auto generate test config files"

parents 5ded3995 efb892d8
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
#
# 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.
#

# This build rule allows TradeFed test config file to be created based on
# following inputs:
#   is_native: If the test is a native test.
#   LOCAL_MANIFEST_FILE: Name of the AndroidManifest file for the test. If it's
#       not set, default value `AndroidManifest.xml` will be used.
# Output:
#   autogen_test_config_file: Path to the test config file generated.

autogen_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config
ifeq (true,$(is_native))
# Auto generating test config file for native test
$(autogen_test_config_file) : $(NATIVE_TEST_CONFIG_TEMPLATE)
	@echo "Auto generating test config $(notdir $@)"
	$(hide) sed 's&{MODULE}&$(PRIVATE_MODULE)&g' $^ > $@
my_auto_generate_config := true
else
# Auto generating test config file for instrumentation test
ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
  LOCAL_MANIFEST_FILE := AndroidManifest.xml
endif
ifdef LOCAL_FULL_MANIFEST_FILE
  my_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
else
  my_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
endif
ifneq (,$(wildcard $(my_android_manifest)))
$(autogen_test_config_file) : $(my_android_manifest) $(EMPTY_TEST_CONFIG) $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE)
	@echo "Auto generating test config $(notdir $@)"
	@rm -f $@
	$(hide) $(AUTOGEN_TEST_CONFIG_SCRIPT) $@ $^
my_auto_generate_config := true
endif # ifeq (,$(wildcard $(my_android_manifest)))
endif # ifneq (true,$(is_native))

ifeq (true,$(my_auto_generate_config))
  LOCAL_INTERMEDIATE_TARGETS += $(autogen_test_config_file)
  $(LOCAL_BUILT_MODULE): $(autogen_test_config_file)
  ALL_MODULES.$(my_register_name).auto_test_config := true
else
  autogen_test_config_file :=
endif

my_android_manifest :=
my_auto_generate_config :=
+27 −3
Original line number Diff line number Diff line
@@ -510,7 +510,6 @@ ifdef LOCAL_MULTILIB
endif
ifdef is_native
  arch_dir := /$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
  is_native :=
endif

# The module itself.
@@ -531,13 +530,35 @@ $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
    $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
      $(s):$(dir)/$(n)))))

test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml)
ifeq (,$(test_config))
  ifneq (true,$(is_native))
    is_instrumentation_test := true
    ifeq (true, $(LOCAL_IS_HOST_MODULE))
      is_instrumentation_test := false
    endif
  endif
  # CTS modules can be used for test data, so test config files must be
  # explicitly created using AndroidTest.xml
  ifeq (,$(filter cts, $(LOCAL_COMPATIBILITY_SUITE)))
    ifeq (true, $(filter true,$(is_native) $(is_instrumentation_test)))
      include $(BUILD_SYSTEM)/autogen_test_config.mk
      test_config := $(autogen_test_config_file)
      autogen_test_config_file :=
    endif
  endif
endif

ifneq (,$(wildcard $(LOCAL_PATH)/AndroidTest.xml))
is_instrumentation_test :=

ifneq (,$(test_config))
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
  $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
    $(LOCAL_PATH)/AndroidTest.xml:$(dir)/$(LOCAL_MODULE).config)))
    $(test_config):$(dir)/$(LOCAL_MODULE).config)))
endif

test_config :=

ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml))
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
  $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
@@ -552,6 +573,9 @@ $(foreach extra_config, $(wildcard $(LOCAL_PATH)/$(LOCAL_MODULE)_*.config), \
endif
endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files

arch_dir :=
is_native :=

ifneq ($(my_test_data_file_pairs),)
$(foreach pair, $(my_test_data_file_pairs), \
  $(eval parts := $(subst :,$(space),$(pair))) \
+9 −2
Original line number Diff line number Diff line
@@ -159,6 +159,13 @@ BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_static_java
BUILD_HOST_TEST_CONFIG := $(BUILD_SYSTEM)/host_test_config.mk
BUILD_TARGET_TEST_CONFIG := $(BUILD_SYSTEM)/target_test_config.mk

INSTRUMENTATION_TEST_CONFIG_TEMPLATE := $(BUILD_SYSTEM)/instrumentation_test_config_template.xml
NATIVE_TEST_CONFIG_TEMPLATE := $(BUILD_SYSTEM)/native_test_config_template.xml
EMPTY_TEST_CONFIG := $(BUILD_SYSTEM)/empty_test_config.xml

# Tool to generate TradeFed test config file automatically.
AUTOGEN_TEST_CONFIG_SCRIPT := build/make/tools/auto_gen_test_config.py

# ###############################################################
# Parse out any modifier targets.
# ###############################################################
+19 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<!-- No AndroidTest.xml was provided and the manifest does not include
     instrumentation, hence this apk is not instrumentable.
-->
<configuration description="Empty Configuration" />
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<!-- This test config file is auto-generated. -->
<configuration description="Runs {LABEL}.">
    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="test-file-name" value="{MODULE}.apk" />
    </target_preparer>

    <test class="com.android.tradefed.testtype.{TEST_TYPE}" >
        <option name="package" value="{PACKAGE}" />
        <option name="runner" value="{RUNNER}" />
    </test>
</configuration>
Loading