1# Copyright (c) 2021-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")
15
16if (defined(ohos_lite)) {
17  import("//build/lite/config/component/lite_component.gni")
18  import("//build/lite/config/test.gni")
19
20  if (ohos_build_type == "debug") {
21    unittest("test_processdump") {
22      output_extension = "bin"
23      output_dir = "$root_out_dir/test/unittest/faultloggerd"
24
25      include_dirs = [
26        "$c_utils_include_path",
27        "$faultloggerd_common_path/dfxutil",
28        "$faultloggerd_interfaces_path/common",
29        "$faultloggerd_interfaces_path/innerkits/procinfo/include",
30        "$faultloggerd_interfaces_path/innerkits/unwinder/include",
31        "$faultloggerd_path/test/utils",
32        "$faultloggerd_path/tools/process_dump",
33        "$hilog_lite_include_path",
34      ]
35
36      sources = [
37        "dfx_processdump_test.cpp",
38        "multithread_constructor.c",
39        "process_dump_test.cpp",
40      ]
41      sources += [ "$c_utils_src_path/directory_ex.cpp" ]
42
43      deps = [
44        "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo",
45        "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder",
46        "$faultloggerd_path/test/utils:dfx_test_util",
47        "$faultloggerd_path/tools/process_dump:process_info_src",
48      ]
49
50      external_deps = [ "hilog_lite:hilog_shared" ]
51    }
52  }
53
54  group("unittest") {
55    deps = [ ":test_processdump" ]
56  }
57} else {
58  import("//build/config/features.gni")
59  import("//build/test.gni")
60
61  config("module_private_config") {
62    visibility = [ ":*" ]
63
64    include_dirs = [
65      "$faultloggerd_common_path/dfxutil",
66      "$faultloggerd_interfaces_path/common",
67      "$faultloggerd_interfaces_path/innerkits/unwinder/include",
68      "$faultloggerd_path/test/utils",
69      "$faultloggerd_path/tools/process_dump",
70    ]
71  }
72
73  module_output_path = "faultloggerd/process_dump"
74
75  ohos_unittest("test_processdump") {
76    module_out_path = module_output_path
77    sources = [
78      "dfx_processdump_test.cpp",
79      "multithread_constructor.c",
80      "process_dump_test.cpp",
81    ]
82    cflags_cc = [ "-Dprivate=public" ]
83
84    configs = [
85      ":module_private_config",
86      "$faultloggerd_path/common/build:coverage_flags",
87    ]
88
89    defines = [ "UNITTEST" ]
90
91    deps = [
92      "$faultloggerd_path/interfaces/innerkits/unwinder:libunwinder_static",
93      "$faultloggerd_path/test/utils:dfx_test_util",
94      "$faultloggerd_path/tools/process_dump:process_info_src",
95    ]
96    external_deps = [
97      "c_utils:utils",
98      "googletest:gmock_main",
99      "googletest:gtest_main",
100      "hilog:libhilog",
101      "jsoncpp:jsoncpp",
102    ]
103    if (support_jsapi) {
104      deps += [ "$faultloggerd_path/test/resource:FaultloggerdJsTest" ]
105    }
106    resource_config_file = "$faultloggerd_path/test/resource/ohos_test.xml"
107  }
108
109  ohos_unittest("test_faultstack") {
110    module_out_path = module_output_path
111    sources = [ "fault_stack_test.cpp" ]
112
113    configs = [
114      ":module_private_config",
115      "$faultloggerd_path/common/build:coverage_flags",
116    ]
117
118    defines = [ "UNITTEST" ]
119
120    deps = [
121      "$faultloggerd_path/interfaces/innerkits/unwinder:libunwinder_static",
122      "$faultloggerd_path/tools/process_dump:process_info_src",
123    ]
124
125    external_deps = [
126      "c_utils:utils",
127      "googletest:gmock_main",
128      "googletest:gtest_main",
129      "hilog:libhilog",
130      "jsoncpp:jsoncpp",
131    ]
132  }
133
134  ohos_unittest("test_lock_parser") {
135    module_out_path = module_output_path
136    sources = [
137      "$faultloggerd_path/tools/process_dump/lock_parser.cpp",
138      "lock_parser_test.cpp",
139    ]
140    configs = [
141      ":module_private_config",
142      "$faultloggerd_path/common/build:coverage_flags",
143    ]
144
145    deps = [
146      "$faultloggerd_path/interfaces/innerkits/unwinder:libunwinder_static",
147      "$faultloggerd_path/tools/process_dump:process_info_src",
148    ]
149
150    external_deps = [
151      "c_utils:utils",
152      "googletest:gmock_main",
153      "googletest:gtest_main",
154      "hilog:libhilog",
155    ]
156  }
157  group("unittest") {
158    testonly = true
159    deps = [
160      ":test_faultstack",
161      ":test_processdump",
162    ]
163
164    if (target_cpu == "arm64") {
165      deps += [ ":test_lock_parser" ]
166    }
167  }
168}
169