1# Copyright (C) 2023 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 15load(":cc_library_common_test.bzl", "target_provides_androidmk_info_test") 16load(":cc_library_shared.bzl", "cc_library_shared") 17load(":cc_library_static.bzl", "cc_library_static") 18load(":cc_test.bzl", "cc_test") 19 20def _cc_test_provides_androidmk_info(): 21 name = "cc_test_provides_androidmk_info" 22 dep_name = name + "_static_dep" 23 whole_archive_dep_name = name + "_whole_archive_dep" 24 dynamic_dep_name = name + "_dynamic_dep" 25 26 srcs = ["//build/bazel/rules/cc/testing:test_srcs"] 27 gunit_test_srcs = ["//build/bazel/rules/cc/testing:gunit_test_srcs"] 28 29 cc_library_static( 30 name = dep_name, 31 srcs = srcs, 32 tags = ["manual"], 33 ) 34 cc_library_static( 35 name = whole_archive_dep_name, 36 srcs = srcs, 37 tags = ["manual"], 38 ) 39 cc_library_shared( 40 name = dynamic_dep_name, 41 srcs = srcs, 42 tags = ["manual"], 43 ) 44 cc_test( 45 name = name, 46 srcs = gunit_test_srcs, 47 deps = [dep_name], 48 whole_archive_deps = [whole_archive_dep_name], 49 dynamic_deps = [dynamic_dep_name], 50 runs_on = ["host_without_device", "device"], 51 target_compatible_with = ["//build/bazel_common_rules/platforms/os:linux"], 52 tags = ["manual"], 53 ) 54 android_test_name = name + "_android" 55 linux_test_name = name + "_linux" 56 target_provides_androidmk_info_test( 57 name = android_test_name, 58 target_under_test = name, 59 expected_static_libs = [dep_name, "libgtest_main", "libgtest", "libc++demangle", "libunwind"], 60 expected_whole_static_libs = [whole_archive_dep_name], 61 expected_shared_libs = [dynamic_dep_name, "libc++", "libc", "libdl", "libm"], 62 target_compatible_with = ["//build/bazel_common_rules/platforms/os:android"], 63 ) 64 target_provides_androidmk_info_test( 65 name = linux_test_name, 66 target_under_test = name, 67 expected_static_libs = [dep_name, "libgtest_main", "libgtest"], 68 expected_whole_static_libs = [whole_archive_dep_name], 69 expected_shared_libs = [dynamic_dep_name, "libc++"], 70 target_compatible_with = ["//build/bazel_common_rules/platforms/os:linux"], 71 ) 72 return [ 73 android_test_name, 74 linux_test_name, 75 ] 76 77def cc_test_test_suite(name): 78 native.test_suite( 79 name = name, 80 tests = _cc_test_provides_androidmk_info(), 81 ) 82