Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2017 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 | # This build rule allows TradeFed test config file to be created based on |
| 18 | # following inputs: |
| 19 | # is_native: If the test is a native test. |
Colin Cross | 1c3d83b | 2018-05-17 12:49:08 -0700 | [diff] [blame] | 20 | # full_android_manifest: Name of the AndroidManifest file for the test. |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 21 | # Output: |
| 22 | # autogen_test_config_file: Path to the test config file generated. |
| 23 | |
| 24 | autogen_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config |
Guang Zhu | 97278c1 | 2021-09-22 04:19:19 +0000 | [diff] [blame] | 25 | # TODO: (b/167308193) Switch to /data/local/tests/unrestricted as the default install base. |
| 26 | autogen_test_install_base := /data/local/tmp |
yangbill | 85146e5 | 2020-08-13 16:14:30 +0800 | [diff] [blame] | 27 | # Automatically setup test root for native test. |
| 28 | ifeq (true,$(is_native)) |
| 29 | ifeq (true,$(LOCAL_VENDOR_MODULE)) |
| 30 | autogen_test_install_base = /data/local/tests/vendor |
| 31 | endif |
Kiyoung Kim | 454265c | 2024-02-05 10:22:04 +0900 | [diff] [blame] | 32 | ifeq (true,$(call module-in-vendor-or-product)) |
yangbill | 85146e5 | 2020-08-13 16:14:30 +0800 | [diff] [blame] | 33 | autogen_test_install_base = /data/local/tests/vendor |
| 34 | endif |
| 35 | endif |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 36 | ifeq (true,$(is_native)) |
Nelson Li | eec9529 | 2018-04-18 17:51:58 +0000 | [diff] [blame] | 37 | ifeq ($(LOCAL_NATIVE_BENCHMARK),true) |
| 38 | autogen_test_config_template := $(NATIVE_BENCHMARK_TEST_CONFIG_TEMPLATE) |
| 39 | else |
yangbill | 976c80a | 2018-06-20 22:37:19 +0800 | [diff] [blame] | 40 | ifeq ($(LOCAL_IS_HOST_MODULE),true) |
| 41 | autogen_test_config_template := $(NATIVE_HOST_TEST_CONFIG_TEMPLATE) |
| 42 | else |
| 43 | autogen_test_config_template := $(NATIVE_TEST_CONFIG_TEMPLATE) |
| 44 | endif |
Nelson Li | eec9529 | 2018-04-18 17:51:58 +0000 | [diff] [blame] | 45 | endif |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 46 | # Auto generating test config file for native test |
yangbill | 85146e5 | 2020-08-13 16:14:30 +0800 | [diff] [blame] | 47 | $(autogen_test_config_file): PRIVATE_TEST_INSTALL_BASE := $(autogen_test_install_base) |
yangbill | 86f441d | 2018-07-13 22:55:36 +0800 | [diff] [blame] | 48 | $(autogen_test_config_file): PRIVATE_MODULE_NAME := $(LOCAL_MODULE) |
Nelson Li | eec9529 | 2018-04-18 17:51:58 +0000 | [diff] [blame] | 49 | $(autogen_test_config_file) : $(autogen_test_config_template) |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 50 | @echo "Auto generating test config $(notdir $@)" |
yangbill | 85146e5 | 2020-08-13 16:14:30 +0800 | [diff] [blame] | 51 | $(hide) sed 's&{MODULE}&$(PRIVATE_MODULE_NAME)&g;s&{TEST_INSTALL_BASE}&$(PRIVATE_TEST_INSTALL_BASE)&g;s&{EXTRA_CONFIGS}&&g' $< > $@ |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 52 | my_auto_generate_config := true |
| 53 | else |
| 54 | # Auto generating test config file for instrumentation test |
Colin Cross | 1c3d83b | 2018-05-17 12:49:08 -0700 | [diff] [blame] | 55 | ifneq (,$(full_android_manifest)) |
Dan Shi | 2b334f5 | 2017-12-22 20:23:22 -0800 | [diff] [blame] | 56 | $(autogen_test_config_file): PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT := $(AUTOGEN_TEST_CONFIG_SCRIPT) |
Colin Cross | 1c3d83b | 2018-05-17 12:49:08 -0700 | [diff] [blame] | 57 | $(autogen_test_config_file): PRIVATE_TEST_CONFIG_ANDROID_MANIFEST := $(full_android_manifest) |
Dan Shi | 2b334f5 | 2017-12-22 20:23:22 -0800 | [diff] [blame] | 58 | $(autogen_test_config_file): PRIVATE_EMPTY_TEST_CONFIG := $(EMPTY_TEST_CONFIG) |
| 59 | $(autogen_test_config_file): PRIVATE_TEMPLATE := $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE) |
Colin Cross | 1c3d83b | 2018-05-17 12:49:08 -0700 | [diff] [blame] | 60 | $(autogen_test_config_file) : $(full_android_manifest) $(EMPTY_TEST_CONFIG) $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE) $(AUTOGEN_TEST_CONFIG_SCRIPT) |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 61 | @echo "Auto generating test config $(notdir $@)" |
| 62 | @rm -f $@ |
Dan Shi | 2b334f5 | 2017-12-22 20:23:22 -0800 | [diff] [blame] | 63 | $(hide) $(PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT) $@ $(PRIVATE_TEST_CONFIG_ANDROID_MANIFEST) $(PRIVATE_EMPTY_TEST_CONFIG) $(PRIVATE_TEMPLATE) |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 64 | my_auto_generate_config := true |
Colin Cross | 1c3d83b | 2018-05-17 12:49:08 -0700 | [diff] [blame] | 65 | endif # ifneq (,$(full_android_manifest)) |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 66 | endif # ifneq (true,$(is_native)) |
| 67 | |
| 68 | ifeq (true,$(my_auto_generate_config)) |
| 69 | LOCAL_INTERMEDIATE_TARGETS += $(autogen_test_config_file) |
| 70 | $(LOCAL_BUILT_MODULE): $(autogen_test_config_file) |
| 71 | ALL_MODULES.$(my_register_name).auto_test_config := true |
yangbill | 86f441d | 2018-07-13 22:55:36 +0800 | [diff] [blame] | 72 | $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_autogen := true |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 73 | else |
| 74 | autogen_test_config_file := |
| 75 | endif |
| 76 | |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 77 | my_auto_generate_config := |