1# Copyright (c) 2021-2022 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("../../../var.gni")
16
17module_output_path = "samgr/samgr"
18samgr_dir = "//foundation/systemabilitymgr/samgr"
19samgr_services_dir = "${samgr_dir}/services/samgr/native"
20
21config("sam_test_config") {
22  visibility = [ ":*" ]
23  include_dirs = [
24    "${samgr_services_dir}/test/unittest/include",
25    "//foundation/systemabilitymgr/samgr/services/dfx/include",
26    "//foundation/systemabilitymgr/samgr/utils/native/include",
27    "//foundation/systemabilitymgr/samgr/services/lsamgr/include",
28  ]
29}
30
31config("samgr_proxy_config") {
32  include_dirs = [ "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include" ]
33}
34
35config("samgr_proxy_private_config") {
36  include_dirs = [
37    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
38    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/lsamgr",
39    "//foundation/systemabilitymgr/samgr/services/lsamgr/include",
40    "//foundation/systemabilitymgr/samgr/services/samgr/native/include",
41    "//foundation/systemabilitymgr/samgr/utils/native/include",
42  ]
43}
44
45ohos_unittest("SystemAbilityMgrTest") {
46  sanitize = {
47    cfi = true
48    cfi_cross_dso = true
49    debug = false
50    cfi_no_nvcall = true
51    blocklist = "../../../../../cfi_blocklist.txt"
52  }
53  module_out_path = module_output_path
54
55  sources = [
56    "${samgr_dir}/utils/native/source/tools.cpp",
57    "${samgr_services_dir}/source/ability_death_recipient.cpp",
58    "${samgr_services_dir}/source/collect/device_param_collect.cpp",
59    "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp",
60    "${samgr_services_dir}/source/collect/device_timed_collect.cpp",
61    "${samgr_services_dir}/source/collect/icollect_plugin.cpp",
62    "${samgr_services_dir}/source/ffrt_handler.cpp",
63    "${samgr_services_dir}/source/memory_guard.cpp",
64    "${samgr_services_dir}/source/rpc_callback_imp.cpp",
65    "${samgr_services_dir}/source/samgr_time_handler.cpp",
66    "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp",
67    "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp",
68    "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp",
69    "${samgr_services_dir}/source/system_ability_load_callback_proxy.cpp",
70    "${samgr_services_dir}/source/system_ability_manager.cpp",
71    "${samgr_services_dir}/source/system_ability_manager_dumper.cpp",
72    "${samgr_services_dir}/source/system_ability_manager_stub.cpp",
73    "${samgr_services_dir}/source/system_ability_manager_util.cpp",
74    "${samgr_services_dir}/source/system_ability_status_change_proxy.cpp",
75    "${samgr_services_dir}/source/system_process_status_change_proxy.cpp",
76    "${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
77    "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp",
78    "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
79    "${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
80    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_process_status_change_stub.cpp",
81    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
82    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
83  ]
84
85  configs = [
86    ":sam_test_config",
87    "${samgr_dir}/services/samgr/native:sam_config",
88    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
89  ]
90
91  cflags = []
92  if (target_cpu == "arm") {
93    cflags += [ "-DBINDER_IPC_32BIT" ]
94  }
95
96  deps = [
97    ":samgr_proxy_tdd",
98    "${samgr_dir}/interfaces/innerkits/common:samgr_common",
99  ]
100
101  external_deps = [
102    "access_token:libaccesstoken_sdk",
103    "access_token:libnativetoken_shared",
104    "access_token:libtokensetproc_shared",
105    "c_utils:utils",
106    "eventhandler:libeventhandler",
107    "ffrt:libffrt",
108    "googletest:gtest_main",
109    "hilog:libhilog",
110    "hisysevent:libhisysevent",
111    "hitrace:hitrace_meter",
112    "init:libbeget_proxy",
113    "init:libbegetutil",
114    "ipc:ipc_core",
115    "ipc:libdbinder",
116    "json:nlohmann_json_static",
117    "safwk:system_ability_fwk",
118  ]
119  defines = []
120  if (use_musl) {
121    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
122      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
123    }
124  }
125  if (hicollie_able) {
126    external_deps += [ "hicollie:libhicollie" ]
127    defines += [ "HICOLLIE_ENABLE" ]
128  }
129
130  if (support_common_event) {
131    sources += [
132      "${samgr_services_dir}/source/collect/common_event_collect.cpp",
133      "${samgr_services_dir}/test/unittest/src/system_ability_mgr_new_test.cpp",
134      "${samgr_services_dir}/test/unittest/src/system_ability_mgr_test.cpp",
135    ]
136    external_deps += [
137      "ability_base:want",
138      "common_event_service:cesfwk_innerkits",
139    ]
140    defines += [ "SUPPORT_COMMON_EVENT" ]
141  }
142}
143
144ohos_unittest("SystemAbilityMgrCollectTest") {
145  module_out_path = module_output_path
146
147  sources = [
148    "${samgr_dir}/utils/native/source/tools.cpp",
149    "${samgr_services_dir}/source/ability_death_recipient.cpp",
150    "${samgr_services_dir}/source/collect/device_param_collect.cpp",
151    "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp",
152    "${samgr_services_dir}/source/collect/device_timed_collect.cpp",
153    "${samgr_services_dir}/source/collect/icollect_plugin.cpp",
154    "${samgr_services_dir}/source/ffrt_handler.cpp",
155    "${samgr_services_dir}/source/memory_guard.cpp",
156    "${samgr_services_dir}/source/rpc_callback_imp.cpp",
157    "${samgr_services_dir}/source/samgr_time_handler.cpp",
158    "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp",
159    "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp",
160    "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp",
161    "${samgr_services_dir}/source/system_ability_load_callback_proxy.cpp",
162    "${samgr_services_dir}/source/system_ability_manager.cpp",
163    "${samgr_services_dir}/source/system_ability_manager_dumper.cpp",
164    "${samgr_services_dir}/source/system_ability_manager_stub.cpp",
165    "${samgr_services_dir}/source/system_ability_manager_util.cpp",
166    "${samgr_services_dir}/source/system_ability_status_change_proxy.cpp",
167    "${samgr_services_dir}/source/system_process_status_change_proxy.cpp",
168    "${samgr_services_dir}/test/unittest/src/device_param_collect_test.cpp",
169    "${samgr_services_dir}/test/unittest/src/device_timed_collect_test.cpp",
170    "${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
171    "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp",
172    "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
173    "${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
174    "${samgr_services_dir}/test/unittest/src/system_ability_mgr_util_test.cpp",
175    "${samgr_services_dir}/test/unittest/src/system_ability_on_demand_event_test.cpp",
176    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_process_status_change_stub.cpp",
177    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
178    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
179  ]
180
181  configs = [
182    ":sam_test_config",
183    "${samgr_dir}/services/samgr/native:sam_config",
184    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
185  ]
186
187  cflags = []
188  if (target_cpu == "arm") {
189    cflags += [ "-DBINDER_IPC_32BIT" ]
190  }
191
192  deps = [
193    ":samgr_proxy_tdd",
194    "${samgr_dir}/interfaces/innerkits/common:samgr_common",
195  ]
196
197  external_deps = [
198    "access_token:libaccesstoken_sdk",
199    "access_token:libnativetoken_shared",
200    "access_token:libtokensetproc_shared",
201    "c_utils:utils",
202    "eventhandler:libeventhandler",
203    "ffrt:libffrt",
204    "googletest:gtest_main",
205    "hilog:libhilog",
206    "hisysevent:libhisysevent",
207    "hitrace:hitrace_meter",
208    "init:libbeget_proxy",
209    "init:libbegetutil",
210    "ipc:ipc_core",
211    "ipc:libdbinder",
212    "json:nlohmann_json_static",
213    "safwk:system_ability_fwk",
214  ]
215  defines = []
216  if (use_musl) {
217    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
218      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
219    }
220  }
221  if (hicollie_able) {
222    external_deps += [ "hicollie:libhicollie" ]
223    defines += [ "HICOLLIE_ENABLE" ]
224  }
225
226  if (preferences_enable) {
227    external_deps += [ "preferences:native_preferences" ]
228    sources +=
229        [ "${samgr_services_dir}/source/collect/device_timed_collect_tool.cpp" ]
230    defines += [ "PREFERENCES_ENABLE" ]
231  }
232
233  if (support_common_event) {
234    sources += [
235      "${samgr_services_dir}/source/collect/common_event_collect.cpp",
236      "${samgr_services_dir}/test/unittest/src/common_event_collect_test.cpp",
237      "${samgr_services_dir}/test/unittest/src/device_status_collect_manager_test.cpp",
238    ]
239    external_deps += [
240      "ability_base:want",
241      "common_event_service:cesfwk_innerkits",
242    ]
243    defines += [ "SUPPORT_COMMON_EVENT" ]
244  }
245
246  if (support_common_event && bluetooth_part_enable) {
247    sources += [
248      "${samgr_services_dir}/source/collect/device_switch_collect.cpp",
249      "${samgr_services_dir}/test/unittest/src/device_switch_collect_test.cpp",
250    ]
251    external_deps += [ "bluetooth:btframework" ]
252    defines += [ "SUPPORT_SWITCH_COLLECT" ]
253  }
254  if (support_device_manager) {
255    sources +=
256        [ "${samgr_services_dir}/source/collect/device_networking_collect.cpp" ]
257    external_deps += [ "device_manager:devicemanagersdk" ]
258    defines += [ "SUPPORT_DEVICE_MANAGER" ]
259  }
260}
261
262ohos_unittest("SystemAbilityMgrDeviceNetworkingTest") {
263  module_out_path = module_output_path
264
265  sources = [
266    "${samgr_dir}/utils/native/source/tools.cpp",
267    "${samgr_services_dir}/source/ability_death_recipient.cpp",
268    "${samgr_services_dir}/source/collect/device_param_collect.cpp",
269    "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp",
270    "${samgr_services_dir}/source/collect/device_timed_collect.cpp",
271    "${samgr_services_dir}/source/collect/icollect_plugin.cpp",
272    "${samgr_services_dir}/source/ffrt_handler.cpp",
273    "${samgr_services_dir}/source/memory_guard.cpp",
274    "${samgr_services_dir}/source/rpc_callback_imp.cpp",
275    "${samgr_services_dir}/source/samgr_time_handler.cpp",
276    "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp",
277    "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp",
278    "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp",
279    "${samgr_services_dir}/source/system_ability_load_callback_proxy.cpp",
280    "${samgr_services_dir}/source/system_ability_manager.cpp",
281    "${samgr_services_dir}/source/system_ability_manager_dumper.cpp",
282    "${samgr_services_dir}/source/system_ability_manager_stub.cpp",
283    "${samgr_services_dir}/source/system_ability_manager_util.cpp",
284    "${samgr_services_dir}/source/system_ability_status_change_proxy.cpp",
285    "${samgr_services_dir}/source/system_process_status_change_proxy.cpp",
286    "${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
287    "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp",
288    "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
289    "${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
290    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_process_status_change_stub.cpp",
291    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
292    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
293  ]
294
295  configs = [
296    ":sam_test_config",
297    "${samgr_dir}/services/samgr/native:sam_config",
298    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
299  ]
300
301  cflags = []
302  if (target_cpu == "arm") {
303    cflags += [ "-DBINDER_IPC_32BIT" ]
304  }
305
306  deps = [
307    ":samgr_proxy_tdd",
308    "${samgr_dir}/interfaces/innerkits/common:samgr_common",
309  ]
310
311  external_deps = [
312    "access_token:libaccesstoken_sdk",
313    "access_token:libnativetoken_shared",
314    "access_token:libtokensetproc_shared",
315    "c_utils:utils",
316    "eventhandler:libeventhandler",
317    "ffrt:libffrt",
318    "googletest:gtest_main",
319    "hilog:libhilog",
320    "hisysevent:libhisysevent",
321    "hitrace:hitrace_meter",
322    "init:libbeget_proxy",
323    "init:libbegetutil",
324    "ipc:ipc_core",
325    "ipc:libdbinder",
326    "json:nlohmann_json_static",
327    "safwk:system_ability_fwk",
328  ]
329  defines = []
330  if (use_musl) {
331    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
332      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
333    }
334  }
335  if (hicollie_able) {
336    external_deps += [ "hicollie:libhicollie" ]
337    defines += [ "HICOLLIE_ENABLE" ]
338  }
339
340  if (support_device_manager) {
341    sources += [
342      "${samgr_services_dir}/source/collect/device_networking_collect.cpp",
343      "${samgr_services_dir}/test/unittest/src/device_networking_collect_test.cpp",
344    ]
345    external_deps += [ "device_manager:devicemanagersdk" ]
346    defines += [ "SUPPORT_DEVICE_MANAGER" ]
347  }
348}
349
350ohos_unittest("SystemAbilityMgrStubTest") {
351  module_out_path = module_output_path
352
353  sources = [
354    "${samgr_dir}/utils/native/source/tools.cpp",
355    "${samgr_services_dir}/source/ability_death_recipient.cpp",
356    "${samgr_services_dir}/source/collect/device_param_collect.cpp",
357    "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp",
358    "${samgr_services_dir}/source/collect/device_timed_collect.cpp",
359    "${samgr_services_dir}/source/collect/icollect_plugin.cpp",
360    "${samgr_services_dir}/source/ffrt_handler.cpp",
361    "${samgr_services_dir}/source/memory_guard.cpp",
362    "${samgr_services_dir}/source/rpc_callback_imp.cpp",
363    "${samgr_services_dir}/source/samgr_time_handler.cpp",
364    "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp",
365    "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp",
366    "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp",
367    "${samgr_services_dir}/source/system_ability_manager.cpp",
368    "${samgr_services_dir}/source/system_ability_manager_dumper.cpp",
369    "${samgr_services_dir}/source/system_ability_manager_stub.cpp",
370    "${samgr_services_dir}/source/system_ability_manager_util.cpp",
371    "${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
372    "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp",
373    "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
374    "${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
375    "${samgr_services_dir}/test/unittest/src/system_ability_mgr_stub_test.cpp",
376    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
377  ]
378
379  configs = [
380    ":sam_test_config",
381    "${samgr_dir}/services/samgr/native:sam_config",
382    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
383  ]
384
385  cflags = []
386  if (target_cpu == "arm") {
387    cflags += [ "-DBINDER_IPC_32BIT" ]
388  }
389
390  deps = [
391    ":samgr_proxy_tdd",
392    "${samgr_dir}/interfaces/innerkits/common:samgr_common",
393  ]
394
395  external_deps = [
396    "access_token:libaccesstoken_sdk",
397    "access_token:libnativetoken_shared",
398    "access_token:libtokensetproc_shared",
399    "c_utils:utils",
400    "eventhandler:libeventhandler",
401    "ffrt:libffrt",
402    "googletest:gtest_main",
403    "hilog:libhilog",
404    "hisysevent:libhisysevent",
405    "hitrace:hitrace_meter",
406    "init:libbeget_proxy",
407    "init:libbegetutil",
408    "ipc:ipc_core",
409    "ipc:libdbinder",
410    "json:nlohmann_json_static",
411    "safwk:system_ability_fwk",
412  ]
413  defines = []
414  if (use_musl) {
415    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
416      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
417    }
418  }
419  if (hicollie_able) {
420    external_deps += [ "hicollie:libhicollie" ]
421    defines += [ "HICOLLIE_ENABLE" ]
422  }
423
424  if (support_device_manager) {
425    sources +=
426        [ "${samgr_services_dir}/source/collect/device_networking_collect.cpp" ]
427    external_deps += [ "device_manager:devicemanagersdk" ]
428    defines += [ "SUPPORT_DEVICE_MANAGER" ]
429  }
430}
431
432ohos_unittest("SystemAbilityMgrProxyTest") {
433  module_out_path = module_output_path
434
435  sources = [
436    "${samgr_services_dir}/source/system_ability_load_callback_proxy.cpp",
437    "${samgr_services_dir}/source/system_ability_status_change_proxy.cpp",
438    "${samgr_services_dir}/source/system_process_status_change_proxy.cpp",
439    "${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
440    "${samgr_services_dir}/test/unittest/src/local_abilitys_test.cpp",
441    "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp",
442    "${samgr_services_dir}/test/unittest/src/mock_iro_sendrequest.cpp",
443    "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
444    "${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
445    "${samgr_services_dir}/test/unittest/src/system_ability_mgr_proxy_test.cpp",
446    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_ability_manager_proxy.cpp",
447    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_process_status_change_stub.cpp",
448    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
449    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
450    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_abilitys.cpp",
451  ]
452
453  configs = [
454    ":sam_test_config",
455    "${samgr_dir}/services/samgr/native:sam_config",
456    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
457  ]
458
459  if (target_cpu == "arm") {
460    cflags = [ "-DBINDER_IPC_32BIT" ]
461  }
462
463  deps = [
464    ":samgr_proxy_tdd",
465    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/dynamic_cache:dynamic_cache",
466  ]
467
468  external_deps = [
469    "access_token:libaccesstoken_sdk",
470    "access_token:libnativetoken_shared",
471    "access_token:libtokensetproc_shared",
472    "c_utils:utils",
473    "hilog:libhilog",
474    "init:libbegetutil",
475    "ipc:ipc_core",
476    "ipc:ipc_single",
477    "json:nlohmann_json_static",
478  ]
479}
480
481ohos_unittest("LocalAbilityManagerProxyTest") {
482  module_out_path = module_output_path
483
484  sources = [
485    "${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
486    "${samgr_services_dir}/test/unittest/src/local_ability_manager_proxy_test.cpp",
487    "${samgr_services_dir}/test/unittest/src/mock_iro_sendrequest.cpp",
488    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
489    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
490  ]
491
492  configs = [
493    ":sam_test_config",
494    "${samgr_dir}/services/samgr/native:sam_config",
495    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
496  ]
497
498  if (target_cpu == "arm") {
499    cflags = [ "-DBINDER_IPC_32BIT" ]
500  }
501
502  deps = [ "//third_party/googletest:gtest_main" ]
503
504  external_deps = [
505    "c_utils:utils",
506    "hilog:libhilog",
507    "ipc:ipc_core",
508    "json:nlohmann_json_static",
509  ]
510}
511
512ohos_unittest("SystemAbilityStateSchedulerTest") {
513  module_out_path = module_output_path
514
515  sources = [
516    "${samgr_dir}/utils/native/source/tools.cpp",
517    "${samgr_services_dir}/source/ability_death_recipient.cpp",
518    "${samgr_services_dir}/source/collect/device_param_collect.cpp",
519    "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp",
520    "${samgr_services_dir}/source/collect/icollect_plugin.cpp",
521    "${samgr_services_dir}/source/ffrt_handler.cpp",
522    "${samgr_services_dir}/source/memory_guard.cpp",
523    "${samgr_services_dir}/source/samgr_time_handler.cpp",
524    "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp",
525    "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp",
526    "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp",
527    "${samgr_services_dir}/source/system_ability_manager.cpp",
528    "${samgr_services_dir}/source/system_ability_manager_dumper.cpp",
529    "${samgr_services_dir}/source/system_ability_manager_stub.cpp",
530    "${samgr_services_dir}/source/system_ability_manager_util.cpp",
531    "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp",
532    "${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
533    "${samgr_services_dir}/test/unittest/src/system_ability_event_handler_test.cpp",
534    "${samgr_services_dir}/test/unittest/src/system_ability_state_machine_test.cpp",
535    "${samgr_services_dir}/test/unittest/src/system_ability_state_scheduler_test.cpp",
536    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
537  ]
538
539  defines = []
540  if (use_musl) {
541    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
542      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
543    }
544  }
545
546  configs = [
547    ":sam_test_config",
548    "${samgr_dir}/services/samgr/native:sam_config",
549    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
550  ]
551
552  if (target_cpu == "arm") {
553    cflags = [ "-DBINDER_IPC_32BIT" ]
554  }
555
556  deps = [
557    ":samgr_proxy_tdd",
558    "${samgr_dir}/interfaces/innerkits/common:samgr_common",
559  ]
560
561  external_deps = [
562    "access_token:libaccesstoken_sdk",
563    "access_token:libnativetoken_shared",
564    "access_token:libtokensetproc_shared",
565    "c_utils:utils",
566    "eventhandler:libeventhandler",
567    "ffrt:libffrt",
568    "googletest:gtest_main",
569    "hilog:libhilog",
570    "hisysevent:libhisysevent",
571    "hitrace:hitrace_meter",
572    "init:libbeget_proxy",
573    "init:libbegetutil",
574    "ipc:ipc_core",
575    "ipc:libdbinder",
576    "json:nlohmann_json_static",
577    "safwk:system_ability_fwk",
578  ]
579
580  if (support_device_manager) {
581    external_deps += [ "device_manager:devicemanagersdk" ]
582    defines += [ "SUPPORT_DEVICE_MANAGER" ]
583  }
584}
585
586ohos_unittest("SystemAbilityMgrDumperTest") {
587  module_out_path = module_output_path
588
589  sources = [
590    "${samgr_dir}/utils/native/source/tools.cpp",
591    "${samgr_services_dir}/source/ability_death_recipient.cpp",
592    "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp",
593    "${samgr_services_dir}/source/collect/icollect_plugin.cpp",
594    "${samgr_services_dir}/source/ffrt_handler.cpp",
595    "${samgr_services_dir}/source/memory_guard.cpp",
596    "${samgr_services_dir}/source/rpc_callback_imp.cpp",
597    "${samgr_services_dir}/source/samgr_time_handler.cpp",
598    "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp",
599    "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp",
600    "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp",
601    "${samgr_services_dir}/source/system_ability_manager.cpp",
602    "${samgr_services_dir}/source/system_ability_manager_dumper.cpp",
603    "${samgr_services_dir}/source/system_ability_manager_stub.cpp",
604    "${samgr_services_dir}/source/system_ability_manager_util.cpp",
605    "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp",
606    "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
607    "${samgr_services_dir}/test/unittest/src/system_ability_manager_dumper_test.cpp",
608    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
609    "//foundation/systemabilitymgr/samgr/services/dfx/source/samgr_xcollie.cpp",
610  ]
611
612  configs = [
613    ":sam_test_config",
614    "${samgr_dir}/services/samgr/native:sam_config",
615    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
616  ]
617
618  if (target_cpu == "arm") {
619    cflags = [ "-DBINDER_IPC_32BIT" ]
620  }
621
622  deps = [ ":samgr_proxy_tdd" ]
623
624  external_deps = [
625    "access_token:libaccesstoken_sdk",
626    "access_token:libnativetoken_shared",
627    "access_token:libtokensetproc_shared",
628    "c_utils:utils",
629    "ffrt:libffrt",
630    "hilog:libhilog",
631    "hisysevent:libhisysevent",
632    "hitrace:hitrace_meter",
633    "init:libbeget_proxy",
634    "init:libbegetutil",
635    "ipc:ipc_core",
636    "ipc:libdbinder",
637    "json:nlohmann_json_static",
638    "safwk:system_ability_fwk",
639  ]
640}
641
642ohos_executable("ondemand") {
643  testonly = true
644  sources = [
645    "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
646    "./src/ondemand_helper.cpp",
647  ]
648  configs = [
649    ":sam_test_config",
650    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
651  ]
652  deps = [ ":samgr_proxy_tdd" ]
653
654  cflags = []
655  if (target_cpu == "arm") {
656    cflags += [ "-DBINDER_IPC_32BIT" ]
657  }
658  external_deps = [
659    "access_token:libnativetoken_shared",
660    "access_token:libtokensetproc_shared",
661    "c_utils:utils",
662    "dsoftbus:softbus_client",
663    "hilog:libhilog",
664    "init:libbeget_proxy",
665    "init:libbegetutil",
666    "ipc:ipc_core",
667    "json:nlohmann_json_static",
668    "safwk:system_ability_fwk",
669  ]
670  part_name = "samgr"
671  subsystem_name = "systemabilitymgr"
672}
673
674ohos_executable("TestTool") {
675  testonly = true
676
677  #module_out_path = module_output_path
678  sources = [
679    "${samgr_dir}/utils/native/source/tools.cpp",
680    "${samgr_services_dir}/source/ability_death_recipient.cpp",
681    "${samgr_services_dir}/source/collect/device_param_collect.cpp",
682    "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp",
683    "${samgr_services_dir}/source/collect/device_timed_collect.cpp",
684    "${samgr_services_dir}/source/collect/icollect_plugin.cpp",
685    "${samgr_services_dir}/source/ffrt_handler.cpp",
686    "${samgr_services_dir}/source/memory_guard.cpp",
687    "${samgr_services_dir}/source/rpc_callback_imp.cpp",
688    "${samgr_services_dir}/source/samgr_time_handler.cpp",
689    "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp",
690    "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp",
691    "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp",
692    "${samgr_services_dir}/source/system_ability_load_callback_proxy.cpp",
693    "${samgr_services_dir}/source/system_ability_manager.cpp",
694    "${samgr_services_dir}/source/system_ability_manager_dumper.cpp",
695    "${samgr_services_dir}/source/system_ability_manager_stub.cpp",
696    "${samgr_services_dir}/source/system_ability_manager_util.cpp",
697    "${samgr_services_dir}/source/system_ability_status_change_proxy.cpp",
698    "${samgr_services_dir}/source/system_process_status_change_proxy.cpp",
699    "${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
700    "./src/system_ability_test_tool.cpp",
701    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
702  ]
703
704  configs = [
705    ":sam_test_config",
706    "${samgr_dir}/interfaces/innerkits/samgr_proxy:samgr_proxy_config",
707    "${samgr_dir}/services/samgr/native:sam_config",
708    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
709  ]
710  deps = [
711    ":samgr_proxy_tdd",
712    "${samgr_dir}/interfaces/innerkits/common:samgr_common",
713  ]
714  external_deps = [ "hilog:libhilog" ]
715
716  cflags = []
717  if (target_cpu == "arm") {
718    cflags += [ "-DBINDER_IPC_32BIT" ]
719  }
720
721  defines = []
722  if (use_musl) {
723    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
724      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
725    }
726  }
727  if (hicollie_able) {
728    external_deps += [ "hicollie:libhicollie" ]
729    defines += [ "HICOLLIE_ENABLE" ]
730  }
731
732  if (support_device_manager) {
733    sources +=
734        [ "${samgr_services_dir}/source/collect/device_networking_collect.cpp" ]
735    external_deps += [ "device_manager:devicemanagersdk" ]
736    defines += [ "SUPPORT_DEVICE_MANAGER" ]
737  }
738  external_deps += [
739    "access_token:libaccesstoken_sdk",
740    "access_token:libnativetoken_shared",
741    "access_token:libtokensetproc_shared",
742    "c_utils:utils",
743    "dsoftbus:softbus_client",
744    "eventhandler:libeventhandler",
745    "ffrt:libffrt",
746    "hisysevent:libhisysevent",
747    "hitrace:hitrace_meter",
748    "init:libbeget_proxy",
749    "init:libbegetutil",
750    "ipc:ipc_core",
751    "ipc:libdbinder",
752    "json:nlohmann_json_static",
753    "safwk:system_ability_fwk",
754  ]
755  part_name = "samgr"
756  subsystem_name = "systemabilitymgr"
757}
758
759ohos_static_library("samgr_proxy_tdd") {
760  defines = [ "SAMGR_PROXY" ]
761  sources = [
762    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_ability_load_callback_stub.cpp",
763    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_ability_manager_proxy.cpp",
764    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_ability_on_demand_event.cpp",
765    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_ability_status_change_stub.cpp",
766    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_process_status_change_stub.cpp",
767    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
768    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_abilitys.cpp",
769    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/service_registry.cpp",
770  ]
771  configs = [
772    ":samgr_proxy_private_config",
773    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
774  ]
775
776  public_configs = [ ":samgr_proxy_config" ]
777
778  deps = [ "//foundation/systemabilitymgr/samgr/interfaces/innerkits/dynamic_cache:dynamic_cache" ]
779  external_deps = [ "json:nlohmann_json_static" ]
780  if (is_standard_system) {
781    external_deps += [
782      "c_utils:utils",
783      "hilog:libhilog",
784      "init:libbegetutil",
785      "ipc:ipc_single",
786    ]
787    part_name = "samgr"
788  }
789  subsystem_name = "systemabilitymgr"
790}
791
792ohos_rust_unittest("rust_samgr_test_client") {
793  module_out_path = module_output_path
794
795  resource_config_file =
796      "//foundation/systemabilitymgr/samgr/test/resource/ohos_test.xml"
797
798  sources = [ "./rust/rust_samgr_test.rs" ]
799  deps = [
800    "//foundation/communication/ipc/interfaces/innerkits/rust:ipc_rust",
801    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/rust:samgr_rust",
802    "//foundation/systemabilitymgr/samgr/services/samgr/native/test/unittest/rust/service:test_access_token",
803  ]
804  external_deps = [
805    "hilog:hilog_rust",
806    "ipc:ipc_rust",
807  ]
808
809  subsystem_name = "systemabilitymgr"
810  part_name = "samgr"
811}
812
813group("unittest") {
814  testonly = true
815  deps = [
816    ":LocalAbilityManagerProxyTest",
817    ":SystemAbilityMgrCollectTest",
818    ":SystemAbilityMgrDeviceNetworkingTest",
819    ":SystemAbilityMgrDumperTest",
820    ":SystemAbilityMgrProxyTest",
821    ":SystemAbilityMgrStubTest",
822    ":SystemAbilityMgrTest",
823    ":SystemAbilityStateSchedulerTest",
824    ":TestTool",
825    ":ondemand",
826
827    #":rust_samgr_test_client",
828  ]
829}
830