1# Copyright (c) 2021-2023 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 14defines = [] 15if (defined(ohos_lite)) { 16 import("//build/lite/config/component/lite_component.gni") 17 import("//build/lite/config/test.gni") 18 import("../../../dsoftbus.gni") 19 20 defines += [ "HAVE_PRO = 0" ] 21 22 if (ohos_build_type == "debug") { 23 unittest("AdapterTest") { 24 output_extension = "bin" 25 output_dir = "$root_out_dir/test/unittest/dsoftbus" 26 sources = [ 27 "dsoftbus_crypto_test.cpp", 28 "dsoftbus_other_test.cpp", 29 "softbus_adapter_range_test.cpp", 30 "softbus_socket_test.cpp", 31 "softbus_thread_test.cpp", 32 ] 33 include_dirs = [ 34 "$dsoftbus_root_path/adapter/common/include", 35 "$dsoftbus_root_path/core/common/include/", 36 "$dsoftbus_root_path/interfaces/kits/common", 37 "//third_party/bounds_checking_function/include", 38 ] 39 deps = [ 40 "../../../adapter:softbus_adapter", 41 "//third_party/bounds_checking_function:libsec_static", 42 ] 43 } 44 } 45} else { 46 import("//build/test.gni") 47 import("../../../dsoftbus.gni") 48 defines += [ "HAVE_PRO = 0" ] 49 module_output_path = "dsoftbus/adapter" 50 51 ohos_unittest("AdaptorDsoftbusCryptTest") { 52 module_out_path = module_output_path 53 sources = [ "dsoftbus_crypto_test.cpp" ] 54 include_dirs = [ 55 "$dsoftbus_root_path/adapter/common/include", 56 "$dsoftbus_root_path/core/common/include/", 57 "$dsoftbus_root_path/interfaces/kits/common", 58 "//third_party/bounds_checking_function/include", 59 ] 60 deps = [ 61 "../../../adapter:softbus_adapter", 62 "//third_party/bounds_checking_function:libsec_static", 63 "//third_party/googletest:gtest_main", 64 ] 65 if (is_standard_system) { 66 external_deps = [ 67 "c_utils:utils", 68 "hilog:libhilog", 69 ] 70 } else { 71 external_deps = [ 72 "c_utils:utils", 73 "hilog:libhilog", 74 ] 75 } 76 } 77 78 ohos_unittest("AdapterDsoftbusDfxTest") { 79 module_out_path = module_output_path 80 sources = [ "softbus_dfx_test.cpp" ] 81 include_dirs = [ 82 "$dsoftbus_root_path/adapter/common/include", 83 "$dsoftbus_root_path/core/common/include/", 84 "$dsoftbus_root_path/interfaces/kits/common", 85 "//third_party/bounds_checking_function/include", 86 ] 87 deps = [ 88 "../../../adapter:softbus_adapter", 89 "//third_party/bounds_checking_function:libsec_static", 90 "//third_party/googletest:gtest_main", 91 ] 92 if (is_standard_system) { 93 external_deps = [ 94 "c_utils:utils", 95 "hilog:libhilog", 96 ] 97 } else { 98 external_deps = [ 99 "c_utils:utils", 100 "hilog:libhilog", 101 ] 102 } 103 } 104 105 ohos_unittest("AdapterDsoftbusOtherTest") { 106 module_out_path = module_output_path 107 sources = [ "dsoftbus_other_test.cpp" ] 108 include_dirs = [ 109 "$dsoftbus_root_path/adapter/common/include", 110 "$dsoftbus_root_path/core/common/include/", 111 "$dsoftbus_root_path/interfaces/kits/common", 112 "//third_party/bounds_checking_function/include", 113 ] 114 deps = [ 115 "../../../adapter:softbus_adapter", 116 "//third_party/bounds_checking_function:libsec_static", 117 "//third_party/googletest:gtest_main", 118 ] 119 if (is_standard_system) { 120 external_deps = [ 121 "c_utils:utils", 122 "hilog:libhilog", 123 ] 124 } else { 125 external_deps = [ 126 "c_utils:utils", 127 "hilog:libhilog", 128 ] 129 } 130 } 131 132 ohos_unittest("AdapterDsoftbusRangeTest") { 133 module_out_path = module_output_path 134 sources = [ "softbus_adapter_range_test.cpp" ] 135 include_dirs = [ 136 "$dsoftbus_root_path/adapter/common/include", 137 "$dsoftbus_root_path/core/common/include/", 138 "$dsoftbus_root_path/interfaces/kits/common", 139 "//third_party/bounds_checking_function/include", 140 ] 141 deps = [ 142 "../../../adapter:softbus_adapter", 143 "//third_party/bounds_checking_function:libsec_static", 144 "//third_party/googletest:gtest_main", 145 ] 146 if (is_standard_system) { 147 external_deps = [ 148 "c_utils:utils", 149 "hilog:libhilog", 150 ] 151 } else { 152 external_deps = [ 153 "c_utils:utils", 154 "hilog:libhilog", 155 ] 156 } 157 } 158 159 ohos_unittest("AdapterDsoftbusSocketTest") { 160 module_out_path = module_output_path 161 sources = [ "softbus_socket_test.cpp" ] 162 include_dirs = [ 163 "$dsoftbus_root_path/adapter/common/include", 164 "$dsoftbus_root_path/core/common/include/", 165 "$dsoftbus_root_path/interfaces/kits/common", 166 "//third_party/bounds_checking_function/include", 167 ] 168 deps = [ 169 "../../../adapter:softbus_adapter", 170 "//third_party/bounds_checking_function:libsec_static", 171 "//third_party/googletest:gtest_main", 172 ] 173 if (is_standard_system) { 174 external_deps = [ 175 "c_utils:utils", 176 "hilog:libhilog", 177 ] 178 } else { 179 external_deps = [ 180 "c_utils:utils", 181 "hilog:libhilog", 182 ] 183 } 184 } 185 186 ohos_unittest("SoftbusThreadTest") { 187 module_out_path = module_output_path 188 sources = [ "softbus_thread_test.cpp" ] 189 include_dirs = [ 190 "$dsoftbus_root_path/adapter/common/include", 191 "$dsoftbus_root_path/core/common/include/", 192 "$dsoftbus_root_path/interfaces/kits/common", 193 "//third_party/bounds_checking_function/include", 194 ] 195 deps = [ 196 "../../../adapter:softbus_adapter", 197 "//third_party/bounds_checking_function:libsec_static", 198 "//third_party/googletest:gtest_main", 199 ] 200 if (is_standard_system) { 201 external_deps = [ 202 "c_utils:utils", 203 "hilog:libhilog", 204 ] 205 } else { 206 external_deps = [ 207 "c_utils:utils", 208 "hilog:libhilog", 209 ] 210 } 211 } 212 213 ohos_unittest("SoftbusTimeTest") { 214 module_out_path = module_output_path 215 sources = [ "softbus_time_test.cpp" ] 216 include_dirs = [ 217 "$dsoftbus_root_path/adapter/common/include", 218 "$dsoftbus_root_path/interfaces/kits/common", 219 "$dsoftbus_root_path/core/common/include/", 220 ] 221 deps = [ 222 "../../../adapter:softbus_adapter", 223 "//third_party/googletest:gtest_main", 224 ] 225 if (is_standard_system) { 226 external_deps = [ 227 "c_utils:utils", 228 "hilog:libhilog", 229 ] 230 } else { 231 external_deps = [ 232 "c_utils:utils", 233 "hilog:libhilog", 234 ] 235 } 236 } 237 238 ohos_unittest("AdaptorDsoftbusFileTest") { 239 module_out_path = module_output_path 240 sources = [ "softbus_file_test.cpp" ] 241 include_dirs = [ 242 "$dsoftbus_root_path/adapter/common/include", 243 "$dsoftbus_root_path/interfaces/kits/common", 244 "$dsoftbus_root_path/core/common/include/", 245 ] 246 deps = [ 247 "../../../adapter:softbus_adapter", 248 "//third_party/googletest:gtest_main", 249 ] 250 if (is_standard_system) { 251 external_deps = [ 252 "c_utils:utils", 253 "hilog:libhilog", 254 ] 255 } else { 256 external_deps = [ 257 "c_utils:utils", 258 "hilog:libhilog", 259 ] 260 } 261 } 262 263 ohos_unittest("AdapterDsoftbusWifiTest") { 264 module_out_path = module_output_path 265 sources = [ 266 "$dsoftbus_root_path/adapter/common/net/wifi/common/softbus_wifi_api_adapter.c", 267 "$dsoftbus_root_path/core/common/log/softbus_log.c", 268 "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/wifi_mock.cpp", 269 "softbus_wifi_api_test.cpp", 270 ] 271 include_dirs = [ 272 "$dsoftbus_root_path/interfaces/kits/common", 273 "$dsoftbus_root_path/tests/core/bus_center/mock_common/src", 274 "$dsoftbus_root_path/tests/core/bus_center/mock_common/include", 275 "$dsoftbus_root_path/adapter/common/net/wifi/include", 276 "$dsoftbus_root_path/adapter/common/net/wifi/common", 277 "//foundation/communication/wifi/wifi/frameworks/native/interfaces", 278 "//foundation/communication/wifi/wifi/interfaces/kits/c", 279 "//foundation/communication/wifi/wifi/interfaces/inner_api", 280 "//foundation/communication/wifi/wifi/frameworks/native/include", 281 "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", 282 "//foundation/communication/wifi/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper", 283 "//foundation/communication/samgr/interfaces/innerkits/samgr_proxy/include", 284 "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", 285 "//foundation/systemabilitymgr/samgr/adapter/interfaces/innerkits/include", 286 "$dsoftbus_root_path/core/common/include", 287 ] 288 deps = [ 289 "$dsoftbus_root_path/core/common:softbus_utils", 290 "../../../adapter:softbus_adapter", 291 "//third_party/googletest:gmock", 292 "//third_party/googletest:gtest_main", 293 ] 294 if (is_standard_system) { 295 external_deps = [ 296 "c_utils:utils", 297 "hilog:libhilog", 298 ] 299 } else { 300 external_deps = [ 301 "c_utils:utils", 302 "hilog:libhilog", 303 ] 304 } 305 } 306 307 ohos_unittest("AdapterDsoftbusNetworkTest") { 308 module_out_path = module_output_path 309 sources = [ 310 "$dsoftbus_root_path/adapter/common/kernel/liteos_m/softbus_adapter_mem.c", 311 "$dsoftbus_root_path/adapter/common/log/softbus_adapter_log.c", 312 "$dsoftbus_root_path/core/common/log/softbus_log.c", 313 "$dsoftbus_root_path/core/common/message_handler/message_handler.c", 314 "$dsoftbus_root_path/core/common/utils/softbus_utils.c", 315 "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/network_mock.cpp", 316 "softbus_network_test.cpp", 317 ] 318 include_dirs = [ 319 "$dsoftbus_root_path/adapter/default_config/spec_config", 320 "$dsoftbus_root_path/core/connection/interface", 321 "$dsoftbus_root_path/core/bus_center/interface", 322 "$dsoftbus_root_path/interfaces/kits/bus_center", 323 "$dsoftbus_root_path/adapter/common/include/OS_adapter_define/linux", 324 "$dsoftbus_root_path/adapter/default_config/spec_config", 325 "$dsoftbus_root_path/adapter/common/bus_center/include", 326 "$dsoftbus_root_path/interfaces/kits/common", 327 "$dsoftbus_root_path/tests/core/bus_center/mock_common/include", 328 "$dsoftbus_root_path/adapter/common/bus_center/network", 329 "$dsoftbus_root_path/core/bus_center/service/include", 330 "$dsoftbus_root_path/core/bus_center/utils/include/lnn_async_callback_utils.h", 331 "$dsoftbus_root_path/adapter/common/net/bluetooth/include", 332 "$dsoftbus_root_path/adapter/common/include", 333 "$dsoftbus_root_path/core/bus_center/service/include", 334 "$dsoftbus_root_path/core/bus_center/utils/include", 335 "$dsoftbus_root_path/core/bus_center/lnn/net_buscenter/include", 336 "$dsoftbus_root_path/adapter/common/include", 337 "$dsoftbus_root_path/core/common/include", 338 ] 339 deps = [ 340 "//third_party/googletest:gmock", 341 "//third_party/googletest:gtest_main", 342 ] 343 if (is_standard_system) { 344 external_deps = [ 345 "c_utils:utils", 346 "hilog:libhilog", 347 ] 348 } else { 349 external_deps = [ 350 "c_utils:utils", 351 "hilog:libhilog", 352 ] 353 } 354 } 355 356 group("unittest") { 357 testonly = true 358 deps = [ 359 ":AdapterDsoftbusDfxTest", 360 ":AdapterDsoftbusOtherTest", 361 ":AdapterDsoftbusRangeTest", 362 ":AdapterDsoftbusSocketTest", 363 ":AdaptorDsoftbusCryptTest", 364 ":AdaptorDsoftbusFileTest", 365 ":SoftbusThreadTest", 366 ":SoftbusTimeTest", 367 ] 368 if (!defined(ohos_lite) && softbus_communication_wifi_feature == true) { 369 deps += [ ":AdapterDsoftbusWifiTest" ] 370 } 371 if (!defined(ohos_lite) && dsoftbus_feature_lnn_net == true && 372 support_bluetooth && dsoftbus_feature_conn_ble) { 373 deps += [ ":AdapterDsoftbusNetworkTest" ] 374 } 375 } 376} 377