blob: 164823002bdc941f5839f4629f2bcac94e0e8192 [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
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070027api_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)
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
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)
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070040 $(call generate-coverage-report,"CTS Tests API Coverage Report",\
Brian Muramatsuad5bcd32010-12-06 12:28:22 -080041 $(CTS_COVERAGE_TEST_CASE_LIST),html,test-coverage.html)
Brian Muramatsu4b32d082010-12-02 13:08:44 -080042
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070043$(cts-verifier-coverage-report) : CtsVerifier $(cts_api_coverage_dependencies)
Brian Muramatsu4b32d082010-12-02 13:08:44 -080044 $(call generate-coverage-report,"CTS Verifier API Coverage Report",\
Brian Muramatsuad5bcd32010-12-06 12:28:22 -080045 CtsVerifier,html,verifier-coverage.html)
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070046
Ying Wang50889ab2010-12-01 16:29:54 -080047.PHONY: cts-test-coverage
48cts-test-coverage : $(cts-test-coverage-report)
49
Brian Muramatsu4b32d082010-12-02 13:08:44 -080050.PHONY: cts-verifier-coverage
51cts-verifier-coverage : $(cts-verifier-coverage-report)
52
Ying Wang50889ab2010-12-01 16:29:54 -080053# Put the test coverage report in the dist dir if "cts" is among the build goals.
54ifneq ($(filter cts, $(MAKECMDGOALS)),)
Brian Muramatsu16fdad82010-12-02 17:13:44 -080055 $(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)
Ying Wang50889ab2010-12-01 16:29:54 -080057endif
58
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070059# 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 - Format of the report
Brian Muramatsuad5bcd32010-12-06 12:28:22 -080063# 4 - Output file name of the report
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070064define generate-coverage-report
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070065 $(foreach testcase,$(2),$(eval $(call add-testcase-apk,$(testcase))))
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070066 $(hide) mkdir -p $(coverage_out)
67 $(hide) $(cts_api_coverage_exe) -d $(dexdeps_exe) -a $(api_xml_description) -f $(3) -o $(coverage_out)/$(4) $(text_apks)
68 $(hide) echo $(1): file://$(ANDROID_BUILD_TOP)/$(coverage_out)/$(4)
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070069endef
70
71define add-testcase-apk
Brian Muramatsu61bd88c2011-04-11 13:48:08 -070072 text_apks += $(call intermediates-dir-for,APPS,$(1))/package.apk
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070073endef