19ba57e7dSThe Android Automerger#
29ba57e7dSThe Android Automerger# Copyright (C) 2010 The Android Open Source Project
39ba57e7dSThe Android Automerger#
49ba57e7dSThe Android Automerger# Licensed under the Apache License, Version 2.0 (the "License");
59ba57e7dSThe Android Automerger# you may not use this file except in compliance with the License.
69ba57e7dSThe Android Automerger# You may obtain a copy of the License at
79ba57e7dSThe Android Automerger#
89ba57e7dSThe Android Automerger#      http://www.apache.org/licenses/LICENSE-2.0
99ba57e7dSThe Android Automerger#
109ba57e7dSThe Android Automerger# Unless required by applicable law or agreed to in writing, software
119ba57e7dSThe Android Automerger# distributed under the License is distributed on an "AS IS" BASIS,
129ba57e7dSThe Android Automerger# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139ba57e7dSThe Android Automerger# See the License for the specific language governing permissions and
149ba57e7dSThe Android Automerger# limitations under the License.
159ba57e7dSThe Android Automerger#
169ba57e7dSThe Android Automerger
179ba57e7dSThe Android Automerger# Makefile for producing CTS coverage reports.
189ba57e7dSThe Android Automerger# Run "make cts-test-coverage" in the $ANDROID_BUILD_TOP directory.
199ba57e7dSThe Android Automerger
209ba57e7dSThe Android Automergerinclude cts/CtsTestCaseList.mk
219ba57e7dSThe Android Automerger
229ba57e7dSThe Android Automergercts_api_coverage_exe := $(HOST_OUT_EXECUTABLES)/cts-api-coverage
239ba57e7dSThe Android Automergerdexdeps_exe := $(HOST_OUT_EXECUTABLES)/dexdeps
249ba57e7dSThe Android Automerger
259ba57e7dSThe Android Automergercoverage_out := $(HOST_OUT)/cts-api-coverage
269ba57e7dSThe Android Automerger
279ba57e7dSThe Android Automergerapi_text_description := $(SRC_API_DIR)/current.txt
289ba57e7dSThe Android Automergerapi_xml_description := $(coverage_out)/api.xml
299ba57e7dSThe Android Automerger$(api_xml_description) : $(api_text_description) $(APICHECK)
309ba57e7dSThe Android Automerger	$(hide) echo "Converting API file to XML: $@"
319ba57e7dSThe Android Automerger	$(hide) mkdir -p $(coverage_out)
329ba57e7dSThe Android Automerger	$(hide) $(APICHECK_COMMAND) -convert2xml $(api_text_description) $(api_xml_description)
339ba57e7dSThe Android Automerger
349ba57e7dSThe Android Automergercts-test-coverage-report := $(coverage_out)/test-coverage.html
359ba57e7dSThe Android Automergercts-verifier-coverage-report := $(coverage_out)/verifier-coverage.html
369ba57e7dSThe Android Automerger
379ba57e7dSThe Android Automergercts_api_coverage_dependencies := $(cts_api_coverage_exe) $(dexdeps_exe) $(api_xml_description) $(ACP)
389ba57e7dSThe Android Automerger
399ba57e7dSThe Android Automerger$(cts-test-coverage-report) : $(CTS_COVERAGE_TEST_CASE_LIST) $(cts_api_coverage_dependencies)
409ba57e7dSThe Android Automerger	$(call generate-coverage-report,"CTS Tests API Coverage Report",\
419ba57e7dSThe Android Automerger			$(CTS_COVERAGE_TEST_CASE_LIST),cts-test-apks,html,test-coverage.html)
429ba57e7dSThe Android Automerger
439ba57e7dSThe Android Automerger$(cts-verifier-coverage-report) : CtsVerifier $(cts_api_coverage_dependencies)
449ba57e7dSThe Android Automerger	$(call generate-coverage-report,"CTS Verifier API Coverage Report",\
459ba57e7dSThe Android Automerger			CtsVerifier,cts-verifier-apks,html,verifier-coverage.html)
469ba57e7dSThe Android Automerger
479ba57e7dSThe Android Automerger.PHONY: cts-test-coverage
489ba57e7dSThe Android Automergercts-test-coverage : $(cts-test-coverage-report)
499ba57e7dSThe Android Automerger
509ba57e7dSThe Android Automerger.PHONY: cts-verifier-coverage
519ba57e7dSThe Android Automergercts-verifier-coverage : $(cts-verifier-coverage-report)
529ba57e7dSThe Android Automerger
539ba57e7dSThe Android Automerger# Put the test coverage report in the dist dir if "cts" is among the build goals.
549ba57e7dSThe Android Automergerifneq ($(filter cts, $(MAKECMDGOALS)),)
559ba57e7dSThe Android Automerger  $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.html)
569ba57e7dSThe Android Automerger  $(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html)
579ba57e7dSThe Android Automergerendif
589ba57e7dSThe Android Automerger
599ba57e7dSThe Android Automerger# Arguments;
609ba57e7dSThe Android Automerger#  1 - Name of the report printed out on the screen
619ba57e7dSThe Android Automerger#  2 - Name of APK packages that will be scanned to generate the report
629ba57e7dSThe Android Automerger#  3 - Name of variable to hold the calculated paths of the APKs
639ba57e7dSThe Android Automerger#  4 - Format of the report
649ba57e7dSThe Android Automerger#  5 - Output file name of the report
659ba57e7dSThe Android Automergerdefine generate-coverage-report
669ba57e7dSThe Android Automerger	$(foreach testcase,$(2),$(eval $(call add-testcase-apk,$(3),$(testcase))))
679ba57e7dSThe Android Automerger	$(hide) mkdir -p $(coverage_out)
689ba57e7dSThe Android Automerger	$(hide) $(cts_api_coverage_exe) -d $(dexdeps_exe) -a $(api_xml_description) -f $(4) -o $(coverage_out)/$(5) $($(3))
699ba57e7dSThe Android Automerger	$(hide) echo $(1): file://$(ANDROID_BUILD_TOP)/$(coverage_out)/$(5)
709ba57e7dSThe Android Automergerendef
719ba57e7dSThe Android Automerger
729ba57e7dSThe Android Automerger# classes.dex is stripped from package.apk if dex-preopt is enabled,
739ba57e7dSThe Android Automerger# so we use the copy that definitely includes classes.dex.
749ba57e7dSThe Android Automergerdefine add-testcase-apk
759ba57e7dSThe Android Automerger	$(1) += $(call intermediates-dir-for,APPS,$(2))/package.apk.unaligned
769ba57e7dSThe Android Automergerendef