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