From c9347b31670c3ee629ffd0a96c29e024344c45d4 Mon Sep 17 00:00:00 2001 From: yangbill Date: Thu, 23 Aug 2018 23:04:37 +0800 Subject: [PATCH] Atest: add LOCAL_TEST_CONFIG to module_info.json Bug: 112335032 Test: 1. Add LOCAL_TEST_CONFIG := ahat-tests.xml in art/tools/ahat/Android.mk for ahat-tests 2. add ahat-tests.xml in local 3. atest -m hello_world_test 4. check module_info.json local_full_test_config": ["art/tools/ahat/ahat-tests.xml"] Change-Id: Ice2a0c85979fa6b872c92aea5ff4a340342408ad --- core/base_rules.mk | 87 +++++++++++++++++++-------------------- core/tasks/module-info.mk | 1 + 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 3a1f39698c..7d96224621 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -573,6 +573,42 @@ $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ $(eval my_compat_dist_config_$(suite) := )) +# Auto-generate build config. +ifneq (,$(LOCAL_FULL_TEST_CONFIG)) + test_config := $(LOCAL_FULL_TEST_CONFIG) +else ifneq (,$(LOCAL_TEST_CONFIG)) + test_config := $(LOCAL_PATH)/$(LOCAL_TEST_CONFIG) +else + test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml) +endif +ifeq (,$(test_config)) + ifneq (true,$(is_native)) + is_instrumentation_test := true + ifeq (true, $(LOCAL_IS_HOST_MODULE)) + is_instrumentation_test := false + endif + # If LOCAL_MODULE_CLASS is not APPS, it's certainly not an instrumentation + # test. However, some packages for test data also have LOCAL_MODULE_CLASS + # set to APPS. These will require flag LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG + # to disable auto-generating test config file. + ifneq (APPS, $(LOCAL_MODULE_CLASS)) + 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))) + ifneq (true, $(LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG)) + 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 +endif +is_instrumentation_test := + # Make sure we only add the files once for multilib modules. ifdef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files # Sync the auto_test_config value for multilib modules. @@ -589,41 +625,6 @@ else $(eval n := $(or $(word 2,$(p)),$(notdir $(word 1, $(p))))) \ $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \ $(s):$(dir)/$(n))))) - ifneq (,$(LOCAL_FULL_TEST_CONFIG)) - test_config := $(LOCAL_FULL_TEST_CONFIG) - else ifneq (,$(LOCAL_TEST_CONFIG)) - test_config := $(LOCAL_PATH)/$(LOCAL_TEST_CONFIG) - else - test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml) - endif - ifeq (,$(test_config)) - ifneq (true,$(is_native)) - is_instrumentation_test := true - ifeq (true, $(LOCAL_IS_HOST_MODULE)) - is_instrumentation_test := false - endif - # If LOCAL_MODULE_CLASS is not APPS, it's certainly not an instrumentation - # test. However, some packages for test data also have LOCAL_MODULE_CLASS - # set to APPS. These will require flag LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG - # to disable auto-generating test config file. - ifneq (APPS, $(LOCAL_MODULE_CLASS)) - 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))) - ifneq (true, $(LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG)) - 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 - endif - - is_instrumentation_test := ifneq (,$(test_config)) $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ @@ -631,8 +632,6 @@ else $(test_config):$(dir)/$(LOCAL_MODULE).config))) endif - test_config := - ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml)) $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ $(eval my_compat_dist_config_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \ @@ -647,19 +646,17 @@ else endif endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files -# HACK: pretend a soong LOCAL_FULL_TEST_CONFIG is autogenerated by copying it to -# the location autogenerated test configs use and setting the flag in +# HACK: pretend a soong LOCAL_FULL_TEST_CONFIG is autogenerated by setting the flag in # module-info.json -ifdef LOCAL_FULL_TEST_CONFIG +# TODO: (b/113029686) Add explicit flag from Soong to determine if a test was +# autogenerated. +ifneq (,$(filter $(SOONG_OUT_DIR)%,$(LOCAL_FULL_TEST_CONFIG))) ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) - my_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config - $(eval $(call copy-one-file,$(LOCAL_FULL_TEST_CONFIG),$(my_test_config_file))) - $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_test_config_file)) ALL_MODULES.$(my_register_name).auto_test_config := true - my_test_config_file := endif endif + ifneq ($(my_test_data_file_pairs),) $(foreach pair, $(my_test_data_file_pairs), \ $(eval parts := $(subst :,$(space),$(pair))) \ @@ -771,6 +768,8 @@ endif ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross) ALL_MODULES.$(my_register_name).MODULE_NAME := $(LOCAL_MODULE) ALL_MODULES.$(my_register_name).COMPATIBILITY_SUITES := $(LOCAL_COMPATIBILITY_SUITE) +ALL_MODULES.$(my_register_name).TEST_CONFIG := $(test_config) +test_config := INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name) diff --git a/core/tasks/module-info.mk b/core/tasks/module-info.mk index 38149d7a96..37e48318c3 100644 --- a/core/tasks/module-info.mk +++ b/core/tasks/module-info.mk @@ -14,6 +14,7 @@ $(MODULE_INFO_JSON): '"compatibility_suites": [$(foreach w,$(sort $(ALL_MODULES.$(m).COMPATIBILITY_SUITES)),"$(w)", )], ' \ '"auto_test_config": [$(ALL_MODULES.$(m).auto_test_config)], ' \ '"module_name": ["$(ALL_MODULES.$(m).MODULE_NAME)"], ' \ + '"test_config": [$(if $(ALL_MODULES.$(m).TEST_CONFIG),"$(ALL_MODULES.$(m).TEST_CONFIG)")], ' \ '},\n' \ ) | sed -e 's/, *\]/]/g' -e 's/, *\}/ }/g' -e '$$s/,$$//' >> $@ $(hide) echo '}' >> $@