Brian Muramatsu | 2f8eead | 2010-09-24 14:56:43 -0700 | [diff] [blame] | 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 | |
| 20 | include cts/CtsTestCaseList.mk |
| 21 | |
Ying Wang | 50889ab | 2010-12-01 16:29:54 -0800 | [diff] [blame] | 22 | CTS_API_COVERAGE_EXE := $(HOST_OUT_EXECUTABLES)/cts-api-coverage |
Brian Muramatsu | 4b32d08 | 2010-12-02 13:08:44 -0800 | [diff] [blame] | 23 | DEXDEPS_EXE := $(HOST_OUT_EXECUTABLES)/dexdeps |
Brian Muramatsu | 2f8eead | 2010-09-24 14:56:43 -0700 | [diff] [blame] | 24 | |
Brian Muramatsu | 4b32d08 | 2010-12-02 13:08:44 -0800 | [diff] [blame] | 25 | COVERAGE_OUT := $(HOST_OUT)/cts/api-coverage |
| 26 | COVERAGE_RES := cts/tools/cts-api-coverage/res |
Ying Wang | 50889ab | 2010-12-01 16:29:54 -0800 | [diff] [blame] | 27 | |
Brian Muramatsu | 4b32d08 | 2010-12-02 13:08:44 -0800 | [diff] [blame] | 28 | cts-test-coverage-report := $(COVERAGE_OUT)/test-coverage.xml |
| 29 | cts-verifier-coverage-report := $(COVERAGE_OUT)/verifier-coverage.xml |
| 30 | api-coverage-css := $(COVERAGE_OUT)/api-coverage.css |
| 31 | api-coverage-xsl := $(COVERAGE_OUT)/api-coverage.xsl |
| 32 | |
| 33 | CTS_API_COVERAGE_DEPENDENCIES := $(CTS_API_COVERAGE_EXE) $(DEXDEPS_EXE) $(ACP) \ |
| 34 | $(api-coverage-css) $(api-coverage-xsl) |
Ying Wang | 50889ab | 2010-12-01 16:29:54 -0800 | [diff] [blame] | 35 | |
| 36 | $(cts-test-coverage-report) : $(CTS_COVERAGE_TEST_CASE_LIST) $(CTS_API_COVERAGE_DEPENDENCIES) |
Brian Muramatsu | 2f8eead | 2010-09-24 14:56:43 -0700 | [diff] [blame] | 37 | $(call generate-coverage-report,"CTS Tests API Coverage Report",\ |
Brian Muramatsu | 4b32d08 | 2010-12-02 13:08:44 -0800 | [diff] [blame] | 38 | $(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 Muramatsu | 2f8eead | 2010-09-24 14:56:43 -0700 | [diff] [blame] | 49 | |
Ying Wang | 50889ab | 2010-12-01 16:29:54 -0800 | [diff] [blame] | 50 | .PHONY: cts-test-coverage |
| 51 | cts-test-coverage : $(cts-test-coverage-report) |
| 52 | |
Brian Muramatsu | 4b32d08 | 2010-12-02 13:08:44 -0800 | [diff] [blame] | 53 | .PHONY: cts-verifier-coverage |
| 54 | cts-verifier-coverage : $(cts-verifier-coverage-report) |
| 55 | |
Ying Wang | 50889ab | 2010-12-01 16:29:54 -0800 | [diff] [blame] | 56 | # Put the test coverage report in the dist dir if "cts" is among the build goals. |
| 57 | ifneq ($(filter cts, $(MAKECMDGOALS)),) |
| 58 | $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.xml) |
Brian Muramatsu | 4b32d08 | 2010-12-02 13:08:44 -0800 | [diff] [blame] | 59 | $(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 Wang | 50889ab | 2010-12-01 16:29:54 -0800 | [diff] [blame] | 62 | endif |
| 63 | |
Brian Muramatsu | 2f8eead | 2010-09-24 14:56:43 -0700 | [diff] [blame] | 64 | # 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 |
| 70 | define generate-coverage-report |
Brian Muramatsu | 2f8eead | 2010-09-24 14:56:43 -0700 | [diff] [blame] | 71 | $(hide) mkdir -p $(4) |
Brian Muramatsu | 2f8eead | 2010-09-24 14:56:43 -0700 | [diff] [blame] | 72 | |
| 73 | $(foreach testcase,$(2),$(eval $(call add-testcase-apk,$(testcase)))) |
Brian Muramatsu | 4b32d08 | 2010-12-02 13:08:44 -0800 | [diff] [blame] | 74 | $(hide) $(CTS_API_COVERAGE_EXE) -d $(DEXDEPS_EXE) -f $(3) -o $(4)/$(5) $(TEST_APKS) |
Brian Muramatsu | 2f8eead | 2010-09-24 14:56:43 -0700 | [diff] [blame] | 75 | |
| 76 | @echo $(1): file://$(ANDROID_BUILD_TOP)/$(4)/$(5) |
| 77 | endef |
| 78 | |
| 79 | define add-testcase-apk |
| 80 | TEST_APKS += $(call intermediates-dir-for,APPS,$(1))/package.apk |
| 81 | endef |
Brian Muramatsu | 4b32d08 | 2010-12-02 13:08:44 -0800 | [diff] [blame] | 82 | |
| 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 |
| 86 | define copy-coverage-resource |
| 87 | $(hide) mkdir -p `dirname $(2)` |
| 88 | $(hide) $(ACP) $(COVERAGE_RES)/$(1) $(2) |
| 89 | endef |