blob: 85f13ccfdeda072aa8380e8fa51c0a27b39a490d [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
Ying Wang50889ab2010-12-01 16:29:54 -080022CTS_API_COVERAGE_EXE := $(HOST_OUT_EXECUTABLES)/cts-api-coverage
Brian Muramatsu4b32d082010-12-02 13:08:44 -080023DEXDEPS_EXE := $(HOST_OUT_EXECUTABLES)/dexdeps
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070024
Brian Muramatsu4b32d082010-12-02 13:08:44 -080025COVERAGE_OUT := $(HOST_OUT)/cts/api-coverage
26COVERAGE_RES := cts/tools/cts-api-coverage/res
Ying Wang50889ab2010-12-01 16:29:54 -080027
Brian Muramatsu4b32d082010-12-02 13:08:44 -080028cts-test-coverage-report := $(COVERAGE_OUT)/test-coverage.xml
29cts-verifier-coverage-report := $(COVERAGE_OUT)/verifier-coverage.xml
30api-coverage-css := $(COVERAGE_OUT)/api-coverage.css
31api-coverage-xsl := $(COVERAGE_OUT)/api-coverage.xsl
32
33CTS_API_COVERAGE_DEPENDENCIES := $(CTS_API_COVERAGE_EXE) $(DEXDEPS_EXE) $(ACP) \
34 $(api-coverage-css) $(api-coverage-xsl)
Ying Wang50889ab2010-12-01 16:29:54 -080035
36$(cts-test-coverage-report) : $(CTS_COVERAGE_TEST_CASE_LIST) $(CTS_API_COVERAGE_DEPENDENCIES)
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070037 $(call generate-coverage-report,"CTS Tests API Coverage Report",\
Brian Muramatsu4b32d082010-12-02 13:08:44 -080038 $(CTS_COVERAGE_TEST_CASE_LIST),xml,$(HOST_OUT)/cts/api-coverage,test-coverage.xml)
39
40$(cts-verifier-coverage-report) : CtsVerifier $(CTS_API_COVERAGE_DEPENDENCIES)
41 $(call generate-coverage-report,"CTS Verifier API Coverage Report",\
42 CtsVerifier,xml,$(HOST_OUT)/cts/api-coverage,verifier-coverage.xml)
43
44$(api-coverage-css) : $(COVERAGE_RES)/api-coverage.css $(ACP)
45 $(call copy-coverage-resource,api-coverage.css,$(api-coverage-css))
46
47$(api-coverage-xsl) : $(COVERAGE_RES)/api-coverage.xsl $(ACP)
48 $(call copy-coverage-resource,api-coverage.xsl,$(api-coverage-xsl))
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070049
Ying Wang50889ab2010-12-01 16:29:54 -080050.PHONY: cts-test-coverage
51cts-test-coverage : $(cts-test-coverage-report)
52
Brian Muramatsu4b32d082010-12-02 13:08:44 -080053.PHONY: cts-verifier-coverage
54cts-verifier-coverage : $(cts-verifier-coverage-report)
55
Ying Wang50889ab2010-12-01 16:29:54 -080056# Put the test coverage report in the dist dir if "cts" is among the build goals.
57ifneq ($(filter cts, $(MAKECMDGOALS)),)
58 $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.xml)
Brian Muramatsu4b32d082010-12-02 13:08:44 -080059 $(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.xml)
60 $(call dist-for-goals, cts, $(api-coverage-css):api-coverage.css)
61 $(call dist-for-goals, cts, $(api-coverage-xsl):api-coverage.xsl)
Ying Wang50889ab2010-12-01 16:29:54 -080062endif
63
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070064# Arguments;
65# 1 - Name of the report printed out on the screen
66# 2 - Name of APK packages that will be scanned to generate the report
67# 3 - Format of the report
68# 4 - Output directory to put the report
69# 5 - Output file name of the report
70define generate-coverage-report
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070071 $(hide) mkdir -p $(4)
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070072
73 $(foreach testcase,$(2),$(eval $(call add-testcase-apk,$(testcase))))
Brian Muramatsu4b32d082010-12-02 13:08:44 -080074 $(hide) $(CTS_API_COVERAGE_EXE) -d $(DEXDEPS_EXE) -f $(3) -o $(4)/$(5) $(TEST_APKS)
Brian Muramatsu2f8eead2010-09-24 14:56:43 -070075
76 @echo $(1): file://$(ANDROID_BUILD_TOP)/$(4)/$(5)
77endef
78
79define add-testcase-apk
80 TEST_APKS += $(call intermediates-dir-for,APPS,$(1))/package.apk
81endef
Brian Muramatsu4b32d082010-12-02 13:08:44 -080082
83# Arguments:
84# 1 - Name of the resources to copy like "api-coverage.css" with no path.
85# 2 - Destination file name of the copied resource
86define copy-coverage-resource
87 $(hide) mkdir -p `dirname $(2)`
88 $(hide) $(ACP) $(COVERAGE_RES)/$(1) $(2)
89endef