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