1# Copyright (c) 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("//base/startup/appspawn/appspawn.gni") 15import("//build/test.gni") 16 17config("utest_config") { 18 cflags = [ 19 "-Wno-implicit-fallthrough", 20 "-Wno-unused-function", 21 "-Dprivate=public", 22 "-Dprotected=public", 23 ] 24 25 cflags_cc = [ 26 "-Wno-implicit-fallthrough", 27 "-fexceptions", 28 ] 29 30 if (build_selinux) { 31 cflags += [ "-DWITH_SELINUX" ] 32 } 33 34 if (build_seccomp) { 35 cflags += [ "-DWITH_SECCOMP" ] 36 } 37 38 include_dirs = [ 39 "${appspawn_path}/test/unittest", 40 "${appspawn_path}/test/mock/include", 41 "${appspawn_path}/common", 42 "${appspawn_path}/standard", 43 "${appspawn_path}/adapter", 44 "${appspawn_path}/adapter/sysevent", 45 "${appspawn_path}/interfaces/innerkits/include", 46 "${appspawn_path}/util/include", 47 "//commonlibrary/c_utils/base/include", 48 "ability_runtime_kits_path/appkit/native/app/include", 49 "${ability_runtime_path}/interfaces/innerkits/app_manager/include/appmgr", 50 "${ability_runtime_path}/interfaces/innerkits/ability_manager/include", 51 "ability_runtime_kits_path/ability/native/include", 52 "${ability_runtime_path}/services/abilitymgr/include", 53 "//base/global/resource_management/interfaces/inner_api/include", 54 "//base/security/access_token/interfaces/innerkits/token_setproc/include", 55 "//base/security/selinux_adapter/interfaces/policycoreutils/include", 56 "//base/startup/init/services/log", 57 "//base/startup/init/services/loopevent/include", 58 "//base/startup/init/services/loopevent/task", 59 "//base/startup/init/services/loopevent/utils", 60 "//third_party/json/include", 61 "//third_party/selinux/libselinux/include", 62 ] 63} 64 65if (!defined(ohos_lite)) { 66 ohos_unittest("AppSpawn_ut") { 67 module_out_path = "${module_output_path}" 68 deps = [] 69 defines = [ 70 "clone=CloneStub", 71 "bind=BindStub", 72 "listen=ListenStub", 73 "lchown=LchownStub", 74 "lchmod=LchmodStub", 75 "getsockopt=GetsockoptStub", 76 "setgroups=SetgroupsStub", 77 "setresuid=SetresuidStub", 78 "setresgid=SetresgidStub", 79 "capset=CapsetStub", 80 "dlopen=DlopenStub", 81 "dlsym=DlsymStub", 82 "dlclose=DlcloseStub", 83 "waitpid=WaitpidStub", 84 "HapContext=HapContextStub", 85 "APPSPAWN_TEST", 86 "OHOS_DEBUG", 87 "GRAPHIC_PERMISSION_CHECK", 88 ] 89 90 if (target_cpu == "arm64") { 91 defines += [ "webview_arm64" ] 92 } 93 if (target_cpu == "x86_64") { 94 defines += [ "webview_x86_64" ] 95 } 96 if (target_cpu == "arm") { 97 defines += [ "webview_arm" ] 98 } 99 100 sources = [ 101 "${appspawn_path}/adapter/appspawn_ace.cpp", 102 "${appspawn_path}/adapter/appspawn_adapter.cpp", 103 "${appspawn_path}/adapter/appspawn_nweb.cpp", 104 "${appspawn_path}/adapter/appspawn_sandbox.cpp", 105 "${appspawn_path}/adapter/nwebspawn_lancher.cpp", 106 "${appspawn_path}/common/appspawn_server.c", 107 "${appspawn_path}/interfaces/innerkits/client/appspawn_socket.cpp", 108 "${appspawn_path}/interfaces/innerkits/client/client_socket.cpp", 109 "${appspawn_path}/interfaces/innerkits/src/appspawn_mount_permission.cpp", 110 "${appspawn_path}/standard/appspawn_process.c", 111 "${appspawn_path}/standard/appspawn_service.c", 112 "${appspawn_path}/util/src/command_lexer.cpp", 113 "${appspawn_path}/util/src/json_utils.cpp", 114 "${appspawn_path}/util/src/param_helper.c", 115 "${appspawn_path}/util/src/sandbox_utils.cpp", 116 ] 117 118 sources += [ 119 "${appspawn_path}/test/unittest/app_spawn_socket_test/app_spawn_socket_test.cpp", 120 "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_command_lexer_test.cpp", 121 "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_sandbox_test.cpp", 122 "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_standard_test.cpp", 123 "${appspawn_path}/test/unittest/app_spawn_stub.cpp", 124 "${appspawn_path}/test/unittest/client_socket_test/client_socket_test.cpp", 125 ] 126 127 configs = [ "//base/startup/appspawn/test/unittest:utest_config" ] 128 deps += [ "//third_party/selinux:libselinux" ] 129 external_deps = [ 130 "ability_base:want", 131 "ability_runtime:app_manager", 132 "ability_runtime:appkit_native", 133 "ability_runtime:runtime", 134 "access_token:libtoken_setproc", 135 "access_token:libtokenid_sdk", 136 "ace_engine:ace_forward_compatibility", 137 "bundle_framework:appexecfwk_base", 138 "bundle_framework:appexecfwk_core", 139 "c_utils:utils", 140 "config_policy:configpolicy_util", 141 "eventhandler:libeventhandler", 142 "hilog:libhilog", 143 "hitrace:hitrace_meter", 144 "init:libbegetutil", 145 "init:seccomp", 146 "ipc:ipc_core", 147 "napi:ace_napi", 148 "os_account:os_account_innerkits", 149 "resource_management:global_resmgr", 150 ] 151 152 if (appspawn_report_event) { 153 defines += [ "REPORT_EVENT" ] 154 external_deps += [ "hisysevent:libhisysevent" ] 155 sources += [ "${appspawn_path}/adapter/sysevent/event_reporter.cpp" ] 156 } 157 } 158} 159