1# Copyright (C) 2016 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
15#
16# Builds a host library and defines a rule to generate the associated test
17# package XML needed by CTS.
18#
19# Disable by default so "m cts" will work in emulator builds
20LOCAL_DEX_PREOPT := false
21LOCAL_STATIC_JAVA_LIBRARIES += platform-test-annotations
22include $(BUILD_JAVA_LIBRARY)
23include $(BUILD_CTS_MODULE_TEST_CONFIG)
24
25cts_library_jar := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).jar
26$(cts_library_jar): $(LOCAL_BUILT_MODULE)
27	$(copy-file-to-target)
28
29CTS_DEQP_CONFIG_PATH := $(call my-dir)
30
31cts_library_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).xml
32$(cts_library_xml): MUSTPASS_XML_FILE := $(LOCAL_CTS_TESTCASE_XML_INPUT)
33$(cts_library_xml): PRIVATE_DUMMY_CASELIST := $(CTS_DEQP_CONFIG_PATH)/deqp_dummy_test_list
34$(cts_library_xml): $(cts_library_jar)
35$(cts_library_xml): $(cts_module_test_config)
36$(cts_library_xml): $(CTS_EXPECTATIONS) $(CTS_UNSUPPORTED_ABIS) $(CTS_XML_GENERATOR) $(CTS_TESTCASE_XML_INPUT)
37	$(hide) echo Generating test description for target testng package $(PRIVATE_LIBRARY)
38	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
39
40# Query build ABIs by routing a dummy test list through xml generator and parse result. Use sed to insert the ABI string into the XML files.
41	$(hide) SUPPORTED_ABI_ATTR=`$(CTS_XML_GENERATOR) -t dummyTest \
42									-n dummyName \
43									-p invalid.dummy \
44									-e $(CTS_EXPECTATIONS) \
45									-b $(CTS_UNSUPPORTED_ABIS) \
46									-a $(CTS_TARGET_ARCH) \
47									< $(PRIVATE_DUMMY_CASELIST) \
48									| grep --only-matching -e " abis=\"[^\"]*\""` && \
49			$(SED_EXTENDED) -e "s:^(\s*)<Test ((.[^/]|[^/])*)(/?)>$$:\1<Test \2 $${SUPPORTED_ABI_ATTR}\4>:" \
50				< $(MUSTPASS_XML_FILE) \
51				> $@
52
53# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
54$(my_register_name) : $(cts_library_jar) $(cts_library_xml) $(cts_module_test_config)
55