• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
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  defines += [ "HAVE_PRO = 0" ]
22
23  if (ohos_build_type == "debug") {
24    unittest("AdapterTest") {
25      output_extension = "bin"
26      output_dir = "$root_out_dir/test/unittest/dsoftbus"
27      sources = [
28        "dsoftbus_crypto_test.cpp",
29        "dsoftbus_other_test.cpp",
30        "softbus_adapter_range_test.cpp",
31        "softbus_socket_test.cpp",
32      ]
33      include_dirs = [
34        "$dsoftbus_dfx_path/interface/include",
35        "$dsoftbus_root_path/adapter/common/include",
36        "$dsoftbus_root_path/core/common/include/",
37        "$dsoftbus_root_path/interfaces/kits/common",
38        "$hilog_lite_include_path",
39      ]
40      deps = [
41        "$dsoftbus_dfx_path:softbus_dfx",
42        "$dsoftbus_root_path/adapter:softbus_adapter",
43        "$hilog_lite_deps_path",
44      ]
45
46      external_deps = [ "bounds_checking_function:libsec_static" ]
47    }
48  }
49} else {
50  import("//build/test.gni")
51  import("../../../dsoftbus.gni")
52  defines += [ "HAVE_PRO = 0" ]
53  module_output_path = "dsoftbus/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  }
153
154  ohos_unittest("SoftbusThreadTest") {
155    module_out_path = module_output_path
156    sources = [ "softbus_thread_test.cpp" ]
157    include_dirs = [
158      "$dsoftbus_root_path/adapter/common/include",
159      "$dsoftbus_root_path/core/common/include/",
160      "$dsoftbus_root_path/interfaces/kits/common",
161    ]
162    deps = [ "../../../adapter:softbus_adapter" ]
163    external_deps = [
164      "bounds_checking_function:libsec_static",
165      "googletest:gtest_main",
166      "hilog:libhilog",
167    ]
168  }
169
170  ohos_unittest("SoftbusTimeTest") {
171    module_out_path = module_output_path
172    sources = [ "softbus_time_test.cpp" ]
173    include_dirs = [
174      "$dsoftbus_root_path/adapter/common/include",
175      "$dsoftbus_root_path/interfaces/kits/common",
176      "$dsoftbus_root_path/core/common/include/",
177    ]
178    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
179
180    external_deps = [
181      "googletest:gtest_main",
182      "hilog:libhilog",
183    ]
184  }
185
186  ohos_unittest("AdaptorDsoftbusFileTest") {
187    module_out_path = module_output_path
188    sources = [ "softbus_file_test.cpp" ]
189    include_dirs = [
190      "$dsoftbus_root_path/adapter/common/include",
191      "$dsoftbus_root_path/interfaces/kits/common",
192      "$dsoftbus_root_path/core/common/include/",
193    ]
194    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
195    external_deps = [ "hilog:libhilog" ]
196  }
197
198  ohos_unittest("AdapterDsoftbusWifiTest") {
199    module_out_path = module_output_path
200    sources = [
201      "$dsoftbus_root_path/adapter/common/net/wifi/common/softbus_wifi_api_adapter.c",
202      "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/wifi_mock.cpp",
203      "softbus_wifi_api_test.cpp",
204    ]
205    include_dirs = [
206      "$dsoftbus_root_path/interfaces/kits/common",
207      "$dsoftbus_root_path/tests/core/bus_center/mock_common/src",
208      "$dsoftbus_root_path/tests/core/bus_center/mock_common/include",
209      "$dsoftbus_root_path/adapter/common/net/wifi/include",
210      "$dsoftbus_root_path/adapter/common/net/wifi/common",
211      "$dsoftbus_root_path/core/common/include",
212      "$dsoftbus_dfx_path/interface/include",
213    ]
214    deps = [
215      "$dsoftbus_dfx_path:softbus_dfx",
216      "$dsoftbus_root_path/adapter:softbus_adapter",
217      "$dsoftbus_root_path/core/common:softbus_utils",
218    ]
219    external_deps = [
220      "c_utils:utils",
221      "googletest:gmock",
222      "googletest:gtest_main",
223      "hilog:libhilog",
224      "ipc:ipc_single",
225      "samgr:samgr_proxy",
226    ]
227    if (!defined(ohos_lite) && softbus_communication_wifi_feature == true) {
228      external_deps += [ "wifi:wifi_sdk" ]
229    }
230  }
231
232  ohos_unittest("AdapterNetManagerMonitorTest") {
233    module_out_path = module_output_path
234    sources = [
235      "$dsoftbus_root_path/adapter/common/kernel/liteos_m/softbus_adapter_mem.c",
236      "$dsoftbus_root_path/core/common/message_handler/message_handler.c",
237      "$dsoftbus_root_path/core/common/utils/softbus_utils.c",
238      "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/network_mock.cpp",
239      "$dsoftbus_root_path/tests/core/connection/wifi_direct_cpp/net_conn_client.cpp",
240      "softbus_netmanager_monitor_test.cpp",
241    ]
242    include_dirs = [
243      "$dsoftbus_root_path/adapter/common/bus_center/include",
244      "$dsoftbus_root_path/adapter/common/bus_center/network",
245      "$dsoftbus_root_path/adapter/common/include",
246      "$dsoftbus_root_path/adapter/common/include/OS_adapter_define/linux",
247      "$dsoftbus_root_path/adapter/common/net/bluetooth/include",
248      "$dsoftbus_root_path/adapter/default_config/spec_config",
249      "$dsoftbus_root_path/core/bus_center/lnn/net_buscenter/include",
250      "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/include",
251      "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/local_ledger/include",
252      "$dsoftbus_root_path/core/bus_center/interface",
253      "$dsoftbus_root_path/core/bus_center/service/include",
254      "$dsoftbus_root_path/core/bus_center/utils/include",
255      "$dsoftbus_root_path/core/common/dfx/interface/include",
256      "$dsoftbus_root_path/core/discovery/manager/include",
257      "$dsoftbus_root_path/core/discovery/interface",
258      "$dsoftbus_root_path/interfaces/kits/bus_center",
259      "$dsoftbus_root_path/interfaces/inner_kits/lnn",
260      "$dsoftbus_root_path/tests/adapter/unittest",
261      "$dsoftbus_root_path/tests/core/bus_center/mock_common/include",
262      "$dsoftbus_root_path/tests/core/connection/wifi_direct_cpp",
263      "$dsoftbus_root_path/core/bus_center/monitor/include",
264    ]
265    deps = [
266      "$dsoftbus_dfx_path:softbus_dfx",
267      "$dsoftbus_root_path/adapter:softbus_adapter",
268      "$dsoftbus_root_path/core/common:softbus_utils",
269      "$dsoftbus_root_path/core/frame:softbus_server",
270    ]
271    external_deps = [
272      "googletest:gmock",
273      "googletest:gtest_main",
274      "hilog:libhilog",
275    ]
276    if (!defined(global_parts_info) ||
277        defined(global_parts_info.communication_netmanager_base)) {
278      external_deps += [ "netmanager_base:net_conn_manager_if" ]
279    }
280  }
281
282  ohos_unittest("AdapterDsoftbusNetworkTest") {
283    module_out_path = module_output_path
284    sources = [
285      "$dsoftbus_root_path/adapter/common/kernel/liteos_m/softbus_adapter_mem.c",
286      "$dsoftbus_root_path/core/bus_center/monitor/src/lnn_init_monitor.c",
287      "$dsoftbus_root_path/core/common/message_handler/message_handler.c",
288      "$dsoftbus_root_path/core/common/utils/softbus_utils.c",
289      "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/network_mock.cpp",
290      "softbus_network_test.cpp",
291    ]
292    include_dirs = [
293      "$dsoftbus_root_path/adapter/default_config/spec_config",
294      "$dsoftbus_root_path/core/connection/interface",
295      "$dsoftbus_root_path/core/bus_center/interface",
296      "$dsoftbus_root_path/interfaces/kits/bus_center",
297      "$dsoftbus_root_path/adapter/common/include/OS_adapter_define/linux",
298      "$dsoftbus_root_path/adapter/default_config/spec_config",
299      "$dsoftbus_root_path/adapter/common/bus_center/include",
300      "$dsoftbus_root_path/interfaces/inner_kits/lnn",
301      "$dsoftbus_root_path/interfaces/kits/common",
302      "$dsoftbus_root_path/tests/core/bus_center/mock_common/include",
303      "$dsoftbus_root_path/adapter/common/bus_center/network",
304      "$dsoftbus_root_path/core/bus_center/service/include",
305      "$dsoftbus_root_path/core/bus_center/utils/include/lnn_async_callback_utils.h",
306      "$dsoftbus_root_path/adapter/common/net/bluetooth/include",
307      "$dsoftbus_root_path/adapter/common/include",
308      "$dsoftbus_root_path/core/bus_center/service/include",
309      "$dsoftbus_root_path/core/bus_center/utils/include",
310      "$dsoftbus_root_path/core/bus_center/lnn/net_buscenter/include",
311      "$dsoftbus_root_path/core/bus_center/monitor/include",
312      "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/include",
313      "$dsoftbus_root_path/adapter/common/include",
314      "$dsoftbus_root_path/core/common/include",
315      "$dsoftbus_dfx_path/interface/include",
316    ]
317    deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
318    external_deps = [
319      "googletest:gmock",
320      "googletest:gtest_main",
321      "hilog:libhilog",
322    ]
323  }
324
325  ohos_unittest("AdapterWlanExtendTest") {
326    module_out_path = module_output_path
327    sources = [ "softbus_adapter_wlan_extend_test.cpp" ]
328    include_dirs = [
329      "$dsoftbus_root_path/adapter/common/include",
330      "$dsoftbus_root_path/interfaces/kits/common",
331      "$dsoftbus_root_path/core/common/include/",
332      "$dsoftbus_root_path/core/bus_center/utils/include/",
333      "$dsoftbus_root_path/adapter/common/net/hdi/include/",
334      "$dsoftbus_dfx_path/interface/include",
335    ]
336    deps = [
337      "$dsoftbus_dfx_path:softbus_dfx",
338      "$dsoftbus_root_path/adapter:softbus_adapter",
339      "$dsoftbus_root_path/core/frame:softbus_server",
340    ]
341    external_deps = [
342      "googletest:gtest_main",
343      "hilog:libhilog",
344    ]
345  }
346
347  group("unittest") {
348    testonly = true
349    deps = [
350      ":AdapterDsoftbusAesCryptoTest",
351      ":AdapterDsoftbusDfxTest",
352      ":AdapterDsoftbusOtherTest",
353      ":AdapterDsoftbusRangeTest",
354      ":AdapterDsoftbusSocketTest",
355      ":AdapterWlanExtendTest",
356      ":AdaptorDsoftbusCryptTest",
357      ":AdaptorDsoftbusFileTest",
358      ":SoftbusThreadTest",
359      ":SoftbusTimeTest",
360    ]
361    if (!defined(ohos_lite) && softbus_communication_wifi_feature == true) {
362      deps += [ ":AdapterDsoftbusWifiTest" ]
363    }
364    if (!defined(ohos_lite) && dsoftbus_feature_lnn_frame == true &&
365        support_bluetooth && dsoftbus_feature_conn_ble) {
366      deps += [ ":AdapterDsoftbusNetworkTest" ]
367    }
368    if (!defined(global_parts_info) ||
369        defined(global_parts_info.communication_netmanager_base)) {
370      deps += [ ":AdapterNetManagerMonitorTest" ]
371    }
372  }
373}
374