Home | History | Annotate | Download | only in cts
      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 
     22 cts_api_coverage_exe := $(HOST_OUT_EXECUTABLES)/cts-api-coverage
     23 dexdeps_exe := $(HOST_OUT_EXECUTABLES)/dexdeps
     24 
     25 coverage_out := $(HOST_OUT)/cts-api-coverage
     26 
     27 api_text_description := frameworks/base/api/current.txt
     28 api_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 $(dir $@)
     32 	$(hide) $(APICHECK_COMMAND) -convert2xml $< $@
     33 
     34 cts-test-coverage-report := $(coverage_out)/test-coverage.html
     35 cts-verifier-coverage-report := $(coverage_out)/verifier-coverage.html
     36 cts-combined-coverage-report := $(coverage_out)/combined-coverage.html
     37 
     38 cts_api_coverage_dependencies := $(cts_api_coverage_exe) $(dexdeps_exe) $(api_xml_description)
     39 
     40 cts_coverage_test_cases_dependencies := $(foreach c, $(CTS_COVERAGE_TEST_CASE_LIST), $(call intermediates-dir-for,APPS,$(c))/package.apk)
     41 $(cts-test-coverage-report): PRIVATE_TEST_CASES_APKS := $(cts_coverage_test_cases_dependencies)
     42 $(cts-test-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
     43 $(cts-test-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
     44 $(cts-test-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
     45 $(cts-test-coverage-report) : $(cts_coverage_test_cases_dependencies) $(cts_api_coverage_dependencies) | $(ACP)
     46 	$(call generate-coverage-report,"CTS Tests API Coverage Report",\
     47 			$(PRIVATE_TEST_CASES_APKS),html)
     48 
     49 cts_coverage_test_cases_dependencies := $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk
     50 $(cts-verifier-coverage-report): PRIVATE_TEST_CASES_APKS := $(cts_coverage_test_cases_dependencies)
     51 $(cts-verifier-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
     52 $(cts-verifier-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
     53 $(cts-verifier-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
     54 $(cts-verifier-coverage-report) : $(cts_coverage_test_cases_dependencies) $(cts_api_coverage_dependencies) | $(ACP)
     55 	$(call generate-coverage-report,"CTS Verifier API Coverage Report",\
     56 			$(PRIVATE_TEST_CASES_APKS),html)
     57 
     58 cts_coverage_test_cases_dependencies := $(foreach c, $(CTS_COVERAGE_TEST_CASE_LIST) CtsVerifier, $(call intermediates-dir-for,APPS,$(c))/package.apk)
     59 $(cts-combined-coverage-report): PRIVATE_TEST_CASES_APKS := $(cts_coverage_test_cases_dependencies)
     60 $(cts-combined-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
     61 $(cts-combined-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
     62 $(cts-combined-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
     63 $(cts-combined-coverage-report) : $(cts_coverage_test_cases_dependencies) $(cts_api_coverage_dependencies) | $(ACP)
     64 	$(call generate-coverage-report,"CTS Combined API Coverage Report",\
     65 			$(PRIVATE_TEST_CASES_APKS),html)
     66 
     67 .PHONY: cts-test-coverage
     68 cts-test-coverage : $(cts-test-coverage-report)
     69 
     70 .PHONY: cts-verifier-coverage
     71 cts-verifier-coverage : $(cts-verifier-coverage-report)
     72 
     73 .PHONY: cts-combined-coverage
     74 cts-combined-coverage : $(cts-combined-coverage-report)
     75 
     76 # Put the test coverage report in the dist dir if "cts" is among the build goals.
     77 ifneq ($(filter cts, $(MAKECMDGOALS)),)
     78   $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.html)
     79   $(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html)
     80   $(call dist-for-goals, cts, $(cts-combined-coverage-report):cts-combined-coverage-report.html)
     81 endif
     82 
     83 # Arguments;
     84 #  1 - Name of the report printed out on the screen
     85 #  2 - List of apk files that will be scanned to generate the report
     86 #  3 - Format of the report
     87 define generate-coverage-report
     88 	$(hide) mkdir -p $(dir $@)
     89 	$(hide) $(PRIVATE_CTS_API_COVERAGE_EXE) -d $(PRIVATE_DEXDEPS_EXE) -a $(PRIVATE_API_XML_DESC) -f $(3) -o $@ $(2)
     90 	@ echo $(1): file://$(ANDROID_BUILD_TOP)/$@
     91 endef
     92 
     93 # Reset temp vars
     94 cts_api_coverage_dependencies :=
     95 cts_coverage_test_cases_dependencies :=
     96 cts-combined-coverage-report :=
     97 cts-verifier-coverage-report :=
     98 cts-test-coverage-report :=
     99 api_xml_description :=
    100 api_text_description :=
    101 coverage_out :=
    102 dexdeps_exe :=
    103 cts_api_coverage_exe :=
    104