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("//build/test.gni") 15import("./../../../usb.gni") 16 17module_output_path = "drivers_peripheral_usb/usb" 18 19config("module_private_config") { 20 visibility = [ ":*" ] 21 22 include_dirs = [ 23 "include", 24 "${usb_driver_path}/test/UsbSubscriberTest", 25 "${usb_driver_path}/utils/include", 26 ] 27} 28 29ohos_unittest("test_transfer") { 30 sources = [ 31 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 32 "src/usbd_transfer_test.cpp", 33 ] 34 35 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 36 37 configs = [ ":module_private_config" ] 38 39 deps = [ 40 "${usb_driver_path}/ddk:libusb_core", 41 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 42 ] 43 44 if (is_standard_system) { 45 external_deps = [ 46 "drivers_interface_usb:libusb_proxy_1.2", 47 "eventhandler:libeventhandler", 48 "googletest:gtest_main", 49 "hdf_core:libhdf_utils", 50 "hilog:libhilog", 51 "ipc:ipc_single", 52 "safwk:system_ability_fwk", 53 ] 54 55 if (usb_samgr_enable) { 56 external_deps += [ "samgr:samgr_proxy" ] 57 58 if (defined(defines)) { 59 defines += [ "USB_ENABLE_SAMGR" ] 60 } else { 61 defines = [ "USB_ENABLE_SAMGR" ] 62 } 63 } 64 65 if (usb_c_utils_enable) { 66 external_deps += [ "c_utils:utils" ] 67 } 68 } else { 69 external_deps = [ "hilog:libhilog" ] 70 } 71 module_out_path = module_output_path 72} 73ohos_unittest("test_device") { 74 sources = [ 75 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 76 "src/usbd_device_test.cpp", 77 ] 78 79 include_dirs = [ 80 "${usb_driver_path}/test/UsbSubscriberTest", 81 "${usb_driver_path}/utils/include", 82 ] 83 84 configs = [ ":module_private_config" ] 85 86 deps = [ 87 "${usb_driver_path}/ddk:libusb_core", 88 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 89 ] 90 91 if (is_standard_system) { 92 external_deps = [ 93 "drivers_interface_usb:libusb_proxy_1.2", 94 "eventhandler:libeventhandler", 95 "googletest:gtest_main", 96 "hdf_core:libhdf_utils", 97 "hilog:libhilog", 98 "ipc:ipc_single", 99 "safwk:system_ability_fwk", 100 ] 101 102 if (usb_samgr_enable) { 103 external_deps += [ "samgr:samgr_proxy" ] 104 105 if (defined(defines)) { 106 defines += [ "USB_ENABLE_SAMGR" ] 107 } else { 108 defines = [ "USB_ENABLE_SAMGR" ] 109 } 110 } 111 112 if (usb_c_utils_enable) { 113 external_deps += [ "c_utils:utils" ] 114 } 115 } else { 116 external_deps = [ "hilog:libhilog" ] 117 } 118 module_out_path = module_output_path 119} 120 121ohos_unittest("test_function") { 122 sources = [ "src/usbd_function_test.cpp" ] 123 124 configs = [ ":module_private_config" ] 125 126 deps = [ 127 "${usb_driver_path}/ddk:libusb_core", 128 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 129 ] 130 131 if (is_standard_system) { 132 external_deps = [ 133 "drivers_interface_usb:libusb_proxy_1.2", 134 "eventhandler:libeventhandler", 135 "googletest:gtest_main", 136 "hdf_core:libhdf_host", 137 "hdf_core:libhdf_utils", 138 "hilog:libhilog", 139 "ipc:ipc_single", 140 "safwk:system_ability_fwk", 141 ] 142 143 if (usb_samgr_enable) { 144 external_deps += [ "samgr:samgr_proxy" ] 145 146 if (defined(defines)) { 147 defines += [ "USB_ENABLE_SAMGR" ] 148 } else { 149 defines = [ "USB_ENABLE_SAMGR" ] 150 } 151 } 152 153 if (usb_c_utils_enable) { 154 external_deps += [ "c_utils:utils" ] 155 } 156 } else { 157 external_deps = [ "hilog:libhilog" ] 158 } 159 module_out_path = module_output_path 160} 161 162ohos_unittest("test_request") { 163 sources = [ 164 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 165 "src/usbd_interface_test.cpp", 166 "src/usbd_request_test.cpp", 167 ] 168 169 include_dirs = [ 170 "${usb_driver_path}/test/UsbSubscriberTest", 171 "${usb_driver_path}/utils/include", 172 ] 173 174 configs = [ ":module_private_config" ] 175 176 deps = [ 177 "${usb_driver_path}/ddk:libusb_core", 178 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 179 ] 180 181 if (is_standard_system) { 182 external_deps = [ 183 "drivers_interface_usb:libusb_proxy_1.2", 184 "eventhandler:libeventhandler", 185 "googletest:gtest_main", 186 "hdf_core:libhdf_utils", 187 "hilog:libhilog", 188 "ipc:ipc_single", 189 "safwk:system_ability_fwk", 190 ] 191 192 if (usb_samgr_enable) { 193 external_deps += [ "samgr:samgr_proxy" ] 194 195 if (defined(defines)) { 196 defines += [ "USB_ENABLE_SAMGR" ] 197 } else { 198 defines = [ "USB_ENABLE_SAMGR" ] 199 } 200 } 201 202 if (usb_c_utils_enable) { 203 external_deps += [ "c_utils:utils" ] 204 } 205 } else { 206 external_deps = [ "hilog:libhilog" ] 207 } 208 module_out_path = module_output_path 209} 210 211ohos_unittest("test_usbfnmtp") { 212 sources = [ "src/usbfn_mtp_test.cpp" ] 213 214 configs = [ ":module_private_config" ] 215 216 deps = [ 217 "${usb_driver_path}/ddk:libusb_core", 218 "${usb_driver_path}/gadget/function/mtp:libusbfn_mtp_interface_service_1.0", 219 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 220 ] 221 222 if (is_standard_system) { 223 external_deps = [ 224 "drivers_interface_usb:libusb_proxy_1.2", 225 "drivers_interface_usb:libusbfn_mtp_proxy_1.0", 226 "eventhandler:libeventhandler", 227 "googletest:gtest_main", 228 "hdf_core:libhdf_host", 229 "hdf_core:libhdf_utils", 230 "hilog:libhilog", 231 "ipc:ipc_single", 232 ] 233 if (usb_c_utils_enable) { 234 external_deps += [ "c_utils:utils" ] 235 } 236 } else { 237 external_deps = [ "hilog:libhilog" ] 238 } 239 module_out_path = module_output_path 240} 241 242ohos_unittest("test_manageinterface") { 243 sources = [ 244 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 245 "src/usbd_manage_interface_test.cpp", 246 ] 247 248 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 249 250 configs = [ ":module_private_config" ] 251 252 deps = [ 253 "${usb_driver_path}/ddk:libusb_core", 254 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 255 ] 256 257 if (is_standard_system) { 258 external_deps = [ 259 "drivers_interface_usb:libusb_proxy_1.2", 260 "eventhandler:libeventhandler", 261 "googletest:gtest_main", 262 "hdf_core:libhdf_utils", 263 "hilog:libhilog", 264 "ipc:ipc_single", 265 "safwk:system_ability_fwk", 266 ] 267 268 if (usb_samgr_enable) { 269 external_deps += [ "samgr:samgr_proxy" ] 270 271 if (defined(defines)) { 272 defines += [ "USB_ENABLE_SAMGR" ] 273 } else { 274 defines = [ "USB_ENABLE_SAMGR" ] 275 } 276 } 277 278 if (usb_c_utils_enable) { 279 external_deps += [ "c_utils:utils" ] 280 } 281 } else { 282 external_deps = [ "hilog:libhilog" ] 283 } 284 module_out_path = module_output_path 285} 286 287ohos_unittest("test_devicestatus") { 288 sources = [ 289 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 290 "src/usbd_device_status_test.cpp", 291 ] 292 293 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 294 295 configs = [ ":module_private_config" ] 296 297 deps = [ 298 "${usb_driver_path}/ddk:libusb_core", 299 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 300 ] 301 302 if (is_standard_system) { 303 external_deps = [ 304 "drivers_interface_usb:libusb_proxy_1.2", 305 "eventhandler:libeventhandler", 306 "googletest:gtest_main", 307 "hdf_core:libhdf_utils", 308 "hilog:libhilog", 309 "ipc:ipc_single", 310 "safwk:system_ability_fwk", 311 ] 312 313 if (usb_samgr_enable) { 314 external_deps += [ "samgr:samgr_proxy" ] 315 316 if (defined(defines)) { 317 defines += [ "USB_ENABLE_SAMGR" ] 318 } else { 319 defines = [ "USB_ENABLE_SAMGR" ] 320 } 321 } 322 323 if (usb_c_utils_enable) { 324 external_deps += [ "c_utils:utils" ] 325 } 326 } else { 327 external_deps = [ "hilog:libhilog" ] 328 } 329 module_out_path = module_output_path 330} 331 332ohos_unittest("test_accessory") { 333 sources = [ 334 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 335 "src/usbd_accessory_test.cpp", 336 ] 337 338 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 339 340 configs = [ ":module_private_config" ] 341 342 deps = [ 343 "${usb_driver_path}/ddk:libusb_core", 344 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 345 ] 346 347 if (is_standard_system) { 348 external_deps = [ 349 "drivers_interface_usb:libusb_proxy_1.2", 350 "eventhandler:libeventhandler", 351 "googletest:gtest_main", 352 "hdf_core:libhdf_utils", 353 "hilog:libhilog", 354 "ipc:ipc_single", 355 "safwk:system_ability_fwk", 356 ] 357 358 if (usb_samgr_enable) { 359 external_deps += [ "samgr:samgr_proxy" ] 360 361 if (defined(defines)) { 362 defines += [ "USB_ENABLE_SAMGR" ] 363 } else { 364 defines = [ "USB_ENABLE_SAMGR" ] 365 } 366 } 367 368 if (usb_c_utils_enable) { 369 external_deps += [ "c_utils:utils" ] 370 } 371 } else { 372 external_deps = [ "hilog:libhilog" ] 373 } 374 module_out_path = module_output_path 375} 376 377ohos_unittest("test_interrupt_transfer") { 378 sources = [ 379 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 380 "src/usbd_interrupt_transfer_test.cpp", 381 ] 382 383 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 384 385 configs = [ ":module_private_config" ] 386 387 deps = [ 388 "${usb_driver_path}/ddk:libusb_core", 389 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 390 ] 391 392 if (is_standard_system) { 393 external_deps = [ 394 "drivers_interface_usb:libusb_proxy_1.2", 395 "eventhandler:libeventhandler", 396 "googletest:gtest_main", 397 "hdf_core:libhdf_utils", 398 "hilog:libhilog", 399 "ipc:ipc_single", 400 "safwk:system_ability_fwk", 401 ] 402 403 if (usb_samgr_enable) { 404 external_deps += [ "samgr:samgr_proxy" ] 405 406 if (defined(defines)) { 407 defines += [ "USB_ENABLE_SAMGR" ] 408 } else { 409 defines = [ "USB_ENABLE_SAMGR" ] 410 } 411 } 412 413 if (usb_c_utils_enable) { 414 external_deps += [ "c_utils:utils" ] 415 } 416 } else { 417 external_deps = [ "hilog:libhilog" ] 418 } 419 module_out_path = module_output_path 420} 421 422ohos_unittest("test_asyncBulkTransfer") { 423 sources = [ 424 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 425 "src/usbd_async_bulk_transfer_test.cpp", 426 ] 427 428 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 429 430 configs = [ ":module_private_config" ] 431 432 deps = [ 433 "${usb_driver_path}/ddk:libusb_core", 434 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 435 "${usb_driver_path}/libusb_adapter:libusb_adapter", 436 ] 437 438 if (is_standard_system) { 439 external_deps = [ 440 "drivers_interface_usb:libusb_proxy_1.2", 441 "eventhandler:libeventhandler", 442 "googletest:gtest_main", 443 "hdf_core:libhdf_utils", 444 "hilog:libhilog", 445 "ipc:ipc_single", 446 "libusb:libusb", 447 "safwk:system_ability_fwk", 448 ] 449 450 if (usb_samgr_enable) { 451 external_deps += [ "samgr:samgr_proxy" ] 452 453 if (defined(defines)) { 454 defines += [ "USB_ENABLE_SAMGR" ] 455 } else { 456 defines = [ "USB_ENABLE_SAMGR" ] 457 } 458 } 459 460 if (usb_c_utils_enable) { 461 external_deps += [ "c_utils:utils" ] 462 } 463 } else { 464 external_deps = [ "hilog:libhilog" ] 465 } 466 module_out_path = module_output_path 467} 468 469ohos_unittest("test_asyncInterruptTransfer") { 470 sources = [ 471 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 472 "src/usbd_async_interrupt_transfer_test.cpp", 473 ] 474 475 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 476 477 configs = [ ":module_private_config" ] 478 479 deps = [ 480 "${usb_driver_path}/ddk:libusb_core", 481 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 482 "${usb_driver_path}/libusb_adapter:libusb_adapter", 483 ] 484 485 if (is_standard_system) { 486 external_deps = [ 487 "drivers_interface_usb:libusb_proxy_1.2", 488 "eventhandler:libeventhandler", 489 "googletest:gtest_main", 490 "hdf_core:libhdf_utils", 491 "hilog:libhilog", 492 "ipc:ipc_single", 493 "libusb:libusb", 494 "safwk:system_ability_fwk", 495 ] 496 497 if (usb_samgr_enable) { 498 external_deps += [ "samgr:samgr_proxy" ] 499 500 if (defined(defines)) { 501 defines += [ "USB_ENABLE_SAMGR" ] 502 } else { 503 defines = [ "USB_ENABLE_SAMGR" ] 504 } 505 } 506 507 if (usb_c_utils_enable) { 508 external_deps += [ "c_utils:utils" ] 509 } 510 } else { 511 external_deps = [ "hilog:libhilog" ] 512 } 513 module_out_path = module_output_path 514} 515 516ohos_unittest("test_asyncIsoTransfer") { 517 sources = [ 518 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 519 "src/usbd_async_iso_transfer_test.cpp", 520 ] 521 522 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 523 524 configs = [ ":module_private_config" ] 525 526 deps = [ 527 "${usb_driver_path}/ddk:libusb_core", 528 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 529 "${usb_driver_path}/libusb_adapter:libusb_adapter", 530 ] 531 532 if (is_standard_system) { 533 external_deps = [ 534 "drivers_interface_usb:libusb_proxy_1.2", 535 "eventhandler:libeventhandler", 536 "googletest:gtest_main", 537 "hdf_core:libhdf_utils", 538 "hilog:libhilog", 539 "ipc:ipc_single", 540 "libusb:libusb", 541 "safwk:system_ability_fwk", 542 ] 543 544 if (usb_samgr_enable) { 545 external_deps += [ "samgr:samgr_proxy" ] 546 547 if (defined(defines)) { 548 defines += [ "USB_ENABLE_SAMGR" ] 549 } else { 550 defines = [ "USB_ENABLE_SAMGR" ] 551 } 552 } 553 554 if (usb_c_utils_enable) { 555 external_deps += [ "c_utils:utils" ] 556 } 557 } else { 558 external_deps = [ "hilog:libhilog" ] 559 } 560 module_out_path = module_output_path 561} 562 563ohos_unittest("test_serial") { 564 sources = [ "src/usbd_serial_test.cpp" ] 565 566 configs = [ ":module_private_config" ] 567 568 deps = [ "${usb_driver_path}/serial:libserial_interface_service_1.0" ] 569 570 if (is_standard_system) { 571 external_deps = [ 572 "drivers_interface_usb:libserial_proxy_1.0", 573 "drivers_interface_usb:libserial_stub_1.0", 574 "eventhandler:libeventhandler", 575 "googletest:gtest_main", 576 "hdf_core:libhdf_host", 577 "hdf_core:libhdf_utils", 578 "hilog:libhilog", 579 "ipc:ipc_single", 580 "safwk:system_ability_fwk", 581 ] 582 583 if (usb_samgr_enable) { 584 external_deps += [ "samgr:samgr_proxy" ] 585 586 if (defined(defines)) { 587 defines += [ "USB_ENABLE_SAMGR" ] 588 } else { 589 defines = [ "USB_ENABLE_SAMGR" ] 590 } 591 } 592 593 if (usb_c_utils_enable) { 594 external_deps += [ "c_utils:utils" ] 595 } 596 } else { 597 external_deps = [ "hilog:libhilog" ] 598 } 599 module_out_path = module_output_path 600} 601 602group("hal_test") { 603 testonly = true 604 deps = [] 605} 606