cts.mk revision fdd3a1020cc63c9f2440f3cff814318d11d6c773
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 := cts 21ifeq ($(HOST_OS),windows) 22 CTS_EXECUTABLE_PATH := $(cts_tools_src_dir)/host/etc/cts.bat 23else 24 CTS_EXECUTABLE_PATH := $(HOST_OUT_EXECUTABLES)/$(CTS_EXECUTABLE) 25endif 26CTS_HOST_JAR := $(HOST_OUT_JAVA_LIBRARIES)/cts.jar 27 28CTS_CASE_LIST := \ 29 DeviceInfoCollector \ 30 CtsTestStubs \ 31 CtsAppTestCases \ 32 CtsContentTestCases \ 33 CtsDatabaseTestCases \ 34 CtsGraphicsTestCases \ 35 CtsHardwareTestCases \ 36 CtsLocationTestCases \ 37 CtsOsTestCases \ 38 CtsPermissionTestCases \ 39 CtsProviderTestCases \ 40 CtsTextTestCases \ 41 CtsUtilTestCases \ 42 CtsViewTestCases \ 43 CtsWidgetTestCases \ 44 CtsNetTestCases \ 45 SignatureTest \ 46 android.core.tests 47 48DEFAULT_TEST_PLAN := $(PRIVATE_DIR)/resource/plans 49 50$(cts_dir)/all_cts_files_stamp: $(CTS_CASE_LIST) | $(ACP) 51# Make necessary directory for CTS 52 @rm -rf $(PRIVATE_CTS_DIR) 53 @mkdir -p $(TMP_DIR) 54 @mkdir -p $(PRIVATE_DIR)/docs 55 @mkdir -p $(PRIVATE_DIR)/tools 56 @mkdir -p $(PRIVATE_DIR)/repository/testcases 57 @mkdir -p $(PRIVATE_DIR)/repository/plans 58# Copy executable to CTS directory 59 $(hide) $(ACP) -fp $(CTS_HOST_JAR) $(PRIVATE_DIR)/tools 60 $(hide) $(ACP) -fp $(CTS_EXECUTABLE_PATH) $(PRIVATE_DIR)/tools 61# Change mode of the executables 62 $(hide) chmod ug+rwX $(PRIVATE_DIR)/tools/$(notdir $(CTS_EXECUTABLE_PATH)) 63 $(foreach apk,$(CTS_CASE_LIST), \ 64 $(call copy-testcase-apk,$(apk))) 65# Copy CTS host config and start script to CTS directory 66 $(hide) $(ACP) -fp $(cts_tools_src_dir)/utils/host_config.xml $(PRIVATE_DIR)/repository/ 67 $(hide) $(ACP) -fp $(cts_tools_src_dir)/utils/startcts $(PRIVATE_DIR)/tools/ 68 $(hide) touch $@ 69 70# Generate the test plan for the core-tests 71CORE_TEST_PLAN := $(cts_dir)/$(cts_name)/repository/testcases/android.core.tests 72 73CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON) 74TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON) 75 76GEN_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) 77 78$(CORE_TEST_PLAN): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH) 79$(CORE_TEST_PLAN): PRIVATE_JAVAOPTS:=-Xmx256M 80$(CORE_TEST_PLAN): PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true 81$(CORE_TEST_PLAN): PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true 82$(CORE_TEST_PLAN): PRIVATE_CUSTOM_TOOL := java $(PRIVATE_JAVAOPTS) \ 83 -classpath $(PRIVATE_CLASSPATH) \ 84 $(PRIVATE_PARAMS) CollectAllTests $(CORE_TEST_PLAN) \ 85 cts/tests/core/AndroidManifest.xml tests.AllTests 86# Why does this depend on javalib.jar instead of classes.jar? Because 87# even though the tool will operate on the classes.jar files, the 88# build system requires that dependencies use javalib.jar. If 89# javalib.jar is up-to-date, then classes.jar is as well. Depending 90# on classes.jar will build the files incorrectly. 91$(CORE_TEST_PLAN): android.core.tests $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(TESTS_INTERMEDIATES)/javalib.jar $(cts_dir)/all_cts_files_stamp 92 @echo "Generate the CTS test plan: $@" 93 @echo $(PRIVATE_CUSTOM_TOOL) 94 $(transform-generated-source) 95 96 97# ----- Generate the test plan for the vm-tests ----- 98# 99CORE_VM_TEST_PLAN := $(cts_dir)/$(cts_name)/repository/testcases/android.core.vm-tests 100 101VMTESTS_INTERMEDIATES :=$(call intermediates-dir-for,EXECUTABLES,vm-tests,1,) 102# core tests only needed to get hold of junit-framework-classes 103TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON) 104CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON) 105 106GEN_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) 107 108$(CORE_VM_TEST_PLAN): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH) 109$(CORE_VM_TEST_PLAN): PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true 110$(CORE_VM_TEST_PLAN): PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true 111$(CORE_VM_TEST_PLAN): PRIVATE_JAVAOPTS:=-Xmx256M 112$(CORE_VM_TEST_PLAN): PRIVATE_CUSTOM_TOOL := java $(PRIVATE_JAVAOPTS) \ 113 -classpath $(PRIVATE_CLASSPATH) \ 114 $(PRIVATE_PARAMS) CollectAllTests $(CORE_VM_TEST_PLAN) \ 115 cts/tests/vm-tests/AndroidManifest.xml dot.junit.AllJunitHostTests cts/tools/vm-tests/Android.mk 116# Please see big comment above on why this line depends on javalib.jar instead of classes.jar 117$(CORE_VM_TEST_PLAN): 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) 118 @echo "Generate the CTS vm-test plan: $@" 119 @echo $(PRIVATE_CUSTOM_TOOL) 120 $(transform-generated-source) 121 $(ACP) -fv $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(PRIVATE_DIR)/repository/testcases/android.core.vm-tests.jar 122 123# Generate the default test plan for User. 124$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_tools_src_dir)/utils/genDefaultTestPlan.sh $(CORE_VM_TEST_PLAN) $(CORE_TEST_PLAN) 125 $(hide) bash $(cts_tools_src_dir)/utils/genDefaultTestPlan.sh cts/tests/tests/ \ 126 $(PRIVATE_DIR) $(TMP_DIR) $(TOP) $(TARGET_COMMON_OUT_ROOT) $(OUT_DIR) 127 128# Package CTS and clean up. 129# 130# TODO: 131# Pack cts.bat into the same zip file as well. See http://buganizer/issue?id=1656821 for more details 132INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip 133$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name) 134$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir) 135$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name) 136$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp 137$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN) $(CORE_TEST_PLAN) $(CORE_VM_TEST_PLAN) 138 @echo "Package CTS: $@" 139 $(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) 140 141.PHONY: cts 142cts: $(INTERNAL_CTS_TARGET) adb 143$(call dist-for-goals,cts,$(INTERNAL_CTS_TARGET)) 144 145define copy-testcase-apk 146 147$(hide) $(ACP) -fp $(call intermediates-dir-for,APPS,$(1))/package.apk \ 148 $(PRIVATE_DIR)/repository/testcases/$(1).apk 149 150endef 151