• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
14import("../../../../dsoftbus.gni")
15
16dsoftbus_root_path = "../../../.."
17
18bus_center_sdk_test_inc = [
19  "$dsoftbus_dfx_path/interface/include/form",
20  "$dsoftbus_root_path/adapter/common/include",
21  "$dsoftbus_root_path/adapter/default_config/spec_config",
22  "$dsoftbus_root_path/core/bus_center/interface",
23  "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/include",
24  "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/lane_manager/include",
25  "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/include",
26  "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/local_ledger/include",
27  "$dsoftbus_root_path/core/common/include",
28  "$dsoftbus_root_path/core/discovery/interface",
29  "$dsoftbus_root_path/core/discovery/manager/include",
30  "$dsoftbus_root_path/core/frame/common/include",
31  "$dsoftbus_root_path/core/frame/standard/init/include",
32  "$dsoftbus_root_path/core/transmission/common/include",
33  "$dsoftbus_root_path/interfaces/kits/bus_center",
34  "$dsoftbus_root_path/interfaces/kits/common",
35  "$dsoftbus_root_path/interfaces/kits/disc",
36  "$dsoftbus_root_path/interfaces/kits/lnn",
37  "$dsoftbus_root_path/sdk/bus_center/ipc/include",
38  "$dsoftbus_root_path/sdk/bus_center/ipc/standard/include",
39  "$dsoftbus_root_path/sdk/bus_center/manager/include",
40  "$dsoftbus_root_path/sdk/bus_center/manager/src",
41  "$dsoftbus_root_path/sdk/frame/common/include",
42  "$dsoftbus_root_path/tests/sdk/common/include",
43]
44bus_center_sdk_test_deps = [
45  "$dsoftbus_root_path/adapter:softbus_adapter",
46  "$dsoftbus_root_path/core/common:softbus_utils",
47  "$dsoftbus_root_path/core/frame:softbus_server",
48]
49
50if (dsoftbus_feature_lnn_ble) {
51  bus_center_sdk_test_inc += [
52    "$dsoftbus_root_path/core/authentication/interface",
53    "$dsoftbus_root_path/core/adapter/bus_center/include",
54    "$dsoftbus_root_path/core/bus_center/interface",
55    "$dsoftbus_root_path/core/bus_center/lnn/decision_center/include",
56    "$dsoftbus_root_path/core/bus_center/lnn/disc_mgr/include",
57    "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/common/include",
58    "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/include",
59    "$dsoftbus_root_path/core/bus_center/lnn/meta_node/include",
60    "$dsoftbus_root_path/core/bus_center/lnn/net_builder/include",
61    "$dsoftbus_root_path/core/bus_center/lnn/net_buscenter/include",
62    "$dsoftbus_root_path/core/bus_center/monitor/include",
63    "$dsoftbus_root_path/core/bus_center/service/include",
64    "$dsoftbus_root_path/core/bus_center/utils/include",
65    "$dsoftbus_root_path/core/common/include",
66    "$dsoftbus_root_path/interfaces/kits/authentication",
67    "$dsoftbus_root_path/interfaces/kits/lnn",
68  ]
69}
70
71if (defined(ohos_lite)) {
72  import("//build/lite/config/component/lite_component.gni")
73  import("//build/lite/config/test.gni")
74
75  if (ohos_build_type == "debug") {
76    unittest("BusCenterSdkRefreshSmall") {
77      output_extension = "bin"
78      output_dir = "$root_out_dir/test/unittest/dsoftbus"
79      sources = [
80        "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_strategy_virtual.c",
81        "bus_center_sdk_refresh_small_test.cpp",
82      ]
83      include_dirs = bus_center_sdk_test_inc
84      include_dirs += [
85        "$dsoftbus_root_path/interfaces/kits/lnn",
86        "$dsoftbus_root_path/adapter/common/bus_center/include",
87        "$dsoftbus_root_path/core/bus_center/service/include",
88        "$dsoftbus_root_path/core/bus_center/utils/include",
89        "$dsoftbus_root_path/sdk/frame/small/include",
90        "unittest/common/",
91      ]
92      deps = bus_center_sdk_test_deps
93      deps += [
94        "$dsoftbus_root_path/core/frame:softbus_server_frame",
95        "$dsoftbus_root_path/sdk:softbus_client",
96        "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
97        "$hilog_lite_deps_path",
98      ]
99    }
100  }
101} else {
102  import("//build/test.gni")
103
104  module_output_path = "dsoftbus/soft_bus/bus_center"
105  ohos_unittest("BusCenterSdkTest") {
106    module_out_path = module_output_path
107    sources = [ "bus_center_sdk_test.cpp" ]
108    include_dirs = bus_center_sdk_test_inc
109    include_dirs += [ "unittest/common/" ]
110    deps = bus_center_sdk_test_deps
111    deps += [
112      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
113      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
114    ]
115    if (is_standard_system) {
116      external_deps = [ "hilog:libhilog" ]
117    } else {
118      external_deps = [ "hilog:libhilog" ]
119    }
120    external_deps += [
121      "c_utils:utils",
122      "ipc:ipc_single",
123    ]
124    if (dsoftbus_access_token_feature) {
125      external_deps += [
126        "access_token:libnativetoken",
127        "access_token:libtoken_setproc",
128        "cJSON:cjson_static",
129      ]
130    }
131  }
132
133  ohos_unittest("ClientBusCenterSdkTest") {
134    module_out_path = module_output_path
135    sources = [ "softbus_center_sdk_test.cpp" ]
136    include_dirs = bus_center_sdk_test_inc
137    include_dirs += [ "unittest/common/" ]
138    deps = bus_center_sdk_test_deps
139    deps += [
140      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
141      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
142    ]
143    if (is_standard_system) {
144      external_deps = [ "hilog:libhilog" ]
145    } else {
146      external_deps = [ "hilog:libhilog" ]
147    }
148    external_deps += [
149      "c_utils:utils",
150      "ipc:ipc_single",
151    ]
152    if (dsoftbus_access_token_feature) {
153      external_deps += [
154        "access_token:libnativetoken",
155        "access_token:libtoken_setproc",
156        "cJSON:cjson_static",
157      ]
158    }
159  }
160
161  ohos_unittest("ClientBusMangerTest") {
162    module_out_path = module_output_path
163    sources = [ "client_bus_center_test.cpp" ]
164    include_dirs = bus_center_sdk_test_inc
165    include_dirs += [ "unittest/common/" ]
166    deps = bus_center_sdk_test_deps
167    deps += [
168      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
169      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
170    ]
171    if (is_standard_system) {
172      external_deps = [ "hilog:libhilog" ]
173    } else {
174      external_deps = [ "hilog:libhilog" ]
175    }
176    external_deps += [
177      "c_utils:utils",
178      "ipc:ipc_single",
179    ]
180    if (dsoftbus_access_token_feature) {
181      external_deps += [
182        "access_token:libnativetoken",
183        "access_token:libtoken_setproc",
184        "cJSON:cjson_static",
185      ]
186    }
187  }
188
189  ohos_unittest("BusCenterSdkDdosTest") {
190    module_out_path = module_output_path
191    sources = [ "bus_center_sdk_ddos_test.cpp" ]
192    include_dirs = bus_center_sdk_test_inc
193    include_dirs += [
194      "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/time_sync/include",
195      "$dsoftbus_root_path/core/frame/common/include",
196      "unittest/common/",
197    ]
198    deps = bus_center_sdk_test_deps
199    deps += [
200      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
201      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
202    ]
203    if (is_standard_system) {
204      external_deps = [ "hilog:libhilog" ]
205    } else {
206      external_deps = [ "hilog:libhilog" ]
207    }
208    external_deps += [
209      "c_utils:utils",
210      "googletest:gmock",
211      "ipc:ipc_single",
212    ]
213    if (dsoftbus_access_token_feature) {
214      external_deps += [
215        "access_token:libnativetoken",
216        "access_token:libtoken_setproc",
217        "cJSON:cjson_static",
218      ]
219    }
220  }
221
222  ohos_unittest("BusCenterHeartbeatSdkTest") {
223    module_out_path = module_output_path
224    sources = [
225      "$dsoftbus_root_path/core/bus_center/service/src/bus_center_manager.c",
226      "bus_center_heartbeat_sdk_test.cpp",
227      "$dsoftbus_root_path/core/frame/init/src/g_enhance_lnn_func.c",
228    ]
229    include_dirs = bus_center_sdk_test_inc
230    include_dirs += [
231      "$dsoftbus_root_path/core/authentication/include",
232      "$dsoftbus_root_path/core/frame/init/include",
233      "unittest/common/",
234    ]
235    deps = bus_center_sdk_test_deps
236    deps += [
237      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
238      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
239    ]
240    if (is_standard_system) {
241      external_deps = [ "hilog:libhilog" ]
242    } else {
243      external_deps = [ "hilog:libhilog" ]
244    }
245    external_deps += [
246      "c_utils:utils",
247      "ipc:ipc_single",
248    ]
249    if (dsoftbus_access_token_feature) {
250      external_deps += [
251        "access_token:libnativetoken",
252        "access_token:libtoken_setproc",
253        "cJSON:cjson_static",
254      ]
255    }
256  }
257
258  ohos_unittest("BusCenterMetaNodeSdkTest") {
259    module_out_path = module_output_path
260    sources = [ "bus_center_meta_node_sdk_test.cpp" ]
261    include_dirs = bus_center_sdk_test_inc
262    include_dirs += [ "unittest/common/" ]
263    deps = bus_center_sdk_test_deps
264    deps += [
265      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
266      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
267    ]
268    if (is_standard_system) {
269      external_deps = [ "hilog:libhilog" ]
270    } else {
271      external_deps = [ "hilog:libhilog" ]
272    }
273    external_deps += [
274      "c_utils:utils",
275      "ipc:ipc_single",
276    ]
277    if (dsoftbus_access_token_feature) {
278      external_deps += [
279        "access_token:libnativetoken",
280        "access_token:libtoken_setproc",
281      ]
282    }
283  }
284
285  ohos_unittest("ClientBusCentManagerTest") {
286    module_out_path = module_output_path
287    sources = [
288      "client_bus_center_manager_mock.cpp",
289      "client_bus_center_manager_test.cpp",
290    ]
291    include_dirs = [
292      "$dsoftbus_root_path/adapter/common/include",
293      "$dsoftbus_root_path/adapter/default_config/spec_config",
294      "$dsoftbus_root_path/core/bus_center/interface",
295      "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/include",
296      "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/lane_manager/include",
297      "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/local_ledger/include",
298      "$dsoftbus_root_path/core/common/include",
299      "$dsoftbus_root_path/core/discovery/interface",
300      "$dsoftbus_root_path/core/discovery/manager/include",
301      "$dsoftbus_root_path/core/frame/common/include",
302      "$dsoftbus_root_path/core/frame/standard/init/include",
303      "$dsoftbus_root_path/core/transmission/common/include",
304      "$dsoftbus_root_path/interfaces/inner_kits/lnn",
305      "$dsoftbus_root_path/interfaces/kits/bus_center",
306      "$dsoftbus_root_path/interfaces/kits/common",
307      "$dsoftbus_root_path/sdk/bus_center/ipc/include",
308      "$dsoftbus_root_path/sdk/bus_center/ipc/standard/include",
309      "$dsoftbus_root_path/sdk/bus_center/manager/include",
310      "$dsoftbus_root_path/sdk/bus_center/manager/src",
311      "$dsoftbus_root_path/sdk/frame/common/include",
312      "$dsoftbus_root_path/tests/sdk/common/include",
313    ]
314    deps = [
315      "$dsoftbus_root_path/adapter:softbus_adapter",
316      "$dsoftbus_root_path/core/common:softbus_utils",
317      "$dsoftbus_root_path/core/frame:softbus_server",
318      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
319    ]
320    if (is_standard_system) {
321      external_deps = [
322        "bounds_checking_function:libsec_shared",
323        "c_utils:utils",
324        "googletest:gmock",
325        "googletest:gtest_main",
326        "hilog:libhilog",
327      ]
328      if (dsoftbus_access_token_feature) {
329        external_deps += [
330          "access_token:libnativetoken",
331          "access_token:libtoken_setproc",
332          "cJSON:cjson_static",
333        ]
334      }
335    } else {
336      external_deps = [
337        "bounds_checking_function:libsec_shared",
338        "c_utils:utils",
339        "googletest:gtest_main",
340        "hilog:libhilog",
341      ]
342    }
343  }
344
345  ohos_unittest("BusCenterServerTest") {
346    module_out_path = module_output_path
347    sources = [ "bus_center_server_test.cpp" ]
348    include_dirs = bus_center_sdk_test_inc
349    include_dirs += [ "unittest/common/" ]
350    deps = bus_center_sdk_test_deps
351    deps += [
352      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
353      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
354    ]
355    if (is_standard_system) {
356      external_deps = [ "hilog:libhilog" ]
357    } else {
358      external_deps = [ "hilog:libhilog" ]
359    }
360    external_deps += [
361      "c_utils:utils",
362      "ipc:ipc_single",
363    ]
364    if (dsoftbus_access_token_feature) {
365      external_deps += [
366        "access_token:libnativetoken",
367        "access_token:libtoken_setproc",
368        "cJSON:cjson_static",
369      ]
370    }
371  }
372
373  ohos_unittest("BusCenterServerProxyStandardTest") {
374    module_out_path = module_output_path
375    sources = [ "bus_center_server_standard_test.cpp" ]
376    include_dirs = bus_center_sdk_test_inc
377    include_dirs += [ "unittest/common/" ]
378    deps = bus_center_sdk_test_deps
379    deps += [
380      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
381      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
382    ]
383    if (is_standard_system) {
384      external_deps = [ "hilog:libhilog" ]
385    } else {
386      external_deps = [ "hilog:libhilog" ]
387    }
388    external_deps += [
389      "c_utils:utils",
390      "ipc:ipc_single",
391    ]
392    if (dsoftbus_access_token_feature) {
393      external_deps += [
394        "access_token:libnativetoken",
395        "access_token:libtoken_setproc",
396        "cJSON:cjson_static",
397      ]
398    }
399  }
400
401  ohos_unittest("BusCenterServerProxyTest") {
402    module_out_path = module_output_path
403    sources = [ "bus_center_server_proxy_test.cpp" ]
404    include_dirs = bus_center_sdk_test_inc
405    include_dirs += [ "unittest/common/" ]
406    deps = bus_center_sdk_test_deps
407    deps += [
408      "$dsoftbus_root_path/tests/sdk:softbus_client_static",
409      "$dsoftbus_root_path/tests/sdk/common:softbus_access_token_test",
410    ]
411    if (is_standard_system) {
412      external_deps = [ "hilog:libhilog" ]
413    } else {
414      external_deps = [ "hilog:libhilog" ]
415    }
416    external_deps += [
417      "c_utils:utils",
418      "ipc:ipc_single",
419    ]
420    if (dsoftbus_access_token_feature) {
421      external_deps += [
422        "access_token:libnativetoken",
423        "access_token:libtoken_setproc",
424        "cJSON:cjson_static",
425      ]
426    }
427  }
428
429  group("unittest") {
430    testonly = true
431    deps = []
432    if (dsoftbus_access_token_feature) {
433      deps += [
434        ":BusCenterMetaNodeSdkTest",
435        ":BusCenterSdkTest",
436        ":BusCenterServerProxyStandardTest",
437        ":BusCenterServerProxyTest",
438        ":BusCenterServerTest",
439        ":ClientBusCentManagerTest",
440        ":ClientBusCenterSdkTest",
441        ":ClientBusMangerTest",
442      ]
443    }
444    if (dsoftbus_feature_lnn_ble) {
445      deps += [ ":BusCenterHeartbeatSdkTest" ]
446    }
447  }
448}
449