1# Copyright (C) 2025 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. 13import("//build/test.gni") 14import("../../../../test_template.gni") 15import("../adlt_common.gni") 16import("test_src_adlt_base.gni") 17 18group("adlt_base_test") { 19 testonly = true 20 deps = [] 21 22 foreach(s, adlt_base_test) { 23 deps += [ ":${s}" ] 24 } 25} 26 27config("post_lib_configs") { 28 ldflags = [ "-Wl,--unresolved-symbols=ignore-all" ] 29} 30 31adlt_executable("unittest_adlt_base_backtrace") { 32 lib_name = "base_backtrace" 33 lib_include_dirs = [ "backtrace" ] 34 lib_configs = [ 35 { 36 name = "base_backtrace_bt_lib" 37 sources = [ "backtrace/bt-lib.c" ] 38 }, 39 { 40 name = "base_backtrace_testbacktrace" 41 sources = [ "backtrace/testbacktrace.cpp" ] 42 external_deps = [ "bounds_checking_function:libsec_shared" ] 43 } 44 ] 45 46 include_dirs = [ "backtrace" ] 47 sources = [ "backtrace/main.cpp" ] 48 49 lib_common_configs = [ 50 ":post_lib_configs" 51 ] 52} 53 54adlt_executable("unittest_adlt_base_backtrace2") { 55 lib_name = "base_backtrace2" 56 lib_include_dirs = [ "backtrace2" ] 57 lib_configs = [ 58 { 59 name = "base_backtrace2_lib_test" 60 sources = [ "backtrace2/bt-lib_test.cpp" ] 61 external_deps = [ "bounds_checking_function:libsec_shared" ] 62 }, 63 { 64 name = "base_backtrace2_lib_a" 65 sources = [ "backtrace2/bt-lib_a.c" ] 66 }, 67 { 68 name = "base_backtrace2_lib_b" 69 sources = [ "backtrace2/bt-lib_b.c" ] 70 }, 71 ] 72 73 sources = [ "backtrace2/main.cpp" ] 74 include_dirs = [ "backtrace2" ] 75 76 lib_common_configs = [ 77 ":post_lib_configs" 78 ] 79} 80 81adlt_executable("unittest_adlt_base_cdtors") { 82 lib_name = "base_cdtors" 83 lib_include_dirs = [ "cdtors" ] 84 lib_configs = [ 85 { 86 name = "base_cdtors_a" 87 sources = [ "cdtors/a.cpp" ] 88 }, 89 { 90 name = "base_cdtors_b" 91 sources = [ "cdtors/b.cpp" ] 92 }, 93 ] 94 95 include_dirs = [ "cdtors" ] 96 sources = [ "cdtors/main.cpp" ] 97 98 lib_common_configs = [ 99 ":post_lib_configs" 100 ] 101} 102 103adlt_executable("unittest_adlt_base_cross") { 104 lib_name = "base_cross" 105 lib_include_dirs = [ "cross" ] 106 lib_configs = [ 107 { 108 name = "base_cross_a" 109 sources = [ "cross/a.c" ] 110 }, 111 { 112 name = "base_cross_b" 113 sources = [ "cross/b.c" ] 114 }, 115 ] 116 117 include_dirs = [ "cross" ] 118 sources = [ "cross/main.cpp" ] 119 120 lib_common_configs = [ 121 ":post_lib_configs" 122 ] 123} 124 125ohos_shared_library("base_deps_e") { 126 output_name = "libadlt_base_deps_e" 127 output_extension = "so" 128 129 subsystem_name = "musl" 130 part_name = "libc-test-lib" 131 testonly = true 132 133 include_dirs = [ "deps" ] 134 sources = [ "deps/e.c" ] 135 deps = [ "../:adlt_common", ":base_deps_a" ] 136} 137 138adlt_executable("unittest_adlt_base_deps") { 139 lib_name = "base_deps" 140 lib_include_dirs = [ "deps" ] 141 lib_configs = [ 142 { 143 name = "base_deps_a" 144 sources = [ "deps/a.c" ] 145 deps = [ ":base_deps_b" ] 146 }, 147 { 148 name = "base_deps_b" 149 sources = [ "deps/b.c" ] 150 }, 151 ] 152 153 include_dirs = [ "deps" ] 154 sources = [ "deps/main.cpp" ] 155 deps = [ ":base_deps_e" ] 156 157 lib_common_configs = [ 158 ":post_lib_configs" 159 ] 160} 161 162adlt_executable("unittest_adlt_base_deps_dlopen") { 163 lib_name = "base_deps_dlopen" 164 lib_include_dirs = [ "deps" ] 165 lib_configs = [ 166 { 167 name = "base_deps_dlopen_a" 168 sources = [ "deps/a.c" ] 169 deps = [ ":base_deps_dlopen_b" ] 170 }, 171 { 172 name = "base_deps_dlopen_b" 173 sources = [ "deps/b.c" ] 174 }, 175 ] 176 177 include_dirs = [ "deps" ] 178 sources = [ "deps/main_with_dlopen.cpp" ] 179 180 lib_common_configs = [ 181 ":post_lib_configs" 182 ] 183} 184 185adlt_executable("unittest_adlt_base_dlopen_c") { 186 lib_name = "base_dlopen_c" 187 lib_include_dirs = [ "dlopen_c" ] 188 lib_configs = [ 189 { 190 name = "base_dlopen_c_lib" 191 sources = [ "dlopen_c/c-lib.c" ] 192 }, 193 { 194 name = "base_dlopen_c_test_dlopen" 195 sources = [ "dlopen_c/testdlopen.cpp" ] 196 }, 197 ] 198 199 include_dirs = [ "dlopen_c" ] 200 sources = [ "dlopen_c/main.cpp" ] 201 lib_common_configs = [ 202 ":post_lib_configs" 203 ] 204} 205 206adlt_executable("unittest_adlt_base_dlopen_cpp") { 207 lib_name = "base_dlopen_cpp" 208 lib_include_dirs = [ "dlopen_cpp" ] 209 lib_configs = [ 210 { 211 name = "base_dlopen_cpp_lib" 212 sources = [ "dlopen_cpp/cpp-lib.cpp" ] 213 }, 214 { 215 name = "base_dlopen_cpp_test_dlopen" 216 sources = [ "dlopen_cpp/testdlopen.cpp" ] 217 }, 218 ] 219 220 include_dirs = [ "dlopen_cpp" ] 221 sources = [ "dlopen_cpp/main.cpp" ] 222 lib_common_configs = [ 223 ":post_lib_configs" 224 ] 225} 226 227adlt_executable("unittest_adlt_base_duplicates") { 228 lib_name = "base_duplicates" 229 lib_include_dirs = [ "duplicates" ] 230 lib_configs = [ 231 { 232 name = "base_duplicates_a" 233 sources = [ "duplicates/a.c" ] 234 }, 235 { 236 name = "base_duplicates_b" 237 sources = [ "duplicates/b.c" ] 238 }, 239 { 240 name = "base_duplicates_c" 241 sources = [ "duplicates/c.c" ] 242 }, 243 ] 244 245 include_dirs = [ "duplicates" ] 246 sources = [ "duplicates/main.cpp" ] 247 lib_common_configs = [ 248 ":post_lib_configs" 249 ] 250} 251 252adlt_executable("unittest_adlt_base_ehframe13") { 253 lib_name = "base_ehframe13" 254 lib_include_dirs = [ "eh_frame" ] 255 lib_configs = [ 256 { 257 name = "eh_frame13_1" 258 sources = [ "eh_frame/lib1.cpp" ] 259 }, 260 { 261 name = "eh_frame13_3" 262 sources = [ "eh_frame/lib3.cpp" ] 263 }, 264 ] 265 266 include_dirs = [ "eh_frame" ] 267 sources = [ "eh_frame/main13.cpp" ] 268 269 lib_common_configs = [ 270 "//build/config/compiler:exceptions", 271 ] 272 273 configs = [ 274 "//build/config/compiler:exceptions", 275 ] 276} 277 278adlt_executable("unittest_adlt_base_ehframe123") { 279 lib_name = "base_ehframe123" 280 lib_include_dirs = [ "eh_frame" ] 281 lib_configs = [ 282 { 283 name = "eh_frame123_1" 284 sources = [ "eh_frame/lib1.cpp" ] 285 }, 286 { 287 name = "eh_frame123_2" 288 sources = [ "eh_frame/lib2.cpp" ] 289 }, 290 { 291 name = "eh_frame123_3" 292 sources = [ "eh_frame/lib3.cpp" ] 293 }, 294 ] 295 296 include_dirs = [ "eh_frame" ] 297 sources = [ "eh_frame/main123.cpp" ] 298 299 lib_common_configs = [ 300 "//build/config/compiler:exceptions", 301 ] 302 303 configs = [ 304 "//build/config/compiler:exceptions", 305 ] 306} 307 308adlt_executable("unittest_adlt_base_heap") { 309 lib_name = "base_heap" 310 lib_include_dirs = [ "heap" ] 311 lib_configs = [ 312 { 313 name = "base_heap_test_malloc" 314 sources = [ "heap/testmalloc.cpp" ] 315 }, 316 ] 317 318 include_dirs = [ "heap" ] 319 sources = [ "heap/main.cpp" ] 320 321 lib_common_configs = [ 322 ":post_lib_configs", 323 ] 324} 325 326adlt_executable("unittest_adlt_base_oop") { 327 lib_name = "base_oop" 328 lib_include_dirs = [ "oop" ] 329 lib_configs = [ 330 { 331 name = "base_oop_a" 332 sources = [ "oop/a.cpp" ] 333 }, 334 { 335 name = "base_oop_b" 336 sources = [ "oop/b.cpp" ] 337 }, 338 ] 339 340 include_dirs = [ "oop" ] 341 sources = [ "oop/main.cpp" ] 342 343 lib_common_configs = [ 344 ":post_lib_configs", 345 ] 346} 347 348adlt_executable("unittest_adlt_base_relocs") { 349 lib_name = "base_relocs" 350 lib_configs = [ 351 { 352 name = "base_relocs_dyn" 353 sources = [ "relocs/dyn_relocs/glob_dat.asm", 354 "relocs/dyn_relocs/jump_slot.asm", 355 "relocs/dyn_relocs/relative.asm", ] 356 cflags = [ "-x", "assembler" ] 357 }, 358 { 359 name = "base_relocs_abs" 360 sources = [ "relocs/abs_relocs/abs64.asm", ] 361 cflags = [ "-x", "assembler" ] 362 }, 363 { 364 name = "base_relocs_plt" 365 sources = [ "relocs/plt_relocs/jump26.asm", 366 "relocs/plt_relocs/call26.asm", 367 "relocs/plt_relocs/condbr19.asm", 368 "relocs/plt_relocs/tstbr14.asm", ] 369 cflags = [ "-x", "assembler" ] 370 }, 371 { 372 name = "base_relocs_got" 373 sources = [ "relocs/got_relocs/ld64_got_lo12_nc.asm", 374 "relocs/got_relocs/ld64_gotpage_lo15.asm", ] 375 cflags = [ "-x", "assembler" ] 376 }, 377 { 378 name= "base_relocs_pc_relative" 379 sources = [ "relocs/pc_relative_relocs/adr_prel_pg_hi21.asm", 380 "relocs/pc_relative_relocs/adr_prel_pg_hi21_nc.asm", 381 "relocs/pc_relative_relocs/adr_prel_lo21.asm", 382 "relocs/pc_relative_relocs/ld_prel_lo19.asm", ] 383 cflags = [ "-x", "assembler" ] 384 }, 385 { 386 name = "base_relocs_null" 387 sources = [ "relocs/null_relocs/null_relocs.asm", ] 388 cflags = [ "-x", "assembler" ] 389 }, 390 { 391 name = "base_relocs_tlsdesc" 392 sources = [ "relocs/tlsdesc_relocs/tlsdesc.asm", ] 393 cflags = [ "-x", "assembler" ] 394 }, 395 { 396 name = "base_relocs_tls_dyn" 397 sources = [ "relocs/tls_dyn_relocs/tls_tprel64.asm", ] 398 cflags = [ "-x", "assembler" ] 399 }, 400 { 401 name = "base_relocs_tlsie" 402 sources = [ "relocs/tlsie_relocs/tlsie_adr_ld64.asm", ] 403 cflags = [ "-x", "assembler" ] 404 } 405 ] 406 407 sources = [ "relocs/main.cpp" ] 408 409 lib_common_configs = [ 410 ":post_lib_configs", 411 ] 412} 413 414adlt_shared_library("base_rpath") { 415 include_dirs = [ "rpath" ] 416 lib_configs = [ 417 { 418 name = "base_rpath_a" 419 sources = [ "rpath/a.c" ] 420 }, 421 ] 422 423 configs = [ 424 ":post_lib_configs" 425 ] 426} 427 428ohos_executable("unittest_adlt_base_rpath_without_rpath") { 429 testonly = true 430 subsystem_name = "musl" 431 part_name = "libc-test" 432 configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ] 433 434 include_dirs = [ 435 "//third_party/musl/libc-test/src/functionalext/adlt/common", 436 "//third_party/musl/libc-test/src/functionalext/common", 437 "//third_party/musl/porting/linux/user/include", 438 "//third_party/musl/libc-test/src/common", 439 "rpath" 440 ] 441 442 cflags = [ "-DWITHOUT_RPATH" ] 443 sources = [ "rpath/main.cpp" ] 444 deps = [ "../:adlt_common", ":base_rpath", ":base_rpath_a" ] 445} 446 447ohos_executable("unittest_adlt_base_rpath_with_rpath") { 448 testonly = true 449 subsystem_name = "musl" 450 part_name = "libc-test" 451 configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ] 452 453 include_dirs = [ 454 "//third_party/musl/libc-test/src/functionalext/adlt/common", 455 "//third_party/musl/libc-test/src/functionalext/common", 456 "//third_party/musl/porting/linux/user/include", 457 "//third_party/musl/libc-test/src/common", 458 "rpath" 459 ] 460 461 sources = [ "rpath/main.cpp" ] 462 ldflags = [ "-Wl,-rpath=./:/data/local/tmp/libc-test-lib/" ] 463 deps = [ "../:adlt_common", ":base_rpath", ":base_rpath_a" ] 464} 465 466action("unittest_adlt_base_rpath") { 467 testonly = true 468 deps = [ 469 ":unittest_adlt_base_rpath_without_rpath", 470 ":unittest_adlt_base_rpath_with_rpath", 471 ] 472 473 script = "../adlt_tools.py" 474 args = [ "build_sym_links", 475 "--lib-dir", rebase_path(adlt_lib_dir, ""), 476 "--target-lib-dir", adlt_target_lib_dir, 477 "--adlt-lib", "libadlt_base_rpath.so", 478 "--orig-lib-list", "libadlt_base_rpath_a.so", 479 ] 480 481 outputs = [ 482 "$adlt_lib_dir/adlt_orig_libs/libadlt_base_rpath_a.so", 483 ] 484} 485 486adlt_executable("unittest_adlt_base_soname1_fix_libab") { 487 lib_name = "base_soname1_fix_libab" 488 lib_include_dirs = [ "soname1_fix" ] 489 lib_configs = [ 490 { 491 name = "base_soname1_fix_libab_a" 492 sources = [ "soname1_fix/a.cpp" ] 493 }, 494 { 495 name = "base_soname1_fix_libab_b" 496 sources = [ "soname1_fix/b.cpp" ] 497 } 498 ] 499 500 include_dirs = [ "soname1_fix" ] 501 sources = [ "soname1_fix/main.cpp" ] 502 503 custom_deps = [ ":base_soname1_fix_libab", ":base_soname1_fix_libab_a" ] 504} 505 506adlt_executable("unittest_adlt_base_soname1_fix_libba") { 507 lib_name = "base_soname1_fix_libba" 508 lib_include_dirs = [ "soname1_fix" ] 509 lib_configs = [ 510 { 511 name = "base_soname1_fix_libba_b" 512 sources = [ "soname1_fix/b.cpp" ] 513 }, 514 { 515 name = "base_soname1_fix_libba_a" 516 sources = [ "soname1_fix/a.cpp" ] 517 } 518 ] 519 520 include_dirs = [ "soname1_fix" ] 521 sources = [ "soname1_fix/main.cpp" ] 522 523 custom_deps = [ ":base_soname1_fix_libba", ":base_soname1_fix_libba_a" ] 524} 525 526adlt_executable("unittest_adlt_base_varargs") { 527 lib_name = "base_varargs" 528 lib_include_dirs = [ "varargs" ] 529 lib_configs = [ 530 { 531 name = "base_varargs_test" 532 sources = [ "varargs/testvarargs.cpp" ] 533 }, 534 ] 535 536 include_dirs = [ "varargs" ] 537 sources = [ "varargs/main.cpp" ] 538 539 lib_common_configs = [ 540 ":post_lib_configs" 541 ] 542} 543 544ohos_shared_library("base_version_neg_verdef_a_v2") { 545 output_name = "libadlt_base_version_neg_verdef_a_v2" 546 output_extension = "so" 547 548 subsystem_name = "musl" 549 part_name = "libc-test-lib" 550 testonly = true 551 552 include_dirs = [ "version/negative_verdef" ] 553 sources = [ "version/negative_verdef/a_v2.c" ] 554 ldflags = [ "-Wl,--version-script," + rebase_path("version/negative_verdef/a_v2.map", "") ] 555 deps = [ "../:adlt_common", ] 556} 557 558adlt_executable("unittest_adlt_base_negative_verdef") { 559 lib_name = "base_negative_verdef" 560 lib_include_dirs = [ "version/negative_verdef" ] 561 lib_configs = [ 562 { 563 name = "base_negative_verdef_a" 564 sources = [ "version/negative_verdef/a.c" ] 565 ldflags = [ "-Wl,--version-script," + rebase_path("version/negative_verdef/a.map", "") ] 566 }, 567 ] 568 569 include_dirs = [ "version/negative_verdef" ] 570 sources = [ "version/negative_verdef/main.cpp" ] 571 data_deps = [ ":base_version_neg_verdef_a_v2" ] 572 lib_common_configs = [ 573 ":post_lib_configs" 574 ] 575} 576 577ohos_shared_library("base_version_neg_verneed_v1") { 578 output_name = "libadlt_base_version_neg_verneed_v1" 579 output_extension = "so" 580 581 subsystem_name = "musl" 582 part_name = "libc-test-lib" 583 testonly = true 584 585 include_dirs = [ "version/negative_verneed" ] 586 sources = [ "version/negative_verneed/v1.c" ] 587 ldflags = [ "-Wl,--version-script," + rebase_path("version/negative_verneed/v1.map", "") ] 588 deps = [ "../:adlt_common", ] 589} 590 591ohos_shared_library("base_version_neg_verneed_v2") { 592 output_name = "libadlt_base_version_neg_verneed_v2" 593 output_extension = "so" 594 595 subsystem_name = "musl" 596 part_name = "libc-test-lib" 597 testonly = true 598 599 include_dirs = [ "version/negative_verneed" ] 600 sources = [ "version/negative_verneed/v2.c" ] 601 ldflags = [ "-Wl,--version-script," + rebase_path("version/negative_verneed/v2.map", "") ] 602 deps = [ "../:adlt_common", ] 603} 604 605adlt_executable("unittest_adlt_base_negative_verneed") { 606 lib_name = "base_negative_verneed" 607 lib_include_dirs = [ "version/negative_verneed" ] 608 lib_configs = [ 609 { 610 name = "base_negative_verneed_a" 611 sources = [ "version/negative_verneed/a.c" ] 612 deps = [ ":base_version_neg_verneed_v1" ] 613 }, 614 ] 615 616 include_dirs = [ "version/negative_verneed" ] 617 sources = [ "version/negative_verneed/main.cpp" ] 618 data_deps = [ ":base_version_neg_verneed_v2" ] 619 620 lib_common_configs = [ 621 ":post_lib_configs" 622 ] 623} 624 625adlt_executable("unittest_adlt_base_verdef") { 626 lib_name = "base_verdef" 627 lib_include_dirs = [ "version/verdef" ] 628 lib_configs = [ 629 { 630 name = "base_verdef_a" 631 sources = [ "version/verdef/a.c" ] 632 ldflags = [ "-Wl,--version-script," + rebase_path("version/verdef/a.map", "") ] 633 }, 634 { 635 name = "base_verdef_b" 636 sources = [ "version/verdef/b.c" ] 637 ldflags = [ "-Wl,--version-script," + rebase_path("version/verdef/b.map", "") ] 638 }, 639 ] 640 641 include_dirs = [ "version/verdef" ] 642 sources = [ "version/verdef/main.cpp" ] 643 lib_common_configs = [ 644 ":post_lib_configs" 645 ] 646} 647 648ohos_shared_library("base_version_verneed_ver_1") { 649 output_name = "libadlt_base_version_verneed_ver_1" 650 output_extension = "so" 651 652 subsystem_name = "musl" 653 part_name = "libc-test-lib" 654 testonly = true 655 656 include_dirs = [ "version/verneed" ] 657 sources = [ "version/verneed/ver_1.c" ] 658 ldflags = [ "-Wl,--version-script," + rebase_path("version/verneed/ver_1.map", "") ] 659 deps = [ "../:adlt_common", ] 660} 661 662ohos_shared_library("base_version_verneed_ver_2") { 663 output_name = "libadlt_base_version_verneed_ver_2" 664 output_extension = "so" 665 666 subsystem_name = "musl" 667 part_name = "libc-test-lib" 668 testonly = true 669 670 include_dirs = [ "version/verneed" ] 671 sources = [ "version/verneed/ver_2.c" ] 672 ldflags = [ "-Wl,--version-script," + rebase_path("version/verneed/ver_2.map", "") ] 673 deps = [ "../:adlt_common", ] 674} 675 676adlt_executable("unittest_adlt_base_verneed") { 677 lib_name = "base_verneed" 678 lib_include_dirs = [ "version/verneed" ] 679 lib_configs = [ 680 { 681 name = "base_verneed_a" 682 sources = [ "version/verneed/a.c" ] 683 deps = [ ":base_version_verneed_ver_1" ] 684 }, 685 { 686 name = "base_verneed_b" 687 sources = [ "version/verneed/b.c" ] 688 deps = [ ":base_version_verneed_ver_2" ] 689 }, 690 ] 691 692 include_dirs = [ "version/verneed" ] 693 sources = [ "version/verneed/main.cpp" ] 694 lib_common_configs = [ 695 ":post_lib_configs" 696 ] 697}