blob: b2fb79ea572474312de0d5a5c9cf39208fde1d7c [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# 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
Xavier Ducrohete743c532010-07-28 11:07:31 -070020DDMLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/ddmlib-prebuilt.jar
Brett Chabot67bae7f2009-06-26 14:41:30 -070021junit_host_jar := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
Phil Dubach3b7521b2009-08-19 16:26:40 -070022HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar
Brett Chabot358b2472011-01-30 15:07:21 -080023TF_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
Brett Chabote847a392011-02-18 15:13:50 -080026CTS_TF_README_PATH := $(cts_tools_src_dir)/tradefed-host/README
Brett Chabot67bae7f2009-06-26 14:41:30 -070027
Ying Wang02d75da2012-08-21 11:54:49 -070028VMTESTSTF_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
Brian Muramatsuc0a69242012-01-05 18:24:43 -080029VMTESTSTF_JAR := $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar
30
Brian Carlstromb6a08f02010-05-28 17:02:57 -070031CTS_CORE_CASE_LIST := \
Brian Carlstromaf850002011-05-27 00:04:57 -070032 android.core.tests.libcore.package.dalvik \
33 android.core.tests.libcore.package.com \
34 android.core.tests.libcore.package.sun \
35 android.core.tests.libcore.package.tests \
36 android.core.tests.libcore.package.org \
37 android.core.tests.libcore.package.libcore \
Jorg Pleumann61788202009-05-07 01:33:14 -070038 android.core.tests.runner
Urs Grobb3c6b2d2009-04-17 11:27:08 -070039
Brian Muramatsuc0a69242012-01-05 18:24:43 -080040# Depend on the full package paths rather than the phony targets to avoid
41# rebuilding the packages every time.
42CTS_CORE_CASES := $(foreach pkg,$(CTS_CORE_CASE_LIST),$(call intermediates-dir-for,APPS,$(pkg))/package.apk)
43
Brian Muramatsufa3d88f2010-07-22 14:46:53 -070044-include cts/CtsTestCaseList.mk
45CTS_CASE_LIST := $(CTS_CORE_CASE_LIST) $(CTS_TEST_CASE_LIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -080046
Joe Onorato80042662010-06-15 17:29:19 -040047DEFAULT_TEST_PLAN := $(cts_dir)/$(cts_name)/resource/plans
Ying Wang51a1ae12013-07-10 11:33:27 -070048CTS_TEST_CASE_LIST_FILES := $(foreach c, $(CTS_TEST_CASE_LIST), $(call intermediates-dir-for,APPS,$(c))/package.apk)
Brett Chabot67bae7f2009-06-26 14:41:30 -070049$(cts_dir)/all_cts_files_stamp: PRIVATE_JUNIT_HOST_JAR := $(junit_host_jar)
Ying Wang51a1ae12013-07-10 11:33:27 -070050$(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)
The Android Open Source Project88b60792009-03-03 19:28:42 -080051# Make necessary directory for CTS
Brian Muramatsu1cf9e0e2010-12-06 12:49:13 -080052 $(hide) rm -rf $(PRIVATE_CTS_DIR)
53 $(hide) mkdir -p $(TMP_DIR)
54 $(hide) mkdir -p $(PRIVATE_DIR)/docs
55 $(hide) mkdir -p $(PRIVATE_DIR)/tools
56 $(hide) mkdir -p $(PRIVATE_DIR)/repository/testcases
57 $(hide) mkdir -p $(PRIVATE_DIR)/repository/plans
Brian Muramatsu45a971d2010-09-02 12:36:59 -070058# Copy executable and JARs to CTS directory
Brian Muramatsuc0a69242012-01-05 18:24:43 -080059 $(hide) $(ACP) -fp $(VMTESTSTF_JAR) $(PRIVATE_DIR)/repository/testcases
Brian Muramatsu277be2f2011-11-03 11:34:06 -070060 $(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
The Android Open Source Project88b60792009-03-03 19:28:42 -080061# Change mode of the executables
Brian Muramatsu237fa072011-12-12 23:54:49 -080062 $(foreach apk,$(CTS_CASE_LIST),$(call copy-testcase-apk,$(apk)))
63 $(foreach testcase,$(CTS_TEST_CASES),$(call copy-testcase,$(testcase)))
The Android Open Source Project88b60792009-03-03 19:28:42 -080064 $(hide) touch $@
65
Urs Grobb3c6b2d2009-04-17 11:27:08 -070066# Generate the test descriptions for the core-tests
Phil Dubachc539dbe2009-08-07 10:59:04 -070067# Parameters:
68# $1 : The output file where the description should be written (without the '.xml' extension)
69# $2 : The AndroidManifest.xml corresponding to the test package
Brian Carlstrombb7c6d82011-04-01 15:45:58 -070070# $3 : The jar file name on PRIVATE_CLASSPATH containing junit tests to search for
Brian Carlstromaf850002011-05-27 00:04:57 -070071# $4 : The package prefix of classes to include, possible empty
72# $5 : The directory containing vogar expectations files
73# $6 : The Android.mk corresponding to the test package (required for host-side tests only)
Urs Grobb3c6b2d2009-04-17 11:27:08 -070074define generate-core-test-description
75@echo "Generate core-test description ("$(notdir $(1))")"
Brian Carlstrombb7c6d82011-04-01 15:45:58 -070076$(hide) java -Xmx256M \
Kenny Root65307c02013-02-27 16:55:56 -080077 -Xbootclasspath/a:$(PRIVATE_CLASSPATH) \
Brian Carlstrombb7c6d82011-04-01 15:45:58 -070078 -classpath $(PRIVATE_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR) \
Brian Carlstromaf850002011-05-27 00:04:57 -070079 $(PRIVATE_PARAMS) CollectAllTests $(1) $(2) $(3) "$(4)" $(5) $(6)
Urs Grobb3c6b2d2009-04-17 11:27:08 -070080endef
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -080081
82CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
Kenny Rootdfaf3842013-04-29 13:25:29 -070083CONSCRYPT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt,,COMMON)
Brian Carlstrombb7c6d82011-04-01 15:45:58 -070084BOUNCYCASTLE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,bouncycastle,,COMMON)
85APACHEXML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-xml,,COMMON)
jwilson190dde02013-03-30 09:00:01 -040086OKHTTP_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp,,COMMON)
Brian Carlstrombb7c6d82011-04-01 15:45:58 -070087SQLITEJDBC_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,sqlite-jdbc,,COMMON)
Brian Carlstromd05d74b2010-05-28 18:47:17 -070088JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
Brian Carlstrombb7c6d82011-04-01 15:45:58 -070089CORETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
90
Kenny Rootdfaf3842013-04-29 13:25:29 -070091GEN_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
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -080092
Brian Muramatsuc0a69242012-01-05 18:24:43 -080093CTS_CORE_XMLS := \
94 $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml \
95 $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com.xml \
96 $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun.xml \
97 $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests.xml \
98 $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org.xml \
99 $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml
100
101$(CTS_CORE_XMLS): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800102# Why does this depend on javalib.jar instead of classes.jar? Because
103# even though the tool will operate on the classes.jar files, the
104# build system requires that dependencies use javalib.jar. If
105# javalib.jar is up-to-date, then classes.jar is as well. Depending
106# on classes.jar will build the files incorrectly.
jwilson190dde02013-03-30 09:00:01 -0400107$(CTS_CORE_XMLS): $(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 | $(ACP)
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800108 $(hide) mkdir -p $(CTS_TESTCASES_OUT)
109 $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik,\
Brian Carlstromaf850002011-05-27 00:04:57 -0700110 cts/tests/core/libcore/dalvik/AndroidManifest.xml,\
111 $(CORETESTS_INTERMEDIATES)/javalib.jar,dalvik,\
112 libcore/expectations)
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800113 $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com,\
Brian Carlstromaf850002011-05-27 00:04:57 -0700114 cts/tests/core/libcore/com/AndroidManifest.xml,\
115 $(CORETESTS_INTERMEDIATES)/javalib.jar,com,\
116 libcore/expectations)
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800117 $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun,\
Brian Carlstromaf850002011-05-27 00:04:57 -0700118 cts/tests/core/libcore/sun/AndroidManifest.xml,\
119 $(CORETESTS_INTERMEDIATES)/javalib.jar,sun,\
120 libcore/expectations)
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800121 $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests,\
Brian Carlstromaf850002011-05-27 00:04:57 -0700122 cts/tests/core/libcore/tests/AndroidManifest.xml,\
123 $(CORETESTS_INTERMEDIATES)/javalib.jar,tests,\
124 libcore/expectations)
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800125 $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org,\
Brian Carlstromaf850002011-05-27 00:04:57 -0700126 cts/tests/core/libcore/org/AndroidManifest.xml,\
127 $(CORETESTS_INTERMEDIATES)/javalib.jar,org,\
128 libcore/expectations)
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800129 $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore,\
Brian Carlstromaf850002011-05-27 00:04:57 -0700130 cts/tests/core/libcore/libcore/AndroidManifest.xml,\
131 $(CORETESTS_INTERMEDIATES)/javalib.jar,libcore,\
Brian Carlstrombb7c6d82011-04-01 15:45:58 -0700132 libcore/expectations)
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800133
Tsu Chiang Chuang9d047ac2011-04-27 17:01:32 -0700134# ----- Generate the test descriptions for the vm-tests-tf -----
135#
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800136CORE_VM_TEST_TF_DESC := $(CTS_TESTCASES_OUT)/android.core.vm-tests-tf.xml
Tsu Chiang Chuang9d047ac2011-04-27 17:01:32 -0700137
Tsu Chiang Chuang9d047ac2011-04-27 17:01:32 -0700138# core tests only needed to get hold of junit-framework-classes
139CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
140JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
141
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800142GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(VMTESTSTF_JAR):$(DDMLIB_JAR):$(TF_JAR)
Tsu Chiang Chuang9d047ac2011-04-27 17:01:32 -0700143
144$(CORE_VM_TEST_TF_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
145# Please see big comment above on why this line depends on javalib.jar instead of classes.jar
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800146$(CORE_VM_TEST_TF_DESC): $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(VMTESTSTF_JAR) $(DDMLIB_JAR) | $(ACP)
147 $(hide) mkdir -p $(CTS_TESTCASES_OUT)
148 $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.vm-tests-tf,\
Tsu Chiang Chuang9d047ac2011-04-27 17:01:32 -0700149 cts/tests/vm-tests-tf/AndroidManifest.xml,\
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800150 $(VMTESTSTF_JAR),"",\
Tsu Chiang Chuang9d047ac2011-04-27 17:01:32 -0700151 libcore/expectations,\
152 cts/tools/vm-tests-tf/Android.mk)
Brian Muramatsu237fa072011-12-12 23:54:49 -0800153
The Android Open Source Project88b60792009-03-03 19:28:42 -0800154# Generate the default test plan for User.
Phil Dubach5e3ab042009-08-14 13:48:34 -0700155# Usage: buildCts.py <testRoot> <ctsOutputDir> <tempDir> <androidRootDir> <docletPath>
Brian Muramatsu237fa072011-12-12 23:54:49 -0800156
Brian Muramatsuc0a69242012-01-05 18:24:43 -0800157$(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)
158 $(hide) $(ACP) -fp $(CTS_CORE_XMLS) $(CTS_TEST_XMLS) $(CORE_VM_TEST_TF_DESC) $(PRIVATE_DIR)/repository/testcases
Phil Dubach5e3ab042009-08-14 13:48:34 -0700159 $(hide) $(cts_tools_src_dir)/utils/buildCts.py cts/tests/tests/ $(PRIVATE_DIR) $(TMP_DIR) \
160 $(TOP) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
Ying Wang51a1ae12013-07-10 11:33:27 -0700161 $(hide) mkdir -p $(dir $@) && touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800162
163# Package CTS and clean up.
164#
165# TODO:
166# Pack cts.bat into the same zip file as well. See http://buganizer/issue?id=1656821 for more details
167INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip
168$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name)
169$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir)
170$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name)
171$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
Brian Muramatsu5fc00572011-12-16 13:07:15 -0800172$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN)
Brian Muramatsu1cf9e0e2010-12-06 12:49:13 -0800173 $(hide) echo "Package CTS: $@"
The Android Open Source Project88b60792009-03-03 19:28:42 -0800174 $(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
175
176.PHONY: cts
177cts: $(INTERNAL_CTS_TARGET) adb
178$(call dist-for-goals,cts,$(INTERNAL_CTS_TARGET))
179
180define copy-testcase-apk
181
Brian Muramatsu9353a3b2011-09-07 18:12:22 -0700182$(hide) $(ACP) -fp $(call intermediates-dir-for,APPS,$(1))/package.apk \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800183 $(PRIVATE_DIR)/repository/testcases/$(1).apk
184
185endef
Brian Muramatsu237fa072011-12-12 23:54:49 -0800186
187define copy-testcase
188
189$(hide) $(ACP) -fp $(1) $(PRIVATE_DIR)/repository/testcases/$(notdir $1)
190
191endef