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/drivers_peripheral_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 "googletest:gtest_main", 48 "hdf_core:libhdf_utils", 49 "hilog:libhilog", 50 "ipc:ipc_single", 51 ] 52 53 if (usb_samgr_enable) { 54 external_deps += [ "samgr:samgr_proxy" ] 55 56 if (defined(defines)) { 57 defines += [ "USB_ENABLE_SAMGR" ] 58 } else { 59 defines = [ "USB_ENABLE_SAMGR" ] 60 } 61 } 62 63 if (usb_c_utils_enable) { 64 external_deps += [ "c_utils:utils" ] 65 } 66 } else { 67 external_deps = [ "hilog:libhilog" ] 68 } 69 module_out_path = module_output_path 70} 71 72ohos_unittest("test_hubdevice") { 73 sources = [ 74 "src/usbd_hub_device_test.cpp", 75 ] 76 77 include_dirs = [ 78 "${usb_driver_path}/utils/include", 79 ] 80 81 configs = [ ":module_private_config" ] 82 83 deps = [ 84 "${usb_driver_path}/ddk:libusb_core", 85 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 86 ] 87 88 if (is_standard_system) { 89 external_deps = [ 90 "drivers_interface_usb:libusb_proxy_1.2", 91 "googletest:gtest_main", 92 "hdf_core:libhdf_utils", 93 "hilog:libhilog", 94 "ipc:ipc_single", 95 "drivers_interface_usb:libusb_proxy_2.0", 96 ] 97 98 if (usb_samgr_enable) { 99 external_deps += [ "samgr:samgr_proxy" ] 100 101 if (defined(defines)) { 102 defines += [ "USB_ENABLE_SAMGR" ] 103 } else { 104 defines = [ "USB_ENABLE_SAMGR" ] 105 } 106 } 107 108 if (usb_c_utils_enable) { 109 external_deps += [ "c_utils:utils" ] 110 } 111 } else { 112 external_deps = [ "hilog:libhilog" ] 113 } 114 module_out_path = module_output_path 115} 116 117ohos_unittest("test_device") { 118 sources = [ 119 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 120 "src/usbd_device_test.cpp", 121 ] 122 123 include_dirs = [ 124 "${usb_driver_path}/test/UsbSubscriberTest", 125 "${usb_driver_path}/utils/include", 126 ] 127 128 configs = [ ":module_private_config" ] 129 130 deps = [ 131 "${usb_driver_path}/ddk:libusb_core", 132 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 133 ] 134 135 if (is_standard_system) { 136 external_deps = [ 137 "drivers_interface_usb:libusb_proxy_1.2", 138 "googletest:gtest_main", 139 "hdf_core:libhdf_utils", 140 "hilog:libhilog", 141 "ipc:ipc_single", 142 ] 143 144 if (usb_samgr_enable) { 145 external_deps += [ "samgr:samgr_proxy" ] 146 147 if (defined(defines)) { 148 defines += [ "USB_ENABLE_SAMGR" ] 149 } else { 150 defines = [ "USB_ENABLE_SAMGR" ] 151 } 152 } 153 154 if (usb_c_utils_enable) { 155 external_deps += [ "c_utils:utils" ] 156 } 157 } else { 158 external_deps = [ "hilog:libhilog" ] 159 } 160 module_out_path = module_output_path 161} 162 163ohos_unittest("test_function") { 164 sources = [ "src/usbd_function_test.cpp" ] 165 166 configs = [ ":module_private_config" ] 167 168 deps = [ 169 "${usb_driver_path}/ddk:libusb_core", 170 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 171 "${usb_driver_path}/hdi_service:libusb_port_interface_service_2.0", 172 ] 173 174 if (is_standard_system) { 175 external_deps = [ 176 "drivers_interface_usb:libusb_proxy_1.0", 177 "drivers_interface_usb:libusb_proxy_1.1", 178 "drivers_interface_usb:libusb_proxy_1.2", 179 "drivers_interface_usb:libusb_proxy_2.0", 180 "googletest:gtest_main", 181 "hdf_core:libhdf_host", 182 "hdf_core:libhdf_utils", 183 "hilog:libhilog", 184 "ipc:ipc_single", 185 ] 186 187 if (usb_samgr_enable) { 188 external_deps += [ "samgr:samgr_proxy" ] 189 190 if (defined(defines)) { 191 defines += [ "USB_ENABLE_SAMGR" ] 192 } else { 193 defines = [ "USB_ENABLE_SAMGR" ] 194 } 195 } 196 197 if (usb_c_utils_enable) { 198 external_deps += [ "c_utils:utils" ] 199 } 200 } else { 201 external_deps = [ "hilog:libhilog" ] 202 } 203 module_out_path = module_output_path 204} 205 206ohos_unittest("test_request") { 207 sources = [ 208 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 209 "src/usbd_interface_test.cpp", 210 "src/usbd_request_test.cpp", 211 ] 212 213 include_dirs = [ 214 "${usb_driver_path}/test/UsbSubscriberTest", 215 "${usb_driver_path}/utils/include", 216 ] 217 218 configs = [ ":module_private_config" ] 219 220 deps = [ 221 "${usb_driver_path}/ddk:libusb_core", 222 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 223 ] 224 225 if (is_standard_system) { 226 external_deps = [ 227 "drivers_interface_usb:libusb_proxy_1.0", 228 "drivers_interface_usb:libusb_proxy_1.1", 229 "drivers_interface_usb:libusb_proxy_1.2", 230 "googletest:gtest_main", 231 "hdf_core:libhdf_utils", 232 "hilog:libhilog", 233 "ipc:ipc_single", 234 ] 235 236 if (usb_samgr_enable) { 237 external_deps += [ "samgr:samgr_proxy" ] 238 239 if (defined(defines)) { 240 defines += [ "USB_ENABLE_SAMGR" ] 241 } else { 242 defines = [ "USB_ENABLE_SAMGR" ] 243 } 244 } 245 246 if (usb_c_utils_enable) { 247 external_deps += [ "c_utils:utils" ] 248 } 249 } else { 250 external_deps = [ "hilog:libhilog" ] 251 } 252 module_out_path = module_output_path 253} 254 255ohos_unittest("test_usbfnmtp") { 256 sources = [ "src/usbfn_mtp_test.cpp" ] 257 258 configs = [ ":module_private_config" ] 259 260 deps = [ 261 "${usb_driver_path}/ddk:libusb_core", 262 "${usb_driver_path}/gadget/function/mtp:libusbfn_mtp_interface_service_1.0", 263 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 264 ] 265 266 if (is_standard_system) { 267 external_deps = [ 268 "drivers_interface_usb:libusb_proxy_1.0", 269 "drivers_interface_usb:libusb_proxy_1.1", 270 "drivers_interface_usb:libusb_proxy_1.2", 271 "drivers_interface_usb:libusbfn_mtp_proxy_1.0", 272 "googletest:gtest_main", 273 "hdf_core:libhdf_host", 274 "hdf_core:libhdf_utils", 275 "hilog:libhilog", 276 "ipc:ipc_single", 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_manageinterface") { 288 sources = [ 289 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 290 "src/usbd_manage_interface_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.0", 305 "drivers_interface_usb:libusb_proxy_1.1", 306 "drivers_interface_usb:libusb_proxy_1.2", 307 "googletest:gtest_main", 308 "hdf_core:libhdf_utils", 309 "hilog:libhilog", 310 "ipc:ipc_single", 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_devicestatus") { 333 sources = [ 334 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 335 "src/usbd_device_status_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 "googletest:gtest_main", 351 "hdf_core:libhdf_utils", 352 "hilog:libhilog", 353 "ipc:ipc_single", 354 ] 355 356 if (usb_samgr_enable) { 357 external_deps += [ "samgr:samgr_proxy" ] 358 359 if (defined(defines)) { 360 defines += [ "USB_ENABLE_SAMGR" ] 361 } else { 362 defines = [ "USB_ENABLE_SAMGR" ] 363 } 364 } 365 366 if (usb_c_utils_enable) { 367 external_deps += [ "c_utils:utils" ] 368 } 369 } else { 370 external_deps = [ "hilog:libhilog" ] 371 } 372 module_out_path = module_output_path 373} 374 375ohos_unittest("test_accessory") { 376 sources = [ 377 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 378 "src/usbd_accessory_test.cpp", 379 ] 380 381 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 382 383 configs = [ ":module_private_config" ] 384 385 deps = [ 386 "${usb_driver_path}/ddk:libusb_core", 387 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 388 ] 389 390 if (is_standard_system) { 391 external_deps = [ 392 "drivers_interface_usb:libusb_proxy_1.2", 393 "googletest:gtest_main", 394 "hdf_core:libhdf_utils", 395 "hilog:libhilog", 396 "ipc:ipc_single", 397 ] 398 399 if (usb_samgr_enable) { 400 external_deps += [ "samgr:samgr_proxy" ] 401 402 if (defined(defines)) { 403 defines += [ "USB_ENABLE_SAMGR" ] 404 } else { 405 defines = [ "USB_ENABLE_SAMGR" ] 406 } 407 } 408 409 if (usb_c_utils_enable) { 410 external_deps += [ "c_utils:utils" ] 411 } 412 } else { 413 external_deps = [ "hilog:libhilog" ] 414 } 415 module_out_path = module_output_path 416} 417 418ohos_unittest("test_interrupt_transfer") { 419 sources = [ 420 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 421 "src/usbd_interrupt_transfer_test.cpp", 422 ] 423 424 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 425 426 configs = [ ":module_private_config" ] 427 428 deps = [ 429 "${usb_driver_path}/ddk:libusb_core", 430 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 431 ] 432 433 if (is_standard_system) { 434 external_deps = [ 435 "drivers_interface_usb:libusb_proxy_1.2", 436 "googletest:gtest_main", 437 "hdf_core:libhdf_utils", 438 "hilog:libhilog", 439 "ipc:ipc_single", 440 ] 441 442 if (usb_samgr_enable) { 443 external_deps += [ "samgr:samgr_proxy" ] 444 445 if (defined(defines)) { 446 defines += [ "USB_ENABLE_SAMGR" ] 447 } else { 448 defines = [ "USB_ENABLE_SAMGR" ] 449 } 450 } 451 452 if (usb_c_utils_enable) { 453 external_deps += [ "c_utils:utils" ] 454 } 455 } else { 456 external_deps = [ "hilog:libhilog" ] 457 } 458 module_out_path = module_output_path 459} 460 461ohos_unittest("test_asyncBulkTransfer") { 462 sources = [ 463 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 464 "src/usbd_async_bulk_transfer_test.cpp", 465 ] 466 467 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 468 469 configs = [ ":module_private_config" ] 470 471 deps = [ 472 "${usb_driver_path}/ddk:libusb_core", 473 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 474 "${usb_driver_path}/libusb_adapter:libusb_adapter", 475 ] 476 477 if (is_standard_system) { 478 external_deps = [ 479 "drivers_interface_usb:libusb_proxy_1.2", 480 "googletest:gtest_main", 481 "hdf_core:libhdf_utils", 482 "hilog:libhilog", 483 "ipc:ipc_single", 484 "libusb:libusb", 485 ] 486 487 if (usb_samgr_enable) { 488 external_deps += [ "samgr:samgr_proxy" ] 489 490 if (defined(defines)) { 491 defines += [ "USB_ENABLE_SAMGR" ] 492 } else { 493 defines = [ "USB_ENABLE_SAMGR" ] 494 } 495 } 496 497 if (usb_c_utils_enable) { 498 external_deps += [ "c_utils:utils" ] 499 } 500 } else { 501 external_deps = [ "hilog:libhilog" ] 502 } 503 module_out_path = module_output_path 504} 505 506ohos_unittest("test_asyncInterruptTransfer") { 507 sources = [ 508 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 509 "src/usbd_async_interrupt_transfer_test.cpp", 510 ] 511 512 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 513 514 configs = [ ":module_private_config" ] 515 516 deps = [ 517 "${usb_driver_path}/ddk:libusb_core", 518 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 519 "${usb_driver_path}/libusb_adapter:libusb_adapter", 520 ] 521 522 if (is_standard_system) { 523 external_deps = [ 524 "drivers_interface_usb:libusb_proxy_1.2", 525 "googletest:gtest_main", 526 "hdf_core:libhdf_utils", 527 "hilog:libhilog", 528 "ipc:ipc_single", 529 "libusb:libusb", 530 ] 531 532 if (usb_samgr_enable) { 533 external_deps += [ "samgr:samgr_proxy" ] 534 535 if (defined(defines)) { 536 defines += [ "USB_ENABLE_SAMGR" ] 537 } else { 538 defines = [ "USB_ENABLE_SAMGR" ] 539 } 540 } 541 542 if (usb_c_utils_enable) { 543 external_deps += [ "c_utils:utils" ] 544 } 545 } else { 546 external_deps = [ "hilog:libhilog" ] 547 } 548 module_out_path = module_output_path 549} 550 551ohos_unittest("test_asyncIsoTransfer") { 552 sources = [ 553 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 554 "src/usbd_async_iso_transfer_test.cpp", 555 ] 556 557 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 558 559 configs = [ ":module_private_config" ] 560 561 deps = [ 562 "${usb_driver_path}/ddk:libusb_core", 563 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 564 "${usb_driver_path}/libusb_adapter:libusb_adapter", 565 ] 566 567 if (is_standard_system) { 568 external_deps = [ 569 "drivers_interface_usb:libusb_proxy_1.2", 570 "googletest:gtest_main", 571 "hdf_core:libhdf_utils", 572 "hilog:libhilog", 573 "ipc:ipc_single", 574 "libusb:libusb", 575 ] 576 577 if (usb_samgr_enable) { 578 external_deps += [ "samgr:samgr_proxy" ] 579 580 if (defined(defines)) { 581 defines += [ "USB_ENABLE_SAMGR" ] 582 } else { 583 defines = [ "USB_ENABLE_SAMGR" ] 584 } 585 } 586 587 if (usb_c_utils_enable) { 588 external_deps += [ "c_utils:utils" ] 589 } 590 } else { 591 external_deps = [ "hilog:libhilog" ] 592 } 593 module_out_path = module_output_path 594} 595 596ohos_unittest("test_serial") { 597 sources = [ "src/usbd_serial_test.cpp" ] 598 599 configs = [ ":module_private_config" ] 600 601 deps = [ "${usb_driver_path}/serial:libserial_interface_service_1.0" ] 602 603 if (is_standard_system) { 604 external_deps = [ 605 "drivers_interface_usb:libserial_proxy_1.0", 606 "drivers_interface_usb:libserial_stub_1.0", 607 "googletest:gtest_main", 608 "hdf_core:libhdf_host", 609 "hdf_core:libhdf_utils", 610 "hilog:libhilog", 611 "ipc:ipc_single", 612 ] 613 614 if (usb_samgr_enable) { 615 external_deps += [ "samgr:samgr_proxy" ] 616 617 if (defined(defines)) { 618 defines += [ "USB_ENABLE_SAMGR" ] 619 } else { 620 defines = [ "USB_ENABLE_SAMGR" ] 621 } 622 } 623 624 if (usb_c_utils_enable) { 625 external_deps += [ "c_utils:utils" ] 626 } 627 } else { 628 external_deps = [ "hilog:libhilog" ] 629 } 630 module_out_path = module_output_path 631} 632 633group("hal_test") { 634 testonly = true 635 deps = [] 636} 637