# 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. import("//base/startup/init/begetd.gni") import("//build/test.gni") config("utest_config") { visibility = [ ":*" ] cflags = [ "-Wno-implicit-fallthrough", "-Wno-unused-function", "-Dprivate=public", "-Dprotected=public", "-Dsprintf_s=SprintfStub", "-Dmount=MountStub", "-Dumount=UmountStub", "-Dumount2=Umount2Stub", "-Dsymlink=SymlinkStub", "-Dprctl=PrctlStub", "-Dexecv=ExecvStub", "-Dlchown=LchownStub", "-Dkill=KillStub", "-Dexecve=ExecveStub", ] cflags_cc = [ "-Wno-implicit-fallthrough", "-fexceptions", ] } FSCRYPT_PATH = "//foundation/filemanagement/storage_service/services/storage_daemon" ohos_unittest("init_unittest") { module_out_path = "startup/init" sources = [ "//base/startup/init/device_info/device_info.cpp", "//base/startup/init/device_info/device_info_stub.cpp", "//base/startup/init/interfaces/innerkits/control_fd/control_fd_client.c", "//base/startup/init/interfaces/innerkits/control_fd/control_fd_service.c", "//base/startup/init/interfaces/innerkits/fd_holder/fd_holder.c", "//base/startup/init/interfaces/innerkits/fd_holder/fd_holder_internal.c", "//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/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/begetctl_cmd.c", "//base/startup/init/services/begetctl/bootchart_cmd.c", "//base/startup/init/services/begetctl/dump_service.c", "//base/startup/init/services/begetctl/init_cmd_reboot.c", "//base/startup/init/services/begetctl/misc_daemon.cpp", "//base/startup/init/services/begetctl/modulectl.c", "//base/startup/init/services/begetctl/param_cmd.c", "//base/startup/init/services/begetctl/sandbox.cpp", "//base/startup/init/services/begetctl/service_control.c", "//base/startup/init/services/begetctl/setloglevel.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/fd_holder_service.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_control_fd_service.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/modules/bootchart/bootchart.c", "//base/startup/init/services/modules/bootchart/bootchart_static.c", "//base/startup/init/services/modules/bootevent/bootevent.c", "//base/startup/init/services/modules/init_hook/init_hook.c", "//base/startup/init/services/modules/init_hook/param_hook.c", "//base/startup/init/services/modules/reboot/reboot.c", "//base/startup/init/services/modules/reboot/reboot_misc.c", "//base/startup/init/services/modules/reboot/reboot_static.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/sandbox/sandbox.c", "//base/startup/init/services/sandbox/sandbox_namespace.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", ] 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", ] if (defined(build_selinux) && build_selinux) { sources += [ "//base/startup/init/services/param/adapter/param_selinux.c" ] } if (enable_ohos_startup_init_feature_watcher) { sources += [ "//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", ] } sources += [ "begetctl/begetctl_unittest.cpp", "deviceinfo/DeviceInfoUnittest.cpp", "init/cmds_unittest.cpp", "init/group_unittest.cpp", "init/init_reboot_unittest.cpp", "init/init_unittest.cpp", "init/mount_unittest.cpp", "init/sandbox_unittest.cpp", "init/service_file_unittest.cpp", "init/service_socket_unittest.cpp", "init/service_unittest.cpp", "init/utils_unittest.cpp", "innerkits/innerkits_unittest.cpp", "loopevent/loopevent_unittest.cpp", "loopevent/loopserver_unittest.cpp", "loopevent/loopsignal_unittest.cpp", "modules/modules_unittest.cpp", "param/client_unittest.cpp", "param/dac_unittest.cpp", "param/param_shell_unittest.cpp", "param/param_stub.cpp", "param/param_unittest.cpp", "param/paramservice_unittest.cpp", "param/trigger_unittest.cpp", "syspara/syspara_unittest.cpp", "ueventd/ueventd_config_unittest.cpp", "ueventd/ueventd_event_unittest.cpp", ] sources += [ "//base/startup/init/interfaces/innerkits/hookmgr/hookmgr.c", "//base/startup/init/interfaces/innerkits/init_module_engine/init_modulemgr.c", "//base/startup/init/interfaces/innerkits/modulemgr/modulemgr.c", "//base/startup/init/interfaces/innerkits/service_control/service_control.c", "//base/startup/init/interfaces/innerkits/service_watcher/service_watcher.c", "//base/startup/init/interfaces/innerkits/syscap/init_syscap.c", "//base/startup/init/interfaces/innerkits/syspara/param_wrapper.cpp", "innerkits/hookmgr_unittest.cpp", "innerkits/modulemgr_unittest.cpp", ] configs = [ "//base/startup/init/test/unittest:utest_config" ] include_dirs = [ "//base/customization/config_policy/interfaces/innerkits/include", "//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/modules", "//base/startup/init/services/modules/bootchart", "//base/startup/init/services/modules/init_hook", "//base/startup/init/services/modules/selinux", "//base/startup/init/services/modules/reboot", "//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", "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", "//foundation/systemabilitymgr/safwk/services/safwk/include", "//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk", "//foundation/systemabilitymgr/samgr/adapter/interfaces/innerkits/include", "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", "//base/startup/init/ueventd/include", "//utils/system/safwk/native/include", "//third_party/bounds_checking_function/include", "//third_party/cJSON", "//base/security/access_token/interfaces/innerkits/token_setproc/include", "//base/security/access_token/interfaces/innerkits/nativetoken/include", "//base/startup/init/services/sandbox/include", "//base/startup/init/interfaces/innerkits/hals", "${FSCRYPT_PATH}/include/libfscrypt", ] deps = [ "//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static", "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", "//third_party/bounds_checking_function:libsec_static", "//third_party/cJSON:cjson", "//third_party/googletest:gmock", "//third_party/googletest:gtest", "//third_party/mbedtls:mbedtls_shared", ] defines = [ "READ_CHECK", "INIT_AGENT", "INIT_DMESG", "INIT_FILE", "STARTUP_INIT_TEST", "PARAM_SUPPORT_DAC", "_GNU_SOURCE", "PARAM_SUPPORT_TRIGGER", "USE_MBEDTLS", "PARAM_DECODE_GROUPID_FROM_FILE", "WORKSPACE_AREA_NEED_MUTEX", "PARAM_SUPPORT_REAL_CHECK", "DISABLE_INIT_TWO_STAGES", ] defines += [ "_GNU_SOURCE" ] if (target_cpu == "arm64") { defines += [ "SUPPORT_64BIT" ] } if (use_musl) { defines += [ "__MUSL__" ] } external_deps = [ "c_utils:utils", "hiviewdfx_hilog_native:libhilog", "init:libinit_module_engine", ] if (enable_ohos_startup_init_feature_ab_partition) { include_dirs += [ "//drivers/hdf_core/adapter/uhdf2/include" ] sources += [ "//base/startup/init/services/begetctl/partitionslot.cpp" ] external_deps += [ "drivers_interface_partitionslot:libpartitionslot_proxy_1.0", "hdf_core:libhdi", ] } if (!defined(ohos_lite) && enable_ohos_startup_init_feature_watcher) { sources += [ "param/watcher_agent_unittest.cpp", "param/watcher_proxy_unittest.cpp", ] external_deps += [ "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] } if (defined(build_seccomp) && build_seccomp) { sources += [ "seccomp/seccomp_unittest.cpp" ] include_dirs += [ "//base/startup/init/interfaces/innerkits/seccomp/include" ] external_deps += [ "init:seccomp" ] } if (defined(build_selinux) && build_selinux) { sources += [ "param/selinux_unittest.cpp" ] include_dirs += [ "//third_party/selinux/libselinux/include/", "//base/security/selinux/interfaces/policycoreutils/include/", ] sources += [ "//base/startup/init/services/modules/selinux/selinux_adp.c", "//base/startup/init/services/modules/selinux/selinux_static.c", ] defines += [ "WITH_SELINUX", "PARAM_SUPPORT_SELINUX", ] } if (enable_ohos_startup_init_feature_deviceinfo) { sources += [ "//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", ] include_dirs += [ "//third_party/selinux/libselinux/include/", "//base/security/access_token/interfaces/innerkits/accesstoken/include", ] defines += [ "PARAM_FEATURE_DEVICEINFO" ] } cflags_cc = [ "-fexceptions" ] }