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 28DDMLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/ddmlib-prebuilt.jar 29junit_host_jar := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar 30HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar 31 32CTS_CORE_CASE_LIST := \ 33 android.core.tests.dom \ 34 android.core.tests.luni.io \ 35 android.core.tests.luni.lang \ 36 android.core.tests.luni.net \ 37 android.core.tests.luni.util \ 38 android.core.tests.xml \ 39 android.core.tests.runner 40 41-include cts/CtsTestCaseList.mk 42CTS_CASE_LIST := $(CTS_CORE_CASE_LIST) $(CTS_TEST_CASE_LIST) 43 44DEFAULT_TEST_PLAN := $(PRIVATE_DIR)/resource/plans 45 46$(cts_dir)/all_cts_files_stamp: PRIVATE_JUNIT_HOST_JAR := $(junit_host_jar) 47 48-include cts/CtsHostLibraryList.mk 49$(cts_dir)/all_cts_files_stamp: $(CTS_CASE_LIST) $(junit_host_jar) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(ACP) 50# Make necessary directory for CTS 51 @rm -rf $(PRIVATE_CTS_DIR) 52 @mkdir -p $(TMP_DIR) 53 @mkdir -p $(PRIVATE_DIR)/docs 54 @mkdir -p $(PRIVATE_DIR)/tools 55 @mkdir -p $(PRIVATE_DIR)/repository/testcases 56 @mkdir -p $(PRIVATE_DIR)/repository/plans 57# Copy executable and JARs to CTS directory 58 $(hide) $(ACP) -fp $(CTS_HOST_JAR) $(CTS_EXECUTABLE_PATH) $(DDMLIB_JAR) $(PRIVATE_JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(PRIVATE_DIR)/tools 59# Change mode of the executables 60 $(hide) chmod ug+rwX $(PRIVATE_DIR)/tools/$(notdir $(CTS_EXECUTABLE_PATH)) 61 $(foreach apk,$(CTS_CASE_LIST), \ 62 $(call copy-testcase-apk,$(apk))) 63# Copy CTS host config to CTS directory 64 $(hide) $(ACP) -fp $(cts_tools_src_dir)/utils/host_config.xml $(PRIVATE_DIR)/repository/ 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 name of the TestSuite generator class to use 72# $4 : The directory containing vogar expectations files 73# $5 : The Android.mk corresponding to the test package (required for host-side tests only) 74define generate-core-test-description 75@echo "Generate core-test description ("$(notdir $(1))")" 76$(hide) java $(PRIVATE_JAVAOPTS) \ 77 -classpath $(PRIVATE_CLASSPATH) \ 78 $(PRIVATE_PARAMS) CollectAllTests $(1) \ 79 $(2) $(3) $(4) $(5) 80endef 81 82CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON) 83JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON) 84RUNNER_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junitrunner,,COMMON) 85SUPPORT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-support,,COMMON) 86DOM_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-dom,,COMMON) 87XML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-xml,,COMMON) 88TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON) 89GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(RUNNER_INTERMEDIATES)/classes.jar:$(SUPPORT_INTERMEDIATES)/classes.jar:$(DOM_INTERMEDIATES)/classes.jar:$(XML_INTERMEDIATES)/classes.jar:$(TESTS_INTERMEDIATES)/classes.jar:$(CORE_INTERMEDIATES)/javalib.jar:$(JUNIT_INTERMEDIATES)/javalib.jar:$(RUNNER_INTERMEDIATES)/javalib.jar:$(SUPPORT_INTERMEDIATES)/javalib.jar:$(DOM_INTERMEDIATES)/javalib.jar:$(XML_INTERMEDIATES)/javalib.jar:$(TESTS_INTERMEDIATES)/javalib.jar:$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR) 90 91$(cts_dir)/all_cts_core_files_stamp: PRIVATE_CLASSPATH:=$(GEN_CLASSPATH) 92$(cts_dir)/all_cts_core_files_stamp: PRIVATE_JAVAOPTS:=-Xmx256M 93$(cts_dir)/all_cts_core_files_stamp: PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true 94$(cts_dir)/all_cts_core_files_stamp: PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true 95# Why does this depend on javalib.jar instead of classes.jar? Because 96# even though the tool will operate on the classes.jar files, the 97# build system requires that dependencies use javalib.jar. If 98# javalib.jar is up-to-date, then classes.jar is as well. Depending 99# on classes.jar will build the files incorrectly. 100$(cts_dir)/all_cts_core_files_stamp: $(CTS_CORE_CASE_LIST) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(RUNNER_INTERMEDIATES)/javalib.jar $(SUPPORT_INTERMEDIATES)/javalib.jar $(DOM_INTERMEDIATES)/javalib.jar $(XML_INTERMEDIATES)/javalib.jar $(TESTS_INTERMEDIATES)/javalib.jar $(cts_dir)/all_cts_files_stamp | $(ACP) 101 $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.dom,\ 102 cts/tests/core/dom/AndroidManifest.xml,\ 103 tests.dom.AllTests, libcore/expectations) 104 $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.io,\ 105 cts/tests/core/luni-io/AndroidManifest.xml,\ 106 tests.luni.AllTestsIo, libcore/expectations) 107 $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.lang,\ 108 cts/tests/core/luni-lang/AndroidManifest.xml,\ 109 tests.luni.AllTestsLang, libcore/expectations) 110 $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.net,\ 111 cts/tests/core/luni-net/AndroidManifest.xml,\ 112 tests.luni.AllTestsNet, libcore/expectations) 113 $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.util,\ 114 cts/tests/core/luni-util/AndroidManifest.xml,\ 115 tests.luni.AllTestsUtil, libcore/expectations) 116 $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.xml,\ 117 cts/tests/core/xml/AndroidManifest.xml,\ 118 tests.xml.AllTests, libcore/expectations) 119 $(hide) touch $@ 120 121 122# ----- Generate the test descriptions for the vm-tests ----- 123# 124CORE_VM_TEST_DESC := $(cts_dir)/$(cts_name)/repository/testcases/android.core.vm-tests 125 126VMTESTS_INTERMEDIATES :=$(call intermediates-dir-for,EXECUTABLES,vm-tests,1,) 127# core tests only needed to get hold of junit-framework-classes 128CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON) 129JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON) 130RUNNER_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junitrunner,,COMMON) 131TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON) 132 133GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(RUNNER_INTERMEDIATES)/classes.jar:$(TESTS_INTERMEDIATES)/classes.jar:$(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar:$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOSTTESTLIB_JAR):$(DDMLIB_JAR):$(HOST_JDK_TOOLS_JAR) 134 135$(CORE_VM_TEST_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH) 136$(CORE_VM_TEST_DESC): PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true 137$(CORE_VM_TEST_DESC): PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true 138$(CORE_VM_TEST_DESC): PRIVATE_JAVAOPTS:=-Xmx256M 139# Please see big comment above on why this line depends on javalib.jar instead of classes.jar 140$(CORE_VM_TEST_DESC): vm-tests $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(RUNNER_INTERMEDIATES)/javalib.jar $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(TESTS_INTERMEDIATES)/javalib.jar $(HOSTTESTLIB_JAR) $(DDMLIB_JAR) $(cts_dir)/all_cts_files_stamp | $(ACP) 141 $(call generate-core-test-description,$(CORE_VM_TEST_DESC),\ 142 cts/tests/vm-tests/AndroidManifest.xml,\ 143 dot.junit.AllJunitHostTests, libcore/expectations, cts/tools/vm-tests/Android.mk) 144 $(ACP) -fv $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(PRIVATE_DIR)/repository/testcases/android.core.vm-tests.jar 145 146# Move app security host-side tests to the repository 147APP_SECURITY_LIB := $(cts_dir)/$(cts_name)/repository/testcases/CtsAppSecurityTests.jar 148 149$(APP_SECURITY_LIB): $(HOST_OUT_JAVA_LIBRARIES)/CtsAppSecurityTests.jar $(cts_dir)/all_cts_files_stamp $(ACP) 150 $(ACP) -fv $(HOST_OUT_JAVA_LIBRARIES)/CtsAppSecurityTests.jar $(APP_SECURITY_LIB) 151 152# Generate the default test plan for User. 153# Usage: buildCts.py <testRoot> <ctsOutputDir> <tempDir> <androidRootDir> <docletPath> 154$(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 155 $(hide) $(cts_tools_src_dir)/utils/buildCts.py cts/tests/tests/ $(PRIVATE_DIR) $(TMP_DIR) \ 156 $(TOP) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar 157 158# Package CTS and clean up. 159# 160# TODO: 161# Pack cts.bat into the same zip file as well. See http://buganizer/issue?id=1656821 for more details 162INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip 163$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name) 164$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir) 165$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name) 166$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp 167$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN) $(CORE_VM_TEST_DESC) 168 @echo "Package CTS: $@" 169 $(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) 170 171.PHONY: cts 172cts: $(INTERNAL_CTS_TARGET) adb 173$(call dist-for-goals,cts,$(INTERNAL_CTS_TARGET)) 174 175define copy-testcase-apk 176 177$(hide) $(ACP) -fp $(call intermediates-dir-for,APPS,$(1))/package.apk \ 178 $(PRIVATE_DIR)/repository/testcases/$(1).apk 179 180endef 181