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