blob: f205cea15633932e49b261a96618649e19a87b2a [file] [log] [blame]
Stuart Scott1926e9b2015-06-03 17:42:39 -07001# Copyright (C) 2015 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# Package up a compatibility test suite in a zip file.
16#
17# Input variables:
18# test_suite_name: the name of this test suite eg. cts
19# test_suite_tradefed: the name of this test suite's tradefed wrapper
Aaron Holdenaee6f602015-12-15 15:04:01 -080020# test_suite_dynamic_config: the path to this test suite's dynamic configuration file
Stuart Scott1926e9b2015-06-03 17:42:39 -070021# test_suite_readme: the path to a README file for this test suite
Todd Leebae7ee52017-06-01 08:00:32 -070022# test_suite_prebuilt_tools: the set of prebuilt tools to be included directly
23# in the 'tools' subdirectory of the test suite.
Siyuan Zhou18883152017-11-20 17:26:40 -080024# test_suite_tools: the set of tools for this test suite
25#
Stuart Scott1926e9b2015-06-03 17:42:39 -070026# Output variables:
27# compatibility_zip: the path to the output zip file.
28
Tongbo Liuca0ace32024-01-10 21:59:22 +080029special_mts_test_suites :=
Tongbo Liu361333e2024-01-18 16:56:45 +080030special_mts_test_suites += $(mts_modules)
Yihan Dongb89bb9d2024-06-07 12:02:03 +080031ifneq ($(filter $(special_mts_test_suites),$(patsubst mcts-%,%,$(test_suite_name))),)
32 test_suite_subdir := android-mts
33else ifneq ($(filter $(special_mts_test_suites),$(patsubst mts-%,%,$(test_suite_name))),)
Tongbo Liuca0ace32024-01-10 21:59:22 +080034 test_suite_subdir := android-mts
35else
36 test_suite_subdir := android-$(test_suite_name)
37endif
38
Colin Crossfa4f7202019-09-10 13:27:32 -070039out_dir := $(HOST_OUT)/$(test_suite_name)/$(test_suite_subdir)
Stuart Scott1926e9b2015-06-03 17:42:39 -070040test_artifacts := $(COMPATIBILITY.$(test_suite_name).FILES)
Julien Desprez8d5158f2020-10-20 13:22:43 -070041test_tools := $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar \
jdesprez46190312018-03-19 16:47:22 -070042 $(HOST_OUT_JAVA_LIBRARIES)/loganalysis.jar \
Stuart Scott19324d12015-07-23 12:56:51 -070043 $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar \
Julien Desprez67e5ec62020-11-24 13:20:04 -080044 $(HOST_OUT_JAVA_LIBRARIES)/compatibility-tradefed.jar \
Stuart Scott1dcff842015-06-08 15:04:31 -070045 $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed).jar \
Julien Desprez7b109502016-09-12 11:19:48 +010046 $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed)-tests.jar \
Stuart Scott1dcff842015-06-08 15:04:31 -070047 $(HOST_OUT_EXECUTABLES)/$(test_suite_tradefed) \
Sorin Bascab5a59ea2022-12-16 16:26:34 +000048 $(HOST_OUT_EXECUTABLES)/test-utils-script \
Stuart Scott1dcff842015-06-08 15:04:31 -070049 $(test_suite_readme)
Stuart Scott1926e9b2015-06-03 17:42:39 -070050
Bob Badour42f00c72022-03-19 23:20:59 -070051$(foreach f,$(test_suite_readme),$(if $(strip $(ALL_TARGETS.$(f).META_LIC)),,$(eval ALL_TARGETS.$(f).META_LIC := $(module_license_metadata))))
52
Siyuan Zhou18883152017-11-20 17:26:40 -080053test_tools += $(test_suite_tools)
54
Colin Crossfa4f7202019-09-10 13:27:32 -070055# The JDK to package into the test suite zip file. Always package the linux JDK.
56test_suite_jdk_dir := $(ANDROID_JAVA_HOME)/../linux-x86
Cole Fausta5f31a52023-05-11 18:22:03 -070057ifndef test_suite_jdk_files
58 # This file gets included many times, so make sure we only run the $(shell) once.
59 # Otherwise it will slow down every build due to all copies of it being rerun when kati
60 # checks the stamp file.
61 test_suite_jdk_files :=$= $(shell find $(test_suite_jdk_dir) -type f | sort)
62endif
Colin Crossfa4f7202019-09-10 13:27:32 -070063test_suite_jdk := $(call intermediates-dir-for,PACKAGING,$(test_suite_name)_jdk,HOST)/jdk.zip
64$(test_suite_jdk): PRIVATE_JDK_DIR := $(test_suite_jdk_dir)
65$(test_suite_jdk): PRIVATE_SUBDIR := $(test_suite_subdir)
Cole Fausta5f31a52023-05-11 18:22:03 -070066$(test_suite_jdk): $(test_suite_jdk_files)
Colin Crossfa4f7202019-09-10 13:27:32 -070067$(test_suite_jdk): $(SOONG_ZIP)
Zhenhuang Wang23d8c722023-02-14 00:29:30 +000068 $(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR) -sha256
Colin Crossfa4f7202019-09-10 13:27:32 -070069
Bob Badour10f5c482022-09-20 21:44:17 -070070$(call declare-license-metadata,$(test_suite_jdk),SPDX-license-identifier-GPL-2.0-with-classpath-exception,permissive,\
Bob Badour42f00c72022-03-19 23:20:59 -070071 $(test_suite_jdk_dir)/legal/java.base/LICENSE,JDK,prebuilts/jdk/$(notdir $(patsubst %/,%,$(dir $(test_suite_jdk_dir)))))
72
Yihan Dong9b75c9e2022-09-07 11:15:01 +080073# Copy license metadata
74$(call declare-copy-target-license-metadata,$(out_dir)/$(notdir $(test_suite_jdk)),$(test_suite_jdk))
75$(foreach t,$(test_tools) $(test_suite_prebuilt_tools),\
76 $(eval _dst := $(out_dir)/tools/$(notdir $(t)))\
77 $(if $(strip $(ALL_TARGETS.$(t).META_LIC)),\
78 $(call declare-copy-target-license-metadata,$(_dst),$(t)),\
79 $(warning $(t) has no license metadata)\
80 )\
81)
82test_copied_tools := $(foreach t,$(test_tools) $(test_suite_prebuilt_tools), $(out_dir)/tools/$(notdir $(t))) $(out_dir)/$(notdir $(test_suite_jdk))
83
Bob Badour42f00c72022-03-19 23:20:59 -070084
Dan Shi6a619b82020-04-13 09:29:16 -070085# Include host shared libraries
86host_shared_libs := $(call copy-many-files, $(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES))
87
Bob Badour42f00c72022-03-19 23:20:59 -070088$(if $(strip $(host_shared_libs)),\
89 $(foreach p,$(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES),\
90 $(eval _src := $(call word-colon,1,$(p)))\
91 $(eval _dst := $(call word-colon,2,$(p)))\
92 $(if $(strip $(ALL_TARGETS.$(_src).META_LIC)),\
Yihan Dong9b75c9e2022-09-07 11:15:01 +080093 $(call declare-copy-target-license-metadata,$(_dst),$(_src)),\
Bob Badour42f00c72022-03-19 23:20:59 -070094 $(warning $(_src) has no license metadata for $(_dst))\
95 )\
96 )\
97)
98
Colin Crossfa4f7202019-09-10 13:27:32 -070099compatibility_zip_deps := \
100 $(test_artifacts) \
101 $(test_tools) \
102 $(test_suite_prebuilt_tools) \
103 $(test_suite_dynamic_config) \
104 $(test_suite_jdk) \
105 $(MERGE_ZIPS) \
106 $(SOONG_ZIP) \
107 $(host_shared_libs) \
Yihan Donge45ff682022-03-25 13:57:05 +0800108 $(test_suite_extra_deps) \
Colin Crossfa4f7202019-09-10 13:27:32 -0700109
jschung904e1732021-04-21 16:09:11 +0900110compatibility_zip_resources := $(out_dir)/tools $(out_dir)/testcases $(out_dir)/lib $(out_dir)/lib64
wangzhou23acb0b2020-07-21 17:18:01 -0700111
112# Test Suite NOTICE files
113test_suite_notice_txt := $(out_dir)/NOTICE.txt
114test_suite_notice_html := $(out_dir)/NOTICE.html
115
Dan Shi413a5302020-10-22 15:36:21 -0700116compatibility_zip_deps += $(test_suite_notice_txt)
117compatibility_zip_resources += $(test_suite_notice_txt)
wangzhoue7f17252020-07-15 07:49:26 -0700118
Tongbo Liuca0ace32024-01-10 21:59:22 +0800119compatibility_tests_list_zip := $(HOST_OUT)/$(test_suite_name)/android-$(test_suite_name)-tests_list.zip
Dan Shifd480242021-10-04 11:04:14 -0700120
Tongbo Liuca0ace32024-01-10 21:59:22 +0800121compatibility_zip := $(HOST_OUT)/$(test_suite_name)/android-$(test_suite_name).zip
Dan Shifd480242021-10-04 11:04:14 -0700122$(compatibility_zip) : .KATI_IMPLICIT_OUTPUTS := $(compatibility_tests_list_zip)
Stuart Scott1926e9b2015-06-03 17:42:39 -0700123$(compatibility_zip): PRIVATE_OUT_DIR := $(out_dir)
Todd Leebae7ee52017-06-01 08:00:32 -0700124$(compatibility_zip): PRIVATE_TOOLS := $(test_tools) $(test_suite_prebuilt_tools)
Aaron Holdenaee6f602015-12-15 15:04:01 -0800125$(compatibility_zip): PRIVATE_SUITE_NAME := $(test_suite_name)
126$(compatibility_zip): PRIVATE_DYNAMIC_CONFIG := $(test_suite_dynamic_config)
wangzhoue7f17252020-07-15 07:49:26 -0700127$(compatibility_zip): PRIVATE_RESOURCES := $(compatibility_zip_resources)
Colin Crossfa4f7202019-09-10 13:27:32 -0700128$(compatibility_zip): PRIVATE_JDK := $(test_suite_jdk)
Dan Shifd480242021-10-04 11:04:14 -0700129$(compatibility_zip): PRIVATE_tests_list := $(out_dir)-tests_list
130$(compatibility_zip): PRIVATE_tests_list_zip := $(compatibility_tests_list_zip)
Jeongik Cha05210f92023-04-27 11:05:22 +0900131ifeq ($(strip $(HAS_BUILD_NUMBER)),true)
132$(compatibility_zip): $(BUILD_NUMBER_FILE)
133endif
wangzhoue7f17252020-07-15 07:49:26 -0700134$(compatibility_zip): $(compatibility_zip_deps) | $(ADB) $(ACP)
Stuart Scott1926e9b2015-06-03 17:42:39 -0700135# Make dir structure
Colin Crossfa4f7202019-09-10 13:27:32 -0700136 mkdir -p $(PRIVATE_OUT_DIR)/tools $(PRIVATE_OUT_DIR)/testcases
137 rm -f $@ $@.tmp $@.jdk
138 echo $(BUILD_NUMBER_FROM_FILE) > $(PRIVATE_OUT_DIR)/tools/version.txt
Stuart Scott1926e9b2015-06-03 17:42:39 -0700139# Copy tools
Colin Crossfa4f7202019-09-10 13:27:32 -0700140 cp $(PRIVATE_TOOLS) $(PRIVATE_OUT_DIR)/tools
Dan Willemsen288bedf2019-05-28 15:36:47 -0700141 $(if $(PRIVATE_DYNAMIC_CONFIG),$(hide) cp $(PRIVATE_DYNAMIC_CONFIG) $(PRIVATE_OUT_DIR)/testcases/$(PRIVATE_SUITE_NAME).dynamic)
Colin Crossfa4f7202019-09-10 13:27:32 -0700142 find $(PRIVATE_RESOURCES) | sort >$@.list
Zhenhuang Wang23d8c722023-02-14 00:29:30 +0000143 $(SOONG_ZIP) -d -o $@.tmp -C $(dir $@) -l $@.list -sha256
Colin Crossfa4f7202019-09-10 13:27:32 -0700144 $(MERGE_ZIPS) $@ $@.tmp $(PRIVATE_JDK)
145 rm -f $@.tmp
Dan Shifd480242021-10-04 11:04:14 -0700146# Build a list of tests
147 rm -f $(PRIVATE_tests_list)
148 $(hide) grep -e .*\\.config$$ $@.list | sed s%$(PRIVATE_OUT_DIR)/testcases/%%g > $(PRIVATE_tests_list)
149 $(SOONG_ZIP) -d -o $(PRIVATE_tests_list_zip) -j -f $(PRIVATE_tests_list)
150 rm -f $(PRIVATE_tests_list)
Aaron Holdenaee6f602015-12-15 15:04:01 -0800151
Bob Badour3a0f0c12022-04-05 10:43:45 -0700152$(call declare-0p-target,$(compatibility_tests_list_zip),)
153
Bob Badour42f00c72022-03-19 23:20:59 -0700154$(call declare-1p-container,$(compatibility_zip),)
Yihan Dong9b75c9e2022-09-07 11:15:01 +0800155$(call declare-container-license-deps,$(compatibility_zip),$(compatibility_zip_deps) $(test_copied_tools), $(out_dir)/:/)
Bob Badour42f00c72022-03-19 23:20:59 -0700156
157$(eval $(call html-notice-rule,$(test_suite_notice_html),"Test suites","Notices for files contained in the test suites filesystem image:",$(compatibility_zip),$(compatibility_zip)))
158$(eval $(call text-notice-rule,$(test_suite_notice_txt),"Test suites","Notices for files contained in the test suites filesystem image:",$(compatibility_zip),$(compatibility_zip)))
159
160$(call declare-0p-target,$(test_suite_notice_html))
161$(call declare-0p-target,$(test_suite_notice_txt))
162
Bob Badour540a3f82022-04-20 13:01:16 -0700163$(call declare-1p-copy-files,$(test_suite_dynamic_config),)
164$(call declare-1p-copy-files,$(test_suite_prebuilt_tools),)
165
Aaron Holdenaee6f602015-12-15 15:04:01 -0800166# Reset all input variables
167test_suite_name :=
168test_suite_tradefed :=
169test_suite_dynamic_config :=
170test_suite_readme :=
Todd Leebae7ee52017-06-01 08:00:32 -0700171test_suite_prebuilt_tools :=
Siyuan Zhou18883152017-11-20 17:26:40 -0800172test_suite_tools :=
Colin Crossfa4f7202019-09-10 13:27:32 -0700173test_suite_jdk :=
174test_suite_jdk_dir :=
Dan Shi6a619b82020-04-13 09:29:16 -0700175host_shared_libs :=
Yihan Donge45ff682022-03-25 13:57:05 +0800176test_suite_extra_deps :=