cts.mk revision dcc08f073b6873c69ab891d4f69f7c568e282df7
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
18# Build a name that looks like:
19#
20#     linux-x86   --> android-cts_12345_linux-x86
21#     darwin-x86  --> android-cts_12345_mac-x86
22#     windows-x86 --> android-cts_12345_windows
23#
24cts_name := android-cts_$(FILE_NAME_TAG)
25ifeq ($(HOST_OS),darwin)
26    cts_host_os := mac
27else
28    cts_host_os := $(HOST_OS)
29endif
30ifneq ($(HOST_OS),windows)
31    cts_host_os := $(cts_host_os)-$(HOST_ARCH)
32endif
33cts_name := $(cts_name)_$(cts_host_os)
34
35CTS_EXECUTABLE := cts
36ifeq ($(HOST_OS),windows)
37    CTS_EXECUTABLE_PATH := $(cts_tools_src_dir)/host/etc/cts.bat
38else
39    CTS_EXECUTABLE_PATH := $(HOST_OUT_EXECUTABLES)/$(CTS_EXECUTABLE)
40endif
41CTS_HOST_JAR := $(HOST_OUT_JAVA_LIBRARIES)/cts.jar
42
43CTS_CASE_LIST := \
44	DeviceInfoCollector \
45	CtsTestStubs \
46	CtsTextTestCases \
47	CtsViewTestCases \
48	CtsGraphicsTestCases \
49	SignatureTest
50
51DEFAULT_TEST_PLAN := $(PRIVATE_DIR)/resource/plans
52
53$(cts_dir)/all_cts_files_stamp: $(CTS_CASE_LIST) | $(ACP)
54# Make necessary directory for CTS
55	@rm -rf $(PRIVATE_CTS_DIR)
56	@mkdir -p $(TMP_DIR)
57	@mkdir -p $(PRIVATE_DIR)/docs
58	@mkdir -p $(PRIVATE_DIR)/tools
59	@mkdir -p $(PRIVATE_DIR)/repository/testcases
60	@mkdir -p $(PRIVATE_DIR)/repository/plans
61# Copy executable to CTS directory
62	$(hide) $(ACP) -fp $(CTS_HOST_JAR) $(PRIVATE_DIR)/tools
63	$(hide) $(ACP) -fp $(CTS_EXECUTABLE_PATH) $(PRIVATE_DIR)/tools
64# Change mode of the executables
65	$(hide) chmod ug+rwX $(PRIVATE_DIR)/tools/$(notdir $(CTS_EXECUTABLE_PATH))
66	$(foreach apk,$(CTS_CASE_LIST), \
67			$(call copy-testcase-apk,$(apk)))
68# Copy CTS host config to CTS directory
69	$(hide) $(ACP) -fp $(cts_tools_src_dir)/utils/host_config.xml $(PRIVATE_DIR)/repository/
70	$(hide) touch $@
71
72# Generate the default test plan for User.
73$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_tools_src_dir)/utils/genDefaultTestPlan.sh
74	$(hide) bash $(cts_tools_src_dir)/utils/genDefaultTestPlan.sh cts/tests/tests/ \
75     $(PRIVATE_DIR) $(TMP_DIR) $(TOP) $(TARGET_COMMON_OUT_ROOT) $(OUT_DIR)
76
77# Package CTS and clean up.
78INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip
79$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name)
80$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir)
81$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name)
82$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
83$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN)
84	@echo "Package CTS: $@"
85	$(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
86
87.PHONY: cts 
88cts: $(INTERNAL_CTS_TARGET) adb
89$(call dist-for-goals,cts,$(INTERNAL_CTS_TARGET))
90
91define copy-testcase-apk
92$(hide) $(ACP) -fp $(call intermediates-dir-for,APPS,$(1))/package.apk \
93	$(PRIVATE_DIR)/repository/testcases/$(1).apk
94
95endef
96
97