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