blob: ed2f2a68c32042527a2ee6f68c98264d7543724a [file] [log] [blame]
Dan Shi705d6522020-11-02 12:02:19 -08001# 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
Sam Saccone7d7ae942022-05-13 19:55:25 +000042 $(hide) $(SOONG_ZIP) -d -o $@ -P host -C $(HOST_OUT) -l $@-host.list \
Dan Shi705d6522020-11-02 12:02:19 -080043 -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
Bob Badour3a0f0c12022-04-05 10:43:45 -070050$(call declare-1p-container,$(host_unit_tests_zip),)
51$(call declare-container-license-deps,$(host_unit_tests_zip),$(COMPATIBILITY.host-unit-tests.FILES) $(my_host_shared_lib_for_host_unit_tests),$(PRODUCT_OUT)/:/)
52
Dan Shi705d6522020-11-02 12:02:19 -080053tests: host-unit-tests