1# Copyright (c) 2024 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/startup/appspawn/appspawn.gni")
15import("//build/test.gni")
16
17ohos_unittest("AppSpawn_client_ut") {
18  module_out_path = "${module_output_path}"
19  deps = []
20  defines = [
21    "APPSPAWN_BASE_DIR=\"/data/appspawn_ut\"",
22    "APPSPAWN_TEST",
23    "APPSPAWN_CLIENT",
24    "OHOS_DEBUG",
25    "USER_TIMER_TO_CHECK",
26    "APPSPAWN_LABEL=\"APPSPAWN_CLENT_UT\"",
27  ]
28
29  include_dirs = [
30    "${appspawn_path}",
31    "${appspawn_path}/common",
32    "${appspawn_path}/standard",
33    "${appspawn_path}/modules/modulemgr",
34    "${appspawn_path}/modules/ace_adapter",
35    "${appspawn_path}/modules/common",
36    "${appspawn_path}/modules/sandbox",
37    "${appspawn_path}/modules/module_engine/include",
38    "${appspawn_path}/modules/sysevent",
39    "${appspawn_innerkits_path}/client",
40    "${appspawn_innerkits_path}/include",
41    "${appspawn_innerkits_path}/permission",
42    "${appspawn_path}/util/include",
43    "${appspawn_path}/test/unittest",
44    "${appspawn_path}/test/mock",
45  ]
46
47  # client
48  sources = [
49    "${appspawn_innerkits_path}/client/appspawn_client.c",
50    "${appspawn_innerkits_path}/client/appspawn_msg.c",
51    "${appspawn_innerkits_path}/permission/appspawn_mount_permission.c",
52    "${appspawn_path}/modules/sandbox/appspawn_permission.c",
53  ]
54
55  # server
56  sources += [
57    "${appspawn_path}/common/appspawn_server.c",
58    "${appspawn_path}/common/appspawn_trace.cpp",
59    "${appspawn_path}/modules/common/appspawn_dfx_dump.cpp",
60    "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c",
61    "${appspawn_path}/standard/appspawn_appmgr.c",
62    "${appspawn_path}/standard/appspawn_msgmgr.c",
63    "${appspawn_path}/standard/appspawn_service.c",
64    "${appspawn_path}/standard/nwebspawn_launcher.c",
65    "${appspawn_path}/util/src/appspawn_utils.c",
66  ]
67
68  sources += [
69    "${appspawn_path}/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp",
70    "${appspawn_path}/test/unittest/app_spawn_client_test/app_spawn_interface_test.cpp",
71    "${appspawn_path}/test/unittest/app_spawn_test_helper.cpp",
72  ]
73
74  if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) {
75    defines += [ "APPSPAWN_SANDBOX_NEW" ]
76  }
77
78  if (asan_detector || is_asan) {
79    defines += [ "ASAN_DETECTOR" ]
80  }
81  external_deps = [
82    "cJSON:cjson",
83    "c_utils:utils",
84    "config_policy:configpolicy_util",
85    "hilog:libhilog",
86    "hitrace:hitrace_meter",
87    "init:libbegetutil",
88  ]
89  if (enable_appspawn_dump_catcher) {
90    external_deps += [ "faultloggerd:libdfx_dumpcatcher" ]
91  }
92  if (appspawn_report_event) {
93    external_deps += [ "hisysevent:libhisysevent" ]
94    sources += [ "${appspawn_path}/modules/sysevent/appspawn_hisysevent.cpp" ]
95  }
96  if (build_selinux) {
97    defines += [ "WITH_SELINUX" ]
98    external_deps += [
99      "selinux:libselinux",
100      "selinux_adapter:libhap_restorecon",
101    ]
102  }
103}
104