1# Copyright 2023 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 15import("//build_overrides/pigweed.gni") 16import("$dir_pw_fuzzer/fuzzer.gni") 17import("$dir_pw_unit_test/test.gni") 18 19dir_public_l2cap = "../../public/pw_bluetooth_sapphire/internal/host/l2cap" 20 21# Basic target with protocol definitions and no logic, suitable for test 22# emulation. 23pw_source_set("definitions") { 24 public = [ 25 "$dir_public_l2cap/frame_headers.h", 26 "$dir_public_l2cap/l2cap_defs.h", 27 ] 28 29 public_deps = [ 30 "$dir_pw_bluetooth_sapphire/host/hci-spec", 31 "$dir_pw_bluetooth_sapphire/host/sm:definitions", 32 ] 33} 34 35pw_source_set("l2cap") { 36 public = [ 37 "$dir_public_l2cap/a2dp_offload_manager.h", 38 "$dir_public_l2cap/basic_mode_rx_engine.h", 39 "$dir_public_l2cap/basic_mode_tx_engine.h", 40 "$dir_public_l2cap/bredr_command_handler.h", 41 "$dir_public_l2cap/bredr_dynamic_channel.h", 42 "$dir_public_l2cap/bredr_signaling_channel.h", 43 "$dir_public_l2cap/channel.h", 44 "$dir_public_l2cap/channel_configuration.h", 45 "$dir_public_l2cap/channel_manager.h", 46 "$dir_public_l2cap/command_handler.h", 47 "$dir_public_l2cap/credit_based_flow_control_rx_engine.h", 48 "$dir_public_l2cap/credit_based_flow_control_tx_engine.h", 49 "$dir_public_l2cap/dynamic_channel.h", 50 "$dir_public_l2cap/dynamic_channel_registry.h", 51 "$dir_public_l2cap/enhanced_retransmission_mode_engines.h", 52 "$dir_public_l2cap/enhanced_retransmission_mode_rx_engine.h", 53 "$dir_public_l2cap/enhanced_retransmission_mode_tx_engine.h", 54 "$dir_public_l2cap/fcs.h", 55 "$dir_public_l2cap/fragmenter.h", 56 "$dir_public_l2cap/le_dynamic_channel.h", 57 "$dir_public_l2cap/le_signaling_channel.h", 58 "$dir_public_l2cap/logical_link.h", 59 "$dir_public_l2cap/low_energy_command_handler.h", 60 "$dir_public_l2cap/pdu.h", 61 "$dir_public_l2cap/recombiner.h", 62 "$dir_public_l2cap/rx_engine.h", 63 "$dir_public_l2cap/scoped_channel.h", 64 "$dir_public_l2cap/signaling_channel.h", 65 "$dir_public_l2cap/tx_engine.h", 66 "$dir_public_l2cap/types.h", 67 ] 68 69 sources = [ 70 "a2dp_offload_manager.cc", 71 "basic_mode_rx_engine.cc", 72 "basic_mode_tx_engine.cc", 73 "bredr_command_handler.cc", 74 "bredr_dynamic_channel.cc", 75 "bredr_signaling_channel.cc", 76 "channel.cc", 77 "channel_configuration.cc", 78 "channel_manager.cc", 79 "command_handler.cc", 80 "credit_based_flow_control_rx_engine.cc", 81 "credit_based_flow_control_tx_engine.cc", 82 "dynamic_channel.cc", 83 "dynamic_channel_registry.cc", 84 "enhanced_retransmission_mode_engines.cc", 85 "enhanced_retransmission_mode_rx_engine.cc", 86 "enhanced_retransmission_mode_tx_engine.cc", 87 "fcs.cc", 88 "fragmenter.cc", 89 "le_dynamic_channel.cc", 90 "le_signaling_channel.cc", 91 "logical_link.cc", 92 "low_energy_command_handler.cc", 93 "pdu.cc", 94 "recombiner.cc", 95 "scoped_channel.cc", 96 "signaling_channel.cc", 97 "types.cc", 98 ] 99 100 public_deps = [ 101 ":definitions", 102 "$dir_pw_bluetooth_sapphire:config", 103 "$dir_pw_bluetooth_sapphire/host/hci", 104 "$dir_pw_bluetooth_sapphire/host/transport", 105 "$dir_pw_string", 106 "$dir_pw_third_party/fuchsia:fit", 107 ] 108 109 deps = [ 110 "$dir_pw_bluetooth:emboss_l2cap_frames", 111 "$dir_pw_preprocessor", 112 ] 113} 114 115# Separate from :testing to avoid a dependency cycle. 116pw_source_set("channel_manager_mock_controller_test_fixture") { 117 testonly = pw_unit_test_TESTONLY 118 119 public = 120 [ "$dir_public_l2cap/channel_manager_mock_controller_test_fixture.h" ] 121 122 public_deps = [ 123 ":l2cap", 124 ":testing", 125 "$dir_pw_bluetooth_sapphire/host/hci", 126 "$dir_pw_bluetooth_sapphire/host/testing", 127 ] 128} 129 130pw_source_set("testing") { 131 testonly = pw_unit_test_TESTONLY 132 133 public = [ 134 "$dir_public_l2cap/fake_channel.h", 135 "$dir_public_l2cap/fake_channel_test.h", 136 "$dir_public_l2cap/fake_l2cap.h", 137 "$dir_public_l2cap/fake_signaling_channel.h", 138 "$dir_public_l2cap/mock_channel_test.h", 139 "$dir_public_l2cap/test_packets.h", 140 ] 141 142 sources = [ 143 "fake_channel.cc", 144 "fake_channel_test.cc", 145 "fake_l2cap.cc", 146 "fake_signaling_channel.cc", 147 "mock_channel_test.cc", 148 "test_packets.cc", 149 ] 150 151 public_deps = [ 152 ":l2cap", 153 "$dir_pw_async:fake_dispatcher_fixture", 154 "$dir_pw_async:heap_dispatcher", 155 "$dir_pw_bluetooth", 156 "$dir_pw_bluetooth_sapphire/host/common", 157 "$dir_pw_bluetooth_sapphire/host/hci", 158 "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", 159 "$dir_pw_unit_test", 160 ] 161} 162 163pw_test("l2cap_tests") { 164 sources = [ 165 "a2dp_offload_manager_test.cc", 166 "basic_mode_rx_engine_test.cc", 167 "basic_mode_tx_engine_test.cc", 168 "bredr_command_handler_test.cc", 169 "bredr_dynamic_channel_test.cc", 170 "bredr_signaling_channel_test.cc", 171 "channel_configuration_test.cc", 172 "channel_manager_test.cc", 173 "channel_test.cc", 174 "command_handler_test.cc", 175 "credit_based_flow_control_rx_engine_test.cc", 176 "credit_based_flow_control_tx_engine_test.cc", 177 "dynamic_channel_registry_test.cc", 178 "enhanced_retransmission_mode_engines_test.cc", 179 "enhanced_retransmission_mode_rx_engine_test.cc", 180 "enhanced_retransmission_mode_tx_engine_test.cc", 181 "fcs_test.cc", 182 "fragmenter_test.cc", 183 "frame_headers_test.cc", 184 "le_dynamic_channel_test.cc", 185 "le_signaling_channel_test.cc", 186 "logical_link_test.cc", 187 "low_energy_command_handler_test.cc", 188 "pdu_test.cc", 189 "recombiner_test.cc", 190 "scoped_channel_test.cc", 191 "signaling_channel_test.cc", 192 "types_test.cc", 193 ] 194 195 deps = [ 196 ":channel_manager_mock_controller_test_fixture", 197 ":l2cap", 198 ":testing", 199 "$dir_pw_async:fake_dispatcher_fixture", 200 "$dir_pw_bluetooth_sapphire/host/hci", 201 "$dir_pw_bluetooth_sapphire/host/hci:testing", 202 "$dir_pw_bluetooth_sapphire/host/testing", 203 "$dir_pw_bluetooth_sapphire/host/transport:testing", 204 ] 205 206 test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" 207} 208 209pw_fuzzer("basic_mode_rx_engine_fuzzer") { 210 sources = [ "basic_mode_rx_engine_fuzztest.cc" ] 211 deps = [ 212 ":l2cap", 213 ":testing", 214 ] 215} 216 217pw_fuzzer("enhanced_retransmission_mode_engines_fuzzer") { 218 sources = [ "enhanced_retransmission_mode_engines_fuzztest.cc" ] 219 deps = [ 220 ":l2cap", 221 ":testing", 222 ] 223} 224 225pw_fuzzer("bredr_dynamic_channel_registry_fuzzer") { 226 sources = [ "bredr_dynamic_channel_registry_fuzztest.cc" ] 227 deps = [ 228 ":l2cap", 229 ":testing", 230 "$dir_pw_random:fuzzer_generator", 231 ] 232} 233 234pw_fuzzer("channel_configuration_fuzzer") { 235 sources = [ "channel_configuration_fuzztest.cc" ] 236 deps = [ 237 ":l2cap", 238 ":testing", 239 ] 240} 241 242pw_fuzzer("common_handler_fuzzer") { 243 sources = [ "common_handler_fuzztest.cc" ] 244 deps = [ 245 ":l2cap", 246 ":testing", 247 ] 248} 249 250pw_fuzzer("l2cap_fuzzer") { 251 sources = [ "l2cap_fuzztest.cc" ] 252 deps = [ 253 ":l2cap", 254 "$dir_pw_bluetooth_sapphire/host/testing", 255 "$dir_pw_bluetooth_sapphire/host/testing:controller_test_double_base", 256 "$dir_pw_random:fuzzer_generator", 257 ] 258} 259 260pw_test_group("tests") { 261 tests = [ 262 ":l2cap_tests", 263 ":basic_mode_rx_engine_fuzzer_test", 264 ":enhanced_retransmission_mode_engines_fuzzer_test", 265 ":bredr_dynamic_channel_registry_fuzzer_test", 266 ":channel_configuration_fuzzer_test", 267 ":common_handler_fuzzer_test", 268 ":l2cap_fuzzer_test", 269 ] 270} 271