1# Copyright (c) 2022-2023 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") 17module_output_path = "faultloggerd/unwind" 18 19ohos_unittest("test_unwind") { 20 module_out_path = module_output_path 21 visibility = [ "*:*" ] 22 include_dirs = [ 23 "$faultloggerd_interfaces_path/common", 24 "$faultloggerd_path/test/unittest/unwind/include", 25 "$faultloggerd_path/test/utils", 26 ] 27 configs = [ "$faultloggerd_common_path/build:coverage_flags" ] 28 defines = [ "DFX_LOG_UNWIND" ] 29 sources = [ 30 "accessors_test.cpp", 31 "ark_test.cpp", 32 "elf_imitate.cpp", 33 "elf_test.cpp", 34 "fp_unwinder_test.cpp", 35 "instr_statistic_test.cpp", 36 "maps_test.cpp", 37 "memory_test.cpp", 38 "regs_test.cpp", 39 "signal_test.cpp", 40 "symbols_test.cpp", 41 "unwinder_test.cpp", 42 "xz_util_test.cpp", 43 ] 44 deps = [ 45 "$faultloggerd_common_path/dfxlog:dfx_hilog", 46 "$faultloggerd_common_path/dfxutil:dfx_util", 47 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 48 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder_src", 49 "$faultloggerd_path/test/utils:dfx_test_util", 50 ] 51 resource_config_file = "$faultloggerd_path/test/resource/ohos_test.xml" 52 external_deps = [ 53 "bounds_checking_function:libsec_shared", 54 "c_utils:utils", 55 "googletest:gtest_main", 56 "hilog:libhilog", 57 ] 58} 59 60ohos_unittest("test_unwind_pac") { 61 module_out_path = module_output_path 62 visibility = [ "*:*" ] 63 include_dirs = [ 64 "$faultloggerd_interfaces_path/common", 65 "$faultloggerd_path/test/unittest/unwind/include", 66 ] 67 configs = [ "$faultloggerd_common_path/build:coverage_flags" ] 68 defines = [ "DFX_LOG_UNWIND" ] 69 sources = [ "unwinder_pac_test.cpp" ] 70 deps = [ 71 "$faultloggerd_common_path/dfxlog:dfx_hilog", 72 "$faultloggerd_common_path/dfxutil:dfx_util", 73 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder_src", 74 ] 75 branch_protector_ret = "pac_ret" 76 external_deps = [ 77 "bounds_checking_function:libsec_shared", 78 "c_utils:utils", 79 "googletest:gtest_main", 80 "hilog:libhilog", 81 ] 82} 83 84ohos_unittest("test_unwind_separate_code") { 85 module_out_path = module_output_path 86 visibility = [ "*:*" ] 87 include_dirs = [ 88 "$faultloggerd_interfaces_path/common", 89 "$faultloggerd_path/test/unittest/unwind/include", 90 ] 91 configs = [ "$faultloggerd_common_path/build:coverage_flags" ] 92 defines = [ "DFX_LOG_UNWIND" ] 93 ldflags = [ "-Wl,-z,separate-code" ] 94 sources = [ "unwinder_pac_test.cpp" ] 95 deps = [ 96 "$faultloggerd_common_path/dfxlog:dfx_hilog", 97 "$faultloggerd_common_path/dfxutil:dfx_util", 98 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder_src", 99 ] 100 external_deps = [ 101 "bounds_checking_function:libsec_shared", 102 "c_utils:utils", 103 "googletest:gtest_main", 104 "hilog:libhilog", 105 ] 106} 107 108ohos_unittest("test_exidx") { 109 module_out_path = module_output_path 110 visibility = [ "*:*" ] 111 include_dirs = [ 112 "$faultloggerd_interfaces_path/common", 113 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 114 ] 115 configs = [ "$faultloggerd_common_path/build:coverage_flags" ] 116 defines = [ 117 "DFX_LOG_UNWIND", 118 "DFX_UNWIND_ERROR", 119 "is_ohos=${is_ohos}", 120 "TEST_ARM_EXIDX", 121 ] 122 sources = [ 123 "$faultloggerd_interfaces_path/innerkits/unwinder/arch_util.cpp", 124 "$faultloggerd_interfaces_path/innerkits/unwinder/arm_exidx.cpp", 125 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_accessors.cpp", 126 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_ark.cpp", 127 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_config.cpp", 128 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_elf.cpp", 129 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_elf_parser.cpp", 130 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_frame_formatter.cpp", 131 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_instructions.cpp", 132 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_map.cpp", 133 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_maps.cpp", 134 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_memory.cpp", 135 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_mmap.cpp", 136 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_ptrace.cpp", 137 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_regs.cpp", 138 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_regs_arm.cpp", 139 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_symbols.cpp", 140 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_xz_utils.cpp", 141 "arm_exidx_test.cpp", 142 ] 143 deps = [ 144 "$faultloggerd_common_path/dfxlog:dfx_hilog", 145 "$faultloggerd_common_path/dfxutil:dfx_util", 146 "$faultloggerd_common_path/trace:dfx_trace_dlsym", 147 ] 148 public_external_deps = [ "lzma:lzma_shared" ] 149 external_deps = [ 150 "bounds_checking_function:libsec_shared", 151 "c_utils:utils", 152 "googletest:gtest_main", 153 "hilog:libhilog", 154 ] 155} 156 157ohos_unittest("test_dwarf") { 158 module_out_path = module_output_path 159 visibility = [ "*:*" ] 160 defines = [ 161 "ALLOW_TO_STDERR", 162 "DFX_LOG_UNWIND", 163 "DFX_LOG_HILOG_BASE", 164 ] 165 include_dirs = [ 166 "$faultloggerd_interfaces_path/common", 167 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 168 ] 169 configs = [ "$faultloggerd_path/common/build:coverage_flags" ] 170 sources = [ 171 "$faultloggerd_interfaces_path/innerkits/unwinder/dwarf_cfa_instructions.cpp", 172 "dwarf_test.cpp", 173 ] 174 cflags_cc = [ "-Dprivate=public" ] 175 176 deps = [ 177 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 178 "$faultloggerd_common_path/dfxutil:dfx_util", 179 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder_base", 180 ] 181 182 resource_config_file = "$faultloggerd_path/test/resource/ohos_test.xml" 183 external_deps = [ 184 "bounds_checking_function:libsec_shared", 185 "c_utils:utils", 186 "googletest:gtest_main", 187 "hilog:libhilog_base", 188 ] 189} 190 191ohos_unittest("test_unwind_supporting") { 192 module_out_path = module_output_path 193 visibility = [ "*:*" ] 194 include_dirs = [ 195 "$faultloggerd_interfaces_path/common", 196 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 197 ] 198 defines = [ "is_ohos=${is_ohos}" ] 199 sources = [ 200 "$faultloggerd_interfaces_path/innerkits/unwinder/arch_util.cpp", 201 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_ark.cpp", 202 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_hap.cpp", 203 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_maps.cpp", 204 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_memory.cpp", 205 "arch_util_test.cpp", 206 "dfx_hap_test.cpp", 207 ] 208 deps = [ 209 "$faultloggerd_common_path/dfxlog:dfx_hilog", 210 "$faultloggerd_common_path/dfxutil:dfx_util", 211 "$faultloggerd_common_path/trace:dfx_trace_dlsym", 212 ] 213 external_deps = [ 214 "c_utils:utils", 215 "hilog:libhilog", 216 ] 217} 218 219group("unittest") { 220 testonly = true 221 deps = [ 222 ":test_unwind", 223 ":test_unwind_pac", 224 ":test_unwind_separate_code", 225 ":test_unwind_supporting", 226 ] 227 if (target_cpu == "arm") { 228 deps += [ ":test_exidx" ] 229 } 230 if (target_cpu == "arm64") { 231 deps += [ ":test_dwarf" ] 232 } 233} 234