• 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 = [
56    "${hidumper_frameworks_path}/src/executor/memory/memory_util.cpp",
57    "hidumper_service_test.cpp",
58  ]
59
60  configs = [
61    "${hidumper_utils_path}:utils_config",
62    ":module_private_config",
63  ]
64
65  deps = [ "${hidumper_service_path}:hidumperservice_source" ]
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 = [ "${hidumper_service_path}:hidumperservice_source" ]
92
93  defines = []
94  if (hidumper_hiviewdfx_hiview_enable) {
95    deps += [ "${hidumper_service_path}:hidumperservice_cpu_source_test" ]
96    defines += [ "HIDUMPER_HIVIEWDFX_HIVIEW_ENABLE" ]
97  }
98
99  external_deps = [
100    "c_utils:utils",
101    "hilog:libhilog",
102    "ipc:ipc_core",
103    "samgr:samgr_proxy",
104  ]
105
106  defines = []
107  if (hidumper_ability_runtime_enable) {
108    external_deps += [ "ability_runtime:app_manager" ]
109    defines += [ "HIDUMPER_ABILITY_RUNTIME_ENABLE" ]
110  }
111}
112
113ohos_unittest("HidumperOutputTest") {
114  module_out_path = module_output_path
115
116  sources = [ "hidumper_output_test.cpp" ]
117
118  configs = [
119    "${hidumper_utils_path}:utils_config",
120    ":module_private_config",
121  ]
122
123  deps = [ "${hidumper_service_path}:hidumperservice_source" ]
124
125  external_deps = [
126    "c_utils:utils",
127    "hilog:libhilog",
128    "ipc:ipc_core",
129    "zlib:shared_libz",
130  ]
131}
132
133ohos_unittest("HidumperConfigUtilsTest") {
134  module_out_path = module_output_path
135
136  sources = [ "hidumper_configutils_test.cpp" ]
137
138  configs = [
139    "${hidumper_utils_path}:utils_config",
140    ":module_private_config",
141  ]
142
143  deps = [ "${hidumper_service_path}:hidumperservice_source" ]
144
145  external_deps = [
146    "c_utils:utils",
147    "hilog:libhilog",
148    "init:libbegetutil",
149    "ipc:ipc_core",
150    "safwk:system_ability_fwk",
151    "samgr:samgr_proxy",
152    "zlib:shared_libz",
153  ]
154}
155
156ohos_unittest("MemoryDumperTest") {
157  module_out_path = module_output_path
158
159  sources = [
160    "${hidumper_frameworks_path}/src/executor/memory/memory_util.cpp",
161    "hidumper_test_utils.cpp",
162    "memory_dumper_test.cpp",
163  ]
164
165  configs = [ ":module_private_config" ]
166
167  deps = [ "${hidumper_service_path}:hidumperservice_source" ]
168
169  external_deps = [
170    "c_utils:utils",
171    "drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
172    "hdf_core:libhdf_utils",
173    "hilog:libhilog",
174    "ipc:ipc_core",
175    "safwk:system_ability_fwk",
176  ]
177  cflags = [
178    "-Dprivate=public",  #allow test code access private members
179  ]
180}
181
182ohos_unittest("HidumperMemoryTest") {
183  module_out_path = module_output_path
184
185  sources = [
186    "hidumper_memory_test.cpp",
187    "hidumper_test_utils.cpp",
188  ]
189
190  configs = [ ":module_private_config" ]
191
192  deps = [
193    #"${hidumper_service_path}:hidumperservice_source",
194    "${hidumper_service_path}:hidumpermemory_source",
195  ]
196
197  external_deps = [
198    "c_utils:utils",
199    "drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
200    "hdf_core:libhdf_utils",
201    "hilog:libhilog",
202    "hiview:libucollection_utility",
203    "ipc:ipc_core",
204    "safwk:system_ability_fwk",
205  ]
206  defines = []
207  if (hidumper_report_memmgr) {
208    defines += [ "HIDUMPER_MEMMGR_ENABLE" ]
209  }
210  cflags = [
211    "-Dprivate=public",  #allow test code access private members
212  ]
213}
214
215ohos_unittest("SADumperTest") {
216  module_out_path = module_output_path
217  sources = [
218    "hidumper_test_utils.cpp",
219    "sa_dumper_test.cpp",
220  ]
221  configs = [ ":module_private_config" ]
222  deps = []
223  external_deps = [
224    "c_utils:utils",
225    "hilog:libhilog",
226    "ipc:ipc_core",
227  ]
228
229  defines = []
230  if (hidumper_hiviewdfx_hiview_enable) {
231    defines += [ "HIDUMPER_HIVIEWDFX_HIVIEW_ENABLE" ]
232  }
233}
234
235ohos_unittest("HidumperPrivacyTest") {
236  module_out_path = module_output_path
237
238  sources = [
239    "hidumper_privacy_test.cpp",
240    "hidumper_test_utils.cpp",
241  ]
242
243  configs = [ ":module_private_config" ]
244
245  deps = []
246
247  external_deps = [ "c_utils:utils" ]
248}
249
250ohos_unittest("HidumperInnerkitsTest") {
251  module_out_path = module_output_path
252
253  sources = [
254    "${hidumper_frameworks_path}/src/executor/memory/get_heap_info.cpp",
255    "${hidumper_frameworks_path}/src/executor/memory/memory_filter.cpp",
256    "${hidumper_frameworks_path}/src/executor/memory/memory_util.cpp",
257    "${hidumper_frameworks_path}/src/executor/memory/parse/parse_smaps_info.cpp",
258    "hidumper_innerkits_test.cpp",
259    "hidumper_test_utils.cpp",
260  ]
261
262  defines = []
263  if (hidumper_hiviewdfx_hiview_enable) {
264    defines += [ "HIDUMPER_HIVIEWDFX_HIVIEW_ENABLE" ]
265  }
266
267  configs = [ ":module_private_config" ]
268
269  deps = [
270    "${hidumper_service_path}:hidumperservice_source",
271    "../../../interfaces/innerkits:lib_dump_usage",
272  ]
273
274  external_deps = [
275    "c_utils:utils",
276    "drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
277    "hdf_core:libhdf_utils",
278    "hilog:libhilog",
279    "hiview:libucollection_utility",
280    "ipc:ipc_core",
281    "samgr:samgr_proxy",
282  ]
283}
284
285ohos_unittest("GetHeapInfoTest") {
286  module_out_path = module_output_path
287
288  sources = [
289    "${hidumper_frameworks_path}/src/executor/memory/get_heap_info.cpp",
290    "get_heap_info_test.cpp",
291  ]
292  cflags = [ "-DHIDUMPER_UNITTEST" ]
293  configs = [ ":module_private_config" ]
294
295  deps = [ "${hidumper_service_path}:hidumperservice_source" ]
296  defines = []
297  external_deps = [
298    "c_utils:utils",
299    "hilog:libhilog",
300    "hiview:libucollection_utility",
301    "ipc:ipc_core",
302    "samgr:samgr_proxy",
303  ]
304  if (hidumper_ability_runtime_enable) {
305    external_deps += [ "ability_runtime:app_manager" ]
306    defines += [ "HIDUMPER_ABILITY_RUNTIME_ENABLE" ]
307  }
308}
309
310ohos_unittest("HidumperManagerTest") {
311  module_out_path = module_output_path
312
313  sources = [
314    "hidumper_manager_test.cpp",
315    "hidumper_test_utils.cpp",
316  ]
317
318  configs = [ ":module_private_config" ]
319
320  deps = [ "${hidumper_service_path}:hidumperservice_source" ]
321
322  external_deps = [
323    "c_utils:utils",
324    "hilog:libhilog",
325    "init:libbegetutil",
326    "ipc:ipc_core",
327    "samgr:samgr_proxy",
328  ]
329
330  defines = []
331  if (hidumper_hiviewdfx_hiview_enable) {
332    defines += [ "HIDUMPER_HIVIEWDFX_HIVIEW_ENABLE" ]
333  }
334
335  cflags = [
336    "-Dprivate=public",  #allow test code access private members
337  ]
338}
339
340ohos_unittest("HidumperCpuServiceTest") {
341  module_out_path = module_output_path
342
343  sources = [ "hidumper_cpu_service_test.cpp" ]
344
345  configs = [
346    "${hidumper_utils_path}:utils_config",
347    ":module_private_config",
348  ]
349
350  deps = [
351    "${hidumper_service_path}:hidumperservice_cpu_source_test",
352    "${hidumper_service_path}:hidumperservice_source",
353  ]
354
355  external_deps = [
356    "c_utils:utils",
357    "eventhandler:libeventhandler",
358    "hilog:libhilog",
359    "ipc:ipc_core",
360    "safwk:system_ability_fwk",
361    "samgr:samgr_proxy",
362  ]
363  defines = []
364  if (hidumper_ablility_base_enable) {
365    external_deps += [ "ability_base:want" ]
366    external_deps += [ "ability_runtime:app_manager" ]
367    defines += [ "HIDUMPER_ABILITY_BASE_ENABLE" ]
368  }
369
370  cflags = [
371    "-Dprivate=public",  #allow test code access private members
372  ]
373}
374
375ohos_unittest("HidumperClientTest") {
376  module_out_path = module_output_path
377
378  sources = [
379    "hidumper_client_test.cpp",
380    "hidumper_test_utils.cpp",
381  ]
382
383  configs = [ ":module_private_config" ]
384
385  deps = [
386    "${hidumper_frameworks_path}:hidumperclient",
387    "${hidumper_service_path}:hidumper_client",
388  ]
389
390  external_deps = [
391    "ability_runtime:app_manager",
392    "c_utils:utils",
393    "hilog:libhilog",
394    "init:libbegetutil",
395    "ipc:ipc_core",
396    "samgr:samgr_proxy",
397  ]
398
399  cflags = [
400    "-Dprivate=public",  #allow test code access private members
401  ]
402}
403
404ohos_unittest("HidumperZidlTest") {
405  module_out_path = module_output_path
406
407  sources = [ "hidumper_zidl_test.cpp" ]
408
409  configs = [
410    ":module_private_config",
411    "${hidumper_service_path}:zidl_config",
412  ]
413
414  deps = [ "${hidumper_service_path}:zidl_service" ]
415
416  external_deps = [
417    "hilog:libhilog",
418    "ipc:ipc_core",
419  ]
420  cflags = [
421    "-Dprivate=public",  #allow test code access private members
422  ]
423}
424
425ohos_unittest("HidumperCpuZidlTest") {
426  module_out_path = module_output_path
427
428  sources = [
429    "${hidumper_service_path}/native/src/dump_cpu_data.cpp",
430    "hidumper_cpu_zidl_test.cpp",
431  ]
432
433  configs = [
434    ":module_private_config",
435    "${hidumper_service_path}:dump_cpu_config",
436    "${hidumper_service_path}:zidl_config",
437  ]
438
439  deps = [ "${hidumper_service_path}:zidl_cpu_service" ]
440
441  external_deps = [
442    "hilog:libhilog",
443    "ipc:ipc_core",
444  ]
445  cflags = [
446    "-Dprivate=public",  #allow test code access private members
447  ]
448}
449
450###############################################################################
451group("unittest") {
452  testonly = true
453
454  deps = [
455    # deps file
456    ":GetHeapInfoTest",
457    ":HidumperClientTest",
458    ":HidumperConfigUtilsTest",
459    ":HidumperDumpersTest",
460    ":HidumperInnerkitsTest",
461    ":HidumperManagerTest",
462    ":HidumperMemoryTest",
463    ":HidumperOutputTest",
464    ":HidumperPrivacyTest",
465    ":HidumperServiceTest",
466    ":HidumperZidlTest",
467    ":MemoryDumperTest",
468    ":SADumperTest",
469  ]
470
471  if (hidumper_hiviewdfx_hiview_enable) {
472    deps += [ ":HidumperCpuServiceTest" ]
473  }
474}
475###############################################################################
476