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("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test") 16load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 17 18package(default_visibility = ["//visibility:public"]) 19 20exports_files(glob(["**/*"])) 21 22cc_library( 23 name = "definitions", 24 deps = [ 25 "//pw_bluetooth_sapphire:public", 26 "//pw_bluetooth_sapphire/host/hci-spec", 27 "//pw_bluetooth_sapphire/host/sm:definitions", 28 ], 29) 30 31cc_library( 32 name = "l2cap", 33 srcs = [ 34 "a2dp_offload_manager.cc", 35 "basic_mode_rx_engine.cc", 36 "basic_mode_tx_engine.cc", 37 "bredr_command_handler.cc", 38 "bredr_dynamic_channel.cc", 39 "bredr_signaling_channel.cc", 40 "channel.cc", 41 "channel_configuration.cc", 42 "channel_manager.cc", 43 "command_handler.cc", 44 "credit_based_flow_control_rx_engine.cc", 45 "credit_based_flow_control_tx_engine.cc", 46 "dynamic_channel.cc", 47 "dynamic_channel_registry.cc", 48 "enhanced_retransmission_mode_engines.cc", 49 "enhanced_retransmission_mode_rx_engine.cc", 50 "enhanced_retransmission_mode_tx_engine.cc", 51 "fcs.cc", 52 "fragmenter.cc", 53 "le_dynamic_channel.cc", 54 "le_signaling_channel.cc", 55 "logical_link.cc", 56 "low_energy_command_handler.cc", 57 "pdu.cc", 58 "recombiner.cc", 59 "scoped_channel.cc", 60 "signaling_channel.cc", 61 "types.cc", 62 ], 63 target_compatible_with = select({ 64 "@platforms//os:fuchsia": [], 65 "@platforms//os:linux": [], 66 "//conditions:default": ["@platforms//:incompatible"], 67 }), 68 deps = [ 69 ":definitions", 70 "//pw_bluetooth:emboss_l2cap_frames", 71 "//pw_bluetooth_sapphire:public", 72 "//pw_bluetooth_sapphire/host/hci", 73 "//pw_bluetooth_sapphire/host/transport", 74 "//pw_string", 75 "//third_party/fuchsia:fit", 76 ], 77) 78 79cc_library( 80 name = "channel_manager_mock_controller_test_fixture", 81 testonly = True, 82 # Header is in bt-host:public 83 deps = [ 84 ":l2cap", 85 ":testing", 86 "//pw_bluetooth_sapphire:public", 87 "//pw_bluetooth_sapphire/host/hci", 88 "//pw_bluetooth_sapphire/host/testing", 89 ], 90) 91 92cc_library( 93 name = "testing", 94 testonly = True, 95 srcs = [ 96 "fake_channel.cc", 97 "fake_channel_test.cc", 98 "fake_l2cap.cc", 99 "fake_signaling_channel.cc", 100 "mock_channel_test.cc", 101 "test_packets.cc", 102 ], 103 deps = [ 104 ":l2cap", 105 "//pw_async:fake_dispatcher_fixture", 106 "//pw_async:heap_dispatcher", 107 "//pw_bluetooth", 108 "//pw_bluetooth_sapphire:public", 109 "//pw_bluetooth_sapphire/host/common", 110 "//pw_bluetooth_sapphire/host/hci", 111 "//pw_bluetooth_sapphire/host/testing:test_helpers", 112 "//pw_unit_test", 113 ], 114) 115 116pw_cc_test( 117 name = "l2cap_test", 118 srcs = [ 119 "a2dp_offload_manager_test.cc", 120 "basic_mode_rx_engine_test.cc", 121 "basic_mode_tx_engine_test.cc", 122 "bredr_command_handler_test.cc", 123 "bredr_dynamic_channel_test.cc", 124 "bredr_signaling_channel_test.cc", 125 "channel_configuration_test.cc", 126 "channel_manager_test.cc", 127 "channel_test.cc", 128 "command_handler_test.cc", 129 "credit_based_flow_control_rx_engine_test.cc", 130 "credit_based_flow_control_tx_engine_test.cc", 131 "dynamic_channel_registry_test.cc", 132 "enhanced_retransmission_mode_engines_test.cc", 133 "enhanced_retransmission_mode_rx_engine_test.cc", 134 "enhanced_retransmission_mode_tx_engine_test.cc", 135 "fcs_test.cc", 136 "fragmenter_test.cc", 137 "frame_headers_test.cc", 138 "le_dynamic_channel_test.cc", 139 "le_signaling_channel_test.cc", 140 "logical_link_test.cc", 141 "low_energy_command_handler_test.cc", 142 "pdu_test.cc", 143 "recombiner_test.cc", 144 "scoped_channel_test.cc", 145 "signaling_channel_test.cc", 146 "types_test.cc", 147 ], 148 test_main = "//pw_bluetooth_sapphire/host/testing:gtest_main", 149 deps = [ 150 ":channel_manager_mock_controller_test_fixture", 151 ":l2cap", 152 ":testing", 153 "//pw_async:fake_dispatcher_fixture", 154 "//pw_bluetooth_sapphire/host/hci", 155 "//pw_bluetooth_sapphire/host/hci:testing", 156 "//pw_bluetooth_sapphire/host/testing", 157 "//pw_bluetooth_sapphire/host/transport:testing", 158 ], 159) 160 161pw_cc_fuzz_test( 162 name = "basic_mode_rx_engine_fuzzer", 163 testonly = True, 164 srcs = ["basic_mode_rx_engine_fuzztest.cc"], 165 deps = [ 166 ":l2cap", 167 ":testing", 168 ], 169) 170