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
14import("../../../core/common/dfx/dsoftbus_dfx.gni")
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  dsoftbus_root_path = "../../.."
21
22  defines += [ "HAVE_PRO = 0" ]
23
24  if (ohos_build_type == "debug") {
25    unittest("AdapterTest") {
26      output_extension = "bin"
27      output_dir = "$root_out_dir/test/unittest/dsoftbus"
28      sources = [
29        "dsoftbus_crypto_test.cpp",
30        "dsoftbus_other_test.cpp",
31        "softbus_adapter_range_test.cpp",
32        "softbus_socket_test.cpp",
33      ]
34      include_dirs = [
35        "$dsoftbus_root_path/adapter/common/include",
36        "$dsoftbus_root_path/core/common/include/",
37        "$dsoftbus_root_path/core/common/dfx/interface/include",
38        "$dsoftbus_root_path/interfaces/kits/common",
39        "$hilog_lite_include_path",
40      ]
41      deps = [
42        "$dsoftbus_root_path/adapter:softbus_adapter",
43        "$dsoftbus_root_path/core/common/dfx/log:softbus_dfx_log",
44        "$hilog_lite_deps_path",
45      ]
46
47      external_deps = [ "bounds_checking_function:libsec_static" ]
48    }
49  }
50} else {
51  import("//build/test.gni")
52  import("../../../dsoftbus.gni")
53  defines += [ "HAVE_PRO = 0" ]
54  module_output_path = "dsoftbus/adapter"
55
56  ohos_unittest("AdaptorDsoftbusCryptTest") {
57    module_out_path = module_output_path
58    sources = [ "dsoftbus_crypto_test.cpp" ]
59    include_dirs = [
60      "$dsoftbus_root_path/adapter/common/include",
61      "$dsoftbus_root_path/core/common/include/",
62      "$dsoftbus_root_path/interfaces/kits/common",
63    ]
64    deps = [ "../../../adapter:softbus_adapter" ]
65    external_deps = [
66      "bounds_checking_function:libsec_static",
67      "hilog:libhilog",
68    ]
69  }
70
71  ohos_unittest("AdapterDsoftbusAesCryptoTest") {
72    module_out_path = module_output_path
73    sources = [ "dsoftbus_aes_crypto_test.cpp" ]
74    include_dirs = [
75      "$dsoftbus_root_path/adapter/common/include",
76      "$dsoftbus_root_path/core/common/include/",
77      "$dsoftbus_root_path/interfaces/kits/common",
78    ]
79    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
80
81    external_deps = [
82      "bounds_checking_function:libsec_static",
83      "googletest:gtest_main",
84      "hilog:libhilog",
85    ]
86  }
87
88  ohos_unittest("AdapterDsoftbusDfxTest") {
89    module_out_path = module_output_path
90    sources = [ "softbus_dfx_test.cpp" ]
91    include_dirs = [
92      "$dsoftbus_root_path/adapter/common/include",
93      "$dsoftbus_root_path/core/common/include/",
94      "$dsoftbus_root_path/interfaces/kits/common",
95    ]
96    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
97
98    external_deps = [
99      "bounds_checking_function:libsec_static",
100      "googletest:gtest_main",
101      "hilog:libhilog",
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    ]
113    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
114
115    external_deps = [
116      "bounds_checking_function:libsec_static",
117      "googletest:gtest_main",
118      "hilog:libhilog",
119    ]
120  }
121
122  ohos_unittest("AdapterDsoftbusRangeTest") {
123    module_out_path = module_output_path
124    sources = [ "softbus_adapter_range_test.cpp" ]
125    include_dirs = [
126      "$dsoftbus_root_path/adapter/common/include",
127      "$dsoftbus_root_path/core/common/include/",
128      "$dsoftbus_root_path/interfaces/kits/common",
129    ]
130    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
131    external_deps = [
132      "bounds_checking_function:libsec_static",
133      "googletest:gtest_main",
134      "hilog:libhilog",
135    ]
136  }
137
138  ohos_unittest("AdapterDsoftbusSocketTest") {
139    module_out_path = module_output_path
140    sources = [ "softbus_socket_test.cpp" ]
141    include_dirs = [
142      "$dsoftbus_root_path/adapter/common/include",
143      "$dsoftbus_root_path/core/common/include/",
144      "$dsoftbus_root_path/interfaces/kits/common",
145    ]
146    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
147
148    external_deps = [
149      "bounds_checking_function:libsec_static",
150      "googletest:gtest_main",
151      "hilog:libhilog",
152    ]
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  }
170
171  ohos_unittest("SoftbusTimeTest") {
172    module_out_path = module_output_path
173    sources = [ "softbus_time_test.cpp" ]
174    include_dirs = [
175      "$dsoftbus_root_path/adapter/common/include",
176      "$dsoftbus_root_path/interfaces/kits/common",
177      "$dsoftbus_root_path/core/common/include/",
178    ]
179    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
180
181    external_deps = [
182      "googletest:gtest_main",
183      "hilog:libhilog",
184    ]
185  }
186
187  ohos_unittest("AdaptorDsoftbusFileTest") {
188    module_out_path = module_output_path
189    sources = [ "softbus_file_test.cpp" ]
190    include_dirs = [
191      "$dsoftbus_root_path/adapter/common/include",
192      "$dsoftbus_root_path/interfaces/kits/common",
193      "$dsoftbus_root_path/core/common/include/",
194    ]
195    deps = [ "$dsoftbus_root_path/adapter:softbus_adapter" ]
196    external_deps = [ "hilog:libhilog" ]
197  }
198
199  ohos_unittest("AdapterDsoftbusWifiTest") {
200    module_out_path = module_output_path
201    sources = [
202      "$dsoftbus_root_path/adapter/common/net/wifi/common/softbus_wifi_api_adapter.c",
203      "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/wifi_mock.cpp",
204      "softbus_wifi_api_test.cpp",
205    ]
206    include_dirs = [
207      "$dsoftbus_root_path/interfaces/kits/common",
208      "$dsoftbus_root_path/tests/core/bus_center/mock_common/src",
209      "$dsoftbus_root_path/tests/core/bus_center/mock_common/include",
210      "$dsoftbus_root_path/adapter/common/net/wifi/include",
211      "$dsoftbus_root_path/adapter/common/net/wifi/common",
212      "$dsoftbus_root_path/core/common/include",
213      "$dsoftbus_root_path/core/common/dfx/interface/include",
214    ]
215    deps = [
216      "$dsoftbus_root_path/adapter:softbus_adapter",
217      "$dsoftbus_root_path/core/common:softbus_utils",
218      "$dsoftbus_root_path/core/common/dfx/log:softbus_dfx_log",
219    ]
220    external_deps = [
221      "c_utils:utils",
222      "googletest:gmock",
223      "googletest:gtest_main",
224      "hilog:libhilog",
225      "ipc:ipc_core",
226      "samgr:samgr_proxy",
227    ]
228    if (!defined(ohos_lite) && softbus_communication_wifi_feature == true) {
229      external_deps += [ "wifi:wifi_sdk" ]
230    }
231  }
232
233  ohos_unittest("AdapterDsoftbusNetworkTest") {
234    module_out_path = module_output_path
235    sources = [
236      "$dsoftbus_root_path/adapter/common/kernel/liteos_m/softbus_adapter_mem.c",
237      "$dsoftbus_root_path/core/common/message_handler/message_handler.c",
238      "$dsoftbus_root_path/core/common/utils/softbus_utils.c",
239      "$dsoftbus_root_path/tests/core/bus_center/mock_common/src/network_mock.cpp",
240      "softbus_network_test.cpp",
241    ]
242    include_dirs = [
243      "$dsoftbus_root_path/adapter/default_config/spec_config",
244      "$dsoftbus_root_path/core/connection/interface",
245      "$dsoftbus_root_path/core/bus_center/interface",
246      "$dsoftbus_root_path/interfaces/kits/bus_center",
247      "$dsoftbus_root_path/adapter/common/include/OS_adapter_define/linux",
248      "$dsoftbus_root_path/adapter/default_config/spec_config",
249      "$dsoftbus_root_path/adapter/common/bus_center/include",
250      "$dsoftbus_root_path/interfaces/kits/common",
251      "$dsoftbus_root_path/tests/core/bus_center/mock_common/include",
252      "$dsoftbus_root_path/adapter/common/bus_center/network",
253      "$dsoftbus_root_path/core/bus_center/service/include",
254      "$dsoftbus_root_path/core/bus_center/utils/include/lnn_async_callback_utils.h",
255      "$dsoftbus_root_path/adapter/common/net/bluetooth/include",
256      "$dsoftbus_root_path/adapter/common/include",
257      "$dsoftbus_root_path/core/bus_center/service/include",
258      "$dsoftbus_root_path/core/bus_center/utils/include",
259      "$dsoftbus_root_path/core/bus_center/lnn/net_buscenter/include",
260      "$dsoftbus_root_path/adapter/common/include",
261      "$dsoftbus_root_path/core/common/include",
262    ]
263    deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
264    external_deps = [
265      "googletest:gmock",
266      "googletest:gtest_main",
267      "hilog:libhilog",
268    ]
269  }
270
271  ohos_unittest("AdapterWlanExtendTest") {
272    module_out_path = module_output_path
273    sources = [ "softbus_adapter_wlan_extend_test.cpp" ]
274    include_dirs = [
275      "$dsoftbus_root_path/adapter/common/include",
276      "$dsoftbus_root_path/interfaces/kits/common",
277      "$dsoftbus_root_path/core/common/include/",
278      "$dsoftbus_root_path/core/bus_center/utils/include/",
279      "$dsoftbus_root_path/adapter/common/net/hdi/include/",
280      "$dsoftbus_root_path/core/common/dfx/interface/include",
281    ]
282    deps = [
283      "$dsoftbus_root_path/adapter:softbus_adapter",
284      "$dsoftbus_root_path/core/common/dfx/log:softbus_dfx_log",
285      "$dsoftbus_root_path/core/frame:softbus_server",
286    ]
287    external_deps = [
288      "googletest:gtest_main",
289      "hilog:libhilog",
290    ]
291  }
292
293  group("unittest") {
294    testonly = true
295    deps = [
296      ":AdapterDsoftbusAesCryptoTest",
297      ":AdapterDsoftbusDfxTest",
298      ":AdapterDsoftbusOtherTest",
299      ":AdapterDsoftbusRangeTest",
300      ":AdapterDsoftbusSocketTest",
301      ":AdapterWlanExtendTest",
302      ":AdaptorDsoftbusCryptTest",
303      ":AdaptorDsoftbusFileTest",
304      ":SoftbusThreadTest",
305      ":SoftbusTimeTest",
306    ]
307    if (!defined(ohos_lite) && softbus_communication_wifi_feature == true) {
308      deps += [ ":AdapterDsoftbusWifiTest" ]
309    }
310    if (!defined(ohos_lite) && dsoftbus_feature_lnn_net == true &&
311        support_bluetooth && dsoftbus_feature_conn_ble) {
312      deps += [ ":AdapterDsoftbusNetworkTest" ]
313    }
314  }
315}
316