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 54# test_helpers is separate from :testing to fix dependency cycles. 55pw_source_set("test_helpers") { 56 testonly = pw_unit_test_TESTONLY 57 58 public = [ "$dir_public_testing/test_helpers.h" ] 59 60 deps = [ "$dir_pw_bluetooth_sapphire/lib/cpp-string" ] 61 62 public_deps = [ 63 "$dir_pw_bluetooth_sapphire/host/common", 64 "$dir_pw_unit_test", 65 ] 66 67 public_configs = [ "$dir_pw_bluetooth_sapphire:public_include_path" ] 68} 69 70pw_test("tests") { 71 sources = [ 72 "fake_controller_test.cc", 73 "fake_dynamic_channel_test.cc", 74 "fake_l2cap_test.cc", 75 "fake_sdp_server_test.cc", 76 "fake_signaling_server_test.cc", 77 "inspect_util_test.cc", 78 "parse_args_test.cc", 79 ] 80 81 deps = [ 82 ":testing", 83 "$dir_pw_bluetooth_sapphire/host/l2cap:testing", 84 ] 85 86 test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" 87} 88 89pw_source_set("controller_test_double_base") { 90 testonly = pw_unit_test_TESTONLY 91 92 public = [ "$dir_public_testing/controller_test_double_base.h" ] 93 94 sources = [ "controller_test_double_base.cc" ] 95 96 public_deps = [ 97 "$dir_pw_async:heap_dispatcher", 98 "$dir_pw_bluetooth", 99 "$dir_pw_bluetooth_sapphire/host/common", 100 "$dir_pw_bluetooth_sapphire/host/hci", 101 "$dir_pw_third_party/fuchsia:fit", 102 ] 103} 104 105pw_source_set("mock_controller") { 106 testonly = pw_unit_test_TESTONLY 107 108 public = [ "$dir_public_testing/mock_controller.h" ] 109 110 sources = [ "mock_controller.cc" ] 111 112 public_deps = [ 113 ":controller_test_double_base", 114 ":test_helpers", 115 "$dir_pw_async:heap_dispatcher", 116 "$dir_pw_bluetooth_sapphire/host/transport", 117 "$dir_pw_bluetooth_sapphire/host/transport:testing", 118 "$dir_pw_unit_test", 119 ] 120} 121 122# Target that includes Fake HCI emulation support. This should NOT depend on 123# gtest. 124pw_source_set("fake_controller") { 125 testonly = pw_unit_test_TESTONLY 126 127 public = [ 128 "$dir_public_testing/fake_controller.h", 129 "$dir_public_testing/fake_dynamic_channel.h", 130 "$dir_public_testing/fake_gatt_server.h", 131 "$dir_public_testing/fake_l2cap.h", 132 "$dir_public_testing/fake_peer.h", 133 "$dir_public_testing/fake_sdp_server.h", 134 "$dir_public_testing/fake_signaling_server.h", 135 ] 136 137 sources = [ 138 "fake_controller.cc", 139 "fake_dynamic_channel.cc", 140 "fake_gatt_server.cc", 141 "fake_l2cap.cc", 142 "fake_peer.cc", 143 "fake_sdp_server.cc", 144 "fake_signaling_server.cc", 145 ] 146 147 public_deps = [ 148 ":controller_test_double_base", 149 ":test_helpers", 150 "$dir_pw_bluetooth:emboss_hci_group", 151 "$dir_pw_bluetooth_sapphire/host/att:definitions", 152 "$dir_pw_bluetooth_sapphire/host/common", 153 "$dir_pw_bluetooth_sapphire/host/gap", 154 "$dir_pw_bluetooth_sapphire/host/gatt:definitions", 155 "$dir_pw_bluetooth_sapphire/host/hci", 156 "$dir_pw_bluetooth_sapphire/host/l2cap:definitions", 157 "$dir_pw_bluetooth_sapphire/host/l2cap:testing", 158 "$dir_pw_bluetooth_sapphire/host/sdp", 159 "$dir_pw_third_party/fuchsia:fit", 160 ] 161} 162 163# Main entry point for host library unittests. 164pw_source_set("gtest_main") { 165 testonly = pw_unit_test_TESTONLY 166 167 sources = [ "run_all_unittests.cc" ] 168 169 deps = [ 170 ":testing", 171 "$dir_pw_bluetooth_sapphire/host/common", 172 ] 173 174 public_deps = [ "$dir_pw_unit_test" ] 175} 176 177pw_source_set("fuzzing") { 178 public = [ "$dir_public_testing/peer_fuzzer.h" ] 179 deps = [ "$dir_pw_bluetooth_sapphire/host/gap" ] 180} 181 182source_set("fuzztest_driver") { 183 sources = [ "fuzztest_driver.cc" ] 184 deps = [ 185 "$dir_pw_bluetooth_sapphire/host/common", 186 "//third_party/pigweed/backends/pw_log:printf", 187 ] 188} 189