1# Copyright 2024 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://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, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 16 17package(default_visibility = ["//visibility:public"]) 18 19exports_files(glob(["**/*"])) 20 21cc_library( 22 name = "testing", 23 testonly = True, 24 srcs = [ 25 "inspect_util.cc", 26 "parse_args.cc", 27 "test_packets.cc", 28 ], 29 copts = [ 30 "-Wno-unused-parameter", 31 ], 32 target_compatible_with = select({ 33 "//pw_unit_test:googletest_only": [], 34 "@platforms//os:fuchsia": [], 35 "//conditions:default": ["@platforms//:incompatible"], 36 }), 37 deps = [ 38 ":fake_controller", 39 ":mock_controller", 40 ":test_helpers", 41 "//pw_bluetooth_sapphire:config", 42 "//pw_bluetooth_sapphire:public", 43 "//pw_bluetooth_sapphire/fuchsia/lib/inspect_testing", 44 "//pw_bluetooth_sapphire/host/transport", 45 "//pw_bluetooth_sapphire/host/transport:testing", 46 "//pw_unit_test", 47 ], 48) 49 50cc_library( 51 name = "test_helpers", 52 testonly = True, 53 copts = [ 54 "-Wno-unused-parameter", 55 ], 56 target_compatible_with = select({ 57 "//pw_unit_test:googletest_only": [], 58 "@platforms//os:fuchsia": [], 59 "//conditions:default": ["@platforms//:incompatible"], 60 }), 61 # test_helpers.h is currently in bt-host:public, but its deps are here. 62 deps = [ 63 "//pw_bluetooth_sapphire:public", 64 "//pw_bluetooth_sapphire/host/common", 65 "//pw_bluetooth_sapphire/lib/cpp-string", 66 "//pw_unit_test", 67 ], 68) 69 70cc_library( 71 name = "controller_test_double_base", 72 testonly = True, 73 srcs = ["controller_test_double_base.cc"], 74 copts = [ 75 "-Wno-unused-parameter", 76 ], 77 target_compatible_with = select({ 78 "//pw_unit_test:googletest_only": [], 79 "@platforms//os:fuchsia": [], 80 "//conditions:default": ["@platforms//:incompatible"], 81 }), 82 deps = [ 83 "//pw_bluetooth_sapphire:public", 84 "//pw_bluetooth_sapphire/host/common", 85 "//pw_bluetooth_sapphire/host/hci", 86 "//pw_unit_test", 87 "@pigweed//pw_async:heap_dispatcher", 88 "@pigweed//pw_bluetooth", 89 "@pigweed//third_party/fuchsia:fit", 90 ], 91) 92 93cc_library( 94 name = "mock_controller", 95 testonly = True, 96 srcs = ["mock_controller.cc"], 97 copts = [ 98 "-Wno-unused-parameter", 99 ], 100 target_compatible_with = select({ 101 "//pw_unit_test:googletest_only": [], 102 "@platforms//os:fuchsia": [], 103 "//conditions:default": ["@platforms//:incompatible"], 104 }), 105 deps = [ 106 ":controller_test_double_base", 107 ":test_helpers", 108 "//pw_bluetooth_sapphire:public", 109 "//pw_bluetooth_sapphire/host/transport", 110 "//pw_bluetooth_sapphire/host/transport:testing", 111 "//pw_unit_test", 112 "@pigweed//pw_async:heap_dispatcher", 113 ], 114) 115 116cc_library( 117 name = "fake_controller", 118 testonly = True, 119 srcs = [ 120 "fake_controller.cc", 121 "fake_dynamic_channel.cc", 122 "fake_gatt_server.cc", 123 "fake_l2cap.cc", 124 "fake_peer.cc", 125 "fake_sdp_server.cc", 126 "fake_signaling_server.cc", 127 ], 128 copts = [ 129 "-Wno-unused-parameter", 130 ], 131 target_compatible_with = select({ 132 "//pw_unit_test:googletest_only": [], 133 "@platforms//os:fuchsia": [], 134 "//conditions:default": ["@platforms//:incompatible"], 135 }), 136 deps = [ 137 ":controller_test_double_base", 138 ":test_helpers", 139 "//pw_bluetooth_sapphire:public", 140 "//pw_bluetooth_sapphire/host/att:definitions", 141 "//pw_bluetooth_sapphire/host/common", 142 "//pw_bluetooth_sapphire/host/gap", 143 "//pw_bluetooth_sapphire/host/gatt:definitions", 144 "//pw_bluetooth_sapphire/host/hci", 145 "//pw_bluetooth_sapphire/host/l2cap:definitions", 146 "//pw_bluetooth_sapphire/host/l2cap:testing", 147 "//pw_bluetooth_sapphire/host/sdp", 148 "//pw_unit_test", 149 "@pigweed//pw_bluetooth:emboss_hci", 150 "@pigweed//third_party/fuchsia:fit", 151 ], 152) 153 154cc_library( 155 name = "gtest_main", 156 testonly = True, 157 srcs = ["run_all_unittests.cc"], 158 deps = [ 159 ":testing", 160 "//pw_bluetooth_sapphire/host/common", 161 ], 162) 163 164cc_library( 165 name = "loop_fixture", 166 testonly = True, 167 target_compatible_with = select({ 168 "//pw_unit_test:googletest_only": [], 169 "@platforms//os:fuchsia": [], 170 "//conditions:default": ["@platforms//:incompatible"], 171 }), 172 # header is in bt-host:public 173 deps = [ 174 "//pw_bluetooth_sapphire:public", 175 "@com_google_googletest//:gtest", 176 "@fuchsia_sdk//pkg/async-testing", 177 ], 178) 179 180pw_cc_test( 181 name = "testing_test", 182 srcs = [ 183 "fake_controller_test.cc", 184 "fake_dynamic_channel_test.cc", 185 "fake_l2cap_test.cc", 186 "fake_sdp_server_test.cc", 187 "fake_signaling_server_test.cc", 188 "inspect_util_test.cc", 189 "parse_args_test.cc", 190 ], 191 test_main = "//pw_bluetooth_sapphire/host/testing:gtest_main", 192 deps = [ 193 ":testing", 194 "//pw_bluetooth_sapphire/host/l2cap:testing", 195 ], 196) 197