BUILD.gn 11.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
M
init  
Mupceet 已提交
13
import("//base/startup/init/begetd.gni")
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
import("//build/test.gni")

config("utest_config") {
  visibility = [ ":*" ]

  cflags = [
    "-fprofile-arcs",
    "-ftest-coverage",
    "-Wno-implicit-fallthrough",
    "-Wno-unused-function",
  ]
  cflags_cc = [
    "-Wno-implicit-fallthrough",
    "-fexceptions",
  ]

  ldflags = [ "--coverage" ]
}

33 34 35
FSCRYPT_PATH =
    "//foundation/filemanagement/storage_service/services/storage_daemon"

L
laiguizhong 已提交
36
ohos_unittest("init_unittest") {
37 38
  module_out_path = "startup/init"
  sources = [
M
init  
Mupceet 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    "//base/startup/init/device_info/device_info.cpp",
    "//base/startup/init/device_info/device_info_stub.cpp",
    "//base/startup/init/interfaces/innerkits/file/init_file.c",
    "//base/startup/init/interfaces/innerkits/fs_manager/fstab.c",
    "//base/startup/init/interfaces/innerkits/fs_manager/fstab_mount.c",
    "//base/startup/init/interfaces/innerkits/reboot/init_reboot_innerkits.c",
    "//base/startup/init/interfaces/innerkits/sandbox/sandbox.c",
    "//base/startup/init/interfaces/innerkits/sandbox/sandbox_namespace.c",
    "//base/startup/init/interfaces/innerkits/socket/init_socket.c",
    "//base/startup/init/interfaces/innerkits/syspara/param_comm.c",
    "//base/startup/init/interfaces/innerkits/syspara/parameter.c",
    "//base/startup/init/interfaces/innerkits/syspara/sysversion.c",
    "//base/startup/init/services/begetctl/param_cmd.c",
    "//base/startup/init/services/begetctl/shell/shell_bas.c",
    "//base/startup/init/services/begetctl/shell/shell_main.c",
    "//base/startup/init/services/init/adapter/init_adapter.c",
    "//base/startup/init/services/init/init_capability.c",
    "//base/startup/init/services/init/init_common_cmds.c",
    "//base/startup/init/services/init/init_common_service.c",
    "//base/startup/init/services/init/init_config.c",
    "//base/startup/init/services/init/init_group_manager.c",
    "//base/startup/init/services/init/init_service_file.c",
    "//base/startup/init/services/init/init_service_manager.c",
    "//base/startup/init/services/init/init_service_socket.c",
    "//base/startup/init/services/init/standard/device.c",
    "//base/startup/init/services/init/standard/init.c",
    "//base/startup/init/services/init/standard/init_cmdexecutor.c",
    "//base/startup/init/services/init/standard/init_cmds.c",
    "//base/startup/init/services/init/standard/init_jobs.c",
    "//base/startup/init/services/init/standard/init_mount.c",
    "//base/startup/init/services/init/standard/init_reboot.c",
    "//base/startup/init/services/init/standard/init_service.c",
    "//base/startup/init/services/init/standard/init_signal_handler.c",
    "//base/startup/init/services/log/init_commlog.c",
    "//base/startup/init/services/log/init_log.c",
    "//base/startup/init/services/loopevent/loop/le_epoll.c",
    "//base/startup/init/services/loopevent/loop/le_loop.c",
    "//base/startup/init/services/loopevent/signal/le_signal.c",
    "//base/startup/init/services/loopevent/socket/le_socket.c",
    "//base/startup/init/services/loopevent/task/le_asynctask.c",
    "//base/startup/init/services/loopevent/task/le_streamtask.c",
    "//base/startup/init/services/loopevent/task/le_task.c",
    "//base/startup/init/services/loopevent/task/le_watchtask.c",
    "//base/startup/init/services/loopevent/timer/le_timer.c",
    "//base/startup/init/services/loopevent/utils/le_utils.c",
    "//base/startup/init/services/param/adapter/param_dac.c",
    "//base/startup/init/services/param/adapter/param_persistadp.c",
    "//base/startup/init/services/param/base/param_base.c",
    "//base/startup/init/services/param/base/param_comm.c",
    "//base/startup/init/services/param/base/param_trie.c",
    "//base/startup/init/services/param/linux/param_message.c",
    "//base/startup/init/services/param/linux/param_msgadp.c",
    "//base/startup/init/services/param/linux/param_osadp.c",
    "//base/startup/init/services/param/linux/param_request.c",
    "//base/startup/init/services/param/linux/param_service.c",
    "//base/startup/init/services/param/manager/param_manager.c",
    "//base/startup/init/services/param/manager/param_persist.c",
    "//base/startup/init/services/param/manager/param_server.c",
    "//base/startup/init/services/param/trigger/trigger_checker.c",
    "//base/startup/init/services/param/trigger/trigger_manager.c",
    "//base/startup/init/services/param/trigger/trigger_processor.c",
    "//base/startup/init/services/utils/init_hashmap.c",
    "//base/startup/init/services/utils/init_utils.c",
    "//base/startup/init/services/utils/list.c",
    "//base/startup/init/ueventd/standard/ueventd_parameter.c",
    "//base/startup/init/ueventd/ueventd.c",
    "//base/startup/init/ueventd/ueventd_device_handler.c",
    "//base/startup/init/ueventd/ueventd_firmware_handler.c",
    "//base/startup/init/ueventd/ueventd_read_cfg.c",
    "//base/startup/init/ueventd/ueventd_socket.c",
109 110
  ]

111 112 113 114 115 116 117
  sources += [
    "${FSCRYPT_PATH}/libfscrypt/src/fscrypt_control.c",
    "${FSCRYPT_PATH}/libfscrypt/src/fscrypt_utils.c",
    "${FSCRYPT_PATH}/libfscrypt/src/key_control.c",
    "${FSCRYPT_PATH}/libfscrypt/src/sysparam_static.c",
  ]

M
Mupceet 已提交
118
  if (defined(build_selinux) && build_selinux) {
M
init  
Mupceet 已提交
119
    sources += [ "//base/startup/init/services/param/adapter/param_selinux.c" ]
M
Mupceet 已提交
120 121
  }

M
Mupceet 已提交
122
  if (enable_ohos_startup_init_feature_watcher) {
H
handyohos 已提交
123
    sources += [
M
init  
Mupceet 已提交
124 125 126 127 128 129 130
      "//base/startup/init/services/param/watcher/agent/watcher.cpp",
      "//base/startup/init/services/param/watcher/agent/watcher_manager_kits.cpp",
      "//base/startup/init/services/param/watcher/agent/watcher_manager_proxy.cpp",
      "//base/startup/init/services/param/watcher/agent/watcher_stub.cpp",
      "//base/startup/init/services/param/watcher/proxy/watcher_manager.cpp",
      "//base/startup/init/services/param/watcher/proxy/watcher_manager_stub.cpp",
      "//base/startup/init/services/param/watcher/proxy/watcher_proxy.cpp",
H
handyohos 已提交
131 132 133
    ]
  }

134
  sources += [
X
xionglei6 已提交
135
    "begetctl/begetctl_unittest.cpp",
M
Mupceet 已提交
136
    "deviceinfo/DeviceInfoUnittest.cpp",
L
laiguizhong 已提交
137
    "init/SignalInitUnitTest.cpp",
138
    "init/cmds_unittest.cpp",
X
xionglei6 已提交
139
    "init/group_unittest.cpp",
X
add ut  
xionglei6 已提交
140 141
    "init/init_reboot_unittest.cpp",
    "init/mount_unittest.cpp",
M
Mupceet 已提交
142
    "init/sandbox_unittest.cpp",
X
add ut  
xionglei6 已提交
143 144 145
    "init/service_file_unittest.cpp",
    "init/service_socket_unittest.cpp",
    "init/utils_unittest.cpp",
L
laiguizhong 已提交
146
    "innerkits/innerkits_unittest.cpp",
147 148
    "param/client_unittest.cpp",
    "param/dac_unittest.cpp",
X
xlei1030 已提交
149
    "param/param_shell_unittest.cpp",
M
Mupceet 已提交
150
    "param/param_stub.cpp",
151
    "param/param_unittest.cpp",
M
Mupceet 已提交
152
    "param/paramservice_unittest.cpp",
153
    "param/trigger_unittest.cpp",
M
Mupceet 已提交
154
    "syspara/syspara_unittest.cpp",
X
add ut  
xionglei6 已提交
155
    "ueventd/ueventd_config_unittest.cpp",
156 157
  ]

158
  sources += [
M
init  
Mupceet 已提交
159 160
    "//base/startup/init/interfaces/innerkits/hookmgr/hookmgr.c",
    "//base/startup/init/interfaces/innerkits/modulemgr/modulemgr.c",
161 162 163 164
    "innerkits/hookmgr_unittest.cpp",
    "innerkits/modulemgr_unittest.cpp",
  ]

M
init  
Mupceet 已提交
165
  configs = [ "//base/startup/init/test/unittest:utest_config" ]
166 167

  include_dirs = [
Z
zhr758 已提交
168
    "//base/customization/config_policy/interfaces/innerkits/include",
M
init  
Mupceet 已提交
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
    "//base/startup/init/device_info",
    "//base/startup/init/services/init/standard",
    "//base/startup/init/interfaces/innerkits/include",
    "//base/startup/init/interfaces/innerkits/include/syspara",
    "//base/startup/init/interfaces/innerkits/fd_holder",
    "//base/startup/init/interfaces/innerkits/syspara",
    "//base/startup/init/interfaces/innerkits/control_fd",
    "//base/startup/init/services/begetctl",
    "//base/startup/init/services/begetctl/shell",
    "//base/startup/init/services/include",
    "//base/startup/init/services/init/include",
    "//base/startup/init/services/include/param",
    "//base/startup/init/services/log",
    "//base/startup/init/services/loopevent/include",
    "//base/startup/init/services/loopevent/loop",
    "//base/startup/init/services/loopevent/socket",
    "//base/startup/init/services/loopevent/signal",
    "//base/startup/init/services/loopevent/task",
    "//base/startup/init/services/loopevent/timer",
    "//base/startup/init/services/loopevent/utils",
    "//base/startup/init/services/param/adapter",
    "//base/startup/init/services/param/base",
    "//base/startup/init/services/param/linux",
    "//base/startup/init/services/param/include",
    "//base/startup/init/services/param/watcher/agent",
    "//base/startup/init/services/param/watcher/include",
    "//base/startup/init/services/param/watcher/proxy",
    "//base/startup/init/test/unittest",
    "//base/startup/init/test/unittest/param",
198 199 200 201 202
    "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
    "//foundation/distributedschedule/safwk/services/safwk/include",
    "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
    "//foundation/distributedschedule/samgr/adapter/interfaces/innerkits/include",
    "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
M
init  
Mupceet 已提交
203
    "//base/startup/init/ueventd/include",
204 205 206
    "//utils/system/safwk/native/include",
    "//third_party/bounds_checking_function/include",
    "//third_party/cJSON",
207 208
    "//base/security/access_token/interfaces/innerkits/token_setproc/include",
    "//base/security/access_token/interfaces/innerkits/nativetoken/include",
M
init  
Mupceet 已提交
209 210
    "//base/startup/init/interfaces/innerkits/sandbox/include",
    "//base/startup/init/interfaces/innerkits/hals",
211
    "${FSCRYPT_PATH}/include/libfscrypt",
212 213 214
  ]

  deps = [
Z
zhr758 已提交
215
    "//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
216 217
    "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
    "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
218
    "//third_party/bounds_checking_function:libsec_static",
L
laiguizhong 已提交
219
    "//third_party/cJSON:cjson",
220 221
    "//third_party/googletest:gmock",
    "//third_party/googletest:gtest",
M
Mupceet 已提交
222
    "//third_party/mbedtls:mbedtls_shared",
223 224 225
  ]

  defines = [
X
xionglei6 已提交
226
    "READ_CHECK",
227 228 229
    "INIT_AGENT",
    "STARTUP_INIT_TEST",
    "PARAM_SUPPORT_DAC",
230
    "_GNU_SOURCE",
M
Mupceet 已提交
231
    "PARAM_SUPPORT_TRIGGER",
M
Mupceet 已提交
232
    "USE_MBEDTLS",
233
  ]
X
xionglei6 已提交
234
  defines += [ "_GNU_SOURCE" ]
235

236 237 238 239
  if (target_cpu == "arm64") {
    defines += [ "SUPPORT_64BIT" ]
  }

H
handyohos 已提交
240
  external_deps = [
H
hongtao 已提交
241
    "c_utils:utils",
H
handyohos 已提交
242
    "hiviewdfx_hilog_native:libhilog",
243
    "init:libinit_module_engine",
H
handyohos 已提交
244
  ]
H
handyohos 已提交
245

M
Mupceet 已提交
246
  if (!defined(ohos_lite) && enable_ohos_startup_init_feature_watcher) {
M
Mupceet 已提交
247 248 249 250
    sources += [
      "param/watcher_agent_unittest.cpp",
      "param/watcher_proxy_unittest.cpp",
    ]
H
handyohos 已提交
251 252 253 254 255 256
    external_deps += [
      "ipc:ipc_core",
      "safwk:system_ability_fwk",
      "samgr_standard:samgr_proxy",
    ]
  }
257

M
Mupceet 已提交
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
  if (defined(build_selinux) && build_selinux) {
    sources += [ "param/selinux_unittest.cpp" ]
    include_dirs += [
      "//third_party/selinux/libselinux/include/",
      "//base/security/selinux/interfaces/policycoreutils/include/",
    ]
    deps += [
      "//base/security/selinux:libload_policy",
      "//base/security/selinux:librestorecon",
      "//third_party/selinux:libselinux",
    ]
    defines += [
      "WITH_SELINUX",
      "PARAM_SUPPORT_SELINUX",
    ]
  }
M
Mupceet 已提交
274 275
  if (enable_ohos_startup_init_feature_deviceinfo) {
    sources += [
M
init  
Mupceet 已提交
276 277 278
      "//base/startup/init/device_info/device_info_kits.cpp",
      "//base/startup/init/device_info/device_info_load.cpp",
      "//base/startup/init/device_info/device_info_proxy.cpp",
M
Mupceet 已提交
279 280 281 282
    ]
    defines += [ "PARAM_FEATURE_DEVICEINFO" ]
    external_deps += [ "access_token:libaccesstoken_sdk" ]
  }
283
  cflags_cc = [ "-fexceptions" ]
L
laiguizhong 已提交
284 285 286 287
  sources += [
    "init/loopevent_unittest.cpp",
    "init/service_unittest.cpp",
  ]
288
}