• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
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
20cts_api_coverage_exe := $(HOST_OUT_EXECUTABLES)/cts-api-coverage
21dexdeps_exe := $(HOST_OUT_EXECUTABLES)/dexdeps
22
23coverage_out := $(HOST_OUT)/cts-api-coverage
24
25api_text_description := frameworks/base/api/current.txt
26api_xml_description := $(coverage_out)/api.xml
27$(api_xml_description) : $(api_text_description) $(APICHECK)
28	$(hide) echo "Converting API file to XML: $@"
29	$(hide) mkdir -p $(dir $@)
30	$(hide) $(APICHECK_COMMAND) -convert2xml $< $@
31
32cts-test-coverage-report := $(coverage_out)/test-coverage.html
33cts-verifier-coverage-report := $(coverage_out)/verifier-coverage.html
34cts-combined-coverage-report := $(coverage_out)/combined-coverage.html
35cts-combined-xml-coverage-report := $(coverage_out)/combined-coverage.xml
36
37cts_api_coverage_dependencies := $(cts_api_coverage_exe) $(dexdeps_exe) $(api_xml_description)
38
39android_cts_zip := $(HOST_OUT)/old-cts/old-android-cts.zip
40cts_verifier_apk := $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk
41
42$(cts-test-coverage-report): PRIVATE_TEST_CASES := $(CTS_TESTCASES_OUT)
43$(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)
46$(cts-test-coverage-report) : $(android_cts_zip) $(cts_api_coverage_dependencies) | $(ACP)
47	$(call generate-coverage-report,"CTS Tests API Coverage Report",\
48			$(PRIVATE_TEST_CASES),html)
49
50$(cts-verifier-coverage-report): PRIVATE_TEST_CASES := $(cts_verifier_apk)
51$(cts-verifier-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
52$(cts-verifier-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
53$(cts-verifier-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
54$(cts-verifier-coverage-report) : $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP)
55	$(call generate-coverage-report,"CTS Verifier API Coverage Report",\
56			$(PRIVATE_TEST_CASES),html)
57
58$(cts-combined-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(CTS_TESTCASES_OUT), $(c))
59$(cts-combined-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
60$(cts-combined-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
61$(cts-combined-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
62$(cts-combined-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP)
63	$(call generate-coverage-report,"CTS Combined API Coverage Report",\
64			$(PRIVATE_TEST_CASES),html)
65
66$(cts-combined-xml-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(CTS_TESTCASES_OUT), $(c))
67$(cts-combined-xml-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
68$(cts-combined-xml-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
69$(cts-combined-xml-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
70$(cts-combined-xml-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP)
71	$(call generate-coverage-report,"CTS Combined API Coverage Report - XML",\
72			$(PRIVATE_TEST_CASES),xml)
73
74.PHONY: cts-test-coverage
75cts-test-coverage : $(cts-test-coverage-report)
76
77.PHONY: cts-verifier-coverage
78cts-verifier-coverage : $(cts-verifier-coverage-report)
79
80.PHONY: cts-combined-coverage
81cts-combined-coverage : $(cts-combined-coverage-report)
82
83.PHONY: cts-combined-xml-coverage
84cts-combined-xml-coverage : $(cts-combined-xml-coverage-report)
85
86# Put the test coverage report in the dist dir if "cts" is among the build goals.
87ifneq ($(filter cts, $(MAKECMDGOALS)),)
88  $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.html)
89  $(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html)
90  $(call dist-for-goals, cts, $(cts-combined-coverage-report):cts-combined-coverage-report.html)
91  $(call dist-for-goals, cts, $(cts-combined-xml-coverage-report):cts-combined-coverage-report.xml)
92endif
93
94# Arguments;
95#  1 - Name of the report printed out on the screen
96#  2 - List of apk files that will be scanned to generate the report
97#  3 - Format of the report
98define generate-coverage-report
99	$(hide) mkdir -p $(dir $@)
100	$(hide) $(PRIVATE_CTS_API_COVERAGE_EXE) -d $(PRIVATE_DEXDEPS_EXE) -a $(PRIVATE_API_XML_DESC) -f $(3) -o $@ $(2)
101	@ echo $(1): file://$(ANDROID_BUILD_TOP)/$@
102endef
103
104# Reset temp vars
105cts_api_coverage_dependencies :=
106cts-combined-coverage-report :=
107cts-combined-xml-coverage-report :=
108cts-verifier-coverage-report :=
109cts-test-coverage-report :=
110api_xml_description :=
111api_text_description :=
112coverage_out :=
113dexdeps_exe :=
114cts_api_coverage_exe :=
115cts_verifier_apk :=
116android_cts_zip :=
117