• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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("//build/test.gni")
15import("../../../hidumper.gni")
16
17module_output_path = "hiviewdfx/hidumper"
18
19source_path = "${hidumper_frameworks_path}"
20
21###############################################################################
22config("module_private_config") {
23  visibility = [ ":*" ]
24
25  include_dirs = [
26    ".",
27    "../../",
28    "${hidumper_interface}/innerkits/include/",
29    "${hidumper_interface}/native/innerkits/include/",
30    "../../../utils/native/include/",
31    "../../../services/zidl/include",
32    "../../../services/native/include",
33    "${source_path}/include",
34    "${source_path}/",
35    "${source_path}/manager",
36    "${source_path}/dumpers",
37    "include",
38    "${hidumper_frameworks_path}",
39    "${hidumper_frameworks_path}/include",
40    "${hidumper_frameworks_path}/include/common",
41    "${hidumper_frameworks_path}/include/executor",
42    "${hidumper_frameworks_path}/include/factory",
43    "${hidumper_service_path}:interface_include",
44    "${hidumper_service_path}/zidl/include",
45    "${hidumper_service_path}/native/include",
46  ]
47
48  cflags_cc = [ "-DDUMP_TEST_MODE" ]
49}
50
51##############################unittest##########################################
52ohos_unittest("HidumperServiceTest") {
53  module_out_path = module_output_path
54
55  sources = [ "hidumper_service_test.cpp" ]
56
57  configs = [
58    "${hidumper_utils_path}:utils_config",
59    ":module_private_config",
60  ]
61
62  deps = [
63    "${hidumper_service_path}:hidumperservice_source",
64    "//third_party/googletest:gtest_main",
65  ]
66
67  external_deps = [
68    "c_utils:utils",
69    "eventhandler:libeventhandler",
70    "hilog:libhilog",
71    "ipc:ipc_core",
72    "safwk:system_ability_fwk",
73    "samgr:samgr_proxy",
74  ]
75
76  cflags = [
77    "-Dprivate=public",  #allow test code access private members
78  ]
79}
80
81ohos_unittest("HidumperDumpersTest") {
82  module_out_path = module_output_path
83
84  sources = [ "hidumper_dumpers_test.cpp" ]
85
86  configs = [
87    "${hidumper_utils_path}:utils_config",
88    ":module_private_config",
89  ]
90
91  deps = [
92    "${hidumper_service_path}:hidumperservice_cpu_source_test",
93    "${hidumper_service_path}:hidumperservice_source",
94    "//third_party/googletest:gtest_main",
95  ]
96
97  external_deps = [ "hilog:libhilog" ]
98}
99
100ohos_unittest("HidumperOutputTest") {
101  module_out_path = module_output_path
102
103  sources = [ "hidumper_output_test.cpp" ]
104
105  configs = [
106    "${hidumper_utils_path}:utils_config",
107    ":module_private_config",
108  ]
109
110  deps = [
111    "${hidumper_service_path}:hidumperservice_source",
112    "//third_party/googletest:gtest_main",
113    "//third_party/zlib:libz",
114  ]
115
116  external_deps = [
117    "c_utils:utils",
118    "hilog:libhilog",
119    "ipc:ipc_core",
120  ]
121}
122
123ohos_unittest("HidumperConfigUtilsTest") {
124  module_out_path = module_output_path
125
126  sources = [
127    "${hidumper_service_path}/native/src/dump_common_utils.cpp",
128    "${source_path}/dump_utils.cpp",
129    "${source_path}/src/common/dump_cfg.cpp",
130    "${source_path}/src/common/dumper_parameter.cpp",
131    "${source_path}/src/common/option_args.cpp",
132    "${source_path}/src/util/config_data.cpp",
133    "${source_path}/src/util/config_utils.cpp",
134    "${source_path}/src/util/file_utils.cpp",
135    "${source_path}/src/util/zip/zip_writer.cpp",
136    "hidumper_configutils_test.cpp",
137  ]
138
139  configs = [
140    "${hidumper_utils_path}:utils_config",
141    ":module_private_config",
142  ]
143
144  deps = [
145    "//third_party/googletest:gtest_main",
146    "//third_party/zlib:libz",
147  ]
148
149  external_deps = [
150    "c_utils:utils",
151    "hilog:libhilog",
152    "init:libbegetutil",
153    "ipc:ipc_core",
154    "safwk:system_ability_fwk",
155  ]
156}
157
158ohos_unittest("MemoryDumperTest") {
159  module_out_path = module_output_path
160
161  sources = [
162    "hidumper_test_utils.cpp",
163    "memory_dumper_test.cpp",
164  ]
165
166  configs = [ ":module_private_config" ]
167
168  deps = [
169    "${hidumper_service_path}:hidumperservice_source",
170    "//third_party/googletest:gtest_main",
171  ]
172
173  external_deps = [
174    "c_utils:utils",
175    "drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
176    "hilog:libhilog",
177  ]
178}
179
180ohos_unittest("HidumperPrivacyTest") {
181  module_out_path = module_output_path
182
183  sources = [
184    "hidumper_privacy_test.cpp",
185    "hidumper_test_utils.cpp",
186  ]
187
188  configs = [ ":module_private_config" ]
189
190  deps = [ "//third_party/googletest:gtest_main" ]
191
192  external_deps = [ "c_utils:utils" ]
193}
194
195ohos_unittest("HidumperInnerkitsTest") {
196  module_out_path = module_output_path
197
198  sources = [ "hidumper_innerkits_test.cpp" ]
199
200  configs = [ ":module_private_config" ]
201
202  deps = [
203    "${hidumper_service_path}:hidumperservice_source",
204    "../../../interfaces/innerkits:lib_dump_usage",
205    "//third_party/googletest:gtest_main",
206  ]
207
208  external_deps = [
209    "drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
210    "hilog:libhilog",
211  ]
212}
213
214ohos_unittest("HidumperManagerTest") {
215  module_out_path = module_output_path
216
217  sources = [
218    "hidumper_manager_test.cpp",
219    "hidumper_test_utils.cpp",
220  ]
221
222  configs = [ ":module_private_config" ]
223
224  deps = [
225    "${hidumper_service_path}:hidumperservice_source",
226    "//third_party/googletest:gtest_main",
227  ]
228
229  external_deps = [
230    "hilog:libhilog",
231    "init:libbegetutil",
232  ]
233
234  cflags = [
235    "-Dprivate=public",  #allow test code access private members
236  ]
237}
238
239ohos_unittest("HidumperCpuServiceTest") {
240  module_out_path = module_output_path
241
242  sources = [ "hidumper_cpu_service_test.cpp" ]
243
244  configs = [
245    "${hidumper_utils_path}:utils_config",
246    ":module_private_config",
247  ]
248
249  deps = [
250    "${hidumper_service_path}:hidumperservice_cpu_source_test",
251    "${hidumper_service_path}:hidumperservice_source",
252    "//third_party/googletest:gtest_main",
253  ]
254
255  external_deps = [
256    "c_utils:utils",
257    "eventhandler:libeventhandler",
258    "hilog:libhilog",
259    "safwk:system_ability_fwk",
260    "samgr:samgr_proxy",
261  ]
262  defines = []
263  if (hidumper_ablility_base_enable) {
264    external_deps += [ "ability_base:want" ]
265    external_deps += [ "ability_runtime:app_manager" ]
266    defines += [ "HIDUMPER_ABILITY_BASE_ENABLE" ]
267  }
268
269  if (hidumper_battery_manager_enable && hidumper_common_event_enable) {
270    external_deps += [ "battery_manager:batterysrv_client" ]
271    external_deps += [ "common_event_service:cesfwk_innerkits" ]
272    defines += [ "HIDUMPER_BATTERY_ENABLE" ]
273  }
274
275  cflags = [
276    "-Dprivate=public",  #allow test code access private members
277  ]
278}
279
280###############################################################################
281group("unittest") {
282  testonly = true
283  deps = []
284
285  deps += [
286    # deps file
287    ":HidumperConfigUtilsTest",
288    ":HidumperCpuServiceTest",
289    ":HidumperDumpersTest",
290    ":HidumperInnerkitsTest",
291    ":HidumperManagerTest",
292    ":HidumperOutputTest",
293    ":HidumperPrivacyTest",
294    ":HidumperServiceTest",
295    ":MemoryDumperTest",
296  ]
297}
298###############################################################################
299