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 20include cts/CtsTestCaseList.mk 21 22cts_api_coverage_exe := $(HOST_OUT_EXECUTABLES)/cts-api-coverage 23dexdeps_exe := $(HOST_OUT_EXECUTABLES)/dexdeps 24 25coverage_out := $(HOST_OUT)/cts-api-coverage 26 27api_text_description := $(SRC_API_DIR)/current.txt 28api_xml_description := $(coverage_out)/api.xml 29$(api_xml_description) : $(api_text_description) $(APICHECK) 30 $(hide) echo "Converting API file to XML: $@" 31 $(hide) mkdir -p $(coverage_out) 32 $(hide) $(APICHECK_COMMAND) -convert2xml $(api_text_description) $(api_xml_description) 33 34cts-test-coverage-report := $(coverage_out)/test-coverage.html 35cts-verifier-coverage-report := $(coverage_out)/verifier-coverage.html 36 37cts_api_coverage_dependencies := $(cts_api_coverage_exe) $(dexdeps_exe) $(api_xml_description) $(ACP) 38 39$(cts-test-coverage-report) : $(CTS_COVERAGE_TEST_CASE_LIST) $(cts_api_coverage_dependencies) 40 $(call generate-coverage-report,"CTS Tests API Coverage Report",\ 41 $(CTS_COVERAGE_TEST_CASE_LIST),cts-test-apks,html,test-coverage.html) 42 43$(cts-verifier-coverage-report) : CtsVerifier $(cts_api_coverage_dependencies) 44 $(call generate-coverage-report,"CTS Verifier API Coverage Report",\ 45 CtsVerifier,cts-verifier-apks,html,verifier-coverage.html) 46 47.PHONY: cts-test-coverage 48cts-test-coverage : $(cts-test-coverage-report) 49 50.PHONY: cts-verifier-coverage 51cts-verifier-coverage : $(cts-verifier-coverage-report) 52 53# Put the test coverage report in the dist dir if "cts" is among the build goals. 54ifneq ($(filter cts, $(MAKECMDGOALS)),) 55 $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.html) 56 $(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html) 57endif 58 59# Arguments; 60# 1 - Name of the report printed out on the screen 61# 2 - Name of APK packages that will be scanned to generate the report 62# 3 - Name of variable to hold the calculated paths of the APKs 63# 4 - Format of the report 64# 5 - Output file name of the report 65define generate-coverage-report 66 $(foreach testcase,$(2),$(eval $(call add-testcase-apk,$(3),$(testcase)))) 67 $(hide) mkdir -p $(coverage_out) 68 $(hide) $(cts_api_coverage_exe) -d $(dexdeps_exe) -a $(api_xml_description) -f $(4) -o $(coverage_out)/$(5) $($(3)) 69 $(hide) echo $(1): file://$(ANDROID_BUILD_TOP)/$(coverage_out)/$(5) 70endef 71 72# classes.dex is stripped from package.apk if dex-preopt is enabled, 73# so we use the copy that definitely includes classes.dex. 74define add-testcase-apk 75 $(1) += $(call intermediates-dir-for,APPS,$(2))/package.apk.unaligned 76endef 77