blob: 798dd5f5b5cded0941be0cd6412d5b9310424610 [file] [log] [blame]
Dan Shiefb892d2017-12-06 15:57:31 -08001#
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 Cross1c3d83b2018-05-17 12:49:08 -070020# full_android_manifest: Name of the AndroidManifest file for the test.
Dan Shiefb892d2017-12-06 15:57:31 -080021# Output:
22# autogen_test_config_file: Path to the test config file generated.
23
24autogen_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config
Guang Zhua736c452021-09-14 10:58:14 -070025autogen_test_install_base := /data/local/tests/unrestricted
yangbill85146e52020-08-13 16:14:30 +080026# Automatically setup test root for native test.
27ifeq (true,$(is_native))
28 ifeq (true,$(LOCAL_VENDOR_MODULE))
29 autogen_test_install_base = /data/local/tests/vendor
30 endif
31 ifeq (true,$(LOCAL_USE_VNDK))
32 autogen_test_install_base = /data/local/tests/vendor
33 endif
34endif
Dan Shiefb892d2017-12-06 15:57:31 -080035ifeq (true,$(is_native))
Nelson Lieec95292018-04-18 17:51:58 +000036ifeq ($(LOCAL_NATIVE_BENCHMARK),true)
37autogen_test_config_template := $(NATIVE_BENCHMARK_TEST_CONFIG_TEMPLATE)
38else
yangbill976c80a2018-06-20 22:37:19 +080039 ifeq ($(LOCAL_IS_HOST_MODULE),true)
40 autogen_test_config_template := $(NATIVE_HOST_TEST_CONFIG_TEMPLATE)
41 else
42 autogen_test_config_template := $(NATIVE_TEST_CONFIG_TEMPLATE)
43 endif
Nelson Lieec95292018-04-18 17:51:58 +000044endif
Dan Shiefb892d2017-12-06 15:57:31 -080045# Auto generating test config file for native test
yangbill85146e52020-08-13 16:14:30 +080046$(autogen_test_config_file): PRIVATE_TEST_INSTALL_BASE := $(autogen_test_install_base)
yangbill86f441d2018-07-13 22:55:36 +080047$(autogen_test_config_file): PRIVATE_MODULE_NAME := $(LOCAL_MODULE)
Nelson Lieec95292018-04-18 17:51:58 +000048$(autogen_test_config_file) : $(autogen_test_config_template)
Dan Shiefb892d2017-12-06 15:57:31 -080049 @echo "Auto generating test config $(notdir $@)"
yangbill85146e52020-08-13 16:14:30 +080050 $(hide) sed 's&{MODULE}&$(PRIVATE_MODULE_NAME)&g;s&{TEST_INSTALL_BASE}&$(PRIVATE_TEST_INSTALL_BASE)&g;s&{EXTRA_CONFIGS}&&g' $< > $@
Dan Shiefb892d2017-12-06 15:57:31 -080051my_auto_generate_config := true
52else
53# Auto generating test config file for instrumentation test
Colin Cross1c3d83b2018-05-17 12:49:08 -070054ifneq (,$(full_android_manifest))
Dan Shi2b334f52017-12-22 20:23:22 -080055$(autogen_test_config_file): PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT := $(AUTOGEN_TEST_CONFIG_SCRIPT)
Colin Cross1c3d83b2018-05-17 12:49:08 -070056$(autogen_test_config_file): PRIVATE_TEST_CONFIG_ANDROID_MANIFEST := $(full_android_manifest)
Dan Shi2b334f52017-12-22 20:23:22 -080057$(autogen_test_config_file): PRIVATE_EMPTY_TEST_CONFIG := $(EMPTY_TEST_CONFIG)
58$(autogen_test_config_file): PRIVATE_TEMPLATE := $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE)
Colin Cross1c3d83b2018-05-17 12:49:08 -070059$(autogen_test_config_file) : $(full_android_manifest) $(EMPTY_TEST_CONFIG) $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE) $(AUTOGEN_TEST_CONFIG_SCRIPT)
Dan Shiefb892d2017-12-06 15:57:31 -080060 @echo "Auto generating test config $(notdir $@)"
61 @rm -f $@
Dan Shi2b334f52017-12-22 20:23:22 -080062 $(hide) $(PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT) $@ $(PRIVATE_TEST_CONFIG_ANDROID_MANIFEST) $(PRIVATE_EMPTY_TEST_CONFIG) $(PRIVATE_TEMPLATE)
Dan Shiefb892d2017-12-06 15:57:31 -080063my_auto_generate_config := true
Colin Cross1c3d83b2018-05-17 12:49:08 -070064endif # ifneq (,$(full_android_manifest))
Dan Shiefb892d2017-12-06 15:57:31 -080065endif # ifneq (true,$(is_native))
66
67ifeq (true,$(my_auto_generate_config))
68 LOCAL_INTERMEDIATE_TARGETS += $(autogen_test_config_file)
69 $(LOCAL_BUILT_MODULE): $(autogen_test_config_file)
70 ALL_MODULES.$(my_register_name).auto_test_config := true
yangbill86f441d2018-07-13 22:55:36 +080071 $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_autogen := true
Dan Shiefb892d2017-12-06 15:57:31 -080072else
73 autogen_test_config_file :=
74endif
75
Dan Shiefb892d2017-12-06 15:57:31 -080076my_auto_generate_config :=