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/test.gni")
16} else {
17  import("//build/config/sanitizers/sanitizers.gni")
18  import("//build/test.gni")
19}
20import("./../../../../hdf_core/adapter/uhdf2/uhdf.gni")
21
22if (defined(ohos_lite)) {
23  output_path = "$root_out_dir/test/moduletest/hdf/usb"
24  moduletest("usb_host_serial_func_test") {
25    output_extension = "bin"
26    output_dir = output_path
27    include_dirs = [
28      "//third_party/googletest/googletest/include",
29      "./../../sample/host/include",
30      "./../../../../hdf_core/adapter/khdf/liteos/model/usb/host/include",
31      "//third_party/bounds_checking_function/include",
32      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
33      "./../../serial/include",
34      "./../../ddk/common/include",
35      "./../../ddk/device/include",
36      "./../../ddk/host/include",
37      "./../../interfaces/ddk/common",
38      "./../../interfaces/ddk/host",
39      "./../../gadget/function/include",
40      "common",
41    ]
42    sources = [
43      "./../../sample/host/src/usbhost_ddk_test.c",
44      "./common/liteos/usb_host_serial_func_test.cpp",
45    ]
46    public_deps = [
47      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
48      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
49      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
50      "//commonlibrary/utils_lite:utils",
51    ]
52    defines = [ "__LITEOS_USB_HOST_DDK_TEST__" ]
53  }
54
55  moduletest("usb_host_raw_api_func_test") {
56    output_extension = "bin"
57    output_dir = output_path
58    include_dirs = [
59      "//third_party/googletest/googletest/include",
60      "./../../sample/host/include",
61      "./../../../../hdf_core/adapter/khdf/liteos/model/usb/host/include",
62      "//third_party/bounds_checking_function/include",
63      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
64      "./../../serial/include",
65      "./../../ddk/common/include",
66      "./../../ddk/device/include",
67      "./../../ddk/host/include",
68      "./../../interfaces/ddk/common",
69      "./../../interfaces/ddk/host",
70      "./../../gadget/function/include",
71      "common",
72    ]
73    sources = [
74      "./../../sample/host/src/usbhost_ddk_test.c",
75      "./common/liteos/usb_host_raw_api_func_test.cpp",
76    ]
77    public_deps = [
78      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
79      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
80      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
81      "//commonlibrary/utils_lite:utils",
82    ]
83    defines = [ "__LITEOS_USB_HOST_DDK_TEST__" ]
84  }
85
86  moduletest("usb_host_serial_loopback") {
87    output_extension = "bin"
88    output_dir = output_path
89    include_dirs = [
90      "//third_party/googletest/googletest/include",
91      "./../../sample/host/include",
92      "./../../../../hdf_core/adapter/khdf/liteos/model/usb/host/include",
93      "//third_party/bounds_checking_function/include",
94      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
95      "./../../serial/include",
96      "./../../ddk/common/include",
97      "./../../ddk/device/include",
98      "./../../ddk/host/include",
99      "./../../interfaces/ddk/common",
100      "./../../interfaces/ddk/host",
101      "./../../gadget/function/include",
102      "common",
103    ]
104    sources = [
105      "./../../sample/host/src/usbhost_ddk_test.c",
106      "./common/liteos/usb_host_serial_loopback.cpp",
107    ]
108    public_deps = [
109      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
110      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
111      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
112      "//commonlibrary/utils_lite:utils",
113    ]
114    defines = [ "__LITEOS_USB_HOST_DDK_TEST__" ]
115  }
116
117  moduletest("usb_device_serial_loopback") {
118    output_extension = "bin"
119    output_dir = output_path
120    include_dirs = [
121      "//third_party/googletest/googletest/include",
122      "./../../sample/device/liteos/lib/include",
123      "//third_party/bounds_checking_function/include",
124      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
125      "common",
126    ]
127    sources = [
128      "./../../sample/device/liteos/lib/src/lib_acm_test.c",
129      "./common/liteos/usb_device_serial_loopback.cpp",
130    ]
131    public_deps = [
132      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
133      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
134      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
135      "//commonlibrary/utils_lite:utils",
136    ]
137  }
138
139  moduletest("usb_device_serial_func_test") {
140    output_extension = "bin"
141    output_dir = output_path
142    include_dirs = [
143      "//third_party/googletest/googletest/include",
144      "./../../sample/device/liteos/lib/include",
145      "//third_party/bounds_checking_function/include",
146      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
147      "common",
148    ]
149    sources = [
150      "./../../sample/device/liteos/lib/src/lib_acm_test.c",
151      "./common/liteos/usb_device_serial_func_test.cpp",
152    ]
153    public_deps = [
154      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
155      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
156      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
157      "//commonlibrary/utils_lite:utils",
158    ]
159  }
160
161  group("hdf_peripheral_usb_test_module") {
162    deps = [
163      ":usb_device_serial_func_test",
164      ":usb_device_serial_loopback",
165      ":usb_host_raw_api_func_test",
166      ":usb_host_serial_func_test",
167      ":usb_host_serial_loopback",
168    ]
169  }
170} else {
171  module_output_path = "hdf/usb"
172  ohos_moduletest("usb_device_serial_func_test") {
173    module_out_path = module_output_path
174    include_dirs = [
175      "//third_party/googletest/googletest/include",
176      "common",
177    ]
178    sources = [
179      "./common/usb_device_serial_func_test.cpp",
180      "./common/usb_utils.cpp",
181    ]
182    external_deps = [
183      "c_utils:utils",
184      "hdf_core:libhdf_utils",
185    ]
186  }
187
188  ohos_moduletest("usb_device_net_func_test") {
189    module_out_path = module_output_path
190    include_dirs = [
191      "//third_party/googletest/googletest/include",
192      "common",
193    ]
194
195    sources = [
196      "./common/usb_device_net_func_test.cpp",
197      "./common/usb_utils.cpp",
198    ]
199    deps = []
200  }
201
202  ohos_moduletest("usb_device_compose_func_test") {
203    module_out_path = module_output_path
204    include_dirs = [
205      "//third_party/googletest/googletest/include",
206      "common",
207    ]
208
209    sources = [
210      "./common/usb_device_compose_func_test.cpp",
211      "./common/usb_utils.cpp",
212    ]
213    deps = []
214  }
215
216  ohos_moduletest("usb_device_performance_test") {
217    module_out_path = module_output_path
218    include_dirs = [
219      "//third_party/googletest/googletest/include",
220      "common",
221    ]
222    sources = [
223      "./common/usb_device_performance_test.cpp",
224      "./common/usb_utils.cpp",
225    ]
226    deps = []
227    external_deps = [ "hdf_core:libhdf_utils" ]
228  }
229
230  ohos_moduletest("usb_host_serial_func_test") {
231    module_out_path = module_output_path
232    include_dirs = [
233      "//third_party/googletest/googletest/include",
234      "common",
235    ]
236    sources = [
237      "./common/usb_host_serial_func_test.cpp",
238      "./common/usb_utils.cpp",
239    ]
240    external_deps = [
241      "c_utils:utils",
242      "hdf_core:libhdf_utils",
243    ]
244  }
245
246  ohos_moduletest("usb_host_raw_api_func_test") {
247    module_out_path = module_output_path
248    include_dirs = [
249      "//third_party/googletest/googletest/include",
250      "common",
251    ]
252    sources = [
253      "./common/usb_host_raw_api_func_test.cpp",
254      "./common/usb_utils.cpp",
255    ]
256    external_deps = [
257      "c_utils:utils",
258      "hdf_core:libhdf_utils",
259    ]
260  }
261
262  ohos_moduletest("usb_host_net_func_test") {
263    module_out_path = module_output_path
264    include_dirs = [
265      "//third_party/googletest/googletest/include",
266      "common",
267    ]
268
269    sources = [
270      "./common/usb_host_net_func_test.cpp",
271      "./common/usb_utils.cpp",
272    ]
273    deps = []
274  }
275
276  ohos_moduletest("usb_host_compose_func_test") {
277    module_out_path = module_output_path
278    include_dirs = [
279      "//third_party/googletest/googletest/include",
280      "common",
281    ]
282
283    sources = [
284      "./common/usb_host_compose_func_test.cpp",
285      "./common/usb_utils.cpp",
286    ]
287    deps = []
288  }
289
290  ohos_moduletest("usb_host_performance_test") {
291    module_out_path = module_output_path
292    include_dirs = [
293      "//third_party/googletest/googletest/include",
294      "common",
295    ]
296
297    sources = [
298      "./common/usb_host_performance_test.cpp",
299      "./common/usb_utils.cpp",
300    ]
301    deps = []
302    external_deps = [ "hdf_core:libhdf_utils" ]
303  }
304
305  group("hdf_moduletest_usb") {
306    testonly = true
307    deps = [
308      ":usb_device_performance_test",
309      ":usb_device_serial_func_test",
310      ":usb_host_performance_test",
311      ":usb_host_raw_api_func_test",
312      ":usb_host_serial_func_test",
313    ]
314  }
315}
316