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 target_compatible_with = ["//build/bazel/platforms/os:linux"], 51 tags = ["manual"], 52 ) 53 android_test_name = name + "_android" 54 linux_test_name = name + "_linux" 55 target_provides_androidmk_info_test( 56 name = android_test_name, 57 target_under_test = name, 58 expected_static_libs = [dep_name, "libgtest_main", "libgtest", "libc++demangle", "libunwind"], 59 expected_whole_static_libs = [whole_archive_dep_name], 60 expected_shared_libs = [dynamic_dep_name, "libc++", "libc", "libdl", "libm"], 61 target_compatible_with = ["//build/bazel/platforms/os:android"], 62 ) 63 target_provides_androidmk_info_test( 64 name = linux_test_name, 65 target_under_test = name, 66 expected_static_libs = [dep_name, "libgtest_main", "libgtest"], 67 expected_whole_static_libs = [whole_archive_dep_name], 68 expected_shared_libs = [dynamic_dep_name, "libc++"], 69 target_compatible_with = ["//build/bazel/platforms/os:linux"], 70 ) 71 return [ 72 android_test_name, 73 linux_test_name, 74 ] 75 76def cc_test_test_suite(name): 77 native.test_suite( 78 name = name, 79 tests = _cc_test_provides_androidmk_info(), 80 ) 81