• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
20DDMLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/ddmlib-prebuilt.jar
21junit_host_jar := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
22HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar
23TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
24CTS_TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/cts-tradefed.jar
25CTS_TF_EXEC_PATH := $(HOST_OUT_EXECUTABLES)/cts-tradefed
26CTS_TF_README_PATH := $(cts_tools_src_dir)/tradefed-host/README
27
28VMTESTSTF_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
29VMTESTSTF_JAR := $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar
30
31CTS_CORE_CASE_LIST := \
32	android.core.tests.libcore.package.dalvik \
33	android.core.tests.libcore.package.com \
34	android.core.tests.libcore.package.conscrypt \
35	android.core.tests.libcore.package.sun \
36	android.core.tests.libcore.package.tests \
37	android.core.tests.libcore.package.org \
38	android.core.tests.libcore.package.libcore \
39	android.core.tests.runner
40
41# Depend on the full package paths rather than the phony targets to avoid
42# rebuilding the packages every time.
43CTS_CORE_CASES := $(foreach pkg,$(CTS_CORE_CASE_LIST),$(call intermediates-dir-for,APPS,$(pkg))/package.apk)
44
45-include cts/CtsTestCaseList.mk
46CTS_CASE_LIST := $(CTS_CORE_CASE_LIST) $(CTS_TEST_CASE_LIST)
47
48DEFAULT_TEST_PLAN := $(cts_dir)/$(cts_name)/resource/plans
49CTS_TEST_CASE_LIST_FILES := $(foreach c, $(CTS_TEST_CASE_LIST), $(call intermediates-dir-for,APPS,$(c))/package.apk)
50$(cts_dir)/all_cts_files_stamp: PRIVATE_JUNIT_HOST_JAR := $(junit_host_jar)
51$(cts_dir)/all_cts_files_stamp: $(CTS_CORE_CASES) $(CTS_TEST_CASES) $(CTS_TEST_CASE_LIST_FILES) $(junit_host_jar) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(VMTESTSTF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(ACP)
52# Make necessary directory for CTS
53	$(hide) rm -rf $(PRIVATE_CTS_DIR)
54	$(hide) mkdir -p $(TMP_DIR)
55	$(hide) mkdir -p $(PRIVATE_DIR)/docs
56	$(hide) mkdir -p $(PRIVATE_DIR)/tools
57	$(hide) mkdir -p $(PRIVATE_DIR)/repository/testcases
58	$(hide) mkdir -p $(PRIVATE_DIR)/repository/plans
59# Copy executable and JARs to CTS directory
60	$(hide) $(ACP) -fp $(VMTESTSTF_JAR) $(PRIVATE_DIR)/repository/testcases
61	$(hide) $(ACP) -fp $(DDMLIB_JAR) $(PRIVATE_JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(PRIVATE_DIR)/tools
62# Change mode of the executables
63	$(foreach apk,$(CTS_CASE_LIST),$(call copy-testcase-apk,$(apk)))
64	$(foreach testcase,$(CTS_TEST_CASES),$(call copy-testcase,$(testcase)))
65	$(hide) touch $@
66
67# Generate the test descriptions for the core-tests
68# Parameters:
69# $1 : The output file where the description should be written (without the '.xml' extension)
70# $2 : The AndroidManifest.xml corresponding to the test package
71# $3 : The jar file name on PRIVATE_CLASSPATH containing junit tests to search for
72# $4 : The package prefix of classes to include, possible empty
73# $5 : The directory containing vogar expectations files
74# $6 : The Android.mk corresponding to the test package (required for host-side tests only)
75define generate-core-test-description
76@echo "Generate core-test description ("$(notdir $(1))")"
77$(hide) java -Xmx256M \
78	-Xbootclasspath/a:$(PRIVATE_CLASSPATH) \
79	-classpath $(PRIVATE_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR) \
80	$(PRIVATE_PARAMS) CollectAllTests $(1) $(2) $(3) "$(4)" $(5) $(6)
81endef
82
83CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
84CONSCRYPT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt,,COMMON)
85BOUNCYCASTLE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,bouncycastle,,COMMON)
86APACHEXML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-xml,,COMMON)
87OKHTTP_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp,,COMMON)
88SQLITEJDBC_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,sqlite-jdbc,,COMMON)
89JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
90CORETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
91CONSCRYPTTESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt-tests,,COMMON)
92
93GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(CONSCRYPT_INTERMEDIATES)/classes.jar:$(BOUNCYCASTLE_INTERMEDIATES)/classes.jar:$(APACHEXML_INTERMEDIATES)/classes.jar:$(OKHTTP_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(SQLITEJDBC_INTERMEDIATES)/javalib.jar:$(CORETESTS_INTERMEDIATES)/javalib.jar:$(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar
94
95CTS_CORE_XMLS := \
96	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml \
97	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com.xml \
98	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt.xml \
99	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun.xml \
100	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests.xml \
101	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org.xml \
102	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml
103
104$(CTS_CORE_XMLS): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
105# Why does this depend on javalib.jar instead of classes.jar?  Because
106# even though the tool will operate on the classes.jar files, the
107# build system requires that dependencies use javalib.jar.  If
108# javalib.jar is up-to-date, then classes.jar is as well.  Depending
109# on classes.jar will build the files incorrectly.
110CTS_CORE_XMLS_DEPS := $(CTS_CORE_CASES) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(BOUNCYCASTLE_INTERMEDIATES)/javalib.jar $(APACHEXML_INTERMEDIATES)/javalib.jar $(OKHTTP_INTERMEDIATES)/javalib.jar $(SQLITEJDBC_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(CORETESTS_INTERMEDIATES)/javalib.jar $(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar | $(ACP)
111
112$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml: $(CTS_CORE_XMLS_DEPS)
113	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
114	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik,\
115		cts/tests/core/libcore/dalvik/AndroidManifest.xml,\
116		$(CORETESTS_INTERMEDIATES)/javalib.jar,dalvik,\
117		libcore/expectations)
118
119$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com.xml: $(CTS_CORE_XMLS_DEPS)
120	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
121	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com,\
122		cts/tests/core/libcore/com/AndroidManifest.xml,\
123		$(CORETESTS_INTERMEDIATES)/javalib.jar,com,\
124		libcore/expectations)
125
126$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt.xml: $(CTS_CORE_XMLS_DEPS)
127	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
128	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt,\
129		cts/tests/core/libcore/conscrypt/AndroidManifest.xml,\
130		$(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar,,\
131		libcore/expectations)
132
133$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun.xml: $(CTS_CORE_XMLS_DEPS)
134	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
135	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun,\
136		cts/tests/core/libcore/sun/AndroidManifest.xml,\
137		$(CORETESTS_INTERMEDIATES)/javalib.jar,sun,\
138		libcore/expectations)
139
140$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests.xml: $(CTS_CORE_XMLS_DEPS)
141	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
142	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests,\
143		cts/tests/core/libcore/tests/AndroidManifest.xml,\
144		$(CORETESTS_INTERMEDIATES)/javalib.jar,tests,\
145		libcore/expectations)
146
147$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org.xml: $(CTS_CORE_XMLS_DEPS)
148	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
149	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org,\
150		cts/tests/core/libcore/org/AndroidManifest.xml,\
151		$(CORETESTS_INTERMEDIATES)/javalib.jar,org,\
152		libcore/expectations)
153
154$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml: $(CTS_CORE_XMLS_DEPS)
155	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
156	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore,\
157		cts/tests/core/libcore/libcore/AndroidManifest.xml,\
158		$(CORETESTS_INTERMEDIATES)/javalib.jar,libcore,\
159		libcore/expectations)
160
161# ----- Generate the test descriptions for the vm-tests-tf -----
162#
163CORE_VM_TEST_TF_DESC := $(CTS_TESTCASES_OUT)/android.core.vm-tests-tf.xml
164
165# core tests only needed to get hold of junit-framework-classes
166CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
167JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
168
169GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(VMTESTSTF_JAR):$(DDMLIB_JAR):$(TF_JAR)
170
171$(CORE_VM_TEST_TF_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
172# Please see big comment above on why this line depends on javalib.jar instead of classes.jar
173$(CORE_VM_TEST_TF_DESC): $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(VMTESTSTF_JAR) $(DDMLIB_JAR) | $(ACP)
174	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
175	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.vm-tests-tf,\
176		cts/tests/vm-tests-tf/AndroidManifest.xml,\
177		$(VMTESTSTF_JAR),"",\
178		libcore/expectations,\
179		cts/tools/vm-tests-tf/Android.mk)
180
181# Generate the default test plan for User.
182# Usage: buildCts.py <testRoot> <ctsOutputDir> <tempDir> <androidRootDir> <docletPath>
183
184$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_tools_src_dir)/utils/buildCts.py $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CTS_CORE_XMLS) $(CTS_TEST_XMLS) $(CORE_VM_TEST_TF_DESC) | $(ACP)
185	$(hide) $(ACP) -fp $(CTS_CORE_XMLS) $(CTS_TEST_XMLS) $(CORE_VM_TEST_TF_DESC) $(PRIVATE_DIR)/repository/testcases
186	$(hide) $(cts_tools_src_dir)/utils/buildCts.py cts/tests/tests/ $(PRIVATE_DIR) $(TMP_DIR) \
187		$(TOP) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
188	$(hide) mkdir -p $(dir $@) && touch $@
189
190# Package CTS and clean up.
191#
192# TODO:
193#   Pack cts.bat into the same zip file as well. See http://buganizer/issue?id=1656821 for more details
194INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip
195$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name)
196$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir)
197$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name)
198$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
199$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN)
200	$(hide) echo "Package CTS: $@"
201	$(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
202
203.PHONY: cts
204cts: $(INTERNAL_CTS_TARGET) adb
205$(call dist-for-goals,cts,$(INTERNAL_CTS_TARGET))
206
207define copy-testcase-apk
208
209$(hide) $(ACP) -fp $(call intermediates-dir-for,APPS,$(1))/package.apk \
210	$(PRIVATE_DIR)/repository/testcases/$(1).apk
211
212endef
213
214define copy-testcase
215
216$(hide) $(ACP) -fp $(1) $(PRIVATE_DIR)/repository/testcases/$(notdir $1)
217
218endef
219