diff --git a/pw_bluetooth_sapphire/BUILD.bazel b/pw_bluetooth_sapphire/BUILD.bazel index 713d2a927..d4b8842fc 100644 --- a/pw_bluetooth_sapphire/BUILD.bazel +++ b/pw_bluetooth_sapphire/BUILD.bazel @@ -21,6 +21,9 @@ package(default_visibility = ["//pw_bluetooth_sapphire:__subpackages__"]) cc_library( name = "config", srcs = [], + hdrs = [ + "public/pw_bluetooth_sapphire/config.h", + ], defines = select({ "@platforms//os:fuchsia": [ "PW_BLUETOOTH_SAPPHIRE_INSPECT_ENABLED", @@ -28,15 +31,7 @@ cc_library( ], "//conditions:default": [], }), -) - -cc_library( - name = "public", - hdrs = [ - "public/pw_bluetooth_sapphire/config.h", - ], strip_include_prefix = "public", - tags = ["manual"], ) cc_library( diff --git a/pw_bluetooth_sapphire/fuchsia/bt_hci_virtual/BUILD.bazel b/pw_bluetooth_sapphire/fuchsia/bt_hci_virtual/BUILD.bazel index 2aa2e765c..71668636c 100644 --- a/pw_bluetooth_sapphire/fuchsia/bt_hci_virtual/BUILD.bazel +++ b/pw_bluetooth_sapphire/fuchsia/bt_hci_virtual/BUILD.bazel @@ -139,6 +139,7 @@ fuchsia_cc_test( deps = [ ":common", "//pw_bluetooth_sapphire/host/testing:gtest_main", + "//pw_unit_test", "@fuchsia_sdk//pkg/driver_testing_cpp", ], ) diff --git a/pw_bluetooth_sapphire/fuchsia/host/fidl/BUILD.bazel b/pw_bluetooth_sapphire/fuchsia/host/fidl/BUILD.bazel index 4000abe40..a08687e2f 100644 --- a/pw_bluetooth_sapphire/fuchsia/host/fidl/BUILD.bazel +++ b/pw_bluetooth_sapphire/fuchsia/host/fidl/BUILD.bazel @@ -211,6 +211,7 @@ fuchsia_cc_test( "//pw_bluetooth_sapphire/host/testing:fake_controller", "//pw_bluetooth_sapphire/host/testing:gtest_main", "//pw_bluetooth_sapphire/host/testing:loop_fixture", + "//pw_bluetooth_sapphire/host/testing:test_helpers", ], ) diff --git a/pw_bluetooth_sapphire/fuchsia/host/socket/BUILD.bazel b/pw_bluetooth_sapphire/fuchsia/host/socket/BUILD.bazel index 6262ad5c3..c5a504527 100644 --- a/pw_bluetooth_sapphire/fuchsia/host/socket/BUILD.bazel +++ b/pw_bluetooth_sapphire/fuchsia/host/socket/BUILD.bazel @@ -62,6 +62,7 @@ fuchsia_cc_test( "//pw_bluetooth_sapphire/host/testing", "//pw_bluetooth_sapphire/host/testing:gtest_main", "//pw_bluetooth_sapphire/host/testing:loop_fixture", + "//pw_bluetooth_sapphire/host/testing:test_helpers", "//pw_bluetooth_sapphire/host/transport:testing", "@fuchsia_sdk//pkg/async-loop-cpp", ], diff --git a/pw_bluetooth_sapphire/fuchsia/lib/fidl/BUILD.bazel b/pw_bluetooth_sapphire/fuchsia/lib/fidl/BUILD.bazel index 25147da16..2f5ac73a3 100644 --- a/pw_bluetooth_sapphire/fuchsia/lib/fidl/BUILD.bazel +++ b/pw_bluetooth_sapphire/fuchsia/lib/fidl/BUILD.bazel @@ -46,6 +46,7 @@ fuchsia_cc_test( deps = [ ":fidl", "//pw_bluetooth_sapphire/host/testing:gtest_main", + "//pw_unit_test", "@fuchsia_sdk//pkg/fidl_cpp", ], ) diff --git a/pw_bluetooth_sapphire/host/att/BUILD.bazel b/pw_bluetooth_sapphire/host/att/BUILD.bazel index ea68293b8..172d60143 100644 --- a/pw_bluetooth_sapphire/host/att/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/att/BUILD.bazel @@ -12,10 +12,12 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) +# Basic target with protocol definitions and no logic, suitable for test +# emulation. cc_library( name = "definitions", srcs = [ @@ -52,14 +54,17 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/att/write_queue.h", ], implementation_deps = [ - "@pigweed//pw_string", + "//pw_preprocessor", + "//pw_string", ], strip_include_prefix = "public", deps = [ ":definitions", + "//pw_async:dispatcher", + "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/l2cap", "//pw_bluetooth_sapphire/host/sm:definitions", - "@pigweed//third_party/fuchsia:fit", + "//third_party/fuchsia:fit", ], ) @@ -76,5 +81,6 @@ pw_cc_test( deps = [ ":att", "//pw_bluetooth_sapphire/host/l2cap:testing", + "//pw_bluetooth_sapphire/host/testing:test_helpers", ], ) diff --git a/pw_bluetooth_sapphire/host/att/BUILD.gn b/pw_bluetooth_sapphire/host/att/BUILD.gn index 2b5bb51a1..bc94ff4f6 100644 --- a/pw_bluetooth_sapphire/host/att/BUILD.gn +++ b/pw_bluetooth_sapphire/host/att/BUILD.gn @@ -22,28 +22,20 @@ config("public_include_path") { # Basic target with protocol definitions and no logic, suitable for test # emulation. pw_source_set("definitions") { + sources = [ "packet.cc" ] public = [ "public/pw_bluetooth_sapphire/internal/host/att/att.h", "public/pw_bluetooth_sapphire/internal/host/att/packet.h", ] - sources = [ "packet.cc" ] + public_configs = [ ":public_include_path" ] public_deps = [ "$dir_pw_bluetooth_sapphire/host/common", "$dir_pw_bluetooth_sapphire/host/hci-spec", "$dir_pw_bluetooth_sapphire/host/l2cap:definitions", ] - public_configs = [ ":public_include_path" ] } pw_source_set("att") { - public = [ - "public/pw_bluetooth_sapphire/internal/host/att/attribute.h", - "public/pw_bluetooth_sapphire/internal/host/att/bearer.h", - "public/pw_bluetooth_sapphire/internal/host/att/database.h", - "public/pw_bluetooth_sapphire/internal/host/att/error.h", - "public/pw_bluetooth_sapphire/internal/host/att/permissions.h", - "public/pw_bluetooth_sapphire/internal/host/att/write_queue.h", - ] sources = [ "attribute.cc", "bearer.cc", @@ -52,20 +44,30 @@ pw_source_set("att") { "permissions.cc", "write_queue.cc", ] + public = [ + "public/pw_bluetooth_sapphire/internal/host/att/attribute.h", + "public/pw_bluetooth_sapphire/internal/host/att/bearer.h", + "public/pw_bluetooth_sapphire/internal/host/att/database.h", + "public/pw_bluetooth_sapphire/internal/host/att/error.h", + "public/pw_bluetooth_sapphire/internal/host/att/permissions.h", + "public/pw_bluetooth_sapphire/internal/host/att/write_queue.h", + ] + public_configs = [ ":public_include_path" ] public_deps = [ ":definitions", + "$dir_pw_async:dispatcher", + "$dir_pw_bluetooth_sapphire/host/common", "$dir_pw_bluetooth_sapphire/host/l2cap", "$dir_pw_bluetooth_sapphire/host/sm:definitions", "$dir_pw_third_party/fuchsia:fit", ] deps = [ - "$dir_pw_preprocessor", - "$dir_pw_string", + dir_pw_preprocessor, + dir_pw_string, ] - public_configs = [ ":public_include_path" ] } -pw_test("tests") { +pw_test("att_test") { sources = [ "attribute_test.cc", "bearer_test.cc", @@ -73,9 +75,14 @@ pw_test("tests") { "error_test.cc", "permissions_test.cc", ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":att", "$dir_pw_bluetooth_sapphire/host/l2cap:testing", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", ] - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" +} + +pw_test_group("tests") { + tests = [ ":att_test" ] } diff --git a/pw_bluetooth_sapphire/host/common/BUILD.bazel b/pw_bluetooth_sapphire/host/common/BUILD.bazel index 661e49cbd..5f5b5ffda 100644 --- a/pw_bluetooth_sapphire/host/common/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/common/BUILD.bazel @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -69,6 +70,10 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/common/weak_self.h", "public/pw_bluetooth_sapphire/internal/host/common/windowed_inspect_numeric_property.h", ], + implementation_deps = [ + "//pw_string", + "//pw_string:utf_codecs", + ], strip_include_prefix = "public", # This library is not compatible with --config=rp2040. target_compatible_with = select({ @@ -78,21 +83,20 @@ cc_library( "//conditions:default": ["@platforms//:incompatible"], }), deps = [ + "//pw_assert", + "//pw_async:dispatcher", + "//pw_async:task", + "//pw_bluetooth:emboss_hci", "//pw_bluetooth_sapphire:config", - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/lib/cpp-string", "//pw_bluetooth_sapphire/lib/cpp-type", - "@pigweed//pw_assert", - "@pigweed//pw_async:dispatcher", - "@pigweed//pw_async:task", - "@pigweed//pw_bluetooth:emboss_hci", - "@pigweed//pw_intrusive_ptr", - "@pigweed//pw_log", - "@pigweed//pw_random", - "@pigweed//pw_span", - "@pigweed//pw_string", - "@pigweed//pw_string:utf_codecs", - "@pigweed//third_party/fuchsia:fit", + "//pw_chrono:system_clock", + "//pw_intrusive_ptr", + "//pw_log", + "//pw_preprocessor", + "//pw_random", + "//pw_span", + "//third_party/fuchsia:fit", ] + select({ "@platforms//os:fuchsia": [ "@fuchsia_sdk//pkg/inspect_component_cpp", @@ -105,7 +109,7 @@ cc_library( cc_library( name = "uuid_string_util", srcs = ["uuid_string_util.cc"], - deps = [":common"], + implementation_deps = [":common"], ) pw_cc_test( @@ -135,7 +139,14 @@ pw_cc_test( deps = [ ":common", ":uuid_string_util", + "//pw_async:fake_dispatcher_fixture", "//pw_bluetooth_sapphire/host/testing", - "@pigweed//pw_async:fake_dispatcher_fixture", + "//pw_bluetooth_sapphire/host/testing:test_helpers", ], ) + +pw_cc_fuzz_test( + name = "advertising_data_fuzzer", + srcs = ["advertising_data_fuzztest.cc"], + deps = [":common"], +) diff --git a/pw_bluetooth_sapphire/host/common/BUILD.gn b/pw_bluetooth_sapphire/host/common/BUILD.gn index c50b8f355..596ecdc9c 100644 --- a/pw_bluetooth_sapphire/host/common/BUILD.gn +++ b/pw_bluetooth_sapphire/host/common/BUILD.gn @@ -21,6 +21,23 @@ config("public_include_path") { } pw_source_set("common") { + sources = [ + "advertising_data.cc", + "bounded_inspect_list_node.cc", + "byte_buffer.cc", + "device_address.cc", + "device_class.cc", + "host_error.cc", + "identifier.cc", + "log.cc", + "manufacturer_names.cc", + "metrics.cc", + "random.cc", + "retire_log.cc", + "slab_allocator.cc", + "supplement_data.cc", + "uuid.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/common/advertising_data.h", "public/pw_bluetooth_sapphire/internal/host/common/assert.h", @@ -55,38 +72,22 @@ pw_source_set("common") { "public/pw_bluetooth_sapphire/internal/host/common/weak_self.h", "public/pw_bluetooth_sapphire/internal/host/common/windowed_inspect_numeric_property.h", ] - sources = [ - "advertising_data.cc", - "bounded_inspect_list_node.cc", - "byte_buffer.cc", - "device_address.cc", - "device_class.cc", - "host_error.cc", - "identifier.cc", - "log.cc", - "manufacturer_names.cc", - "metrics.cc", - "random.cc", - "retire_log.cc", - "slab_allocator.cc", - "supplement_data.cc", - "uuid.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ - "$dir_pw_assert", "$dir_pw_async:dispatcher", "$dir_pw_async:task", "$dir_pw_bluetooth:emboss_hci_group", "$dir_pw_bluetooth_sapphire:config", "$dir_pw_bluetooth_sapphire/lib/cpp-string", "$dir_pw_bluetooth_sapphire/lib/cpp-type", - "$dir_pw_intrusive_ptr", - "$dir_pw_log", - "$dir_pw_random", - "$dir_pw_span", - "$dir_pw_string", - "$dir_pw_string:utf_codecs", + "$dir_pw_chrono:system_clock", "$dir_pw_third_party/fuchsia:fit", + dir_pw_assert, + dir_pw_intrusive_ptr, + dir_pw_log, + dir_pw_preprocessor, + dir_pw_random, + dir_pw_span, ] if (current_os == "fuchsia") { public_deps += [ @@ -94,16 +95,18 @@ pw_source_set("common") { "//zircon/system/ulib/trace", ] } - public_configs = [ ":public_include_path" ] - deps = [ "$dir_pw_preprocessor" ] + deps = [ + "$dir_pw_string:utf_codecs", + dir_pw_preprocessor, + ] } pw_source_set("uuid_string_util") { sources = [ "uuid_string_util.cc" ] - public_deps = [ ":common" ] + deps = [ ":common" ] } -pw_test("common_tests") { +pw_test("common_test") { sources = [ "advertising_data_test.cc", "bounded_inspect_list_node_test.cc", @@ -125,13 +128,14 @@ pw_test("common_tests") { "weak_self_test.cc", "windowed_inspect_numeric_property_test.cc", ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":common", ":uuid_string_util", "$dir_pw_async:fake_dispatcher_fixture", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", ] - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" } pw_fuzzer("advertising_data_fuzzer") { @@ -141,7 +145,7 @@ pw_fuzzer("advertising_data_fuzzer") { pw_test_group("tests") { tests = [ - ":common_tests", + ":common_test", ":advertising_data_fuzzer_test", ] } diff --git a/pw_bluetooth_sapphire/host/gap/BUILD.bazel b/pw_bluetooth_sapphire/host/gap/BUILD.bazel index 9acc36e49..640efbf24 100644 --- a/pw_bluetooth_sapphire/host/gap/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/gap/BUILD.bazel @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -27,8 +28,9 @@ cc_library( ], strip_include_prefix = "public", deps = [ - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/common", + "//pw_bluetooth_sapphire/host/sm:definitions", + "//third_party/fuchsia:fit", ], ) @@ -94,10 +96,13 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/gap/secure_simple_pairing_state.h", "public/pw_bluetooth_sapphire/internal/host/gap/types.h", ], + implementation_deps = [ + "//pw_string:utf_codecs", + ], strip_include_prefix = "public", deps = [ ":definitions", - "//pw_bluetooth_sapphire:public", + "//pw_async:heap_dispatcher", "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/gatt", "//pw_bluetooth_sapphire/host/hci", @@ -106,11 +111,8 @@ cc_library( "//pw_bluetooth_sapphire/host/sco", "//pw_bluetooth_sapphire/host/sdp", "//pw_bluetooth_sapphire/host/sm", - "//pw_bluetooth_sapphire/host/sm:definitions", - "@pigweed//pw_async:heap_dispatcher", - "@pigweed//pw_bluetooth", - "@pigweed//pw_string:utf_codecs", - "@pigweed//third_party/fuchsia:fit", + "//pw_bluetooth_sapphire/host/transport", + "//third_party/fuchsia:fit", ], ) @@ -125,13 +127,17 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/gap/fake_adapter.h", "public/pw_bluetooth_sapphire/internal/host/gap/fake_pairing_delegate.h", ], + implementation_deps = [ + "//pw_unit_test", + ], strip_include_prefix = "public", deps = [ + ":definitions", ":gap", - "//pw_bluetooth_sapphire:public", + "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/hci:testing", + "//pw_bluetooth_sapphire/host/l2cap", "//pw_bluetooth_sapphire/host/l2cap:testing", - "@pigweed//pw_unit_test", ], ) @@ -169,5 +175,20 @@ pw_cc_test( "//pw_bluetooth_sapphire/host/sm", "//pw_bluetooth_sapphire/host/sm:testing", "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:fake_controller", + "//pw_bluetooth_sapphire/host/testing:mock_controller", + "//pw_bluetooth_sapphire/host/testing:test_helpers", + "//pw_bluetooth_sapphire/host/transport:testing", + ], +) + +pw_cc_fuzz_test( + name = "peer_cache_fuzzer", + srcs = ["peer_cache_fuzztest.cc"], + deps = [ + ":gap", + "//pw_async:fake_dispatcher", + "//pw_bluetooth_sapphire/host/testing:fuzzing", + "//pw_random:fuzzer_generator", ], ) diff --git a/pw_bluetooth_sapphire/host/gap/BUILD.gn b/pw_bluetooth_sapphire/host/gap/BUILD.gn index c52f9dfbe..c60803991 100644 --- a/pw_bluetooth_sapphire/host/gap/BUILD.gn +++ b/pw_bluetooth_sapphire/host/gap/BUILD.gn @@ -21,13 +21,45 @@ config("public_include_path") { } pw_source_set("definitions") { - public = [ "public/pw_bluetooth_sapphire/internal/host/gap/gap.h" ] sources = [ "gap.cc" ] + public = [ "public/pw_bluetooth_sapphire/internal/host/gap/gap.h" ] public_configs = [ ":public_include_path" ] - deps = [ "$dir_pw_bluetooth_sapphire/host/common" ] + public_deps = [ + "$dir_pw_bluetooth_sapphire/host/common", + "$dir_pw_bluetooth_sapphire/host/sm:definitions", + "$dir_pw_third_party/fuchsia:fit", + ] } pw_source_set("gap") { + sources = [ + "adapter.cc", + "android_vendor_capabilities.cc", + "bredr_connection.cc", + "bredr_connection_manager.cc", + "bredr_connection_request.cc", + "bredr_discovery_manager.cc", + "bredr_interrogator.cc", + "discovery_filter.cc", + "generic_access_client.cc", + "identity_resolving_list.cc", + "legacy_pairing_state.cc", + "low_energy_address_manager.cc", + "low_energy_advertising_manager.cc", + "low_energy_connection.cc", + "low_energy_connection_handle.cc", + "low_energy_connection_manager.cc", + "low_energy_connection_request.cc", + "low_energy_connector.cc", + "low_energy_discovery_manager.cc", + "low_energy_interrogator.cc", + "pairing_state_manager.cc", + "peer.cc", + "peer_cache.cc", + "peer_metrics.cc", + "secure_simple_pairing_state.cc", + "types.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/gap/adapter.h", "public/pw_bluetooth_sapphire/internal/host/gap/adapter_state.h", @@ -61,34 +93,7 @@ pw_source_set("gap") { "public/pw_bluetooth_sapphire/internal/host/gap/secure_simple_pairing_state.h", "public/pw_bluetooth_sapphire/internal/host/gap/types.h", ] - sources = [ - "adapter.cc", - "android_vendor_capabilities.cc", - "bredr_connection.cc", - "bredr_connection_manager.cc", - "bredr_connection_request.cc", - "bredr_discovery_manager.cc", - "bredr_interrogator.cc", - "discovery_filter.cc", - "generic_access_client.cc", - "identity_resolving_list.cc", - "legacy_pairing_state.cc", - "low_energy_address_manager.cc", - "low_energy_advertising_manager.cc", - "low_energy_connection.cc", - "low_energy_connection_handle.cc", - "low_energy_connection_manager.cc", - "low_energy_connection_request.cc", - "low_energy_connector.cc", - "low_energy_discovery_manager.cc", - "low_energy_interrogator.cc", - "pairing_state_manager.cc", - "peer.cc", - "peer_cache.cc", - "peer_metrics.cc", - "secure_simple_pairing_state.cc", - "types.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ ":definitions", "$dir_pw_async:heap_dispatcher", @@ -105,7 +110,6 @@ pw_source_set("gap") { "$dir_pw_string:utf_codecs", "$dir_pw_third_party/fuchsia:fit", ] - public_configs = [ ":public_include_path" ] deps = [ "$dir_pw_bluetooth_sapphire/host/sm", "$dir_pw_preprocessor", @@ -131,7 +135,7 @@ pw_source_set("testing") { public_configs = [ ":public_include_path" ] } -pw_test("gap_tests") { +pw_test("gap_test") { sources = [ "adapter_test.cc", "android_vendor_capabilities_test.cc", @@ -163,6 +167,10 @@ pw_test("gap_tests") { "$dir_pw_bluetooth_sapphire/host/sm", "$dir_pw_bluetooth_sapphire/host/sm:testing", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:fake_controller", + "$dir_pw_bluetooth_sapphire/host/testing:mock_controller", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", + "$dir_pw_bluetooth_sapphire/host/transport:testing", ] test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" } @@ -179,7 +187,7 @@ pw_fuzzer("peer_cache_fuzzer") { pw_test_group("tests") { tests = [ - ":gap_tests", + ":gap_test", ":peer_cache_fuzzer_test", ] } diff --git a/pw_bluetooth_sapphire/host/gatt/BUILD.bazel b/pw_bluetooth_sapphire/host/gatt/BUILD.bazel index 06375c6e1..48855bef3 100644 --- a/pw_bluetooth_sapphire/host/gatt/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/gatt/BUILD.bazel @@ -12,10 +12,12 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) +# Basic target with protocol definitions and no logic, suitable for test +# emulation. cc_library( name = "definitions", srcs = [ @@ -26,8 +28,9 @@ cc_library( ], strip_include_prefix = "public", deps = [ - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/att:definitions", + "//pw_bluetooth_sapphire/host/common", + "//third_party/fuchsia:fit", ], ) @@ -61,7 +64,6 @@ cc_library( strip_include_prefix = "public", deps = [ ":definitions", - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/att", "//third_party/fuchsia:fit", ], @@ -80,14 +82,21 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/gatt/fake_layer.h", "public/pw_bluetooth_sapphire/internal/host/gatt/mock_server.h", ], + implementation_deps = [ + "//pw_bluetooth_sapphire/host/common", + "//pw_unit_test:googletest", + ], strip_include_prefix = "public", + target_compatible_with = select({ + "//pw_unit_test:googletest_only": [], + "@platforms//os:fuchsia": [], + "//conditions:default": ["@platforms//:incompatible"], + }), deps = [ ":gatt", "//pw_async:heap_dispatcher", - "//pw_bluetooth_sapphire:public", - "//pw_bluetooth_sapphire/host/common", - "//pw_bluetooth_sapphire/host/common:uuid_string_util", - "//pw_unit_test:googletest", + "//pw_bluetooth_sapphire/host/att", + "//third_party/fuchsia:fit", ], ) @@ -106,7 +115,8 @@ pw_cc_test( ":gatt", ":testing", "//pw_bluetooth_sapphire/host/att", + "//pw_bluetooth_sapphire/host/common:uuid_string_util", "//pw_bluetooth_sapphire/host/l2cap:testing", - "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:test_helpers", ], ) diff --git a/pw_bluetooth_sapphire/host/gatt/BUILD.gn b/pw_bluetooth_sapphire/host/gatt/BUILD.gn index 0c847d47c..257d7a61f 100644 --- a/pw_bluetooth_sapphire/host/gatt/BUILD.gn +++ b/pw_bluetooth_sapphire/host/gatt/BUILD.gn @@ -23,13 +23,29 @@ config("public_include_path") { # Basic target with protocol definitions and no logic, suitable for test # emulation. pw_source_set("definitions") { - public = [ "public/pw_bluetooth_sapphire/internal/host/gatt/gatt_defs.h" ] sources = [ "gatt_defs.cc" ] - public_deps = [ "$dir_pw_bluetooth_sapphire/host/att:definitions" ] + public = [ "public/pw_bluetooth_sapphire/internal/host/gatt/gatt_defs.h" ] public_configs = [ ":public_include_path" ] + public_deps = [ + "$dir_pw_bluetooth_sapphire/host/att:definitions", + "$dir_pw_bluetooth_sapphire/host/common", + "$dir_pw_third_party/fuchsia:fit", + ] } pw_source_set("gatt") { + sources = [ + "client.cc", + "connection.cc", + "gatt.cc", + "generic_attribute_service.cc", + "local_service_manager.cc", + "remote_characteristic.cc", + "remote_service.cc", + "remote_service_manager.cc", + "server.cc", + "types.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/gatt/client.h", "public/pw_bluetooth_sapphire/internal/host/gatt/connection.h", @@ -43,50 +59,40 @@ pw_source_set("gatt") { "public/pw_bluetooth_sapphire/internal/host/gatt/server.h", "public/pw_bluetooth_sapphire/internal/host/gatt/types.h", ] - sources = [ - "client.cc", - "connection.cc", - "gatt.cc", - "generic_attribute_service.cc", - "local_service_manager.cc", - "remote_characteristic.cc", - "remote_service.cc", - "remote_service_manager.cc", - "server.cc", - "types.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ ":definitions", - "$dir_pw_bluetooth_sapphire:config", "$dir_pw_bluetooth_sapphire/host/att", "$dir_pw_third_party/fuchsia:fit", ] - public_configs = [ ":public_include_path" ] } pw_source_set("testing") { testonly = pw_unit_test_TESTONLY - public = [ - "public/pw_bluetooth_sapphire/internal/host/gatt/fake_client.h", - "public/pw_bluetooth_sapphire/internal/host/gatt/fake_layer.h", - "public/pw_bluetooth_sapphire/internal/host/gatt/mock_server.h", - ] sources = [ "fake_client.cc", "fake_layer.cc", "mock_server.cc", ] + public = [ + "public/pw_bluetooth_sapphire/internal/host/gatt/fake_client.h", + "public/pw_bluetooth_sapphire/internal/host/gatt/fake_layer.h", + "public/pw_bluetooth_sapphire/internal/host/gatt/mock_server.h", + ] + public_configs = [ ":public_include_path" ] public_deps = [ ":gatt", "$dir_pw_async:heap_dispatcher", + "$dir_pw_bluetooth_sapphire/host/att", + "$dir_pw_third_party/fuchsia:fit", + ] + deps = [ "$dir_pw_bluetooth_sapphire/host/common", - "$dir_pw_bluetooth_sapphire/host/common:uuid_string_util", - "$dir_pw_unit_test", + dir_pw_unit_test, ] - public_configs = [ ":public_include_path" ] } -pw_test("tests") { +pw_test("gatt_test") { sources = [ "client_test.cc", "gatt_test.cc", @@ -95,13 +101,17 @@ pw_test("tests") { "remote_service_manager_test.cc", "server_test.cc", ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":gatt", ":testing", "$dir_pw_bluetooth_sapphire/host/att", + "$dir_pw_bluetooth_sapphire/host/common:uuid_string_util", "$dir_pw_bluetooth_sapphire/host/l2cap:testing", - "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", ] - public_configs = [ ":public_include_path" ] - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" +} + +pw_test_group("tests") { + tests = [ ":gatt_test" ] } diff --git a/pw_bluetooth_sapphire/host/hci-spec/BUILD.bazel b/pw_bluetooth_sapphire/host/hci-spec/BUILD.bazel index 649ad63ca..d96d52a49 100644 --- a/pw_bluetooth_sapphire/host/hci-spec/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/hci-spec/BUILD.bazel @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -35,9 +35,8 @@ cc_library( strip_include_prefix = "public", deps = [ "//pw_bluetooth:emboss_hci", - "//pw_bluetooth_sapphire:config", - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/common", + "//pw_bluetooth_sapphire/lib/cpp-string", "//pw_chrono:system_clock", ], ) diff --git a/pw_bluetooth_sapphire/host/hci-spec/BUILD.gn b/pw_bluetooth_sapphire/host/hci-spec/BUILD.gn index 7cdae11c2..d1597b8e9 100644 --- a/pw_bluetooth_sapphire/host/hci-spec/BUILD.gn +++ b/pw_bluetooth_sapphire/host/hci-spec/BUILD.gn @@ -21,6 +21,10 @@ config("public_include_path") { # Static library containing the HCI specification definitions pw_source_set("hci-spec") { + sources = [ + "le_connection_parameters.cc", + "util.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/hci-spec/constants.h", "public/pw_bluetooth_sapphire/internal/host/hci-spec/defaults.h", @@ -31,21 +35,21 @@ pw_source_set("hci-spec") { "public/pw_bluetooth_sapphire/internal/host/hci-spec/util.h", "public/pw_bluetooth_sapphire/internal/host/hci-spec/vendor_protocol.h", ] - sources = [ - "le_connection_parameters.cc", - "util.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ "$dir_pw_bluetooth:emboss_hci_group", - "$dir_pw_bluetooth_sapphire:config", "$dir_pw_bluetooth_sapphire/host/common", + "$dir_pw_bluetooth_sapphire/lib/cpp-string", "$dir_pw_chrono:system_clock", ] - public_configs = [ ":public_include_path" ] } -pw_test("tests") { +pw_test("hci-spec_test") { sources = [ "util_test.cc" ] - deps = [ ":hci-spec" ] test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" + deps = [ ":hci-spec" ] +} + +pw_test_group("tests") { + tests = [ ":hci-spec_test" ] } diff --git a/pw_bluetooth_sapphire/host/hci/BUILD.bazel b/pw_bluetooth_sapphire/host/hci/BUILD.bazel index 42360a38e..db6cf8261 100644 --- a/pw_bluetooth_sapphire/host/hci/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/hci/BUILD.bazel @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -56,13 +56,17 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/hci/sco_connection.h", "public/pw_bluetooth_sapphire/internal/host/hci/sequential_command_runner.h", ], + implementation_deps = [ + "//pw_async:heap_dispatcher", + "//pw_bluetooth:emboss_hci", + "//pw_preprocessor", + ], strip_include_prefix = "public", deps = [ - "//pw_bluetooth_sapphire:public", + "//pw_bluetooth_sapphire/host/common", + "//pw_bluetooth_sapphire/host/hci-spec", "//pw_bluetooth_sapphire/host/transport", - "@pigweed//pw_async:heap_dispatcher", - "@pigweed//pw_bluetooth:emboss_hci", - "@pigweed//third_party/fuchsia:fit", + "//third_party/fuchsia:fit", ], ) @@ -83,9 +87,8 @@ cc_library( strip_include_prefix = "public", deps = [ ":hci", - "//pw_bluetooth_sapphire:public", + "//pw_async:heap_dispatcher", "//pw_bluetooth_sapphire/host/common", - "@pigweed//pw_async:heap_dispatcher", ], ) @@ -108,7 +111,11 @@ pw_cc_test( deps = [ ":hci", ":testing", + "//pw_bluetooth:emboss_hci_test", "//pw_bluetooth_sapphire/host/testing", - "@pigweed//pw_bluetooth:emboss_hci_test", + "//pw_bluetooth_sapphire/host/testing:fake_controller", + "//pw_bluetooth_sapphire/host/testing:mock_controller", + "//pw_bluetooth_sapphire/host/testing:test_helpers", + "//pw_bluetooth_sapphire/host/transport:testing", ], ) diff --git a/pw_bluetooth_sapphire/host/hci/BUILD.gn b/pw_bluetooth_sapphire/host/hci/BUILD.gn index f12e4f13c..966e9c28f 100644 --- a/pw_bluetooth_sapphire/host/hci/BUILD.gn +++ b/pw_bluetooth_sapphire/host/hci/BUILD.gn @@ -20,6 +20,24 @@ config("public_include_path") { } pw_source_set("hci") { + sources = [ + "acl_connection.cc", + "advertising_handle_map.cc", + "android_extended_low_energy_advertiser.cc", + "bredr_connection.cc", + "bredr_connection_request.cc", + "connection.cc", + "extended_low_energy_advertiser.cc", + "extended_low_energy_scanner.cc", + "legacy_low_energy_advertiser.cc", + "legacy_low_energy_scanner.cc", + "low_energy_advertiser.cc", + "low_energy_connection.cc", + "low_energy_connector.cc", + "low_energy_scanner.cc", + "sco_connection.cc", + "sequential_command_runner.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/hci/acl_connection.h", "public/pw_bluetooth_sapphire/internal/host/hci/advertising_handle_map.h", @@ -40,53 +58,42 @@ pw_source_set("hci") { "public/pw_bluetooth_sapphire/internal/host/hci/sco_connection.h", "public/pw_bluetooth_sapphire/internal/host/hci/sequential_command_runner.h", ] - sources = [ - "acl_connection.cc", - "advertising_handle_map.cc", - "android_extended_low_energy_advertiser.cc", - "bredr_connection.cc", - "bredr_connection_request.cc", - "connection.cc", - "extended_low_energy_advertiser.cc", - "extended_low_energy_scanner.cc", - "legacy_low_energy_advertiser.cc", - "legacy_low_energy_scanner.cc", - "low_energy_advertiser.cc", - "low_energy_connection.cc", - "low_energy_connector.cc", - "low_energy_scanner.cc", - "sco_connection.cc", - "sequential_command_runner.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ - "$dir_pw_async:heap_dispatcher", - "$dir_pw_bluetooth:emboss_hci_group", + "$dir_pw_bluetooth_sapphire/host/common", + "$dir_pw_bluetooth_sapphire/host/hci-spec", "$dir_pw_bluetooth_sapphire/host/transport", "$dir_pw_third_party/fuchsia:fit", ] - public_configs = [ ":public_include_path" ] - deps = [ "$dir_pw_preprocessor" ] + deps = [ + "$dir_pw_async:heap_dispatcher", + "$dir_pw_bluetooth:emboss_hci_group", + dir_pw_preprocessor, + ] } pw_source_set("testing") { - public = [ - "public/pw_bluetooth_sapphire/internal/host/hci/fake_bredr_connection.h", - "public/pw_bluetooth_sapphire/internal/host/hci/fake_local_address_delegate.h", - "public/pw_bluetooth_sapphire/internal/host/hci/fake_low_energy_connection.h", - "public/pw_bluetooth_sapphire/internal/host/hci/fake_sco_connection.h", - ] sources = [ "fake_bredr_connection.cc", "fake_local_address_delegate.cc", "fake_low_energy_connection.cc", "fake_sco_connection.cc", ] - public_deps = [ ":hci" ] + public = [ + "public/pw_bluetooth_sapphire/internal/host/hci/fake_bredr_connection.h", + "public/pw_bluetooth_sapphire/internal/host/hci/fake_local_address_delegate.h", + "public/pw_bluetooth_sapphire/internal/host/hci/fake_low_energy_connection.h", + "public/pw_bluetooth_sapphire/internal/host/hci/fake_sco_connection.h", + ] public_configs = [ ":public_include_path" ] - deps = [ "$dir_pw_async:heap_dispatcher" ] + public_deps = [ + ":hci", + "$dir_pw_async:heap_dispatcher", + "$dir_pw_bluetooth_sapphire/host/common", + ] } -pw_test("tests") { +pw_test("hci_test") { sources = [ "advertising_handle_map_test.cc", "connection_test.cc", @@ -100,10 +107,18 @@ pw_test("tests") { "low_energy_scanner_test.cc", "sequential_command_runner_test.cc", ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":testing", "$dir_pw_bluetooth:emboss_hci_test", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:fake_controller", + "$dir_pw_bluetooth_sapphire/host/testing:mock_controller", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", + "$dir_pw_bluetooth_sapphire/host/transport:testing", ] - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" +} + +pw_test_group("tests") { + tests = [ ":hci_test" ] } diff --git a/pw_bluetooth_sapphire/host/iso/BUILD.bazel b/pw_bluetooth_sapphire/host/iso/BUILD.bazel index 83f1c2ff8..cba010638 100644 --- a/pw_bluetooth_sapphire/host/iso/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/iso/BUILD.bazel @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -29,12 +29,18 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/iso/iso_stream.h", "public/pw_bluetooth_sapphire/internal/host/iso/iso_stream_manager.h", ], + implementation_deps = [ + "//pw_bluetooth_sapphire/host/hci", + ], strip_include_prefix = "public", deps = [ - "//pw_bluetooth_sapphire:public", + "//pw_bluetooth:emboss_hci_data", + "//pw_bluetooth:emboss_hci_events", "//pw_bluetooth_sapphire/host/common", - "//pw_bluetooth_sapphire/host/hci", + "//pw_bluetooth_sapphire/host/hci-spec", "//pw_bluetooth_sapphire/host/transport", + "//pw_function", + "//pw_span", ], ) @@ -62,5 +68,6 @@ pw_cc_test( deps = [ ":iso", "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:mock_controller", ], ) diff --git a/pw_bluetooth_sapphire/host/iso/BUILD.gn b/pw_bluetooth_sapphire/host/iso/BUILD.gn index 021484096..ba27d6eb9 100644 --- a/pw_bluetooth_sapphire/host/iso/BUILD.gn +++ b/pw_bluetooth_sapphire/host/iso/BUILD.gn @@ -20,36 +20,53 @@ config("public_include_path") { } pw_source_set("iso") { + sources = [ + "iso_inbound_packet_assembler.cc", + "iso_stream.cc", + "iso_stream_manager.cc", + ] public = [ - "public/pw_bluetooth_sapphire/internal/host/iso/fake_iso_stream.h", "public/pw_bluetooth_sapphire/internal/host/iso/iso_common.h", "public/pw_bluetooth_sapphire/internal/host/iso/iso_inbound_packet_assembler.h", "public/pw_bluetooth_sapphire/internal/host/iso/iso_stream.h", "public/pw_bluetooth_sapphire/internal/host/iso/iso_stream_manager.h", ] - sources = [ - "iso_inbound_packet_assembler.cc", - "iso_stream.cc", - "iso_stream_manager.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ + "$dir_pw_bluetooth:emboss_hci_data", + "$dir_pw_bluetooth:emboss_hci_events", "$dir_pw_bluetooth_sapphire/host/common", - "$dir_pw_bluetooth_sapphire/host/hci", + "$dir_pw_bluetooth_sapphire/host/hci-spec", "$dir_pw_bluetooth_sapphire/host/transport", + dir_pw_function, + dir_pw_span, ] + deps = [ "$dir_pw_bluetooth_sapphire/host/hci" ] +} + +pw_source_set("testing") { + testonly = pw_unit_test_TESTONLY + public = + [ "public/pw_bluetooth_sapphire/internal/host/iso/fake_iso_stream.h" ] public_configs = [ ":public_include_path" ] + public_deps = [ ":iso" ] } -pw_test("tests") { +pw_test("iso_test") { sources = [ "iso_common_test.cc", "iso_inbound_packet_assembler_test.cc", "iso_stream_manager_test.cc", "iso_stream_test.cc", ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":iso", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:mock_controller", ] - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" +} + +pw_test_group("tests") { + tests = [ ":iso_test" ] } diff --git a/pw_bluetooth_sapphire/host/l2cap/BUILD.bazel b/pw_bluetooth_sapphire/host/l2cap/BUILD.bazel index 7fcfe3ec3..23c3ae278 100644 --- a/pw_bluetooth_sapphire/host/l2cap/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/l2cap/BUILD.bazel @@ -17,6 +17,8 @@ load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) +# Basic target with protocol definitions and no logic, suitable for test +# emulation. cc_library( name = "definitions", hdrs = [ @@ -25,9 +27,9 @@ cc_library( ], strip_include_prefix = "public", deps = [ - "//pw_bluetooth_sapphire:public", - "//pw_bluetooth_sapphire/host/hci-spec", - "//pw_bluetooth_sapphire/host/sm:definitions", + "//pw_bluetooth_sapphire/host/common", + "//pw_bytes", + "//pw_chrono:system_clock", ], ) @@ -95,6 +97,10 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/l2cap/tx_engine.h", "public/pw_bluetooth_sapphire/internal/host/l2cap/types.h", ], + implementation_deps = [ + "//pw_bluetooth:emboss_l2cap_frames", + "//pw_preprocessor", + ], strip_include_prefix = "public", target_compatible_with = select({ "@platforms//os:fuchsia": [], @@ -104,15 +110,18 @@ cc_library( }), deps = [ ":definitions", - "//pw_bluetooth:emboss_l2cap_frames", - "//pw_bluetooth_sapphire:public", + "//pw_bluetooth", + "//pw_bluetooth:emboss_hci_android", + "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/hci", + "//pw_bluetooth_sapphire/host/sm:definitions", "//pw_bluetooth_sapphire/host/transport", "//pw_string", "//third_party/fuchsia:fit", ], ) +# Separate from :testing to avoid a dependency cycle. cc_library( name = "channel_manager_mock_controller_test_fixture", testonly = True, @@ -123,9 +132,8 @@ cc_library( deps = [ ":l2cap", ":testing", - "//pw_bluetooth_sapphire:public", - "//pw_bluetooth_sapphire/host/hci", "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:mock_controller", ], ) @@ -149,17 +157,23 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/l2cap/mock_channel_test.h", "public/pw_bluetooth_sapphire/internal/host/l2cap/test_packets.h", ], + implementation_deps = [ + "//pw_bluetooth_sapphire/host/testing:test_helpers", + "//pw_unit_test:googletest", + ], strip_include_prefix = "public", + target_compatible_with = select({ + "//pw_unit_test:googletest_only": [], + "@platforms//os:fuchsia": [], + "//conditions:default": ["@platforms//:incompatible"], + }), deps = [ ":l2cap", "//pw_async:fake_dispatcher_fixture", "//pw_async:heap_dispatcher", - "//pw_bluetooth", - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/common", - "//pw_bluetooth_sapphire/host/hci", - "//pw_bluetooth_sapphire/host/testing:test_helpers", - "//pw_unit_test:googletest", + "//pw_bluetooth_sapphire/host/hci-spec", + "//third_party/fuchsia:fit", ], ) @@ -204,16 +218,64 @@ pw_cc_test( "//pw_bluetooth_sapphire/host/hci", "//pw_bluetooth_sapphire/host/hci:testing", "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:test_helpers", "//pw_bluetooth_sapphire/host/transport:testing", ], ) pw_cc_fuzz_test( name = "basic_mode_rx_engine_fuzzer", - testonly = True, srcs = ["basic_mode_rx_engine_fuzztest.cc"], deps = [ ":l2cap", ":testing", ], ) + +pw_cc_fuzz_test( + name = "enhanced_retransmission_mode_engines_fuzzer", + srcs = ["enhanced_retransmission_mode_engines_fuzztest.cc"], + deps = [ + ":l2cap", + ":testing", + ], +) + +pw_cc_fuzz_test( + name = "bredr_dynamic_channel_registry_fuzzer", + srcs = ["bredr_dynamic_channel_registry_fuzztest.cc"], + deps = [ + ":l2cap", + ":testing", + "//pw_random:fuzzer_generator", + ], +) + +pw_cc_fuzz_test( + name = "channel_configuration_fuzzer", + srcs = ["channel_configuration_fuzztest.cc"], + deps = [ + ":l2cap", + ":testing", + ], +) + +pw_cc_fuzz_test( + name = "common_handler_fuzzer", + srcs = ["common_handler_fuzztest.cc"], + deps = [ + ":l2cap", + ":testing", + ], +) + +pw_cc_fuzz_test( + name = "l2cap_fuzzer", + srcs = ["l2cap_fuzztest.cc"], + deps = [ + ":l2cap", + "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:controller_test_double_base", + "//pw_random:fuzzer_generator", + ], +) diff --git a/pw_bluetooth_sapphire/host/l2cap/BUILD.gn b/pw_bluetooth_sapphire/host/l2cap/BUILD.gn index 2c7dda3c1..0618e7e5c 100644 --- a/pw_bluetooth_sapphire/host/l2cap/BUILD.gn +++ b/pw_bluetooth_sapphire/host/l2cap/BUILD.gn @@ -27,14 +27,45 @@ pw_source_set("definitions") { "public/pw_bluetooth_sapphire/internal/host/l2cap/frame_headers.h", "public/pw_bluetooth_sapphire/internal/host/l2cap/l2cap_defs.h", ] + public_configs = [ ":public_include_path" ] public_deps = [ - "$dir_pw_bluetooth_sapphire/host/hci-spec", - "$dir_pw_bluetooth_sapphire/host/sm:definitions", + "$dir_pw_bluetooth_sapphire/host/common", + "$dir_pw_chrono:system_clock", + dir_pw_bytes, ] - public_configs = [ ":public_include_path" ] } pw_source_set("l2cap") { + sources = [ + "a2dp_offload_manager.cc", + "basic_mode_rx_engine.cc", + "basic_mode_tx_engine.cc", + "bredr_command_handler.cc", + "bredr_dynamic_channel.cc", + "bredr_signaling_channel.cc", + "channel.cc", + "channel_configuration.cc", + "channel_manager.cc", + "command_handler.cc", + "credit_based_flow_control_rx_engine.cc", + "credit_based_flow_control_tx_engine.cc", + "dynamic_channel.cc", + "dynamic_channel_registry.cc", + "enhanced_retransmission_mode_engines.cc", + "enhanced_retransmission_mode_rx_engine.cc", + "enhanced_retransmission_mode_tx_engine.cc", + "fcs.cc", + "fragmenter.cc", + "le_dynamic_channel.cc", + "le_signaling_channel.cc", + "logical_link.cc", + "low_energy_command_handler.cc", + "pdu.cc", + "recombiner.cc", + "scoped_channel.cc", + "signaling_channel.cc", + "types.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/l2cap/a2dp_offload_manager.h", "public/pw_bluetooth_sapphire/internal/host/l2cap/basic_mode_rx_engine.h", @@ -67,48 +98,21 @@ pw_source_set("l2cap") { "public/pw_bluetooth_sapphire/internal/host/l2cap/tx_engine.h", "public/pw_bluetooth_sapphire/internal/host/l2cap/types.h", ] - sources = [ - "a2dp_offload_manager.cc", - "basic_mode_rx_engine.cc", - "basic_mode_tx_engine.cc", - "bredr_command_handler.cc", - "bredr_dynamic_channel.cc", - "bredr_signaling_channel.cc", - "channel.cc", - "channel_configuration.cc", - "channel_manager.cc", - "command_handler.cc", - "credit_based_flow_control_rx_engine.cc", - "credit_based_flow_control_tx_engine.cc", - "dynamic_channel.cc", - "dynamic_channel_registry.cc", - "enhanced_retransmission_mode_engines.cc", - "enhanced_retransmission_mode_rx_engine.cc", - "enhanced_retransmission_mode_tx_engine.cc", - "fcs.cc", - "fragmenter.cc", - "le_dynamic_channel.cc", - "le_signaling_channel.cc", - "logical_link.cc", - "low_energy_command_handler.cc", - "pdu.cc", - "recombiner.cc", - "scoped_channel.cc", - "signaling_channel.cc", - "types.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ ":definitions", - "$dir_pw_bluetooth_sapphire:config", + "$dir_pw_bluetooth:emboss_hci_android", + "$dir_pw_bluetooth_sapphire/host/common", "$dir_pw_bluetooth_sapphire/host/hci", + "$dir_pw_bluetooth_sapphire/host/sm:definitions", "$dir_pw_bluetooth_sapphire/host/transport", - "$dir_pw_string", "$dir_pw_third_party/fuchsia:fit", + dir_pw_bluetooth, + dir_pw_string, ] - public_configs = [ ":public_include_path" ] deps = [ "$dir_pw_bluetooth:emboss_l2cap_frames", - "$dir_pw_preprocessor", + dir_pw_preprocessor, ] } @@ -116,17 +120,25 @@ pw_source_set("l2cap") { pw_source_set("channel_manager_mock_controller_test_fixture") { testonly = pw_unit_test_TESTONLY public = [ "public/pw_bluetooth_sapphire/internal/host/l2cap/channel_manager_mock_controller_test_fixture.h" ] + public_configs = [ ":public_include_path" ] public_deps = [ ":l2cap", ":testing", - "$dir_pw_bluetooth_sapphire/host/hci", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:mock_controller", ] - public_configs = [ ":public_include_path" ] } pw_source_set("testing") { testonly = pw_unit_test_TESTONLY + sources = [ + "fake_channel.cc", + "fake_channel_test.cc", + "fake_l2cap.cc", + "fake_signaling_channel.cc", + "mock_channel_test.cc", + "test_packets.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/l2cap/fake_channel.h", "public/pw_bluetooth_sapphire/internal/host/l2cap/fake_channel_test.h", @@ -136,25 +148,19 @@ pw_source_set("testing") { "public/pw_bluetooth_sapphire/internal/host/l2cap/mock_channel_test.h", "public/pw_bluetooth_sapphire/internal/host/l2cap/test_packets.h", ] - sources = [ - "fake_channel.cc", - "fake_channel_test.cc", - "fake_l2cap.cc", - "fake_signaling_channel.cc", - "mock_channel_test.cc", - "test_packets.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ ":l2cap", "$dir_pw_async:fake_dispatcher_fixture", "$dir_pw_async:heap_dispatcher", - "$dir_pw_bluetooth", "$dir_pw_bluetooth_sapphire/host/common", - "$dir_pw_bluetooth_sapphire/host/hci", + "$dir_pw_bluetooth_sapphire/host/hci-spec", + "$dir_pw_third_party/fuchsia:fit", + ] + deps = [ "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", - "$dir_pw_unit_test", + dir_pw_unit_test, ] - public_configs = [ ":public_include_path" ] } pw_test("l2cap_tests") { @@ -188,7 +194,7 @@ pw_test("l2cap_tests") { "signaling_channel_test.cc", "types_test.cc", ] - public_configs = [ ":public_include_path" ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":channel_manager_mock_controller_test_fixture", ":l2cap", @@ -197,9 +203,9 @@ pw_test("l2cap_tests") { "$dir_pw_bluetooth_sapphire/host/hci", "$dir_pw_bluetooth_sapphire/host/hci:testing", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", "$dir_pw_bluetooth_sapphire/host/transport:testing", ] - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" } pw_fuzzer("basic_mode_rx_engine_fuzzer") { diff --git a/pw_bluetooth_sapphire/host/sco/BUILD.bazel b/pw_bluetooth_sapphire/host/sco/BUILD.bazel index bd8f24a6b..6a22d3169 100644 --- a/pw_bluetooth_sapphire/host/sco/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/sco/BUILD.bazel @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -29,9 +29,10 @@ cc_library( ], strip_include_prefix = "public", deps = [ - "//pw_bluetooth_sapphire:public", + "//pw_bluetooth:emboss_hci_commands", "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/hci", + "//pw_bluetooth_sapphire/host/hci-spec", "//pw_bluetooth_sapphire/host/transport", "//third_party/fuchsia:fit", ], @@ -48,6 +49,8 @@ pw_cc_test( ":sco", "//pw_bluetooth_sapphire/host/hci:testing", "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:mock_controller", + "//pw_bluetooth_sapphire/host/testing:test_helpers", "//pw_bluetooth_sapphire/host/transport:testing", ], ) diff --git a/pw_bluetooth_sapphire/host/sco/BUILD.gn b/pw_bluetooth_sapphire/host/sco/BUILD.gn index aff377de8..2fd6dd36f 100644 --- a/pw_bluetooth_sapphire/host/sco/BUILD.gn +++ b/pw_bluetooth_sapphire/host/sco/BUILD.gn @@ -20,34 +20,42 @@ config("public_include_path") { } pw_source_set("sco") { + sources = [ + "sco_connection.cc", + "sco_connection_manager.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/sco/sco.h", "public/pw_bluetooth_sapphire/internal/host/sco/sco_connection.h", "public/pw_bluetooth_sapphire/internal/host/sco/sco_connection_manager.h", ] - sources = [ - "sco_connection.cc", - "sco_connection_manager.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ + "$dir_pw_bluetooth:emboss_hci_commands", "$dir_pw_bluetooth_sapphire/host/common", "$dir_pw_bluetooth_sapphire/host/hci", + "$dir_pw_bluetooth_sapphire/host/hci-spec", "$dir_pw_bluetooth_sapphire/host/transport", "$dir_pw_third_party/fuchsia:fit", ] - public_configs = [ ":public_include_path" ] } -pw_test("tests") { +pw_test("sco_test") { sources = [ "sco_connection_manager_test.cc", "sco_connection_test.cc", ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":sco", "$dir_pw_bluetooth_sapphire/host/hci:testing", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:mock_controller", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", "$dir_pw_bluetooth_sapphire/host/transport:testing", ] - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" +} + +pw_test_group("tests") { + tests = [ ":sco_test" ] } diff --git a/pw_bluetooth_sapphire/host/sdp/BUILD.bazel b/pw_bluetooth_sapphire/host/sdp/BUILD.bazel index 2cb35a15f..d4f8b516e 100644 --- a/pw_bluetooth_sapphire/host/sdp/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/sdp/BUILD.bazel @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -31,7 +32,6 @@ cc_library( ], strip_include_prefix = "public", deps = [ - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/common", ], ) @@ -53,9 +53,8 @@ cc_library( strip_include_prefix = "public", deps = [ ":definitions", - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/l2cap", - "//third_party/fuchsia:stdcompat", + "//third_party/fuchsia:fit", ], ) @@ -75,5 +74,19 @@ pw_cc_test( "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/l2cap:testing", "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:fake_controller", + "//pw_bluetooth_sapphire/host/testing:test_helpers", ], ) + +pw_cc_fuzz_test( + name = "data_element_fuzzer", + srcs = ["data_element_fuzztest.cc"], + deps = [":definitions"], +) + +pw_cc_fuzz_test( + name = "pdu_fuzzer", + srcs = ["pdu_fuzztest.cc"], + deps = [":sdp"], +) diff --git a/pw_bluetooth_sapphire/host/sdp/BUILD.gn b/pw_bluetooth_sapphire/host/sdp/BUILD.gn index e8751b7c0..012597f0d 100644 --- a/pw_bluetooth_sapphire/host/sdp/BUILD.gn +++ b/pw_bluetooth_sapphire/host/sdp/BUILD.gn @@ -23,46 +23,40 @@ config("public_include_path") { # Basic target with protocol definitions and no logic, suitable for test # emulation. pw_source_set("definitions") { + sources = [ + "data_element.cc", + "error.cc", + "service_record.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/sdp/data_element.h", "public/pw_bluetooth_sapphire/internal/host/sdp/error.h", "public/pw_bluetooth_sapphire/internal/host/sdp/sdp.h", "public/pw_bluetooth_sapphire/internal/host/sdp/service_record.h", ] - - sources = [ - "data_element.cc", - "error.cc", - "service_record.cc", - ] - - public_deps = [ "$dir_pw_bluetooth_sapphire/host/common" ] - public_configs = [ ":public_include_path" ] + public_deps = [ "$dir_pw_bluetooth_sapphire/host/common" ] } pw_source_set("sdp") { - public = [ - "public/pw_bluetooth_sapphire/internal/host/sdp/client.h", - "public/pw_bluetooth_sapphire/internal/host/sdp/pdu.h", - "public/pw_bluetooth_sapphire/internal/host/sdp/server.h", - "public/pw_bluetooth_sapphire/internal/host/sdp/service_discoverer.h", - ] - sources = [ "client.cc", "pdu.cc", "server.cc", "service_discoverer.cc", ] - + public = [ + "public/pw_bluetooth_sapphire/internal/host/sdp/client.h", + "public/pw_bluetooth_sapphire/internal/host/sdp/pdu.h", + "public/pw_bluetooth_sapphire/internal/host/sdp/server.h", + "public/pw_bluetooth_sapphire/internal/host/sdp/service_discoverer.h", + ] + public_configs = [ ":public_include_path" ] public_deps = [ ":definitions", "$dir_pw_bluetooth_sapphire/host/l2cap", - "$dir_pw_third_party/fuchsia:stdcompat", + "$dir_pw_third_party/fuchsia:fit", ] - - public_configs = [ ":public_include_path" ] } pw_test("sdp_tests") { @@ -74,15 +68,15 @@ pw_test("sdp_tests") { "service_discoverer_test.cc", "service_record_test.cc", ] - + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":sdp", "$dir_pw_bluetooth_sapphire/host/common", "$dir_pw_bluetooth_sapphire/host/l2cap:testing", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:fake_controller", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", ] - - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" } pw_fuzzer("data_element_fuzzer") { diff --git a/pw_bluetooth_sapphire/host/sdp/data_element_fuzztest.cc b/pw_bluetooth_sapphire/host/sdp/data_element_fuzztest.cc index 375ea39a0..587aae9bb 100644 --- a/pw_bluetooth_sapphire/host/sdp/data_element_fuzztest.cc +++ b/pw_bluetooth_sapphire/host/sdp/data_element_fuzztest.cc @@ -20,7 +20,9 @@ namespace bt::sdp { void fuzz(const uint8_t* data, size_t size) { DynamicByteBuffer buf(size); - memcpy(buf.mutable_data(), data, size); + if (buf.size() != 0) { + memcpy(buf.mutable_data(), data, size); + } DataElement elem; DataElement::Read(&elem, buf); } diff --git a/pw_bluetooth_sapphire/host/sdp/pdu_fuzztest.cc b/pw_bluetooth_sapphire/host/sdp/pdu_fuzztest.cc index de1635fcf..6c16dc061 100644 --- a/pw_bluetooth_sapphire/host/sdp/pdu_fuzztest.cc +++ b/pw_bluetooth_sapphire/host/sdp/pdu_fuzztest.cc @@ -24,7 +24,9 @@ void fuzz(const uint8_t* data, size_t size) { std::vector remaining_bytes = fuzzed_data.ConsumeRemainingBytes(); DynamicByteBuffer buf(remaining_bytes.size()); - memcpy(buf.mutable_data(), remaining_bytes.data(), remaining_bytes.size()); + if (buf.size() != 0) { + memcpy(buf.mutable_data(), remaining_bytes.data(), remaining_bytes.size()); + } fit::result> status = fit::ok(); ErrorResponse error_response; ServiceSearchResponse service_search_response; diff --git a/pw_bluetooth_sapphire/host/sm/BUILD.bazel b/pw_bluetooth_sapphire/host/sm/BUILD.bazel index da453b8c8..68fd3bb5c 100644 --- a/pw_bluetooth_sapphire/host/sm/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/sm/BUILD.bazel @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -24,18 +25,22 @@ cc_library( "types.cc", ], hdrs = [ - "public/pw_bluetooth_sapphire/internal/host/sm/delegate.h", "public/pw_bluetooth_sapphire/internal/host/sm/error.h", "public/pw_bluetooth_sapphire/internal/host/sm/packet.h", "public/pw_bluetooth_sapphire/internal/host/sm/smp.h", "public/pw_bluetooth_sapphire/internal/host/sm/types.h", - "public/pw_bluetooth_sapphire/internal/host/sm/util.h", + ], + implementation_deps = [ + "//pw_bluetooth_sapphire/lib/cpp-string", + "//pw_preprocessor", + "//pw_string", ], strip_include_prefix = "public", deps = [ - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/hci-spec", + "//pw_chrono:system_clock", + "//third_party/fuchsia:fit", ], ) @@ -56,8 +61,8 @@ cc_library( "util.cc", ], hdrs = [ + "public/pw_bluetooth_sapphire/internal/host/sm/delegate.h", "public/pw_bluetooth_sapphire/internal/host/sm/ecdh_key.h", - "public/pw_bluetooth_sapphire/internal/host/sm/fake_phase_listener.h", "public/pw_bluetooth_sapphire/internal/host/sm/pairing_channel.h", "public/pw_bluetooth_sapphire/internal/host/sm/pairing_phase.h", "public/pw_bluetooth_sapphire/internal/host/sm/phase_1.h", @@ -69,17 +74,18 @@ cc_library( "public/pw_bluetooth_sapphire/internal/host/sm/sc_stage_1_passkey.h", "public/pw_bluetooth_sapphire/internal/host/sm/security_manager.h", "public/pw_bluetooth_sapphire/internal/host/sm/security_request_phase.h", + "public/pw_bluetooth_sapphire/internal/host/sm/util.h", ], strip_include_prefix = "public", deps = [ ":definitions", - "//pw_bluetooth_sapphire:public", + "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/gap:definitions", "//pw_bluetooth_sapphire/host/hci", "//pw_bluetooth_sapphire/host/l2cap", + "//pw_bluetooth_sapphire/lib/cpp-string", + "//third_party/fuchsia:fit", "@boringssl//:crypto", - "@pigweed//pw_string", - "@pigweed//third_party/fuchsia:fit", ], ) @@ -89,12 +95,18 @@ cc_library( "test_security_manager.cc", ], hdrs = [ + "public/pw_bluetooth_sapphire/internal/host/sm/fake_phase_listener.h", "public/pw_bluetooth_sapphire/internal/host/sm/test_security_manager.h", ], strip_include_prefix = "public", deps = [ + ":definitions", ":sm", - "//pw_bluetooth_sapphire:public", + "//pw_bluetooth_sapphire/host/common", + "//pw_bluetooth_sapphire/host/gap:definitions", + "//pw_bluetooth_sapphire/host/hci", + "//pw_bluetooth_sapphire/host/hci-spec", + "//pw_bluetooth_sapphire/host/l2cap", ], ) @@ -124,5 +136,13 @@ pw_cc_test( "//pw_bluetooth_sapphire/host/hci:testing", "//pw_bluetooth_sapphire/host/l2cap:testing", "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:mock_controller", + "//pw_bluetooth_sapphire/host/testing:test_helpers", ], ) + +pw_cc_fuzz_test( + name = "valid_packet_reader_fuzzer", + srcs = ["valid_packet_reader_parse_sdu_fuzztest.cc"], + deps = [":definitions"], +) diff --git a/pw_bluetooth_sapphire/host/sm/BUILD.gn b/pw_bluetooth_sapphire/host/sm/BUILD.gn index e9a3a5f9e..b650d128e 100644 --- a/pw_bluetooth_sapphire/host/sm/BUILD.gn +++ b/pw_bluetooth_sapphire/host/sm/BUILD.gn @@ -21,6 +21,11 @@ config("public_include_path") { } pw_source_set("definitions") { + sources = [ + "error.cc", + "packet.cc", + "types.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/sm/delegate.h", "public/pw_bluetooth_sapphire/internal/host/sm/error.h", @@ -28,24 +33,35 @@ pw_source_set("definitions") { "public/pw_bluetooth_sapphire/internal/host/sm/smp.h", "public/pw_bluetooth_sapphire/internal/host/sm/types.h", ] - - sources = [ - "error.cc", - "packet.cc", - "types.cc", - ] - + public_configs = [ ":public_include_path" ] public_deps = [ "$dir_pw_bluetooth_sapphire/host/common", "$dir_pw_bluetooth_sapphire/host/hci-spec", # hci_spec::LinkKey + "$dir_pw_chrono:system_clock", + "$dir_pw_third_party/fuchsia:fit", + ] + deps = [ + "$dir_pw_bluetooth_sapphire/lib/cpp-string", + dir_pw_preprocessor, + dir_pw_string, ] - - public_configs = [ ":public_include_path" ] - - deps = [ "$dir_pw_preprocessor" ] } pw_source_set("sm") { + sources = [ + "ecdh_key.cc", + "pairing_channel.cc", + "pairing_phase.cc", + "phase_1.cc", + "phase_2_legacy.cc", + "phase_2_secure_connections.cc", + "phase_3.cc", + "sc_stage_1_just_works_numeric_comparison.cc", + "sc_stage_1_passkey.cc", + "security_manager.cc", + "security_request_phase.cc", + "util.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/sm/ecdh_key.h", "public/pw_bluetooth_sapphire/internal/host/sm/pairing_channel.h", @@ -61,47 +77,35 @@ pw_source_set("sm") { "public/pw_bluetooth_sapphire/internal/host/sm/security_request_phase.h", "public/pw_bluetooth_sapphire/internal/host/sm/util.h", ] - - sources = [ - "ecdh_key.cc", - "pairing_channel.cc", - "pairing_phase.cc", - "phase_1.cc", - "phase_2_legacy.cc", - "phase_2_secure_connections.cc", - "phase_3.cc", - "sc_stage_1_just_works_numeric_comparison.cc", - "sc_stage_1_passkey.cc", - "security_manager.cc", - "security_request_phase.cc", - "util.cc", - ] - + public_configs = [ ":public_include_path" ] public_deps = [ ":definitions", "$dir_pw_bluetooth_sapphire:config", "$dir_pw_bluetooth_sapphire/host/gap:definitions", "$dir_pw_bluetooth_sapphire/host/hci", "$dir_pw_bluetooth_sapphire/host/l2cap", - "$dir_pw_string", "$dir_pw_third_party/boringssl", "$dir_pw_third_party/fuchsia:fit", + dir_pw_string, ] - - public_configs = [ ":public_include_path" ] } pw_source_set("testing") { + sources = [ "test_security_manager.cc" ] public = [ "public/pw_bluetooth_sapphire/internal/host/sm/fake_phase_listener.h", "public/pw_bluetooth_sapphire/internal/host/sm/test_security_manager.h", ] - - sources = [ "test_security_manager.cc" ] - - deps = [ ":sm" ] - public_configs = [ ":public_include_path" ] + deps = [ + ":definitions", + ":sm", + "$dir_pw_bluetooth_sapphire/host/common", + "$dir_pw_bluetooth_sapphire/host/gap:definitions", + "$dir_pw_bluetooth_sapphire/host/hci", + "$dir_pw_bluetooth_sapphire/host/hci-spec", + "$dir_pw_bluetooth_sapphire/host/l2cap", + ] } pw_test("sm_tests") { @@ -122,21 +126,20 @@ pw_test("sm_tests") { "types_test.cc", "util_test.cc", ] - + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ ":sm", ":testing", "$dir_pw_bluetooth_sapphire/host/hci:testing", "$dir_pw_bluetooth_sapphire/host/l2cap:testing", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:mock_controller", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", ] - - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" } pw_fuzzer("valid_packet_reader_fuzzer") { sources = [ "valid_packet_reader_parse_sdu_fuzztest.cc" ] - deps = [ ":definitions" ] } diff --git a/pw_bluetooth_sapphire/host/sm/valid_packet_reader_parse_sdu_fuzztest.cc b/pw_bluetooth_sapphire/host/sm/valid_packet_reader_parse_sdu_fuzztest.cc index fb1bd3dd5..72753f7f1 100644 --- a/pw_bluetooth_sapphire/host/sm/valid_packet_reader_parse_sdu_fuzztest.cc +++ b/pw_bluetooth_sapphire/host/sm/valid_packet_reader_parse_sdu_fuzztest.cc @@ -21,7 +21,9 @@ namespace bt::sm { void fuzz(const uint8_t* data, size_t size) { DynamicByteBuffer buf(size); - memcpy(buf.mutable_data(), data, size); + if (buf.size() != 0) { + memcpy(buf.mutable_data(), data, size); + } ByteBufferPtr buf_ptr = std::make_unique(buf); [[maybe_unused]] fit::result result = ValidPacketReader::ParseSdu(buf_ptr); diff --git a/pw_bluetooth_sapphire/host/testing/BUILD.bazel b/pw_bluetooth_sapphire/host/testing/BUILD.bazel index c7ddb2b1f..0f20dbe9f 100644 --- a/pw_bluetooth_sapphire/host/testing/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/testing/BUILD.bazel @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations under # the License. -load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") +load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package(default_visibility = ["//visibility:public"]) @@ -34,22 +34,21 @@ cc_library( copts = [ "-Wno-unused-parameter", ], + implementation_deps = [ + ":test_helpers", + ], strip_include_prefix = "public", - target_compatible_with = select({ - "//pw_unit_test:googletest_only": [], - "@platforms//os:fuchsia": [], - "//conditions:default": ["@platforms//:incompatible"], - }), deps = [ - ":fake_controller", - ":mock_controller", - ":test_helpers", + "//pw_async:fake_dispatcher_fixture", + "//pw_async:heap_dispatcher", + "//pw_bluetooth", "//pw_bluetooth_sapphire:config", - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/fuchsia/lib/inspect_testing", + "//pw_bluetooth_sapphire/host/common", + "//pw_bluetooth_sapphire/host/gap:definitions", + "//pw_bluetooth_sapphire/host/hci-spec", + "//pw_bluetooth_sapphire/host/l2cap", "//pw_bluetooth_sapphire/host/transport", - "//pw_bluetooth_sapphire/host/transport:testing", - "//pw_unit_test:googletest", ], ) @@ -69,7 +68,6 @@ cc_library( "//conditions:default": ["@platforms//:incompatible"], }), deps = [ - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/lib/cpp-string", "//pw_unit_test:googletest", @@ -87,19 +85,10 @@ cc_library( "-Wno-unused-parameter", ], strip_include_prefix = "public", - target_compatible_with = select({ - "//pw_unit_test:googletest_only": [], - "@platforms//os:fuchsia": [], - "//conditions:default": ["@platforms//:incompatible"], - }), deps = [ - "//pw_bluetooth_sapphire:public", + "//pw_async:heap_dispatcher", + "//pw_bluetooth", "//pw_bluetooth_sapphire/host/common", - "//pw_bluetooth_sapphire/host/hci", - "//pw_unit_test:googletest", - "@pigweed//pw_async:heap_dispatcher", - "@pigweed//pw_bluetooth", - "@pigweed//third_party/fuchsia:fit", ], ) @@ -113,23 +102,20 @@ cc_library( copts = [ "-Wno-unused-parameter", ], + implementation_deps = [ + ":test_helpers", + ], strip_include_prefix = "public", - target_compatible_with = select({ - "//pw_unit_test:googletest_only": [], - "@platforms//os:fuchsia": [], - "//conditions:default": ["@platforms//:incompatible"], - }), deps = [ ":controller_test_double_base", - ":test_helpers", - "//pw_bluetooth_sapphire:public", - "//pw_bluetooth_sapphire/host/transport", - "//pw_bluetooth_sapphire/host/transport:testing", - "//pw_unit_test:googletest", - "@pigweed//pw_async:heap_dispatcher", + "//pw_bluetooth_sapphire/host/common", + "//pw_bluetooth_sapphire/host/hci-spec", + "//third_party/fuchsia:fit", ], ) +# Target that includes Fake HCI emulation support. This should NOT depend on +# gtest. cc_library( name = "fake_controller", testonly = True, @@ -154,38 +140,52 @@ cc_library( copts = [ "-Wno-unused-parameter", ], + implementation_deps = [ + "//pw_bluetooth:emboss_hci_android", + "//pw_bluetooth:emboss_hci_data", + "//pw_bluetooth:emboss_hci_events", + "//pw_bluetooth_sapphire/host/gap", + "//pw_bluetooth_sapphire/host/gatt:definitions", + "//pw_bytes", + ], strip_include_prefix = "public", - target_compatible_with = select({ - "//pw_unit_test:googletest_only": [], - "@platforms//os:fuchsia": [], - "//conditions:default": ["@platforms//:incompatible"], - }), deps = [ ":controller_test_double_base", - ":test_helpers", - "//pw_bluetooth_sapphire:public", "//pw_bluetooth_sapphire/host/att:definitions", "//pw_bluetooth_sapphire/host/common", - "//pw_bluetooth_sapphire/host/gap", - "//pw_bluetooth_sapphire/host/gatt:definitions", - "//pw_bluetooth_sapphire/host/hci", + "//pw_bluetooth_sapphire/host/hci-spec", "//pw_bluetooth_sapphire/host/l2cap:definitions", "//pw_bluetooth_sapphire/host/l2cap:testing", "//pw_bluetooth_sapphire/host/sdp", - "//pw_unit_test:googletest", - "@pigweed//pw_bluetooth:emboss_hci", - "@pigweed//third_party/fuchsia:fit", + "//third_party/fuchsia:fit", ], ) +# Main entry point for host library unittests. cc_library( name = "gtest_main", testonly = True, srcs = ["run_all_unittests.cc"], - deps = [ + implementation_deps = [ ":testing", "//pw_bluetooth_sapphire/host/common", + "//pw_unit_test:googletest", + ], + target_compatible_with = select({ + "//pw_unit_test:googletest_only": [], + "@platforms//os:fuchsia": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_library( + name = "fuzzing", + testonly = True, + hdrs = [ + "public/pw_bluetooth_sapphire/internal/host/testing/peer_fuzzer.h", ], + strip_include_prefix = "public", + deps = ["//pw_bluetooth_sapphire/host/gap"], ) cc_library( @@ -201,8 +201,7 @@ cc_library( "//conditions:default": ["@platforms//:incompatible"], }), deps = [ - "//pw_bluetooth_sapphire:public", - "@com_google_googletest//:gtest", + "//pw_unit_test:googletest", "@fuchsia_sdk//pkg/async-testing", ], ) @@ -220,6 +219,8 @@ pw_cc_test( ], test_main = "//pw_bluetooth_sapphire/host/testing:gtest_main", deps = [ + ":fake_controller", + ":test_helpers", ":testing", "//pw_bluetooth_sapphire/host/l2cap:testing", ], diff --git a/pw_bluetooth_sapphire/host/testing/BUILD.gn b/pw_bluetooth_sapphire/host/testing/BUILD.gn index 0769876ec..2d0794659 100644 --- a/pw_bluetooth_sapphire/host/testing/BUILD.gn +++ b/pw_bluetooth_sapphire/host/testing/BUILD.gn @@ -21,6 +21,11 @@ config("public_include_path") { pw_source_set("testing") { testonly = pw_unit_test_TESTONLY + sources = [ + "inspect_util.cc", + "parse_args.cc", + "test_packets.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/testing/controller_test.h", "public/pw_bluetooth_sapphire/internal/host/testing/inspect.h", @@ -28,25 +33,24 @@ pw_source_set("testing") { "public/pw_bluetooth_sapphire/internal/host/testing/parse_args.h", "public/pw_bluetooth_sapphire/internal/host/testing/test_packets.h", ] - sources = [ - "inspect_util.cc", - "parse_args.cc", - "test_packets.cc", - ] - deps = [ "$dir_pw_unit_test" ] + public_configs = [ ":public_include_path" ] + remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] + configs = [ "$dir_pw_build:internal_strict_warnings_core" ] public_deps = [ - ":fake_controller", - ":mock_controller", - ":test_helpers", + "$dir_pw_async:fake_dispatcher_fixture", + "$dir_pw_async:heap_dispatcher", + "$dir_pw_bluetooth_sapphire:config", + "$dir_pw_bluetooth_sapphire/host/common", + "$dir_pw_bluetooth_sapphire/host/gap:definitions", + "$dir_pw_bluetooth_sapphire/host/hci-spec", + "$dir_pw_bluetooth_sapphire/host/l2cap", "$dir_pw_bluetooth_sapphire/host/transport", - "$dir_pw_bluetooth_sapphire/host/transport:testing", + dir_pw_bluetooth, ] if (current_os == "fuchsia") { public_deps += [ "//sdk/lib/inspect/testing/cpp" ] } - public_configs = [ ":public_include_path" ] - remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] - configs = [ "$dir_pw_build:internal_strict_warnings_core" ] + deps = [ ":test_helpers" ] } # test_helpers is separate from :testing to fix dependency cycles. @@ -54,78 +58,49 @@ pw_source_set("test_helpers") { testonly = pw_unit_test_TESTONLY public = [ "public/pw_bluetooth_sapphire/internal/host/testing/test_helpers.h" ] - deps = [ "$dir_pw_bluetooth_sapphire/lib/cpp-string" ] + public_configs = [ ":public_include_path" ] public_deps = [ "$dir_pw_bluetooth_sapphire/host/common", - "$dir_pw_unit_test", - ] - public_configs = [ ":public_include_path" ] -} - -pw_test("tests") { - sources = [ - "fake_controller_test.cc", - "fake_dynamic_channel_test.cc", - "fake_l2cap_test.cc", - "fake_sdp_server_test.cc", - "fake_signaling_server_test.cc", - "inspect_util_test.cc", - "parse_args_test.cc", + "$dir_pw_bluetooth_sapphire/lib/cpp-string", + dir_pw_unit_test, ] - deps = [ - ":testing", - "$dir_pw_bluetooth_sapphire/host/l2cap:testing", - ] - test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" } pw_source_set("controller_test_double_base") { testonly = pw_unit_test_TESTONLY - public = [ "public/pw_bluetooth_sapphire/internal/host/testing/controller_test_double_base.h" ] sources = [ "controller_test_double_base.cc" ] + public = [ "public/pw_bluetooth_sapphire/internal/host/testing/controller_test_double_base.h" ] + public_configs = [ ":public_include_path" ] + remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] + configs = [ "$dir_pw_build:internal_strict_warnings_core" ] public_deps = [ "$dir_pw_async:heap_dispatcher", - "$dir_pw_bluetooth", "$dir_pw_bluetooth_sapphire/host/common", - "$dir_pw_bluetooth_sapphire/host/hci", - "$dir_pw_third_party/fuchsia:fit", + dir_pw_bluetooth, ] - public_configs = [ ":public_include_path" ] - remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] - configs = [ "$dir_pw_build:internal_strict_warnings_core" ] } pw_source_set("mock_controller") { testonly = pw_unit_test_TESTONLY + sources = [ "mock_controller.cc" ] public = [ "public/pw_bluetooth_sapphire/internal/host/testing/mock_controller.h" ] - sources = [ "mock_controller.cc" ] - public_deps = [ - ":controller_test_double_base", - ":test_helpers", - "$dir_pw_async:heap_dispatcher", - "$dir_pw_bluetooth_sapphire/host/transport", - "$dir_pw_bluetooth_sapphire/host/transport:testing", - "$dir_pw_unit_test", - ] public_configs = [ ":public_include_path" ] remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] configs = [ "$dir_pw_build:internal_strict_warnings_core" ] + public_deps = [ + ":controller_test_double_base", + "$dir_pw_bluetooth_sapphire/host/common", + "$dir_pw_bluetooth_sapphire/host/hci-spec", + "$dir_pw_third_party/fuchsia:fit", + ] + deps = [ ":test_helpers" ] } # Target that includes Fake HCI emulation support. This should NOT depend on # gtest. pw_source_set("fake_controller") { testonly = pw_unit_test_TESTONLY - public = [ - "public/pw_bluetooth_sapphire/internal/host/testing/fake_controller.h", - "public/pw_bluetooth_sapphire/internal/host/testing/fake_dynamic_channel.h", - "public/pw_bluetooth_sapphire/internal/host/testing/fake_gatt_server.h", - "public/pw_bluetooth_sapphire/internal/host/testing/fake_l2cap.h", - "public/pw_bluetooth_sapphire/internal/host/testing/fake_peer.h", - "public/pw_bluetooth_sapphire/internal/host/testing/fake_sdp_server.h", - "public/pw_bluetooth_sapphire/internal/host/testing/fake_signaling_server.h", - ] sources = [ "fake_controller.cc", "fake_dynamic_channel.cc", @@ -135,23 +110,34 @@ pw_source_set("fake_controller") { "fake_sdp_server.cc", "fake_signaling_server.cc", ] + public = [ + "public/pw_bluetooth_sapphire/internal/host/testing/fake_controller.h", + "public/pw_bluetooth_sapphire/internal/host/testing/fake_dynamic_channel.h", + "public/pw_bluetooth_sapphire/internal/host/testing/fake_gatt_server.h", + "public/pw_bluetooth_sapphire/internal/host/testing/fake_l2cap.h", + "public/pw_bluetooth_sapphire/internal/host/testing/fake_peer.h", + "public/pw_bluetooth_sapphire/internal/host/testing/fake_sdp_server.h", + "public/pw_bluetooth_sapphire/internal/host/testing/fake_signaling_server.h", + ] + public_configs = [ ":public_include_path" ] + remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] + configs = [ "$dir_pw_build:internal_strict_warnings_core" ] public_deps = [ ":controller_test_double_base", - ":test_helpers", - "$dir_pw_bluetooth:emboss_hci_group", "$dir_pw_bluetooth_sapphire/host/att:definitions", "$dir_pw_bluetooth_sapphire/host/common", - "$dir_pw_bluetooth_sapphire/host/gap", - "$dir_pw_bluetooth_sapphire/host/gatt:definitions", - "$dir_pw_bluetooth_sapphire/host/hci", + "$dir_pw_bluetooth_sapphire/host/hci-spec", "$dir_pw_bluetooth_sapphire/host/l2cap:definitions", "$dir_pw_bluetooth_sapphire/host/l2cap:testing", "$dir_pw_bluetooth_sapphire/host/sdp", "$dir_pw_third_party/fuchsia:fit", ] - public_configs = [ ":public_include_path" ] - remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] - configs = [ "$dir_pw_build:internal_strict_warnings_core" ] + deps = [ + "$dir_pw_bluetooth:emboss_hci_group", + "$dir_pw_bluetooth_sapphire/host/gap", + "$dir_pw_bluetooth_sapphire/host/gatt:definitions", + dir_pw_bytes, + ] } # Main entry point for host library unittests. @@ -161,15 +147,16 @@ pw_source_set("gtest_main") { deps = [ ":testing", "$dir_pw_bluetooth_sapphire/host/common", + dir_pw_unit_test, ] - public_deps = [ "$dir_pw_unit_test" ] } pw_source_set("fuzzing") { + testonly = pw_unit_test_TESTONLY public = [ "public/pw_bluetooth_sapphire/internal/host/testing/peer_fuzzer.h" ] - deps = [ "$dir_pw_bluetooth_sapphire/host/gap" ] public_configs = [ ":public_include_path" ] + public_deps = [ "$dir_pw_bluetooth_sapphire/host/gap" ] } source_set("fuzztest_driver") { @@ -186,9 +173,28 @@ source_set("loop_fixture") { testonly = true public = [ "public/pw_bluetooth_sapphire/internal/host/testing/loop_fixture.h" ] + public_configs = [ ":public_include_path" ] public_deps = [ - "$dir_pw_unit_test", "//zircon/system/ulib/async-testing", + dir_pw_unit_test, + ] +} + +pw_test("tests") { + sources = [ + "fake_controller_test.cc", + "fake_dynamic_channel_test.cc", + "fake_l2cap_test.cc", + "fake_sdp_server_test.cc", + "fake_signaling_server_test.cc", + "inspect_util_test.cc", + "parse_args_test.cc", + ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" + deps = [ + ":fake_controller", + ":test_helpers", + ":testing", + "$dir_pw_bluetooth_sapphire/host/l2cap:testing", ] - public_configs = [ ":public_include_path" ] } diff --git a/pw_bluetooth_sapphire/host/testing/public/pw_bluetooth_sapphire/internal/host/testing/fake_gatt_server.h b/pw_bluetooth_sapphire/host/testing/public/pw_bluetooth_sapphire/internal/host/testing/fake_gatt_server.h index 96d82d5fa..0d444e01d 100644 --- a/pw_bluetooth_sapphire/host/testing/public/pw_bluetooth_sapphire/internal/host/testing/fake_gatt_server.h +++ b/pw_bluetooth_sapphire/host/testing/public/pw_bluetooth_sapphire/internal/host/testing/fake_gatt_server.h @@ -15,10 +15,10 @@ #pragma once #include -#include "fake_l2cap.h" #include "pw_bluetooth_sapphire/internal/host/att/att.h" #include "pw_bluetooth_sapphire/internal/host/common/byte_buffer.h" #include "pw_bluetooth_sapphire/internal/host/hci-spec/protocol.h" +#include "pw_bluetooth_sapphire/internal/host/testing/fake_l2cap.h" namespace bt::testing { diff --git a/pw_bluetooth_sapphire/host/testing/public/pw_bluetooth_sapphire/internal/host/testing/fake_sdp_server.h b/pw_bluetooth_sapphire/host/testing/public/pw_bluetooth_sapphire/internal/host/testing/fake_sdp_server.h index be42bb511..537bcee04 100644 --- a/pw_bluetooth_sapphire/host/testing/public/pw_bluetooth_sapphire/internal/host/testing/fake_sdp_server.h +++ b/pw_bluetooth_sapphire/host/testing/public/pw_bluetooth_sapphire/internal/host/testing/fake_sdp_server.h @@ -13,7 +13,6 @@ // the License. #pragma once -#include "fake_l2cap.h" #include "pw_bluetooth_sapphire/internal/host/common/byte_buffer.h" #include "pw_bluetooth_sapphire/internal/host/common/packet_view.h" #include "pw_bluetooth_sapphire/internal/host/hci-spec/protocol.h" @@ -21,6 +20,7 @@ #include "pw_bluetooth_sapphire/internal/host/l2cap/l2cap_defs.h" #include "pw_bluetooth_sapphire/internal/host/sdp/server.h" #include "pw_bluetooth_sapphire/internal/host/testing/fake_dynamic_channel.h" +#include "pw_bluetooth_sapphire/internal/host/testing/fake_l2cap.h" namespace bt::testing { diff --git a/pw_bluetooth_sapphire/host/transport/BUILD.bazel b/pw_bluetooth_sapphire/host/transport/BUILD.bazel index e7231d28e..31efcbb6e 100644 --- a/pw_bluetooth_sapphire/host/transport/BUILD.bazel +++ b/pw_bluetooth_sapphire/host/transport/BUILD.bazel @@ -51,9 +51,7 @@ cc_library( "//pw_async:dispatcher", "//pw_async:task", "//pw_bluetooth", - "//pw_bluetooth:emboss_hci", - "//pw_bluetooth:emboss_hci_test", - "//pw_bluetooth_sapphire:public", + "//pw_bluetooth:emboss_hci_common", "//pw_bluetooth_sapphire/host/common", "//pw_bluetooth_sapphire/host/hci-spec", "//third_party/fuchsia:fit", @@ -75,7 +73,6 @@ cc_library( strip_include_prefix = "public", deps = [ ":transport", - "//pw_bluetooth_sapphire:public", ], ) @@ -94,7 +91,11 @@ pw_cc_test( ], test_main = "//pw_bluetooth_sapphire/host/testing:gtest_main", deps = [ + ":testing", ":transport", + "//pw_bluetooth:emboss_hci_test", "//pw_bluetooth_sapphire/host/testing", + "//pw_bluetooth_sapphire/host/testing:mock_controller", + "//pw_bluetooth_sapphire/host/testing:test_helpers", ], ) diff --git a/pw_bluetooth_sapphire/host/transport/BUILD.gn b/pw_bluetooth_sapphire/host/transport/BUILD.gn index 028975ea0..4a44af6b0 100644 --- a/pw_bluetooth_sapphire/host/transport/BUILD.gn +++ b/pw_bluetooth_sapphire/host/transport/BUILD.gn @@ -21,6 +21,18 @@ config("public_include_path") { } pw_source_set("transport") { + sources = [ + "acl_data_channel.cc", + "acl_data_packet.cc", + "command_channel.cc", + "control_packets.cc", + "error.cc", + "iso_data_channel.cc", + "link_type.cc", + "sco_data_channel.cc", + "sco_data_packet.cc", + "transport.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/transport/acl_data_channel.h", "public/pw_bluetooth_sapphire/internal/host/transport/acl_data_packet.h", @@ -37,46 +49,34 @@ pw_source_set("transport") { "public/pw_bluetooth_sapphire/internal/host/transport/slab_allocators.h", "public/pw_bluetooth_sapphire/internal/host/transport/transport.h", ] - sources = [ - "acl_data_channel.cc", - "acl_data_packet.cc", - "command_channel.cc", - "control_packets.cc", - "error.cc", - "iso_data_channel.cc", - "link_type.cc", - "sco_data_channel.cc", - "sco_data_packet.cc", - "transport.cc", - ] + public_configs = [ ":public_include_path" ] public_deps = [ "$dir_pw_async:dispatcher", "$dir_pw_async:task", - "$dir_pw_bluetooth", "$dir_pw_bluetooth:emboss_hci_group", - "$dir_pw_bluetooth:emboss_hci_test", "$dir_pw_bluetooth_sapphire/host/common", "$dir_pw_bluetooth_sapphire/host/hci-spec", "$dir_pw_third_party/fuchsia:fit", + dir_pw_bluetooth, ] - public_configs = [ ":public_include_path" ] } pw_source_set("testing") { + testonly = pw_unit_test_TESTONLY + sources = [ + "fake_sco_data_channel.cc", + "mock_acl_data_channel.cc", + ] public = [ "public/pw_bluetooth_sapphire/internal/host/transport/fake_acl_connection.h", "public/pw_bluetooth_sapphire/internal/host/transport/fake_sco_data_channel.h", "public/pw_bluetooth_sapphire/internal/host/transport/mock_acl_data_channel.h", ] - sources = [ - "fake_sco_data_channel.cc", - "mock_acl_data_channel.cc", - ] - public_deps = [ ":transport" ] public_configs = [ ":public_include_path" ] + public_deps = [ ":transport" ] } -pw_test("tests") { +pw_test("transport_test") { sources = [ "acl_data_channel_test.cc", "command_channel_test.cc", @@ -88,9 +88,17 @@ pw_test("tests") { "slab_allocators_test.cc", "transport_test.cc", ] + test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" deps = [ + ":testing", ":transport", + "$dir_pw_bluetooth:emboss_hci_test", "$dir_pw_bluetooth_sapphire/host/testing", + "$dir_pw_bluetooth_sapphire/host/testing:mock_controller", + "$dir_pw_bluetooth_sapphire/host/testing:test_helpers", ] - public_configs = [ ":public_include_path" ] +} + +pw_test_group("tests") { + tests = [ ":transport_test" ] } diff --git a/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/config.h b/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/config.h index c42f026c9..a4311cf09 100644 --- a/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/config.h +++ b/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/config.h @@ -15,10 +15,12 @@ // Configuration macros for the pw_bluetooth_sapphire module. #pragma once -// Disable Fuchsia inspect and tracing code by default. +// Disable Fuchsia inspect code by default. #ifndef PW_BLUETOOTH_SAPPHIRE_INSPECT_ENABLED #define NINSPECT 1 #endif // PW_BLUETOOTH_SAPPHIRE_INSPECT_ENABLED + +// Disable Fuchsia tracing code by default. #ifndef PW_BLUETOOTH_SAPPHIRE_TRACE_ENABLED #define NTRACE 1 #endif // PW_BLUETOOTH_SAPPHIRE_TRACE_ENABLED diff --git a/pw_fuzzer/fuzzer.gni b/pw_fuzzer/fuzzer.gni index 512bc8a51..bbb8dcc43 100644 --- a/pw_fuzzer/fuzzer.gni +++ b/pw_fuzzer/fuzzer.gni @@ -74,6 +74,7 @@ template("pw_fuzzer") { pw_executable(target_name) { configs = [] deps = [] + testonly = pw_unit_test_TESTONLY forward_variables_from(invoker, "*", [