1# Copyright (c) 2022-2024 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("//base/hiviewdfx/faultloggerd/faultloggerd.gni") 15import("//build/config/features.gni") 16import("//build/test.gni") 17 18module_output_path = "faultloggerd/backtrace" 19 20ohos_unittest("backtrace_utils_test") { 21 module_out_path = module_output_path 22 visibility = [ "*:*" ] 23 include_dirs = [ 24 "$faultloggerd_interfaces_path/common", 25 "$faultloggerd_path/test/utils", 26 ] 27 sources = [ "backtrace_utils_test.cpp" ] 28 deps = [ 29 "$faultloggerd_common_path/dfxutil:dfx_util", 30 "$faultloggerd_interfaces_path/innerkits/backtrace:libbacktrace_local", 31 "$faultloggerd_path/test/utils:dfx_test_util", 32 ] 33 if (use_musl && musl_use_jemalloc && musl_use_jemalloc_dfx_intf) { 34 defines = [ "USE_JEMALLOC_DFX_INTF" ] 35 } 36 branch_protector_ret = "pac_ret" 37 external_deps = [ 38 "c_utils:utils", 39 "googletest:gtest_main", 40 "hilog:libhilog", 41 ] 42} 43 44ohos_unittest("backtrace_local_test") { 45 module_out_path = module_output_path 46 visibility = [ "*:*" ] 47 include_dirs = [ 48 "$faultloggerd_interfaces_path/common", 49 "$faultloggerd_path/test/utils", 50 "$faultloggerd_interfaces_path/innerkits/backtrace", 51 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 52 ] 53 sources = [ "backtrace_local_test.cpp" ] 54 deps = [ 55 "$faultloggerd_common_path/dfxutil:dfx_util", 56 "$faultloggerd_interfaces_path/innerkits/backtrace:libbacktrace_local", 57 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder", 58 "$faultloggerd_path/test/utils:dfx_test_util", 59 ] 60 branch_protector_ret = "pac_ret" 61 external_deps = [ 62 "bounds_checking_function:libsec_shared", 63 "c_utils:utils", 64 "ffrt:libffrt", 65 "googletest:gtest_main", 66 "hilog:libhilog", 67 ] 68} 69 70ohos_unittest("backtrace_utils_test_static") { 71 module_out_path = module_output_path 72 visibility = [ "*:*" ] 73 include_dirs = [ 74 "$faultloggerd_interfaces_path/common", 75 "$faultloggerd_path/test/utils", 76 "$faultloggerd_interfaces_path/innerkits/backtrace", 77 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 78 ] 79 defines = [ "DFX_LOG_HILOG_BASE" ] 80 sources = [ "backtrace_utils_test.cpp" ] 81 deps = [ 82 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 83 "$faultloggerd_common_path/dfxutil:dfx_util_static", 84 "$faultloggerd_interfaces_path/innerkits/backtrace:backtrace_local", 85 "$faultloggerd_path/test/utils:dfx_test_util", 86 ] 87 if (use_musl && musl_use_jemalloc && musl_use_jemalloc_dfx_intf) { 88 defines += [ "USE_JEMALLOC_DFX_INTF" ] 89 } 90 branch_protector_ret = "pac_ret" 91 public_external_deps = [ "lzma:lzma_static" ] 92 external_deps = [ 93 "c_utils:utilsbase", 94 "googletest:gtest_main", 95 "hilog:libhilog_base", 96 ] 97} 98 99ohos_unittest("backtrace_local_test_static") { 100 module_out_path = module_output_path 101 visibility = [ "*:*" ] 102 include_dirs = [ 103 "$faultloggerd_interfaces_path/common", 104 "$faultloggerd_path/test/utils", 105 "$faultloggerd_interfaces_path/innerkits/backtrace", 106 ] 107 defines = [ 108 "BACKTRACE_LOCAL_TEST_STATIC", 109 "DFX_LOG_HILOG_BASE", 110 ] 111 sources = [ "backtrace_local_test.cpp" ] 112 deps = [ 113 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 114 "$faultloggerd_common_path/dfxutil:dfx_util_static", 115 "$faultloggerd_interfaces_path/innerkits/backtrace:backtrace_local", 116 "$faultloggerd_path/test/utils:dfx_test_util", 117 ] 118 branch_protector_ret = "pac_ret" 119 public_external_deps = [ "lzma:lzma_static" ] 120 external_deps = [ 121 "bounds_checking_function:libsec_static", 122 "c_utils:utilsbase", 123 "ffrt:libffrt", 124 "googletest:gtest_main", 125 "hilog:libhilog_base", 126 ] 127} 128 129group("unittest") { 130 testonly = true 131 deps = [ 132 ":backtrace_local_test", 133 ":backtrace_utils_test", 134 ] 135 if (target_cpu == "arm64") { 136 deps += [ 137 ":backtrace_local_test_static", 138 ":backtrace_utils_test_static", 139 ] 140 } 141} 142