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 "DFX_LOG_UNWIND", 162 "DFX_LOG_HILOG_BASE", 163 ] 164 include_dirs = [ 165 "$faultloggerd_interfaces_path/common", 166 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 167 ] 168 configs = [ "$faultloggerd_path/common/build:coverage_flags" ] 169 sources = [ 170 "$faultloggerd_interfaces_path/innerkits/unwinder/dwarf_cfa_instructions.cpp", 171 "dwarf_test.cpp", 172 ] 173 cflags_cc = [ "-Dprivate=public" ] 174 175 deps = [ 176 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 177 "$faultloggerd_common_path/dfxutil:dfx_util", 178 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder_base", 179 ] 180 181 resource_config_file = "$faultloggerd_path/test/resource/ohos_test.xml" 182 external_deps = [ 183 "bounds_checking_function:libsec_shared", 184 "c_utils:utils", 185 "googletest:gtest_main", 186 "hilog:libhilog_base", 187 ] 188} 189 190ohos_unittest("test_unwind_supporting") { 191 module_out_path = module_output_path 192 visibility = [ "*:*" ] 193 include_dirs = [ 194 "$faultloggerd_interfaces_path/common", 195 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 196 ] 197 defines = [ "is_ohos=${is_ohos}" ] 198 sources = [ 199 "$faultloggerd_interfaces_path/innerkits/unwinder/arch_util.cpp", 200 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_ark.cpp", 201 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_hap.cpp", 202 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_maps.cpp", 203 "$faultloggerd_interfaces_path/innerkits/unwinder/dfx_memory.cpp", 204 "arch_util_test.cpp", 205 "dfx_hap_test.cpp", 206 ] 207 deps = [ 208 "$faultloggerd_common_path/dfxlog:dfx_hilog", 209 "$faultloggerd_common_path/dfxutil:dfx_util", 210 "$faultloggerd_common_path/trace:dfx_trace_dlsym", 211 ] 212 external_deps = [ 213 "c_utils:utils", 214 "hilog:libhilog", 215 ] 216} 217 218group("unittest") { 219 testonly = true 220 deps = [ 221 ":test_unwind", 222 ":test_unwind_pac", 223 ":test_unwind_separate_code", 224 ":test_unwind_supporting", 225 ] 226 if (target_cpu == "arm") { 227 deps += [ ":test_exidx" ] 228 } 229 if (target_cpu == "arm64") { 230 deps += [ ":test_dwarf" ] 231 } 232} 233