1# Copyright (C) 2016 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Rules to generate a tests zip file that included test modules
16# based on the configuration.
17
18LOCAL_PATH := $(call my-dir)
19include $(LOCAL_PATH)/tests/instrumentation_test_list.mk
20-include $(wildcard vendor/*/build/tasks/tests/instrumentation_test_list.mk)
21
22my_modules := \
23    $(instrumentation_tests)
24
25my_package_name := continuous_instrumentation_tests
26
27include $(BUILD_SYSTEM)/tasks/tools/package-modules.mk
28
29.PHONY: continuous_instrumentation_tests
30continuous_instrumentation_tests : $(my_package_zip)
31
32name := $(TARGET_PRODUCT)-continuous_instrumentation_tests-$(FILE_NAME_TAG)
33$(call dist-for-goals, continuous_instrumentation_tests, $(my_package_zip):$(name).zip)
34
35# Also build this when you run "make tests".
36tests: continuous_instrumentation_tests
37
38# Include test em files in emma metadata
39ifeq ($(EMMA_INSTRUMENT_STATIC),true)
40    $(EMMA_META_ZIP) : continuous_instrumentation_tests
41endif
42
43# Rules to generate an API-coverage report based on the above tests
44
45# Coverage report output location
46coverage_out := $(call intermediates-dir-for,PACKAGING,continuous_instrumentation_tests_coverage)
47coverage_report := $(coverage_out)/api_coverage.html
48
49# Framework API descriptions
50api_text := frameworks/base/api/system-current.txt
51api_xml := $(coverage_out)/api.xml
52$(api_xml) : $(api_text) $(APICHECK)
53	$(hide) echo "Converting API file to XML: $@"
54	$(hide) mkdir -p $(dir $@)
55	$(hide) $(APICHECK_COMMAND) -convert2xml $< $@
56
57# CTS API coverage tool
58api_coverage_exe := $(HOST_OUT_EXECUTABLES)/cts-api-coverage
59dexdeps_exe := $(HOST_OUT_EXECUTABLES)/dexdeps
60
61# APKs to measure for coverage
62test_apks := $(call intermediates-dir-for,PACKAGING,continuous_instrumentation_tests)/DATA/app/*
63
64# Rule to generate the coverage report
65api_coverage_dep := continuous_instrumentation_tests $(api_coverage_exe) $(dexdeps_exe) $(api_xml)
66$(coverage_report): PRIVATE_API_COVERAGE_EXE := $(api_coverage_exe)
67$(coverage_report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
68$(coverage_report): PRIVATE_API_XML := $(api_xml)
69$(coverage_report): PRIVATE_REPORT_TITLE := "APCT API Coverage Report"
70$(coverage_report): PRIVATE_TEST_APKS := $(test_apks)
71$(coverage_report): $(api_coverage_dep) | $(ACP)
72	$(hide) mkdir -p $(dir $@)
73	$(hide) $(PRIVATE_API_COVERAGE_EXE) -d $(PRIVATE_DEXDEPS_EXE) \
74		-a $(PRIVATE_API_XML) -t $(PRIVATE_REPORT_TITLE) -f html -o $@ $(PRIVATE_TEST_APKS)
75	@ echo $(PRIVATE_REPORT_TITLE): file://$(ANDROID_BUILD_TOP)/$@
76
77.PHONY: continuous_instrumentation_tests_api_coverage
78continuous_instrumentation_tests_api_coverage : $(coverage_report)
79
80# Include the coverage report in the dist folder
81$(call dist-for-goals, continuous_instrumentation_tests_api_coverage, \
82	$(coverage_report):$(name)-api_coverage.html)
83
84# Also build this when you run "make tests".
85# This allow us to not change the build server config.
86tests : continuous_instrumentation_tests_api_coverage
87
88# Reset temp vars
89coverage_out :=
90coverage_report :=
91api_text :=
92api_xml :=
93api_coverage_exe :=
94dexdeps_exe :=
95test_apks :=
96api_coverage_dep :=
97