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# List all TradeFed tests from COMPATIBILITY.tradefed_tests_dir
16.PHONY: tradefed-tests-list
17
18tradefed_tests :=
19$(foreach dir, $(COMPATIBILITY.tradefed_tests_dir), \
20  $(eval tradefed_tests += $(shell find $(dir) -type f -name "*.xml")))
21tradefed_tests_list_intermediates := $(call intermediates-dir-for,PACKAGING,tradefed_tests_list,HOST,COMMON)
22tradefed_tests_list_zip := $(tradefed_tests_list_intermediates)/tradefed-tests_list.zip
23all_tests :=
24$(foreach test, $(tradefed_tests), \
25  $(eval all_tests += $(word 2,$(subst /res/config/,$(space),$(test)))))
26$(tradefed_tests_list_zip) : PRIVATE_tradefed_tests := $(subst .xml,,$(subst $(space),\n,$(sort $(all_tests))))
27$(tradefed_tests_list_zip) : PRIVATE_tradefed_tests_list := $(tradefed_tests_list_intermediates)/tradefed-tests_list
28
29$(tradefed_tests_list_zip) : $(tradefed_tests) $(SOONG_ZIP)
30	@echo "Package: $@"
31	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
32	$(hide) echo -e "$(PRIVATE_tradefed_tests)" > $(PRIVATE_tradefed_tests_list)
33	$(hide) $(SOONG_ZIP) -d -o $@ -C $(dir $@) -f $(PRIVATE_tradefed_tests_list)
34
35tradefed-tests-list : $(tradefed_tests_list_zip)
36$(call dist-for-goals, tradefed-tests-list, $(tradefed_tests_list_zip))
37
38tests: tradefed-tests-list
39