1# Copyright (c) 2021-2022 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("//build/test.gni") 15import("./../../../usbmgr.gni") 16 17declare_args() { 18 usb_manage_feature_support_port_change = false 19} 20 21module_output_path = "${usb_manager_part_name}/usb_unittest_test" 22 23config("module_private_config") { 24 visibility = [ ":*" ] 25 26 include_dirs = [ 27 "include", 28 "${usb_manager_path}/test/common/include/", 29 ] 30} 31 32ohos_unittest("test_bulk_transfer") { 33 module_out_path = module_output_path 34 sources = [ 35 "src/usb_common_test.cpp", 36 "src/usb_submit_transfer_bulk_test.cpp", 37 ] 38 39 configs = [ 40 "${utils_path}:utils_config", 41 ":module_private_config", 42 ] 43 44 deps = [ 45 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 46 "${usb_manager_path}/services:usbservice", 47 ] 48 49 external_deps = [ 50 "ability_base:want", 51 "access_token:libaccesstoken_sdk", 52 "access_token:libnativetoken", 53 "access_token:libtoken_setproc", 54 "bundle_framework:appexecfwk_base", 55 "c_utils:utils", 56 "common_event_service:cesfwk_innerkits", 57 "drivers_interface_usb:libusb_proxy_1.0", 58 "eventhandler:libeventhandler", 59 "googletest:gtest_main", 60 "hilog:libhilog", 61 "ipc:ipc_core", 62 "safwk:system_ability_fwk", 63 "samgr:samgr_proxy", 64 ] 65} 66 67ohos_unittest("test_isochronous_transfer") { 68 module_out_path = module_output_path 69 sources = [ 70 "src/usb_common_test.cpp", 71 "src/usb_submit_transfer_isochronous_test.cpp", 72 ] 73 74 configs = [ 75 "${utils_path}:utils_config", 76 ":module_private_config", 77 ] 78 79 deps = [ 80 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 81 "${usb_manager_path}/services:usbservice", 82 ] 83 84 external_deps = [ 85 "ability_base:want", 86 "access_token:libaccesstoken_sdk", 87 "access_token:libnativetoken", 88 "access_token:libtoken_setproc", 89 "bundle_framework:appexecfwk_base", 90 "c_utils:utils", 91 "common_event_service:cesfwk_innerkits", 92 "drivers_interface_usb:libusb_proxy_1.0", 93 "eventhandler:libeventhandler", 94 "googletest:gtest_main", 95 "hilog:libhilog", 96 "ipc:ipc_core", 97 "safwk:system_ability_fwk", 98 "samgr:samgr_proxy", 99 ] 100} 101 102ohos_unittest("test_interrupt_transfer") { 103 module_out_path = module_output_path 104 sources = [ 105 "src/usb_common_test.cpp", 106 "src/usb_submit_transfer_interrupt_test.cpp", 107 ] 108 109 configs = [ 110 "${utils_path}:utils_config", 111 ":module_private_config", 112 ] 113 114 deps = [ 115 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 116 "${usb_manager_path}/services:usbservice", 117 ] 118 119 external_deps = [ 120 "ability_base:want", 121 "access_token:libaccesstoken_sdk", 122 "access_token:libnativetoken", 123 "access_token:libtoken_setproc", 124 "bundle_framework:appexecfwk_base", 125 "c_utils:utils", 126 "common_event_service:cesfwk_innerkits", 127 "drivers_interface_usb:libusb_proxy_1.0", 128 "eventhandler:libeventhandler", 129 "googletest:gtest_main", 130 "hilog:libhilog", 131 "ipc:ipc_core", 132 "safwk:system_ability_fwk", 133 "samgr:samgr_proxy", 134 ] 135} 136 137ohos_unittest("test_usbhubdevice") { 138 module_out_path = module_output_path 139 sanitize = { 140 integer_overflow = true 141 ubsan = true 142 boundary_sanitize = true 143 cfi = true 144 cfi_cross_dso = true 145 debug = false 146 } 147 branch_protector_ret = "pac_ret" 148 149 sources = [ 150 "src/usb_common_test.cpp", 151 "src/usb_hub_device_test.cpp", 152 ] 153 154 configs = [ 155 "${utils_path}:utils_config", 156 ":module_private_config", 157 ] 158 159 deps = [ 160 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 161 "${usb_manager_path}/services:usbservice", 162 ] 163 164 external_deps = [ 165 "ability_base:want", 166 "access_token:libaccesstoken_sdk", 167 "access_token:libnativetoken", 168 "access_token:libtoken_setproc", 169 "bundle_framework:appexecfwk_base", 170 "cJSON:cjson", 171 "c_utils:utils", 172 "common_event_service:cesfwk_innerkits", 173 "drivers_interface_usb:libusb_proxy_1.0", 174 "eventhandler:libeventhandler", 175 "googletest:gtest_main", 176 "hilog:libhilog", 177 "ipc:ipc_core", 178 "safwk:system_ability_fwk", 179 "samgr:samgr_proxy", 180 ] 181} 182 183ohos_unittest("test_usbdevicepipe") { 184 module_out_path = module_output_path 185 sources = [ 186 "src/usb_common_test.cpp", 187 "src/usb_device_pipe_test.cpp", 188 ] 189 190 configs = [ 191 "${utils_path}:utils_config", 192 ":module_private_config", 193 ] 194 195 deps = [ 196 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 197 "${usb_manager_path}/services:usbservice", 198 ] 199 200 external_deps = [ 201 "ability_base:want", 202 "access_token:libaccesstoken_sdk", 203 "access_token:libnativetoken", 204 "access_token:libtoken_setproc", 205 "bundle_framework:appexecfwk_base", 206 "c_utils:utils", 207 "common_event_service:cesfwk_innerkits", 208 "drivers_interface_usb:libusb_proxy_1.0", 209 "eventhandler:libeventhandler", 210 "googletest:gtest_main", 211 "hilog:libhilog", 212 "ipc:ipc_core", 213 "safwk:system_ability_fwk", 214 "samgr:samgr_proxy", 215 ] 216} 217 218ohos_unittest("test_bulkcallback") { 219 module_out_path = module_output_path 220 sources = [ 221 "${usb_manager_path}/test/common/src/usb_callback_test.cpp", 222 "src/usb_bulkcallback_test.cpp", 223 "src/usb_common_test.cpp", 224 ] 225 226 configs = [ 227 "${utils_path}:utils_config", 228 ":module_private_config", 229 ] 230 231 deps = [ 232 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 233 "${usb_manager_path}/services:usbservice", 234 ] 235 236 external_deps = [ 237 "ability_base:want", 238 "access_token:libaccesstoken_sdk", 239 "access_token:libnativetoken", 240 "access_token:libtoken_setproc", 241 "bundle_framework:appexecfwk_base", 242 "c_utils:utils", 243 "common_event_service:cesfwk_innerkits", 244 "drivers_interface_usb:libusb_proxy_1.0", 245 "eventhandler:libeventhandler", 246 "googletest:gtest_main", 247 "hilog:libhilog", 248 "ipc:ipc_core", 249 "safwk:system_ability_fwk", 250 "samgr:samgr_proxy", 251 ] 252} 253 254ohos_unittest("test_usbrequest") { 255 module_out_path = module_output_path 256 sources = [ 257 "src/usb_common_test.cpp", 258 "src/usb_request_test.cpp", 259 ] 260 261 configs = [ 262 "${utils_path}:utils_config", 263 ":module_private_config", 264 ] 265 266 deps = [ 267 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 268 "${usb_manager_path}/services:usbservice", 269 ] 270 271 external_deps = [ 272 "ability_base:want", 273 "access_token:libaccesstoken_sdk", 274 "access_token:libnativetoken", 275 "access_token:libtoken_setproc", 276 "bundle_framework:appexecfwk_base", 277 "c_utils:utils", 278 "common_event_service:cesfwk_innerkits", 279 "drivers_interface_usb:libusb_proxy_1.0", 280 "eventhandler:libeventhandler", 281 "googletest:gtest_main", 282 "hilog:libhilog", 283 "ipc:ipc_core", 284 "safwk:system_ability_fwk", 285 "samgr:samgr_proxy", 286 ] 287} 288 289ohos_unittest("test_usbcore") { 290 module_out_path = module_output_path 291 sources = [ 292 "src/usb_common_test.cpp", 293 "src/usb_core_test.cpp", 294 ] 295 296 configs = [ 297 "${utils_path}:utils_config", 298 ":module_private_config", 299 ] 300 301 deps = [ 302 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 303 "${usb_manager_path}/services:usbservice", 304 ] 305 306 external_deps = [ 307 "ability_base:want", 308 "access_token:libaccesstoken_sdk", 309 "access_token:libnativetoken", 310 "access_token:libtoken_setproc", 311 "bundle_framework:appexecfwk_base", 312 "c_utils:utils", 313 "common_event_service:cesfwk_innerkits", 314 "drivers_interface_usb:libusb_proxy_1.0", 315 "eventhandler:libeventhandler", 316 "googletest:gtest_main", 317 "hilog:libhilog", 318 "ipc:ipc_core", 319 "safwk:system_ability_fwk", 320 "samgr:samgr_proxy", 321 ] 322} 323 324ohos_unittest("test_usbevent") { 325 module_out_path = module_output_path 326 sources = [ "src/usb_event_test.cpp" ] 327 328 configs = [ 329 "${utils_path}:utils_config", 330 ":module_private_config", 331 ] 332 333 deps = [ 334 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 335 "${usb_manager_path}/services:usbservice", 336 ] 337 338 external_deps = [ 339 "ability_base:want", 340 "bundle_framework:appexecfwk_base", 341 "cJSON:cjson", 342 "c_utils:utils", 343 "common_event_service:cesfwk_innerkits", 344 "drivers_interface_usb:libusb_proxy_1.0", 345 "eventhandler:libeventhandler", 346 "googletest:gtest_main", 347 "hilog:libhilog", 348 "ipc:ipc_core", 349 "safwk:system_ability_fwk", 350 "samgr:samgr_proxy", 351 ] 352 353 if (usb_manage_feature_support_port_change) { 354 if (defined(defines)) { 355 defines += [ "SUPPORT_PORT_CHNAGE_TEST" ] 356 } else { 357 defines = [ "SUPPORT_PORT_CHNAGE_TEST" ] 358 } 359 } 360} 361 362ohos_unittest("test_usbmanageinterface") { 363 module_out_path = module_output_path 364 sources = [ 365 "src/usb_common_test.cpp", 366 "src/usb_manage_interface_test.cpp", 367 ] 368 369 configs = [ 370 "${utils_path}:utils_config", 371 ":module_private_config", 372 ] 373 374 deps = [ 375 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 376 "${usb_manager_path}/services:usbservice", 377 ] 378 379 external_deps = [ 380 "ability_base:want", 381 "access_token:libaccesstoken_sdk", 382 "access_token:libnativetoken", 383 "access_token:libtoken_setproc", 384 "bundle_framework:appexecfwk_base", 385 "c_utils:utils", 386 "common_event_service:cesfwk_innerkits", 387 "drivers_interface_usb:libusb_proxy_1.0", 388 "eventhandler:libeventhandler", 389 "googletest:gtest_main", 390 "hilog:libhilog", 391 "ipc:ipc_core", 392 "safwk:system_ability_fwk", 393 "samgr:samgr_proxy", 394 ] 395} 396 397ohos_unittest("test_usbdevicestatus") { 398 module_out_path = module_output_path 399 sources = [ 400 "src/usb_common_test.cpp", 401 "src/usb_device_status_test.cpp", 402 ] 403 404 configs = [ 405 "${utils_path}:utils_config", 406 ":module_private_config", 407 ] 408 409 deps = [ 410 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 411 "${usb_manager_path}/services:usbservice", 412 ] 413 414 external_deps = [ 415 "ability_base:want", 416 "access_token:libaccesstoken_sdk", 417 "access_token:libnativetoken", 418 "access_token:libtoken_setproc", 419 "bundle_framework:appexecfwk_base", 420 "c_utils:utils", 421 "common_event_service:cesfwk_innerkits", 422 "drivers_interface_usb:libusb_proxy_1.2", 423 "eventhandler:libeventhandler", 424 "googletest:gtest_main", 425 "hilog:libhilog", 426 "ipc:ipc_core", 427 "safwk:system_ability_fwk", 428 "samgr:samgr_proxy", 429 ] 430} 431 432ohos_unittest("test_usbdfx") { 433 module_out_path = module_output_path 434 sources = [ 435 "src/usb_common_test.cpp", 436 "src/usb_dfx_test.cpp", 437 ] 438 439 configs = [ 440 "${utils_path}:utils_config", 441 ":module_private_config", 442 ] 443 444 deps = [ 445 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 446 "${usb_manager_path}/services:usbservice", 447 ] 448 449 external_deps = [ 450 "ability_base:want", 451 "access_token:libaccesstoken_sdk", 452 "access_token:libnativetoken", 453 "access_token:libtoken_setproc", 454 "bundle_framework:appexecfwk_base", 455 "cJSON:cjson", 456 "c_utils:utils", 457 "common_event_service:cesfwk_innerkits", 458 "drivers_interface_usb:libusb_proxy_1.0", 459 "eventhandler:libeventhandler", 460 "googletest:gtest_main", 461 "hilog:libhilog", 462 "ipc:ipc_core", 463 "safwk:system_ability_fwk", 464 "samgr:samgr_proxy", 465 ] 466} 467 468group("unittest") { 469 testonly = true 470 deps = [ 471 ":test_bulk_transfer", 472 ":test_bulkcallback", 473 ":test_interrupt_transfer", 474 ":test_isochronous_transfer", 475 ":test_usbcore", 476 ":test_usbdevicepipe", 477 ":test_usbdevicestatus", 478 ":test_usbdfx", 479 ":test_usbevent", 480 ":test_usbhubdevice", 481 ":test_usbmanageinterface", 482 ":test_usbrequest", 483 ] 484} 485