1# Copyright (c) 2021-2025 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14if (defined(ohos_lite)) { 15 import("//build/lite/config/component/lite_component.gni") 16 import("//build/lite/config/test.gni") 17 import("../../../dsoftbus.gni") 18 19 dsoftbus_root_path = "../../.." 20 21 if (ohos_build_type == "debug") { 22 unittest("AdapterTest") { 23 output_extension = "bin" 24 output_dir = "$root_out_dir/test/unittest/dsoftbus" 25 sources = [ 26 "dsoftbus_crypto_test.cpp", 27 "dsoftbus_other_test.cpp", 28 "softbus_adapter_range_test.cpp", 29 "softbus_socket_test.cpp", 30 ] 31 include_dirs = [ 32 "$dsoftbus_dfx_path/interface/include", 33 "$dsoftbus_root_path/adapter/common/include", 34 "$dsoftbus_root_path/core/common/include/", 35 "$dsoftbus_root_path/interfaces/kits/common", 36 "$dsoftbus_root_path/interfaces/inner_kits/lnn", 37 "$hilog_lite_include_path", 38 ] 39 deps = [ 40 "$dsoftbus_dfx_path:softbus_dfx", 41 "$dsoftbus_root_path/adapter:softbus_adapter", 42 "$hilog_lite_deps_path", 43 ] 44 45 external_deps = [ "bounds_checking_function:libsec_static" ] 46 47 defines += [ "HAVE_PRO = 0" ] 48 } 49 } 50} else { 51 import("//build/test.gni") 52 import("../../../dsoftbus.gni") 53 module_output_path = "dsoftbus/soft_bus/adapter" 54 55 ohos_unittest("AdaptorDsoftbusCryptTest") { 56 module_out_path = module_output_path 57 sources = [ "dsoftbus_crypto_test.cpp" ] 58 include_dirs = [ 59 "$dsoftbus_root_path/adapter/common/include", 60 "$dsoftbus_root_path/core/common/include/", 61 "$dsoftbus_root_path/interfaces/kits/common", 62 ] 63 deps = [ "../../../adapter:softbus_adapter" ] 64 external_deps = [ 65 "bounds_checking_function:libsec_static", 66 "hilog:libhilog", 67 ] 68 } 69 70 ohos_unittest("AdapterDsoftbusAesCryptoTest") { 71 module_out_path = module_output_path 72 sources = [ "dsoftbus_aes_crypto_test.cpp" ] 73 include_dirs = [ 74 "$dsoftbus_root_path/adapter/common/include", 75 "$dsoftbus_root_path/core/common/include/", 76 "$dsoftbus_root_path/interfaces/kits/common", 77 ] 78 deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ] 79 80 external_deps = [ 81 "bounds_checking_function:libsec_static", 82 "googletest:gtest_main", 83 "hilog:libhilog", 84 ] 85 } 86 87 ohos_unittest("AdapterDsoftbusDfxTest") { 88 module_out_path = module_output_path 89 sources = [ "softbus_dfx_test.cpp" ] 90 include_dirs = [ 91 "$dsoftbus_root_path/adapter/common/include", 92 "$dsoftbus_root_path/core/common/include/", 93 "$dsoftbus_root_path/interfaces/kits/common", 94 ] 95 deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ] 96 97 external_deps = [ 98 "bounds_checking_function:libsec_static", 99 "googletest:gtest_main", 100 "hilog:libhilog", 101 ] 102 } 103 104 ohos_unittest("AdapterDsoftbusOtherTest") { 105 module_out_path = module_output_path 106 sources = [ "dsoftbus_other_test.cpp" ] 107 include_dirs = [ 108 "$dsoftbus_root_path/adapter/common/include", 109 "$dsoftbus_root_path/core/common/include/", 110 "$dsoftbus_root_path/interfaces/kits/common", 111 ] 112 deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ] 113 114 external_deps = [ 115 "bounds_checking_function:libsec_static", 116 "googletest:gtest_main", 117 "hilog:libhilog", 118 ] 119 } 120 121 ohos_unittest("AdapterDsoftbusRangeTest") { 122 module_out_path = module_output_path 123 sources = [ "softbus_adapter_range_test.cpp" ] 124 include_dirs = [ 125 "$dsoftbus_root_path/adapter/common/include", 126 "$dsoftbus_root_path/core/common/include/", 127 "$dsoftbus_root_path/interfaces/kits/common", 128 ] 129 deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ] 130 external_deps = [ 131 "bounds_checking_function:libsec_static", 132 "googletest:gtest_main", 133 "hilog:libhilog", 134 ] 135 } 136 137 ohos_unittest("AdapterDsoftbusSocketTest") { 138 module_out_path = module_output_path 139 sources = [ "softbus_socket_test.cpp" ] 140 include_dirs = [ 141 "$dsoftbus_root_path/adapter/common/include", 142 "$dsoftbus_root_path/core/common/include/", 143 "$dsoftbus_root_path/interfaces/kits/common", 144 ] 145 deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ] 146 147 external_deps = [ 148 "bounds_checking_function:libsec_static", 149 "googletest:gtest_main", 150 "hilog:libhilog", 151 ] 152 defines += [ "HAVE_PRO = 1" ] 153 } 154 155 ohos_unittest("SoftbusThreadTest") { 156 module_out_path = module_output_path 157 sources = [ "softbus_thread_test.cpp" ] 158 include_dirs = [ 159 "$dsoftbus_root_path/adapter/common/include", 160 "$dsoftbus_root_path/core/common/include/", 161 "$dsoftbus_root_path/interfaces/kits/common", 162 ] 163 deps = [ "../../../adapter:softbus_adapter" ] 164 external_deps = [ 165 "bounds_checking_function:libsec_static", 166 "googletest:gtest_main", 167 "hilog:libhilog", 168 ] 169 defines += [ "HAVE_PRO = 1" ] 170 } 171 172 ohos_unittest("SoftbusTimeTest") { 173 module_out_path = module_output_path 174 sources = [ "softbus_time_test.cpp" ] 175 include_dirs = [ 176 "$dsoftbus_root_path/adapter/common/include", 177 "$dsoftbus_root_path/interfaces/kits/common", 178 "$dsoftbus_root_path/core/common/include/", 179 ] 180 deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ] 181 182 external_deps = [ 183 "googletest:gtest_main", 184 "hilog:libhilog", 185 ] 186 } 187 188 ohos_unittest("AdaptorDsoftbusFileTest") { 189 module_out_path = module_output_path 190 sources = [ "softbus_file_test.cpp" ] 191 include_dirs = [ 192 "$dsoftbus_root_path/adapter/common/include", 193 "$dsoftbus_root_path/interfaces/kits/common", 194 "$dsoftbus_root_path/core/common/include/", 195 ] 196 deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ] 197 external_deps = [ "hilog:libhilog" ] 198 } 199 200 ohos_unittest("AdapterDsoftbusWifiTest") { 201 module_out_path = module_output_path 202 sources = [ 203 "$dsoftbus_root_path/adapter/common/net/wifi/common/softbus_wifi_api_adapter.c", 204 "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/wifi_mock.cpp", 205 "softbus_wifi_api_test.cpp", 206 ] 207 include_dirs = [ 208 "$dsoftbus_root_path/interfaces/kits/common", 209 "$dsoftbus_root_path/tests/core/bus_center/mock_common/src", 210 "$dsoftbus_root_path/tests/core/bus_center/mock_common/include", 211 "$dsoftbus_root_path/interfaces/kits/transport", 212 "$dsoftbus_root_path/adapter/common/net/wifi/include", 213 "$dsoftbus_root_path/adapter/common/net/wifi/common", 214 "$dsoftbus_root_path/core/common/include", 215 "$dsoftbus_dfx_path/interface/include", 216 ] 217 deps = [ 218 "$dsoftbus_dfx_path:softbus_dfx", 219 "$dsoftbus_root_path/adapter:softbus_adapter", 220 "$dsoftbus_root_path/core/common:softbus_utils", 221 ] 222 external_deps = [ 223 "c_utils:utils", 224 "googletest:gmock", 225 "googletest:gtest_main", 226 "hilog:libhilog", 227 "ipc:ipc_single", 228 "samgr:samgr_proxy", 229 ] 230 if (!defined(ohos_lite) && softbus_communication_wifi_feature == true) { 231 external_deps += [ "wifi:wifi_sdk" ] 232 } 233 } 234 235 ohos_unittest("AdapterNetManagerMonitorTest") { 236 module_out_path = module_output_path 237 sources = [ 238 "$dsoftbus_root_path/adapter/common/kernel/liteos_m/softbus_adapter_mem.c", 239 "$dsoftbus_root_path/core/common/message_handler/message_handler.c", 240 "$dsoftbus_root_path/core/common/utils/softbus_utils.c", 241 "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/network_mock.cpp", 242 "$dsoftbus_root_path/tests/core/connection/wifi_direct_cpp/net_conn_client.cpp", 243 "softbus_netmanager_monitor_test.cpp", 244 ] 245 include_dirs = [ 246 "$dsoftbus_root_path/adapter/common/bus_center/include", 247 "$dsoftbus_root_path/adapter/common/bus_center/network", 248 "$dsoftbus_root_path/adapter/common/include", 249 "$dsoftbus_root_path/adapter/common/include/OS_adapter_define/linux", 250 "$dsoftbus_root_path/adapter/common/net/bluetooth/include", 251 "$dsoftbus_root_path/adapter/common/net/wifi/include", 252 "$dsoftbus_root_path/adapter/default_config/spec_config", 253 "$dsoftbus_root_path/core/bus_center/lnn/net_buscenter/include", 254 "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/include", 255 "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/local_ledger/include", 256 "$dsoftbus_root_path/core/bus_center/interface", 257 "$dsoftbus_root_path/core/bus_center/service/include", 258 "$dsoftbus_root_path/core/bus_center/utils/include", 259 "$dsoftbus_root_path/core/common/dfx/interface/include", 260 "$dsoftbus_root_path/core/discovery/manager/include", 261 "$dsoftbus_root_path/core/discovery/interface", 262 "$dsoftbus_root_path/interfaces/kits/bus_center", 263 "$dsoftbus_root_path/interfaces/inner_kits/lnn", 264 "$dsoftbus_root_path/tests/adapter/unittest", 265 "$dsoftbus_root_path/tests/core/bus_center/mock_common/include", 266 "$dsoftbus_root_path/tests/core/connection/wifi_direct_cpp", 267 "$dsoftbus_root_path/core/bus_center/monitor/include", 268 ] 269 deps = [ 270 "$dsoftbus_dfx_path:softbus_dfx", 271 "$dsoftbus_root_path/adapter:softbus_adapter", 272 "$dsoftbus_root_path/core/common:softbus_utils", 273 "$dsoftbus_root_path/core/frame:softbus_server", 274 ] 275 external_deps = [ 276 "googletest:gmock", 277 "googletest:gtest_main", 278 "hilog:libhilog", 279 ] 280 if (!defined(global_parts_info) || 281 defined(global_parts_info.communication_netmanager_base)) { 282 external_deps += [ "netmanager_base:net_conn_manager_if" ] 283 } 284 } 285 286 ohos_unittest("AdapterDsoftbusNetworkTest") { 287 module_out_path = module_output_path 288 sources = [ 289 "$dsoftbus_root_path/adapter/common/kernel/liteos_m/softbus_adapter_mem.c", 290 "$dsoftbus_root_path/core/bus_center/monitor/src/lnn_init_monitor.c", 291 "$dsoftbus_root_path/core/common/message_handler/message_handler.c", 292 "$dsoftbus_root_path/core/common/utils/softbus_utils.c", 293 "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/network_mock.cpp", 294 "softbus_network_test.cpp", 295 ] 296 include_dirs = [ 297 "$dsoftbus_root_path/adapter/default_config/spec_config", 298 "$dsoftbus_root_path/interfaces/kits/connect", 299 "$dsoftbus_root_path/core/connection/interface", 300 "$dsoftbus_root_path/adapter/common/net/wifi/include", 301 "$dsoftbus_root_path/core/bus_center/interface", 302 "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/include", 303 "$dsoftbus_root_path/core/discovery/interface", 304 "$dsoftbus_root_path/core/discovery/manager/include", 305 "$dsoftbus_root_path/interfaces/kits/bus_center", 306 "$dsoftbus_root_path/adapter/common/include/OS_adapter_define/linux", 307 "$dsoftbus_root_path/adapter/default_config/spec_config", 308 "$dsoftbus_root_path/adapter/common/bus_center/include", 309 "$dsoftbus_root_path/interfaces/inner_kits/lnn", 310 "$dsoftbus_root_path/interfaces/kits/common", 311 "$dsoftbus_root_path/tests/core/bus_center/mock_common/include", 312 "$dsoftbus_root_path/adapter/common/bus_center/network", 313 "$dsoftbus_root_path/core/bus_center/service/include", 314 "$dsoftbus_root_path/core/bus_center/utils/include/lnn_async_callback_utils.h", 315 "$dsoftbus_root_path/adapter/common/net/bluetooth/include", 316 "$dsoftbus_root_path/adapter/common/include", 317 "$dsoftbus_root_path/core/bus_center/service/include", 318 "$dsoftbus_root_path/core/bus_center/utils/include", 319 "$dsoftbus_root_path/core/bus_center/lnn/net_buscenter/include", 320 "$dsoftbus_root_path/core/bus_center/monitor/include", 321 "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/include", 322 "$dsoftbus_root_path/adapter/common/include", 323 "$dsoftbus_root_path/core/common/include", 324 "$dsoftbus_dfx_path/interface/include", 325 ] 326 deps = [ 327 "$dsoftbus_root_path/core/common:softbus_utils", 328 "$dsoftbus_root_path/adapter:softbus_adapter", 329 ] 330 external_deps = [ 331 "googletest:gmock", 332 "googletest:gtest_main", 333 "hilog:libhilog", 334 ] 335 } 336 337 ohos_unittest("SoftbusSleMonitorTest") { 338 module_out_path = module_output_path 339 sources = [ 340 "$dsoftbus_root_path/core/bus_center/monitor/src/lnn_init_monitor.c", 341 "$dsoftbus_root_path/core/common/message_handler/message_handler.c", 342 "$dsoftbus_root_path/core/common/utils/softbus_utils.c", 343 "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/network_mock.cpp", 344 "softbus_sle_monitor_test.cpp", 345 "$dsoftbus_root_path/core/frame/init/src/g_enhance_adapter_func_pack.c", 346 "$dsoftbus_root_path/core/frame/init/src/g_enhance_adapter_func.c", 347 ] 348 include_dirs = [ 349 "$dsoftbus_root_path/adapter/default_config/spec_config", 350 "$dsoftbus_root_path/core/connection/interface", 351 "$dsoftbus_root_path/core/bus_center/interface", 352 "$dsoftbus_root_path/interfaces/kits/bus_center", 353 "$dsoftbus_root_path/adapter/common/include/OS_adapter_define/linux", 354 "$dsoftbus_root_path/adapter/default_config/spec_config", 355 "$dsoftbus_root_path/interfaces/kits/lnn", 356 "$dsoftbus_root_path/adapter/common/bus_center/include", 357 "$dsoftbus_root_path/interfaces/inner_kits/lnn", 358 "$dsoftbus_root_path/interfaces/kits/common", 359 "$dsoftbus_root_path/tests/core/bus_center/mock_common/include", 360 "$dsoftbus_root_path/adapter/common/bus_center/network", 361 "$dsoftbus_root_path/interfaces/kits/adapter", 362 "$dsoftbus_root_path/core/bus_center/service/include", 363 "$dsoftbus_root_path/core/bus_center/utils/include/lnn_async_callback_utils.h", 364 "$dsoftbus_root_path/adapter/common/net/bluetooth/include", 365 "$dsoftbus_root_path/adapter/common/net/wifi/include", 366 "$dsoftbus_root_path/adapter/common/include", 367 "$dsoftbus_root_path/core/bus_center/service/include", 368 "$dsoftbus_root_path/core/bus_center/utils/include", 369 "$dsoftbus_root_path/core/bus_center/lnn/net_buscenter/include", 370 "$dsoftbus_root_path/core/bus_center/monitor/include", 371 "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/include", 372 "$dsoftbus_root_path/adapter/common/include", 373 "$dsoftbus_root_path/core/common/include", 374 "$dsoftbus_root_path/core/frame/init/include", 375 ] 376 deps = [ 377 "$dsoftbus_root_path/core/common:softbus_utils", 378 "$dsoftbus_root_path/adapter:softbus_adapter", 379 ] 380 external_deps = [ 381 "googletest:gmock", 382 "googletest:gtest_main", 383 "hilog:libhilog", 384 ] 385 } 386 387 ohos_unittest("AdapterWlanExtendTest") { 388 module_out_path = module_output_path 389 sources = [ "softbus_adapter_wlan_extend_test.cpp" ] 390 include_dirs = [ 391 "$dsoftbus_root_path/adapter/common/include", 392 "$dsoftbus_root_path/interfaces/kits/common", 393 "$dsoftbus_root_path/core/common/include/", 394 "$dsoftbus_root_path/core/bus_center/utils/include/", 395 "$dsoftbus_root_path/adapter/common/net/hdi/include/", 396 "$dsoftbus_dfx_path/interface/include", 397 "$dsoftbus_root_path/interfaces/kits/adapter", 398 "$dsoftbus_root_path/interfaces/kits/bus_center", 399 ] 400 deps = [ 401 "$dsoftbus_dfx_path:softbus_dfx", 402 "$dsoftbus_root_path/adapter:softbus_adapter", 403 "$dsoftbus_root_path/core/frame:softbus_server", 404 ] 405 external_deps = [ 406 "googletest:gtest_main", 407 "hilog:libhilog", 408 ] 409 } 410 411 group("unittest") { 412 testonly = true 413 deps = [ 414 ":AdapterDsoftbusAesCryptoTest", 415 ":AdapterDsoftbusDfxTest", 416 ":AdapterDsoftbusOtherTest", 417 ":AdapterDsoftbusRangeTest", 418 ":AdapterDsoftbusSocketTest", 419 ":AdapterWlanExtendTest", 420 ":AdaptorDsoftbusCryptTest", 421 ":AdaptorDsoftbusFileTest", 422 ":SoftbusThreadTest", 423 ":SoftbusTimeTest", 424 ] 425 if (!defined(ohos_lite) && softbus_communication_wifi_feature == true) { 426 deps += [ ":AdapterDsoftbusWifiTest" ] 427 } 428 if (!defined(ohos_lite) && dsoftbus_feature_lnn_frame == true && 429 support_bluetooth && dsoftbus_feature_conn_ble) { 430 deps += [ 431 ":AdapterDsoftbusNetworkTest", 432 ":SoftbusSleMonitorTest", 433 ] 434 } 435 if (!defined(global_parts_info) || 436 defined(global_parts_info.communication_netmanager_base)) { 437 deps += [ ":AdapterNetManagerMonitorTest" ] 438 } 439 } 440} 441