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    "googletest:gtest_main",
65    "hilog:libhilog",
66  ]
67}
68
69ohos_unittest("backtrace_utils_test_static") {
70  module_out_path = module_output_path
71  visibility = [ "*:*" ]
72  include_dirs = [
73    "$faultloggerd_interfaces_path/common",
74    "$faultloggerd_path/test/utils",
75    "$faultloggerd_interfaces_path/innerkits/backtrace",
76  ]
77  defines = [ "DFX_LOG_HILOG_BASE" ]
78  sources = [ "backtrace_utils_test.cpp" ]
79  deps = [
80    "$faultloggerd_common_path/dfxlog:dfx_hilog_base",
81    "$faultloggerd_common_path/dfxutil:dfx_util_static",
82    "$faultloggerd_interfaces_path/innerkits/backtrace:backtrace_local",
83    "$faultloggerd_path/test/utils:dfx_test_util",
84  ]
85  if (use_musl && musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
86    defines += [ "USE_JEMALLOC_DFX_INTF" ]
87  }
88  branch_protector_ret = "pac_ret"
89  public_external_deps = [ "lzma:lzma_static" ]
90  external_deps = [
91    "c_utils:utilsbase",
92    "googletest:gtest_main",
93    "hilog:libhilog_base",
94  ]
95}
96
97ohos_unittest("backtrace_local_test_static") {
98  module_out_path = module_output_path
99  visibility = [ "*:*" ]
100  include_dirs = [
101    "$faultloggerd_interfaces_path/common",
102    "$faultloggerd_path/test/utils",
103    "$faultloggerd_interfaces_path/innerkits/backtrace",
104  ]
105  defines = [
106    "BACKTRACE_LOCAL_TEST_STATIC",
107    "DFX_LOG_HILOG_BASE",
108  ]
109  sources = [ "backtrace_local_test.cpp" ]
110  deps = [
111    "$faultloggerd_common_path/dfxlog:dfx_hilog_base",
112    "$faultloggerd_common_path/dfxutil:dfx_util_static",
113    "$faultloggerd_interfaces_path/innerkits/backtrace:backtrace_local",
114    "$faultloggerd_path/test/utils:dfx_test_util",
115  ]
116  branch_protector_ret = "pac_ret"
117  public_external_deps = [ "lzma:lzma_static" ]
118  external_deps = [
119    "bounds_checking_function:libsec_static",
120    "c_utils:utilsbase",
121    "googletest:gtest_main",
122    "hilog:libhilog_base",
123  ]
124}
125
126group("unittest") {
127  testonly = true
128  deps = [
129    ":backtrace_local_test",
130    ":backtrace_utils_test",
131  ]
132  if (target_cpu == "arm64") {
133    deps += [
134      ":backtrace_local_test_static",
135      ":backtrace_utils_test_static",
136    ]
137  }
138}
139