1# Copyright (c) 2021 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/ohos.gni") 15 16import("//build/ohos_var.gni") 17import("//build/test.gni") 18import("../../ffrt.gni") 19 20module_output_path = "ffrt/ffrt" 21 22gtest_public_external_deps = [ "googletest:gtest_main" ] 23 24ffrt_ut_base_cflags_cc = [ 25 "-frtti", 26 "-Xclang", 27 "-fcxx-exceptions", 28 "-std=c++11", 29 "-DFFRT_PERF_EVENT_ENABLE", 30 "-DFFRT_WORKER_MONITOR", 31 "-DFFRT_BBOX_ENABLE", 32] 33 34ffrt_ut_base_deps = [ "../..:libffrt" ] 35 36ffrt_ut_base_external_deps = [ 37 "c_utils:utils", 38 "faultloggerd:libbacktrace_local", 39 "faultloggerd:libdfx_dumpcatcher", 40 "googletest:gtest", 41 "hilog:libhilog", 42 "hisysevent:libhisysevent", 43] 44 45config("ffrt_test_config") { 46 include_dirs = [ 47 "../../src", 48 "../../src/dfx/log", 49 "../../src/dfx/trace", 50 "../../src/dfx/trace_record", 51 "../../src/sched", 52 ] 53 54 cflags = [ 55 "-fno-rtti", 56 "-Wno-unused-variable", 57 "-Wno-unused-function", 58 ] 59 60 defines = [ 61 "QOS_INTERVAL", 62 "QOS_DISPATCH", 63 "QOS_RTG", 64 "QOS_MULTI_RTG", 65 "QOS_RTG_RT", 66 "QOS_CHECKPOINT", 67 "QOS_SUBMIT", 68 "QOS_DEMO", 69 "ATRACE_MODE=0", # 0 is off, 5 is bytrace, 6 is pmu 70 "ATRACE_LEVEL=0", 71 "ATRACE_LOGI_ENABLE=0", 72 "ATRACE_LOGD_ENABLE=0", 73 "ATRACE_SCOPE_LOG_ENABLE=0", 74 "ATRACE_DURATION_LOG_ENABLE=0", 75 "FFRT_RELEASE", 76 "DISABLE_MONITOR", 77 "FFRT_ENABLE_HITRACE_CHAIN", 78 "FFRT_GITEE", 79 "FFRT_PTHREAD_ENABLE", 80 "FFRT_OH_WATCHDOG_ENABLE", 81 "QOS_WORKER_FRAME_RTG", 82 "USE_OHOS_QOS", 83 "OHOS_STANDARD_SYSTEM", 84 "TASKSTAT_LOG_ENABLE=0", 85 ] 86 if (use_musl) { 87 defines += [ "TDD_MUSL" ] 88 } 89 if (ffrt_async_stack_enable) { 90 defines += [ "FFRT_ASYNC_STACKTRACE" ] 91 } 92 if (target_cpu == "arm") { 93 defines += [ "APP_USE_ARM" ] 94 } 95} 96 97ohos_unittest("frame_interval_test") { 98 module_out_path = module_output_path 99 cflags_cc = [] 100 101 configs = [ ":ffrt_test_config" ] 102 include_dirs = [ "../testfunc" ] 103 104 cflags_cc += ffrt_ut_base_cflags_cc 105 106 sources = [ "frame_interval_test.cpp" ] 107 deps = ffrt_ut_base_deps 108 external_deps = ffrt_ut_base_external_deps 109 110 if (is_standard_system) { 111 public_external_deps = gtest_public_external_deps 112 } 113 114 install_enable = true 115 part_name = "ffrt" 116} 117 118ohos_unittest("deadline_test") { 119 module_out_path = module_output_path 120 cflags_cc = [] 121 122 configs = [ ":ffrt_test_config" ] 123 include_dirs = [ "../testfunc" ] 124 125 cflags_cc += ffrt_ut_base_cflags_cc 126 127 sources = [ "deadline_test.cpp" ] 128 deps = ffrt_ut_base_deps 129 external_deps = ffrt_ut_base_external_deps 130 131 if (is_standard_system) { 132 public_external_deps = gtest_public_external_deps 133 } 134 135 install_enable = true 136 part_name = "ffrt" 137} 138 139ohos_unittest("task_ctx_test") { 140 module_out_path = module_output_path 141 cflags_cc = [] 142 143 configs = [ ":ffrt_test_config" ] 144 include_dirs = [ "../testfunc" ] 145 146 cflags_cc += ffrt_ut_base_cflags_cc 147 148 sources = [ "task_ctx_test.cpp" ] 149 deps = ffrt_ut_base_deps 150 external_deps = ffrt_ut_base_external_deps 151 152 if (is_standard_system) { 153 public_external_deps = gtest_public_external_deps 154 } 155 156 install_enable = true 157 part_name = "ffrt" 158} 159 160ohos_unittest("ut_coroutine") { 161 module_out_path = module_output_path 162 cflags_cc = [] 163 164 configs = [ ":ffrt_test_config" ] 165 include_dirs = [ "../testfunc" ] 166 167 cflags_cc += ffrt_ut_base_cflags_cc 168 169 sources = [ "testcase/ut_coroutine.cpp" ] 170 deps = ffrt_ut_base_deps 171 external_deps = ffrt_ut_base_external_deps 172 173 if (is_standard_system) { 174 public_external_deps = gtest_public_external_deps 175 } 176 177 install_enable = true 178 part_name = "ffrt" 179} 180 181ohos_unittest("ut_cpu_worker") { 182 module_out_path = module_output_path 183 cflags_cc = [] 184 deps = [] 185 external_deps = [] 186 187 configs = [ ":ffrt_test_config" ] 188 include_dirs = ["../testfunc"] 189 190 cflags_cc += ffrt_ut_base_cflags_cc 191 192 sources = [ 193 "testcase/ut_cpu_worker.cpp", 194 ] 195 deps += ffrt_ut_base_deps 196 external_deps += ffrt_ut_base_external_deps 197 198 if (is_standard_system) { 199 public_external_deps = gtest_public_external_deps 200 } 201 202 install_enable = true 203 part_name = "ffrt" 204} 205 206ohos_unittest("inherit_test") { 207 module_out_path = module_output_path 208 cflags_cc = [] 209 210 configs = [ ":ffrt_test_config" ] 211 include_dirs = [ "../testfunc" ] 212 213 cflags_cc += ffrt_ut_base_cflags_cc 214 215 sources = [ "testcase/inherit_test.cpp" ] 216 deps = ffrt_ut_base_deps 217 external_deps = ffrt_ut_base_external_deps 218 219 if (is_standard_system) { 220 public_external_deps = gtest_public_external_deps 221 } 222 223 install_enable = true 224 part_name = "ffrt" 225} 226 227ohos_unittest("multi_workgroup_test") { 228 module_out_path = module_output_path 229 cflags_cc = [] 230 231 configs = [ ":ffrt_test_config" ] 232 include_dirs = [ "../testfunc" ] 233 234 cflags_cc += ffrt_ut_base_cflags_cc 235 236 sources = [ "multi_workgroup_test.cpp" ] 237 deps = ffrt_ut_base_deps 238 external_deps = ffrt_ut_base_external_deps 239 240 if (is_standard_system) { 241 public_external_deps = gtest_public_external_deps 242 } 243 244 install_enable = true 245 part_name = "ffrt" 246} 247 248ohos_unittest("qos_convert_test") { 249 module_out_path = module_output_path 250 cflags_cc = [] 251 252 configs = [ ":ffrt_test_config" ] 253 include_dirs = [ "../testfunc" ] 254 255 cflags_cc += ffrt_ut_base_cflags_cc 256 257 sources = [ "qos_convert_test.cpp" ] 258 deps = ffrt_ut_base_deps 259 external_deps = ffrt_ut_base_external_deps 260 261 if (is_standard_system) { 262 public_external_deps = gtest_public_external_deps 263 } 264 265 part_name = "ffrt" 266} 267 268ohos_unittest("qos_interface_test") { 269 module_out_path = module_output_path 270 cflags_cc = [] 271 272 configs = [ ":ffrt_test_config" ] 273 include_dirs = [ "../testfunc" ] 274 275 cflags_cc += ffrt_ut_base_cflags_cc 276 277 sources = [ "qos_interface_test.cpp" ] 278 deps = ffrt_ut_base_deps 279 external_deps = ffrt_ut_base_external_deps 280 281 if (is_standard_system) { 282 public_external_deps = gtest_public_external_deps 283 } 284 285 install_enable = true 286 part_name = "ffrt" 287} 288 289ohos_unittest("ut_cgroup_qos") { 290 module_out_path = module_output_path 291 cflags_cc = [] 292 293 configs = [ ":ffrt_test_config" ] 294 include_dirs = [ "../testfunc" ] 295 296 cflags_cc += ffrt_ut_base_cflags_cc 297 cflags_cc += [ "-DWITH_NO_MOCKER" ] 298 299 sources = [ "testcase/ut_cgroup_qos.cpp" ] 300 deps = ffrt_ut_base_deps 301 external_deps = ffrt_ut_base_external_deps 302 303 if (is_standard_system) { 304 public_external_deps = gtest_public_external_deps 305 } 306 307 install_enable = true 308 part_name = "ffrt" 309} 310 311ohos_unittest("ut_condition") { 312 module_out_path = module_output_path 313 cflags_cc = [] 314 315 configs = [ ":ffrt_test_config" ] 316 include_dirs = [ "../testfunc" ] 317 318 cflags_cc += ffrt_ut_base_cflags_cc 319 320 sources = [ "testcase/ut_condition.cpp" ] 321 deps = ffrt_ut_base_deps 322 external_deps = ffrt_ut_base_external_deps 323 324 if (is_standard_system) { 325 public_external_deps = gtest_public_external_deps 326 } 327 328 install_enable = true 329 part_name = "ffrt" 330} 331 332ohos_unittest("ut_core") { 333 module_out_path = module_output_path 334 cflags_cc = [] 335 336 configs = [ ":ffrt_test_config" ] 337 include_dirs = [ "../testfunc" ] 338 339 cflags_cc += ffrt_ut_base_cflags_cc 340 341 sources = [ "testcase/ut_core.cpp" ] 342 deps = ffrt_ut_base_deps 343 external_deps = ffrt_ut_base_external_deps 344 345 if (is_standard_system) { 346 public_external_deps = gtest_public_external_deps 347 } 348 349 install_enable = true 350 part_name = "ffrt" 351} 352 353ohos_unittest("ut_csync") { 354 module_out_path = module_output_path 355 cflags_cc = [] 356 357 configs = [ ":ffrt_test_config" ] 358 include_dirs = [ "../testfunc" ] 359 360 cflags_cc += ffrt_ut_base_cflags_cc 361 362 sources = [ "testcase/ut_csync.cpp" ] 363 deps = ffrt_ut_base_deps 364 external_deps = ffrt_ut_base_external_deps 365 366 if (is_standard_system) { 367 public_external_deps = gtest_public_external_deps 368 } 369 370 install_enable = true 371 part_name = "ffrt" 372} 373 374ohos_unittest("ut_deadline") { 375 module_out_path = module_output_path 376 cflags_cc = [] 377 378 configs = [ ":ffrt_test_config" ] 379 include_dirs = [ "../testfunc" ] 380 381 cflags_cc += ffrt_ut_base_cflags_cc 382 383 sources = [ "testcase/ut_deadline.cpp" ] 384 deps = ffrt_ut_base_deps 385 external_deps = ffrt_ut_base_external_deps 386 387 if (is_standard_system) { 388 public_external_deps = gtest_public_external_deps 389 } 390 391 install_enable = true 392 part_name = "ffrt" 393} 394 395ohos_unittest("ut_dependency") { 396 module_out_path = module_output_path 397 cflags_cc = [] 398 399 configs = [ ":ffrt_test_config" ] 400 include_dirs = [ "../testfunc" ] 401 402 cflags_cc += ffrt_ut_base_cflags_cc 403 404 sources = [ "testcase/ut_dependency.cpp" ] 405 deps = ffrt_ut_base_deps 406 external_deps = ffrt_ut_base_external_deps 407 408 if (is_standard_system) { 409 public_external_deps = gtest_public_external_deps 410 } 411 412 install_enable = true 413 part_name = "ffrt" 414} 415 416ohos_unittest("ut_execute_unit") { 417 module_out_path = module_output_path 418 cflags_cc = [] 419 420 configs = [ ":ffrt_test_config" ] 421 include_dirs = [ "../testfunc" ] 422 423 cflags_cc += ffrt_ut_base_cflags_cc 424 425 sources = [ "testcase/ut_execute_unit.cpp" ] 426 deps = ffrt_ut_base_deps 427 external_deps = ffrt_ut_base_external_deps 428 429 if (is_standard_system) { 430 public_external_deps = gtest_public_external_deps 431 } 432 433 install_enable = true 434 part_name = "ffrt" 435} 436 437ohos_unittest("ut_ffrt_io") { 438 module_out_path = module_output_path 439 cflags_cc = [] 440 441 configs = [ ":ffrt_test_config" ] 442 include_dirs = [ "../testfunc" ] 443 444 cflags_cc += ffrt_ut_base_cflags_cc 445 446 sources = [ 447 "testcase/ut_ffrt_io.cpp", 448 "testcase/ut_poller.cpp", 449 ] 450 deps = ffrt_ut_base_deps 451 external_deps = ffrt_ut_base_external_deps 452 453 if (is_standard_system) { 454 public_external_deps = gtest_public_external_deps 455 } 456 457 install_enable = true 458 part_name = "ffrt" 459} 460 461ohos_unittest("ut_graphCheck") { 462 module_out_path = module_output_path 463 cflags_cc = [] 464 465 configs = [ ":ffrt_test_config" ] 466 include_dirs = [ "../testfunc" ] 467 468 cflags_cc += ffrt_ut_base_cflags_cc 469 470 sources = [ "testcase/ut_graphCheck.cpp" ] 471 deps = ffrt_ut_base_deps 472 external_deps = ffrt_ut_base_external_deps 473 474 if (is_standard_system) { 475 public_external_deps = gtest_public_external_deps 476 } 477 478 install_enable = true 479 part_name = "ffrt" 480} 481 482ohos_unittest("ut_interval") { 483 module_out_path = module_output_path 484 cflags_cc = [] 485 486 configs = [ ":ffrt_test_config" ] 487 include_dirs = [ "../testfunc" ] 488 489 cflags_cc += ffrt_ut_base_cflags_cc 490 491 sources = [ "testcase/ut_interval.cpp" ] 492 deps = ffrt_ut_base_deps 493 external_deps = ffrt_ut_base_external_deps 494 495 if (is_standard_system) { 496 public_external_deps = gtest_public_external_deps 497 } 498 499 install_enable = true 500 part_name = "ffrt" 501} 502 503ohos_unittest("ut_whitelist") { 504 module_out_path = module_output_path 505 cflags_cc = [] 506 507 configs = [ ":ffrt_test_config" ] 508 include_dirs = ["../testfunc"] 509 510 cflags_cc += ffrt_ut_base_cflags_cc 511 512 sources = [ 513 "testcase/ut_whitelist.cpp", 514 ] 515 deps = ffrt_ut_base_deps 516 external_deps = ffrt_ut_base_external_deps 517 518 if (is_standard_system) { 519 public_external_deps = gtest_public_external_deps 520 } 521 522 install_enable = true 523 part_name = "ffrt" 524} 525 526ohos_unittest("ut_loop") { 527 module_out_path = module_output_path 528 cflags_cc = [] 529 530 configs = [ ":ffrt_test_config" ] 531 include_dirs = [ "../testfunc" ] 532 533 cflags_cc += ffrt_ut_base_cflags_cc 534 cflags_cc += [ "-DWITH_NO_MOCKER" ] 535 536 sources = [ "testcase/ut_loop.cpp" ] 537 deps = ffrt_ut_base_deps 538 external_deps = [] 539 external_deps += ffrt_ut_base_external_deps 540 external_deps += [ "googletest:gmock" ] 541 542 if (is_standard_system) { 543 public_external_deps = gtest_public_external_deps 544 } 545 546 install_enable = true 547 part_name = "ffrt" 548} 549 550ohos_unittest("ut_queue") { 551 module_out_path = module_output_path 552 cflags_cc = [] 553 554 configs = [ ":ffrt_test_config" ] 555 include_dirs = [ "../testfunc" ] 556 557 cflags_cc += ffrt_ut_base_cflags_cc 558 559 sources = [ "testcase/ut_queue.cpp" ] 560 deps = ffrt_ut_base_deps 561 external_deps = ffrt_ut_base_external_deps 562 563 if (is_standard_system) { 564 public_external_deps = gtest_public_external_deps 565 } 566 567 install_enable = true 568 part_name = "ffrt" 569} 570 571ohos_unittest("ut_rtg") { 572 module_out_path = module_output_path 573 cflags_cc = [] 574 575 configs = [ ":ffrt_test_config" ] 576 include_dirs = [ "../testfunc" ] 577 578 cflags_cc += ffrt_ut_base_cflags_cc 579 580 sources = [ "testcase/ut_rtg.cpp" ] 581 deps = ffrt_ut_base_deps 582 external_deps = ffrt_ut_base_external_deps 583 584 if (is_standard_system) { 585 public_external_deps = gtest_public_external_deps 586 } 587 588 install_enable = true 589 part_name = "ffrt" 590} 591 592ohos_unittest("ut_scheduler") { 593 module_out_path = module_output_path 594 cflags_cc = [] 595 596 configs = [ ":ffrt_test_config" ] 597 include_dirs = [ "../testfunc" ] 598 599 cflags_cc += ffrt_ut_base_cflags_cc 600 601 sources = [ "testcase/ut_scheduler.cpp" ] 602 deps = ffrt_ut_base_deps 603 external_deps = ffrt_ut_base_external_deps 604 605 if (is_standard_system) { 606 public_external_deps = gtest_public_external_deps 607 } 608 609 install_enable = true 610 part_name = "ffrt" 611} 612 613ohos_unittest("ut_thread") { 614 module_out_path = module_output_path 615 cflags_cc = [] 616 617 configs = [ ":ffrt_test_config" ] 618 include_dirs = [ "../testfunc" ] 619 620 cflags_cc += ffrt_ut_base_cflags_cc 621 622 sources = [ "testcase/ut_thread.cpp" ] 623 deps = ffrt_ut_base_deps 624 external_deps = ffrt_ut_base_external_deps 625 626 if (is_standard_system) { 627 public_external_deps = gtest_public_external_deps 628 } 629 630 install_enable = true 631 part_name = "ffrt" 632} 633 634ohos_unittest("ut_mem") { 635 module_out_path = module_output_path 636 cflags_cc = [] 637 638 configs = [ ":ffrt_test_config" ] 639 include_dirs = [ "../testfunc" ] 640 641 cflags_cc += ffrt_ut_base_cflags_cc 642 cflags_cc += [ "-DUSE_GTEST" ] 643 644 sources = [ 645 "../testfunc/func_pool.cpp", 646 "../testfunc/util.cpp", 647 "testcase/ut_mem.cpp", 648 ] 649 deps = ffrt_ut_base_deps 650 external_deps = ffrt_ut_base_external_deps 651 652 if (is_standard_system) { 653 public_external_deps = gtest_public_external_deps 654 } 655 656 install_enable = true 657 part_name = "ffrt" 658} 659 660ohos_unittest("ut_queue_dump") { 661 module_out_path = module_output_path 662 cflags_cc = [] 663 664 configs = [ ":ffrt_test_config" ] 665 include_dirs = [ "../testfunc" ] 666 667 cflags_cc += ffrt_ut_base_cflags_cc 668 669 sources = [ "testcase/ut_queue_dump.cpp" ] 670 deps = ffrt_ut_base_deps 671 external_deps = ffrt_ut_base_external_deps 672 673 if (is_standard_system) { 674 public_external_deps = gtest_public_external_deps 675 } 676 677 install_enable = true 678 part_name = "ffrt" 679} 680 681ohos_unittest("ut_dump") { 682 module_out_path = module_output_path 683 cflags_cc = [] 684 685 configs = [ ":ffrt_test_config" ] 686 include_dirs = [ "../testfunc" ] 687 688 cflags_cc += ffrt_ut_base_cflags_cc 689 690 sources = [ "testcase/ut_dump.cpp" ] 691 deps = ffrt_ut_base_deps 692 external_deps = ffrt_ut_base_external_deps 693 694 if (is_standard_system) { 695 public_external_deps = gtest_public_external_deps 696 } 697 698 install_enable = true 699 part_name = "ffrt" 700} 701 702ohos_unittest("ut_qos_convert") { 703 module_out_path = module_output_path 704 cflags_cc = [] 705 706 configs = [ ":ffrt_test_config" ] 707 include_dirs = [ "../testfunc" ] 708 709 cflags_cc += ffrt_ut_base_cflags_cc 710 711 sources = [ "testcase/ut_qos_convert.cpp" ] 712 deps = ffrt_ut_base_deps 713 external_deps = ffrt_ut_base_external_deps 714 715 if (is_standard_system) { 716 public_external_deps = gtest_public_external_deps 717 } 718 719 install_enable = true 720 part_name = "ffrt" 721} 722 723ohos_unittest("ut_cpu_boost") { 724 module_out_path = module_output_path 725 configs = [] 726 include_dirs = [] 727 cflags_cc = [] 728 deps = [] 729 external_deps = [] 730 731 configs = [ ":ffrt_test_config" ] 732 include_dirs = [ "../testfunc" ] 733 734 cflags_cc += ffrt_ut_base_cflags_cc 735 cflags_cc += [ "-DWITH_NO_MOCKER" ] 736 737 sources = [ "testcase/ut_cpu_boost.cpp" ] 738 deps += ffrt_ut_base_deps 739 external_deps += ffrt_ut_base_external_deps 740 741 if (is_standard_system) { 742 public_external_deps = gtest_public_external_deps 743 } 744 745 install_enable = true 746 part_name = "ffrt" 747} 748 749group("ffrt_unittest_ffrt") { 750 testonly = true 751 752 deps = [] 753 if (!is_asan) { 754 deps += [ 755 ":deadline_test", 756 ":frame_interval_test", 757 ":inherit_test", 758 ":multi_workgroup_test", 759 ":qos_convert_test", 760 ":qos_interface_test", 761 ":task_ctx_test", 762 ":ut_cgroup_qos", 763 ":ut_condition", 764 ":ut_core", 765 ":ut_coroutine", 766 ":ut_cpu_boost", 767 ":ut_csync", 768 ":ut_deadline", 769 ":ut_dependency", 770 ":ut_dump", 771 ":ut_execute_unit", 772 ":ut_ffrt_io", 773 ":ut_graphCheck", 774 ":ut_interval", 775 ":ut_loop", 776 ":ut_mem", 777 ":ut_qos_convert", 778 ":ut_queue", 779 ":ut_queue_dump", 780 ":ut_rtg", 781 ":ut_scheduler", 782 ":ut_whitelist", 783 ] 784 } 785} 786