1# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15.PHONY: general-tests
16
17general_tests_tools := \
18    $(HOST_OUT_JAVA_LIBRARIES)/cts-tradefed.jar \
19    $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar \
20    $(HOST_OUT_JAVA_LIBRARIES)/vts-tradefed.jar \
21
22intermediates_dir := $(call intermediates-dir-for,PACKAGING,general-tests)
23general_tests_zip := $(PRODUCT_OUT)/general-tests.zip
24# Create an artifact to include a list of test config files in general-tests.
25general_tests_list_zip := $(PRODUCT_OUT)/general-tests_list.zip
26
27# Create an artifact to include all test config files in general-tests.
28general_tests_configs_zip := $(PRODUCT_OUT)/general-tests_configs.zip
29
30# Copy kernel test modules to testcases directories
31include $(BUILD_SYSTEM)/tasks/tools/vts-kernel-tests.mk
32ltp_copy_pairs := \
33  $(call target-native-copy-pairs,$(kernel_ltp_modules),$(kernel_ltp_host_out))
34copy_ltp_tests := $(call copy-many-files,$(ltp_copy_pairs))
35
36# PHONY target to be used to build and test `vts_ltp_tests` without building full vts
37.PHONY: vts_kernel_ltp_tests
38vts_kernel_ltp_tests: $(copy_ltp_tests)
39
40general_tests_shared_libs_zip := $(PRODUCT_OUT)/general-tests_host-shared-libs.zip
41
42$(general_tests_zip) : $(general_tests_shared_libs_zip)
43$(general_tests_zip) : $(copy_ltp_tests)
44$(general_tests_zip) : PRIVATE_KERNEL_LTP_HOST_OUT := $(kernel_ltp_host_out)
45$(general_tests_zip) : PRIVATE_general_tests_list_zip := $(general_tests_list_zip)
46$(general_tests_zip) : .KATI_IMPLICIT_OUTPUTS := $(general_tests_list_zip) $(general_tests_configs_zip)
47$(general_tests_zip) : PRIVATE_TOOLS := $(general_tests_tools)
48$(general_tests_zip) : PRIVATE_INTERMEDIATES_DIR := $(intermediates_dir)
49$(general_tests_zip) : PRIVATE_general_tests_configs_zip := $(general_tests_configs_zip)
50$(general_tests_zip) : $(COMPATIBILITY.general-tests.FILES) $(COMPATIBILITY.general-tests.SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES) $(general_tests_tools) $(SOONG_ZIP)
51	rm -rf $(PRIVATE_INTERMEDIATES_DIR)
52	rm -f $@ $(PRIVATE_general_tests_list_zip)
53	mkdir -p $(PRIVATE_INTERMEDIATES_DIR) $(PRIVATE_INTERMEDIATES_DIR)/tools
54	echo $(sort $(COMPATIBILITY.general-tests.FILES) $(COMPATIBILITY.general-tests.SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES)) | tr " " "\n" > $(PRIVATE_INTERMEDIATES_DIR)/list
55	find $(PRIVATE_KERNEL_LTP_HOST_OUT) >> $(PRIVATE_INTERMEDIATES_DIR)/list
56	grep $(HOST_OUT_TESTCASES) $(PRIVATE_INTERMEDIATES_DIR)/list > $(PRIVATE_INTERMEDIATES_DIR)/host.list || true
57	grep $(TARGET_OUT_TESTCASES) $(PRIVATE_INTERMEDIATES_DIR)/list > $(PRIVATE_INTERMEDIATES_DIR)/target.list || true
58	grep -e .*\\.config$$ $(PRIVATE_INTERMEDIATES_DIR)/host.list > $(PRIVATE_INTERMEDIATES_DIR)/host-test-configs.list || true
59	grep -e .*\\.config$$ $(PRIVATE_INTERMEDIATES_DIR)/target.list > $(PRIVATE_INTERMEDIATES_DIR)/target-test-configs.list || true
60	cp -fp $(PRIVATE_TOOLS) $(PRIVATE_INTERMEDIATES_DIR)/tools/
61	$(SOONG_ZIP) -d -o $@ \
62	  -P host -C $(PRIVATE_INTERMEDIATES_DIR) -D $(PRIVATE_INTERMEDIATES_DIR)/tools \
63	  -P host -C $(HOST_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/host.list \
64	  -P target -C $(PRODUCT_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/target.list \
65	  -sha256
66	$(SOONG_ZIP) -d -o $(PRIVATE_general_tests_configs_zip) \
67	  -P host -C $(HOST_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/host-test-configs.list \
68	  -P target -C $(PRODUCT_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/target-test-configs.list
69	grep -e .*\\.config$$ $(PRIVATE_INTERMEDIATES_DIR)/host.list | sed s%$(HOST_OUT)%host%g > $(PRIVATE_INTERMEDIATES_DIR)/general-tests_list
70	grep -e .*\\.config$$ $(PRIVATE_INTERMEDIATES_DIR)/target.list | sed s%$(PRODUCT_OUT)%target%g >> $(PRIVATE_INTERMEDIATES_DIR)/general-tests_list
71	$(SOONG_ZIP) -d -o $(PRIVATE_general_tests_list_zip) -C $(PRIVATE_INTERMEDIATES_DIR) -f $(PRIVATE_INTERMEDIATES_DIR)/general-tests_list
72
73general-tests: $(general_tests_zip)
74$(call dist-for-goals, general-tests, $(general_tests_zip) $(general_tests_list_zip) $(general_tests_configs_zip) $(general_tests_shared_libs_zip))
75
76$(call declare-1p-container,$(general_tests_zip),)
77$(call declare-container-license-deps,$(general_tests_zip),$(COMPATIBILITY.general-tests.FILES) $(general_tests_tools),$(PRODUCT_OUT)/:/)
78
79intermediates_dir :=
80general_tests_tools :=
81general_tests_zip :=
82general_tests_list_zip :=
83general_tests_configs_zip :=
84general_tests_shared_libs_zip :=
85