• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2020 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# `host-unit-tests` shall only include hostside unittest that don't require a device to run. Tests
16# included will be run as part of presubmit check.
17# To add tests to the suite, do one of the following:
18# * For test modules configured with Android.bp, set attribute `test_options: { unit_test: true }`
19# * For test modules configured with mk, set `LOCAL_IS_UNIT_TEST := true`
20.PHONY: host-unit-tests
21
22intermediates_dir := $(call intermediates-dir-for,PACKAGING,host-unit-tests)
23host_unit_tests_zip := $(PRODUCT_OUT)/host-unit-tests.zip
24# Get the hostside libraries to be packaged in the test zip. Unlike
25# device-tests.mk or general-tests.mk, the files are not copied to the
26# testcases directory.
27my_host_shared_lib_for_host_unit_tests := $(foreach f,$(COMPATIBILITY.host-unit-tests.HOST_SHARED_LIBRARY.FILES),$(strip \
28    $(eval _cmf_tuple := $(subst :, ,$(f))) \
29    $(eval _cmf_src := $(word 1,$(_cmf_tuple))) \
30    $(_cmf_src)))
31
32$(host_unit_tests_zip) : PRIVATE_HOST_SHARED_LIBS := $(my_host_shared_lib_for_host_unit_tests)
33
34$(host_unit_tests_zip) : $(COMPATIBILITY.host-unit-tests.FILES) $(my_host_shared_lib_for_host_unit_tests) $(SOONG_ZIP)
35	echo $(sort $(COMPATIBILITY.host-unit-tests.FILES)) | tr " " "\n" > $@.list
36	grep $(HOST_OUT_TESTCASES) $@.list > $@-host.list || true
37	echo "" >> $@-host-libs.list
38	$(hide) for shared_lib in $(PRIVATE_HOST_SHARED_LIBS); do \
39	  echo $$shared_lib >> $@-host-libs.list; \
40	done
41	grep $(TARGET_OUT_TESTCASES) $@.list > $@-target.list || true
42	$(hide) $(SOONG_ZIP) -d -o $@ -P host -C $(HOST_OUT) -l $@-host.list \
43	  -P target -C $(PRODUCT_OUT) -l $@-target.list \
44	  -P host/testcases -C $(HOST_OUT) -l $@-host-libs.list
45	rm -f $@.list $@-host.list $@-target.list $@-host-libs.list
46
47host-unit-tests: $(host_unit_tests_zip)
48$(call dist-for-goals, host-unit-tests, $(host_unit_tests_zip))
49
50tests: host-unit-tests
51