blob: 4b01005cdb861a281af5457bf0bf4613c17fdde5 [file] [log] [blame]
Brian Muramatsu2f8eead2010-09-24 14:56:43 -07001#
2# Copyright (C) 2010 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# Makefile for producing CTS coverage reports.
18# Run "make cts-test-coverage" in the $ANDROID_BUILD_TOP directory.
19
20include cts/CtsTestCaseList.mk
21
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070022cts_api_coverage_exe := $(HOST_OUT_EXECUTABLES)/cts-api-coverage
23dexdeps_exe := $(HOST_OUT_EXECUTABLES)/dexdeps
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070024
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070025coverage_out := $(HOST_OUT)/cts-api-coverage
Ying Wang50889ab2010-12-01 16:29:54 -080026
Ying Wangd97c2b12012-10-05 16:43:21 -070027api_text_description := frameworks/base/api/current.txt
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070028api_xml_description := $(coverage_out)/api.xml
29$(api_xml_description) : $(api_text_description) $(APICHECK)
30 $(hide) echo "Converting API file to XML: $@"
Ying Wang697ebf02013-08-01 11:09:25 -070031 $(hide) mkdir -p $(dir $@)
32 $(hide) $(APICHECK_COMMAND) -convert2xml $< $@
Ying Wang50889ab2010-12-01 16:29:54 -080033
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070034cts-test-coverage-report := $(coverage_out)/test-coverage.html
35cts-verifier-coverage-report := $(coverage_out)/verifier-coverage.html
Keun young Park506ca412012-08-28 10:52:31 -070036cts-combined-coverage-report := $(coverage_out)/combined-coverage.html
Nicholas Sauer0130e902015-12-23 20:37:15 -080037cts-combined-xml-coverage-report := $(coverage_out)/combined-coverage.xml
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070038
Ying Wang1a833732013-07-10 11:29:35 -070039cts_api_coverage_dependencies := $(cts_api_coverage_exe) $(dexdeps_exe) $(api_xml_description)
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070040
Nicholas Sauerf7e8eae2016-01-05 19:47:07 +000041cts_coverage_test_cases_dependencies := $(foreach c, $(CTS_COVERAGE_TEST_CASE_LIST), $(call intermediates-dir-for,APPS,$(c))/package.apk)
42$(cts-test-coverage-report): PRIVATE_TEST_CASES_APKS := $(cts_coverage_test_cases_dependencies)
Ying Wang697ebf02013-08-01 11:09:25 -070043$(cts-test-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
44$(cts-test-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
45$(cts-test-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
Ying Wang1a833732013-07-10 11:29:35 -070046$(cts-test-coverage-report) : $(cts_coverage_test_cases_dependencies) $(cts_api_coverage_dependencies) | $(ACP)
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070047 $(call generate-coverage-report,"CTS Tests API Coverage Report",\
Ying Wang697ebf02013-08-01 11:09:25 -070048 $(PRIVATE_TEST_CASES_APKS),html)
Brian Muramatsu4b32d082010-12-02 13:08:44 -080049
Ying Wangd1ea6cc2013-07-10 13:40:48 -070050cts_coverage_test_cases_dependencies := $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk
Ying Wang697ebf02013-08-01 11:09:25 -070051$(cts-verifier-coverage-report): PRIVATE_TEST_CASES_APKS := $(cts_coverage_test_cases_dependencies)
52$(cts-verifier-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
53$(cts-verifier-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
54$(cts-verifier-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
Ying Wang1a833732013-07-10 11:29:35 -070055$(cts-verifier-coverage-report) : $(cts_coverage_test_cases_dependencies) $(cts_api_coverage_dependencies) | $(ACP)
Brian Muramatsu4b32d082010-12-02 13:08:44 -080056 $(call generate-coverage-report,"CTS Verifier API Coverage Report",\
Ying Wang697ebf02013-08-01 11:09:25 -070057 $(PRIVATE_TEST_CASES_APKS),html)
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070058
Nicholas Sauerf7e8eae2016-01-05 19:47:07 +000059cts_coverage_test_cases_dependencies := $(foreach c, $(CTS_COVERAGE_TEST_CASE_LIST) CtsVerifier, $(call intermediates-dir-for,APPS,$(c))/package.apk)
60$(cts-combined-coverage-report): PRIVATE_TEST_CASES_APKS := $(cts_coverage_test_cases_dependencies)
Ying Wang697ebf02013-08-01 11:09:25 -070061$(cts-combined-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
62$(cts-combined-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
63$(cts-combined-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
Ying Wang1a833732013-07-10 11:29:35 -070064$(cts-combined-coverage-report) : $(cts_coverage_test_cases_dependencies) $(cts_api_coverage_dependencies) | $(ACP)
Keun young Park506ca412012-08-28 10:52:31 -070065 $(call generate-coverage-report,"CTS Combined API Coverage Report",\
Ying Wang697ebf02013-08-01 11:09:25 -070066 $(PRIVATE_TEST_CASES_APKS),html)
Keun young Park506ca412012-08-28 10:52:31 -070067
Nicholas Sauerf7e8eae2016-01-05 19:47:07 +000068cts_coverage_test_cases_dependencies := $(foreach c, $(CTS_COVERAGE_TEST_CASE_LIST) CtsVerifier, $(call intermediates-dir-for,APPS,$(c))/package.apk)
69$(cts-combined-xml-coverage-report): PRIVATE_TEST_CASES_APKS := $(cts_coverage_test_cases_dependencies)
Nicholas Sauer0130e902015-12-23 20:37:15 -080070$(cts-combined-xml-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
71$(cts-combined-xml-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
72$(cts-combined-xml-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
73$(cts-combined-xml-coverage-report) : $(cts_coverage_test_cases_dependencies) $(cts_api_coverage_dependencies) | $(ACP)
74 $(call generate-coverage-report,"CTS Combined API Coverage Report - XML",\
75 $(PRIVATE_TEST_CASES_APKS),xml)
76
Ying Wang50889ab2010-12-01 16:29:54 -080077.PHONY: cts-test-coverage
78cts-test-coverage : $(cts-test-coverage-report)
79
Brian Muramatsu4b32d082010-12-02 13:08:44 -080080.PHONY: cts-verifier-coverage
81cts-verifier-coverage : $(cts-verifier-coverage-report)
82
Keun young Park506ca412012-08-28 10:52:31 -070083.PHONY: cts-combined-coverage
84cts-combined-coverage : $(cts-combined-coverage-report)
85
Nicholas Sauer0130e902015-12-23 20:37:15 -080086.PHONY: cts-combined-xml-coverage
87cts-combined-xml-coverage : $(cts-combined-xml-coverage-report)
88
Ying Wang50889ab2010-12-01 16:29:54 -080089# Put the test coverage report in the dist dir if "cts" is among the build goals.
90ifneq ($(filter cts, $(MAKECMDGOALS)),)
Brian Muramatsu16fdad82010-12-02 17:13:44 -080091 $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.html)
92 $(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html)
Keun young Park506ca412012-08-28 10:52:31 -070093 $(call dist-for-goals, cts, $(cts-combined-coverage-report):cts-combined-coverage-report.html)
Nicholas Sauer0130e902015-12-23 20:37:15 -080094 $(call dist-for-goals, cts, $(cts-combined-xml-coverage-report):cts-combined-coverage-report.xml)
Ying Wang50889ab2010-12-01 16:29:54 -080095endif
96
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070097# Arguments;
98# 1 - Name of the report printed out on the screen
Ying Wang1a833732013-07-10 11:29:35 -070099# 2 - List of apk files that will be scanned to generate the report
100# 3 - Format of the report
Brian Muramatsu2f8eead2010-09-24 14:56:43 -0700101define generate-coverage-report
Ying Wang697ebf02013-08-01 11:09:25 -0700102 $(hide) mkdir -p $(dir $@)
103 $(hide) $(PRIVATE_CTS_API_COVERAGE_EXE) -d $(PRIVATE_DEXDEPS_EXE) -a $(PRIVATE_API_XML_DESC) -f $(3) -o $@ $(2)
104 @ echo $(1): file://$(ANDROID_BUILD_TOP)/$@
Brian Muramatsu2f8eead2010-09-24 14:56:43 -0700105endef
Ying Wang697ebf02013-08-01 11:09:25 -0700106
107# Reset temp vars
108cts_api_coverage_dependencies :=
109cts_coverage_test_cases_dependencies :=
110cts-combined-coverage-report :=
Nicholas Sauer0130e902015-12-23 20:37:15 -0800111cts-combined-xml-coverage-report :=
Ying Wang697ebf02013-08-01 11:09:25 -0700112cts-verifier-coverage-report :=
113cts-test-coverage-report :=
114api_xml_description :=
115api_text_description :=
116coverage_out :=
117dexdeps_exe :=
118cts_api_coverage_exe :=