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