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_unit_test/test.gni") 17 18config("public_include_path") { 19 include_dirs = [ "public" ] 20} 21 22pw_source_set("testing") { 23 testonly = pw_unit_test_TESTONLY 24 sources = [ 25 "inspect_util.cc", 26 "parse_args.cc", 27 "test_packets.cc", 28 ] 29 public = [ 30 "public/pw_bluetooth_sapphire/internal/host/testing/controller_test.h", 31 "public/pw_bluetooth_sapphire/internal/host/testing/inspect.h", 32 "public/pw_bluetooth_sapphire/internal/host/testing/inspect_util.h", 33 "public/pw_bluetooth_sapphire/internal/host/testing/parse_args.h", 34 "public/pw_bluetooth_sapphire/internal/host/testing/test_packets.h", 35 ] 36 public_configs = [ ":public_include_path" ] 37 remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] 38 configs = [ "$dir_pw_build:internal_strict_warnings_core" ] 39 public_deps = [ 40 "$dir_pw_async:fake_dispatcher_fixture", 41 "$dir_pw_async:heap_dispatcher", 42 "$dir_pw_bluetooth_sapphire:config", 43 "$dir_pw_bluetooth_sapphire/host/common", 44 "$dir_pw_bluetooth_sapphire/host/gap:definitions", 45 "$dir_pw_bluetooth_sapphire/host/hci-spec", 46 "$dir_pw_bluetooth_sapphire/host/l2cap", 47 "$dir_pw_bluetooth_sapphire/host/transport", 48 dir_pw_bluetooth, 49 ] 50 if (current_os == "fuchsia") { 51 public_deps += [ "//sdk/lib/inspect/testing/cpp" ] 52 } 53 deps = [ ":test_helpers" ] 54} 55 56# test_helpers is separate from :testing to fix dependency cycles. 57pw_source_set("test_helpers") { 58 testonly = pw_unit_test_TESTONLY 59 public = 60 [ "public/pw_bluetooth_sapphire/internal/host/testing/test_helpers.h" ] 61 public_configs = [ ":public_include_path" ] 62 public_deps = [ 63 "$dir_pw_bluetooth_sapphire/host/common", 64 "$dir_pw_bluetooth_sapphire/lib/cpp-string", 65 ] 66} 67 68pw_source_set("gtest_helpers") { 69 testonly = pw_unit_test_TESTONLY 70 public = 71 [ "public/pw_bluetooth_sapphire/internal/host/testing/gtest_helpers.h" ] 72 public_configs = [ ":public_include_path" ] 73 public_deps = [ 74 "$dir_pw_bluetooth_sapphire/host/common", 75 dir_pw_unit_test, 76 ] 77} 78 79pw_source_set("controller_test_double_base") { 80 testonly = pw_unit_test_TESTONLY 81 sources = [ "controller_test_double_base.cc" ] 82 public = [ "public/pw_bluetooth_sapphire/internal/host/testing/controller_test_double_base.h" ] 83 public_configs = [ ":public_include_path" ] 84 remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] 85 configs = [ "$dir_pw_build:internal_strict_warnings_core" ] 86 public_deps = [ 87 "$dir_pw_async:heap_dispatcher", 88 "$dir_pw_bluetooth_sapphire/host/common", 89 dir_pw_bluetooth, 90 ] 91} 92 93pw_source_set("mock_controller") { 94 testonly = pw_unit_test_TESTONLY 95 sources = [ "mock_controller.cc" ] 96 public = 97 [ "public/pw_bluetooth_sapphire/internal/host/testing/mock_controller.h" ] 98 public_configs = [ ":public_include_path" ] 99 remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] 100 configs = [ "$dir_pw_build:internal_strict_warnings_core" ] 101 public_deps = [ 102 ":controller_test_double_base", 103 "$dir_pw_bluetooth_sapphire/host/common", 104 "$dir_pw_bluetooth_sapphire/host/hci-spec", 105 "$dir_pw_third_party/fuchsia:fit", 106 ] 107 deps = [ 108 ":gtest_helpers", 109 ":test_helpers", 110 ] 111} 112 113# Target that includes Fake HCI emulation support. This should NOT depend on 114# gtest. 115pw_source_set("fake_controller") { 116 testonly = pw_unit_test_TESTONLY 117 sources = [ 118 "fake_controller.cc", 119 "fake_dynamic_channel.cc", 120 "fake_gatt_server.cc", 121 "fake_l2cap.cc", 122 "fake_peer.cc", 123 "fake_sdp_server.cc", 124 "fake_signaling_server.cc", 125 ] 126 public = [ 127 "public/pw_bluetooth_sapphire/internal/host/testing/fake_controller.h", 128 "public/pw_bluetooth_sapphire/internal/host/testing/fake_dynamic_channel.h", 129 "public/pw_bluetooth_sapphire/internal/host/testing/fake_gatt_server.h", 130 "public/pw_bluetooth_sapphire/internal/host/testing/fake_l2cap.h", 131 "public/pw_bluetooth_sapphire/internal/host/testing/fake_peer.h", 132 "public/pw_bluetooth_sapphire/internal/host/testing/fake_sdp_server.h", 133 "public/pw_bluetooth_sapphire/internal/host/testing/fake_signaling_server.h", 134 ] 135 public_configs = [ ":public_include_path" ] 136 remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] 137 configs = [ "$dir_pw_build:internal_strict_warnings_core" ] 138 public_deps = [ 139 ":controller_test_double_base", 140 "$dir_pw_bluetooth_sapphire/host/att:definitions", 141 "$dir_pw_bluetooth_sapphire/host/common", 142 "$dir_pw_bluetooth_sapphire/host/hci-spec", 143 "$dir_pw_bluetooth_sapphire/host/l2cap:definitions", 144 "$dir_pw_bluetooth_sapphire/host/l2cap:testing", 145 "$dir_pw_bluetooth_sapphire/host/sdp", 146 "$dir_pw_third_party/fuchsia:fit", 147 ] 148 deps = [ 149 "$dir_pw_bluetooth:emboss_hci_group", 150 "$dir_pw_bluetooth_sapphire/host/gap", 151 "$dir_pw_bluetooth_sapphire/host/gatt:definitions", 152 dir_pw_bytes, 153 ] 154} 155 156# Main entry point for host library unittests. 157pw_source_set("gtest_main") { 158 testonly = pw_unit_test_TESTONLY 159 sources = [ "run_all_unittests.cc" ] 160 deps = [ 161 ":testing", 162 "$dir_pw_bluetooth_sapphire/host/common", 163 dir_pw_unit_test, 164 ] 165} 166 167pw_source_set("fuzzing") { 168 testonly = pw_unit_test_TESTONLY 169 public = 170 [ "public/pw_bluetooth_sapphire/internal/host/testing/peer_fuzzer.h" ] 171 public_configs = [ ":public_include_path" ] 172 public_deps = [ "$dir_pw_bluetooth_sapphire/host/gap" ] 173} 174 175source_set("fuzztest_driver") { 176 sources = [ "fuzztest_driver.cc" ] 177 deps = [ 178 "$dir_pw_bluetooth_sapphire/host/common", 179 "//third_party/pigweed/backends/pw_log:printf", 180 ] 181} 182 183# TODO(fxbug.dev/324105856): Delete after socket and fidl libraries are 184# migrated to Bazel. 185source_set("loop_fixture") { 186 testonly = true 187 public = 188 [ "public/pw_bluetooth_sapphire/internal/host/testing/loop_fixture.h" ] 189 public_configs = [ ":public_include_path" ] 190 public_deps = [ 191 "//zircon/system/ulib/async-testing", 192 dir_pw_unit_test, 193 ] 194} 195 196pw_test("tests") { 197 sources = [ 198 "fake_controller_test.cc", 199 "fake_dynamic_channel_test.cc", 200 "fake_l2cap_test.cc", 201 "fake_sdp_server_test.cc", 202 "fake_signaling_server_test.cc", 203 "inspect_util_test.cc", 204 "parse_args_test.cc", 205 ] 206 test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" 207 deps = [ 208 ":fake_controller", 209 ":test_helpers", 210 ":testing", 211 "$dir_pw_bluetooth_sapphire/host/l2cap:testing", 212 ] 213} 214