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