cts.mk revision b6a08f0cd36b12054ac73992a2737ea294387116
1# Copyright (C) 2008 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
15cts_dir := $(HOST_OUT)/cts
16cts_tools_src_dir := cts/tools
17
18cts_name := android-cts
19
20CTS_EXECUTABLE := startcts
21ifeq ($(HOST_OS),windows)
22    CTS_EXECUTABLE_PATH := $(cts_tools_src_dir)/host/etc/cts.bat
23else
24    CTS_EXECUTABLE_PATH := $(cts_tools_src_dir)/utils/$(CTS_EXECUTABLE)
25endif
26CTS_HOST_JAR := $(HOST_OUT_JAVA_LIBRARIES)/cts.jar
27
28junit_host_jar := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
29HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar
30
31CTS_CORE_CASE_LIST := \
32	android.core.tests.dom \
33	android.core.tests.luni.io \
34	android.core.tests.luni.lang \
35	android.core.tests.luni.net \
36	android.core.tests.luni.util \
37	android.core.tests.xml \
38	android.core.tests.runner
39
40CTS_SECURITY_APPS_LIST := \
41	CtsAppAccessData \
42	CtsAppWithData \
43	CtsInstrumentationAppDiffCert \
44	CtsPermissionDeclareApp \
45	CtsSharedUidInstall \
46	CtsSharedUidInstallDiffCert \
47	CtsSimpleAppInstall \
48	CtsSimpleAppInstallDiffCert \
49	CtsTargetInstrumentationApp \
50	CtsUsePermissionDiffCert
51
52CTS_CASE_LIST := \
53	TestDeviceSetup \
54	CtsTestStubs \
55	CtsAccessibilityServiceTestCases \
56	CtsAccountManagerTestCases \
57	CtsAppTestCases \
58	CtsBluetoothTestCases \
59	CtsContentTestCases \
60	CtsDatabaseTestCases \
61	CtsDelegatingAccessibilityService \
62	CtsDpiTestCases \
63	CtsDpiTestCases2 \
64	CtsExampleTestCases \
65	CtsGestureTestCases \
66	CtsGraphicsTestCases \
67	CtsHardwareTestCases \
68	CtsJniTestCases \
69	CtsLocationTestCases \
70	CtsMediaTestCases \
71	CtsOsTestCases \
72	CtsPermissionTestCases \
73	CtsPermission2TestCases \
74	CtsProviderTestCases \
75	CtsSpeechTestCases \
76	CtsTelephonyTestCases \
77	CtsTextTestCases \
78	CtsUtilTestCases \
79	CtsViewTestCases \
80	CtsWebkitTestCases \
81	CtsWidgetTestCases \
82	CtsNetTestCases \
83	SignatureTest \
84	CtsPerformanceTestCases \
85	CtsPerformance2TestCases \
86	CtsPerformance3TestCases \
87	CtsPerformance4TestCases \
88	CtsPerformance5TestCases \
89	ApiDemos \
90	ApiDemosReferenceTest \
91	$(CTS_CORE_CASE_LIST) \
92	$(CTS_SECURITY_APPS_LIST)
93
94DEFAULT_TEST_PLAN := $(PRIVATE_DIR)/resource/plans
95
96$(cts_dir)/all_cts_files_stamp: PRIVATE_JUNIT_HOST_JAR := $(junit_host_jar)
97
98$(cts_dir)/all_cts_files_stamp: $(CTS_CASE_LIST) $(junit_host_jar) $(HOSTTESTLIB_JAR) $(ACP)
99# Make necessary directory for CTS
100	@rm -rf $(PRIVATE_CTS_DIR)
101	@mkdir -p $(TMP_DIR)
102	@mkdir -p $(PRIVATE_DIR)/docs
103	@mkdir -p $(PRIVATE_DIR)/tools
104	@mkdir -p $(PRIVATE_DIR)/repository/testcases
105	@mkdir -p $(PRIVATE_DIR)/repository/plans
106# Copy executable to CTS directory
107	$(hide) $(ACP) -fp $(CTS_HOST_JAR) $(PRIVATE_DIR)/tools
108	$(hide) $(ACP) -fp $(CTS_EXECUTABLE_PATH) $(PRIVATE_DIR)/tools
109# Copy junit jar
110	$(hide) $(ACP) -fp $(PRIVATE_JUNIT_HOST_JAR) $(PRIVATE_DIR)/tools
111# Copy hosttestlib jar
112	$(hide) $(ACP) -fp $(HOSTTESTLIB_JAR) $(PRIVATE_DIR)/tools
113# Change mode of the executables
114	$(hide) chmod ug+rwX $(PRIVATE_DIR)/tools/$(notdir $(CTS_EXECUTABLE_PATH))
115	$(foreach apk,$(CTS_CASE_LIST), \
116			$(call copy-testcase-apk,$(apk)))
117# Copy CTS host config to CTS directory
118	$(hide) $(ACP) -fp $(cts_tools_src_dir)/utils/host_config.xml $(PRIVATE_DIR)/repository/
119	$(hide) touch $@
120
121# Generate the test descriptions for the core-tests
122# Parameters:
123# $1 : The output file where the description should be written (without the '.xml' extension)
124# $2 : The AndroidManifest.xml corresponding to the test package
125# $3 : The name of the TestSuite generator class to use
126# $4 : The Android.mk corresponding to the test package (required for host-side tests only)
127define generate-core-test-description
128@echo "Generate core-test description ("$(notdir $(1))")"
129$(hide) java $(PRIVATE_JAVAOPTS) \
130	-classpath $(PRIVATE_CLASSPATH) \
131	$(PRIVATE_PARAMS) CollectAllTests $(1) \
132	$(2) $(3) $(4)
133endef
134
135CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
136TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
137GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(TESTS_INTERMEDIATES)/classes.jar:$(CORE_INTERMEDIATES)/javalib.jar:$(TESTS_INTERMEDIATES)/javalib.jar:$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR)
138
139$(cts_dir)/all_cts_core_files_stamp: PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
140$(cts_dir)/all_cts_core_files_stamp: PRIVATE_JAVAOPTS:=-Xmx256M
141$(cts_dir)/all_cts_core_files_stamp: PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true
142$(cts_dir)/all_cts_core_files_stamp: PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true
143# Why does this depend on javalib.jar instead of classes.jar?  Because
144# even though the tool will operate on the classes.jar files, the
145# build system requires that dependencies use javalib.jar.  If
146# javalib.jar is up-to-date, then classes.jar is as well.  Depending
147# on classes.jar will build the files incorrectly.
148$(cts_dir)/all_cts_core_files_stamp: $(CTS_CORE_CASE_LIST) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(TESTS_INTERMEDIATES)/javalib.jar $(cts_dir)/all_cts_files_stamp | $(ACP)
149	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.dom,\
150		cts/tests/core/dom/AndroidManifest.xml,\
151		tests.dom.AllTests)
152	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.io,\
153		cts/tests/core/luni-io/AndroidManifest.xml,\
154		tests.luni.AllTestsIo)
155	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.lang,\
156		cts/tests/core/luni-lang/AndroidManifest.xml,\
157		tests.luni.AllTestsLang)
158	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.net,\
159		cts/tests/core/luni-net/AndroidManifest.xml,\
160		tests.luni.AllTestsNet)
161	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.util,\
162		cts/tests/core/luni-util/AndroidManifest.xml,\
163		tests.luni.AllTestsUtil)
164	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.xml,\
165		cts/tests/core/xml/AndroidManifest.xml,\
166		tests.xml.AllTests)
167	$(hide) touch $@
168
169
170# ----- Generate the test descriptions for the vm-tests -----
171#
172CORE_VM_TEST_DESC := $(cts_dir)/$(cts_name)/repository/testcases/android.core.vm-tests
173
174VMTESTS_INTERMEDIATES :=$(call intermediates-dir-for,EXECUTABLES,vm-tests,1,)
175# core tests only needed to get hold of junit-framework-classes
176TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
177CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
178
179GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(TESTS_INTERMEDIATES)/classes.jar:$(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar:$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR)
180
181$(CORE_VM_TEST_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
182$(CORE_VM_TEST_DESC): PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true
183$(CORE_VM_TEST_DESC): PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true
184$(CORE_VM_TEST_DESC): PRIVATE_JAVAOPTS:=-Xmx256M
185# Please see big comment above on why this line depends on javalib.jar instead of classes.jar
186$(CORE_VM_TEST_DESC): vm-tests $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(TESTS_INTERMEDIATES)/javalib.jar $(cts_dir)/all_cts_files_stamp | $(ACP)
187	$(call generate-core-test-description,$(CORE_VM_TEST_DESC),\
188		cts/tests/vm-tests/AndroidManifest.xml,\
189		dot.junit.AllJunitHostTests, cts/tools/vm-tests/Android.mk)
190	$(ACP) -fv $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(PRIVATE_DIR)/repository/testcases/android.core.vm-tests.jar
191
192# Move app security host-side tests to the repository
193APP_SECURITY_LIB := $(cts_dir)/$(cts_name)/repository/testcases/CtsAppSecurityTests.jar
194
195$(APP_SECURITY_LIB): $(HOST_OUT_JAVA_LIBRARIES)/CtsAppSecurityTests.jar $(cts_dir)/all_cts_files_stamp $(ACP)
196	$(ACP) -fv $(HOST_OUT_JAVA_LIBRARIES)/CtsAppSecurityTests.jar $(APP_SECURITY_LIB)
197
198# Generate the default test plan for User.
199# Usage: buildCts.py <testRoot> <ctsOutputDir> <tempDir> <androidRootDir> <docletPath>
200$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_dir)/all_cts_core_files_stamp $(cts_tools_src_dir)/utils/buildCts.py $(CORE_VM_TEST_DESC) $(APP_SECURITY_LIB) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
201	$(hide) $(cts_tools_src_dir)/utils/buildCts.py cts/tests/tests/ $(PRIVATE_DIR) $(TMP_DIR) \
202		$(TOP) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
203
204# Package CTS and clean up.
205#
206# TODO:
207#   Pack cts.bat into the same zip file as well. See http://buganizer/issue?id=1656821 for more details
208INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip
209$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name)
210$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir)
211$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name)
212$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
213$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN) $(CORE_VM_TEST_DESC)
214	@echo "Package CTS: $@"
215	$(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
216
217.PHONY: cts
218cts: $(INTERNAL_CTS_TARGET) adb
219$(call dist-for-goals,cts,$(INTERNAL_CTS_TARGET))
220
221define copy-testcase-apk
222
223$(hide) $(ACP) -fp $(call intermediates-dir-for,APPS,$(1))/package.apk \
224	$(PRIVATE_DIR)/repository/testcases/$(1).apk
225
226endef
227