• 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
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
26cts-test-coverage-report := $(COVERAGE_OUT)/test-coverage.html
27cts-verifier-coverage-report := $(COVERAGE_OUT)/verifier-coverage.html
28
29CTS_API_COVERAGE_DEPENDENCIES := $(CTS_API_COVERAGE_EXE) $(DEXDEPS_EXE) $(ACP)
30
31$(cts-test-coverage-report) : $(CTS_COVERAGE_TEST_CASE_LIST) $(CTS_API_COVERAGE_DEPENDENCIES)
32	$(call generate-coverage-report,"CTS Tests API Coverage Report",\
33			$(CTS_COVERAGE_TEST_CASE_LIST),html,test-coverage.html)
34
35$(cts-verifier-coverage-report) : CtsVerifier $(CTS_API_COVERAGE_DEPENDENCIES)
36	$(call generate-coverage-report,"CTS Verifier API Coverage Report",\
37			CtsVerifier,html,verifier-coverage.html)
38
39.PHONY: cts-test-coverage
40cts-test-coverage : $(cts-test-coverage-report)
41
42.PHONY: cts-verifier-coverage
43cts-verifier-coverage : $(cts-verifier-coverage-report)
44
45# Put the test coverage report in the dist dir if "cts" is among the build goals.
46ifneq ($(filter cts, $(MAKECMDGOALS)),)
47  $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.html)
48  $(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html)
49endif
50
51# Arguments;
52#  1 - Name of the report printed out on the screen
53#  2 - Name of APK packages that will be scanned to generate the report
54#  3 - Format of the report
55#  4 - Output file name of the report
56define generate-coverage-report
57	$(foreach testcase,$(2),$(eval $(call add-testcase-apk,$(testcase))))
58	$(hide) mkdir -p $(COVERAGE_OUT)
59	$(hide) $(CTS_API_COVERAGE_EXE) -d $(DEXDEPS_EXE) -f $(3) -o $(COVERAGE_OUT)/$(4) $(TEST_APKS)
60	$(hide) echo $(1): file://$(ANDROID_BUILD_TOP)/$(COVERAGE_OUT)/$(4)
61endef
62
63define add-testcase-apk
64	TEST_APKS += $(call intermediates-dir-for,APPS,$(1))/package.apk
65endef
66