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/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/interfaces/innerkits/formatter:libjson_stack_formatter", 32 "$faultloggerd_path/test/utils:dfx_test_util", 33 ] 34 if (use_musl && musl_use_jemalloc && musl_use_jemalloc_dfx_intf) { 35 defines = [ "USE_JEMALLOC_DFX_INTF" ] 36 } 37 branch_protector_ret = "pac_ret" 38 external_deps = [ 39 "c_utils:utils", 40 "googletest:gtest_main", 41 "hilog:libhilog", 42 ] 43} 44 45ohos_unittest("backtrace_local_test") { 46 module_out_path = module_output_path 47 visibility = [ "*:*" ] 48 include_dirs = [ 49 "$faultloggerd_interfaces_path/common", 50 "$faultloggerd_path/test/utils", 51 "$faultloggerd_interfaces_path/innerkits/backtrace", 52 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 53 ] 54 sources = [ 55 "backtrace_local_test.cpp", 56 "fp_backtrace_test.cpp", 57 ] 58 deps = [ 59 "$faultloggerd_common_path/dfxutil:dfx_util", 60 "$faultloggerd_interfaces_path/innerkits/backtrace:libbacktrace_local", 61 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder", 62 "$faultloggerd_path/interfaces/innerkits/formatter:libjson_stack_formatter", 63 "$faultloggerd_path/interfaces/innerkits/procinfo:libdfx_procinfo", 64 "$faultloggerd_path/test/utils:dfx_test_util", 65 ] 66 branch_protector_ret = "pac_ret" 67 external_deps = [ 68 "bounds_checking_function:libsec_shared", 69 "c_utils:utils", 70 "ffrt:libffrt", 71 "googletest:gtest_main", 72 "hilog:libhilog", 73 ] 74} 75 76ohos_unittest("backtrace_utils_test_static") { 77 module_out_path = module_output_path 78 visibility = [ "*:*" ] 79 include_dirs = [ 80 "$faultloggerd_interfaces_path/common", 81 "$faultloggerd_path/test/utils", 82 "$faultloggerd_interfaces_path/innerkits/backtrace", 83 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 84 ] 85 defines = [ "DFX_LOG_HILOG_BASE" ] 86 sources = [ "backtrace_utils_test.cpp" ] 87 deps = [ 88 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 89 "$faultloggerd_common_path/dfxutil:dfx_util_static", 90 "$faultloggerd_interfaces_path/innerkits/backtrace:backtrace_local", 91 "$faultloggerd_path/interfaces/innerkits/formatter:libjson_stack_formatter", 92 "$faultloggerd_path/test/utils:dfx_test_util", 93 ] 94 if (use_musl && musl_use_jemalloc && musl_use_jemalloc_dfx_intf) { 95 defines += [ "USE_JEMALLOC_DFX_INTF" ] 96 } 97 branch_protector_ret = "pac_ret" 98 external_deps = [ 99 "c_utils:utilsbase", 100 "googletest:gtest_main", 101 "hilog:libhilog_base", 102 ] 103} 104 105ohos_unittest("backtrace_local_test_static") { 106 module_out_path = module_output_path 107 visibility = [ "*:*" ] 108 include_dirs = [ 109 "$faultloggerd_interfaces_path/common", 110 "$faultloggerd_path/test/utils", 111 "$faultloggerd_interfaces_path/innerkits/backtrace", 112 ] 113 defines = [ 114 "BACKTRACE_LOCAL_TEST_STATIC", 115 "DFX_LOG_HILOG_BASE", 116 ] 117 sources = [ 118 "backtrace_local_test.cpp", 119 "fp_backtrace_test.cpp", 120 ] 121 deps = [ 122 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 123 "$faultloggerd_common_path/dfxutil:dfx_util_static", 124 "$faultloggerd_interfaces_path/innerkits/backtrace:backtrace_local", 125 "$faultloggerd_path/interfaces/innerkits/formatter:libjson_stack_formatter", 126 "$faultloggerd_path/interfaces/innerkits/procinfo:dfx_procinfo_static", 127 "$faultloggerd_path/test/utils:dfx_test_util", 128 ] 129 branch_protector_ret = "pac_ret" 130 external_deps = [ 131 "bounds_checking_function:libsec_static", 132 "c_utils:utilsbase", 133 "ffrt:libffrt", 134 "googletest:gtest_main", 135 "hilog:libhilog_base", 136 ] 137} 138 139group("unittest") { 140 testonly = true 141 deps = [ 142 ":backtrace_local_test", 143 ":backtrace_utils_test", 144 ] 145 if (target_cpu == "arm64") { 146 deps += [ 147 ":backtrace_local_test_static", 148 ":backtrace_utils_test_static", 149 ] 150 } 151} 152