# Copyright 2023 The Pigweed Authors # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of # the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. import("//build_overrides/pigweed.gni") import("$dir_pw_unit_test/test.gni") config("public_include_path") { include_dirs = [ "public" ] } 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", "public/pw_bluetooth_sapphire/internal/host/testing/inspect_util.h", "public/pw_bluetooth_sapphire/internal/host/testing/parse_args.h", "public/pw_bluetooth_sapphire/internal/host/testing/test_packets.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: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, ] if (current_os == "fuchsia") { public_deps += [ "//sdk/lib/inspect/testing/cpp" ] } deps = [ ":test_helpers" ] } # test_helpers is separate from :testing to fix dependency cycles. pw_source_set("test_helpers") { testonly = pw_unit_test_TESTONLY public = [ "public/pw_bluetooth_sapphire/internal/host/testing/test_helpers.h" ] public_configs = [ ":public_include_path" ] public_deps = [ "$dir_pw_bluetooth_sapphire/host/common", "$dir_pw_bluetooth_sapphire/lib/cpp-string", ] } pw_source_set("gtest_helpers") { testonly = pw_unit_test_TESTONLY public = [ "public/pw_bluetooth_sapphire/internal/host/testing/gtest_helpers.h" ] public_configs = [ ":public_include_path" ] public_deps = [ "$dir_pw_bluetooth_sapphire/host/common", dir_pw_unit_test, ] } pw_source_set("controller_test_double_base") { testonly = pw_unit_test_TESTONLY 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_sapphire/host/common", dir_pw_bluetooth, ] } 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" ] 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 = [ ":gtest_helpers", ":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 sources = [ "fake_controller.cc", "fake_dynamic_channel.cc", "fake_gatt_server.cc", "fake_l2cap.cc", "fake_peer.cc", "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", "$dir_pw_bluetooth_sapphire/host/att:definitions", "$dir_pw_bluetooth_sapphire/host/common", "$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", ] 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. pw_source_set("gtest_main") { testonly = pw_unit_test_TESTONLY sources = [ "run_all_unittests.cc" ] deps = [ ":testing", "$dir_pw_bluetooth_sapphire/host/common", dir_pw_unit_test, ] } pw_source_set("fuzzing") { testonly = pw_unit_test_TESTONLY public = [ "public/pw_bluetooth_sapphire/internal/host/testing/peer_fuzzer.h" ] public_configs = [ ":public_include_path" ] public_deps = [ "$dir_pw_bluetooth_sapphire/host/gap" ] } source_set("fuzztest_driver") { sources = [ "fuzztest_driver.cc" ] deps = [ "$dir_pw_bluetooth_sapphire/host/common", "//third_party/pigweed/backends/pw_log:printf", ] } # TODO(fxbug.dev/324105856): Delete after socket and fidl libraries are # migrated to Bazel. source_set("loop_fixture") { testonly = true public = [ "public/pw_bluetooth_sapphire/internal/host/testing/loop_fixture.h" ] public_configs = [ ":public_include_path" ] public_deps = [ "//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", ] }