1# Copyright (c) 2022-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("//build/test.gni") 15import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni") 16 17ROOT_DIR = "${storage_daemon_path}" 18 19ohos_unittest("storage_daemon_test") { 20 branch_protector_ret = "pac_ret" 21 sanitize = { 22 integer_overflow = true 23 cfi = true 24 cfi_cross_dso = true 25 debug = false 26 } 27 module_out_path = "storage_service/storage_daemon" 28 29 defines = [ 30 "STORAGE_LOG_TAG = \"StorageDaemon\"", 31 "LOG_DOMAIN = 0xD004301", 32 ] 33 34 if (storage_service_user_crypto_manager) { 35 defines += [ "USER_CRYPTO_MANAGER" ] 36 } 37 38 if (storage_service_external_storage_manager) { 39 defines += [ "EXTERNAL_STORAGE_MANAGER" ] 40 } 41 42 cflags_cc = [ "-Wno-unused-const-variable" ] 43 44 include_dirs = [ 45 "$ROOT_DIR/include", 46 "$ROOT_DIR/include/crypto", 47 "$ROOT_DIR/utils", 48 "$ROOT_DIR/../storage_manager/include", 49 "${storage_daemon_path}/include/utils", 50 "${storage_interface_path}/innerkits/storage_manager/native", 51 "${storage_service_common_path}/include", 52 ] 53 54 sources = [ 55 "$ROOT_DIR/crypto/src/app_clone_key_manager.cpp", 56 "$ROOT_DIR/crypto/test/key_manager_mock.cpp", 57 "$ROOT_DIR/disk/src/disk_config.cpp", 58 "$ROOT_DIR/disk/src/disk_info.cpp", 59 "$ROOT_DIR/disk/src/disk_manager.cpp", 60 "$ROOT_DIR/ipc/src/storage_daemon.cpp", 61 "$ROOT_DIR/ipc/src/storage_daemon_stub.cpp", 62 "$ROOT_DIR/ipc/src/storage_manager_client.cpp", 63 "$ROOT_DIR/ipc/test/storage_daemon_test.cpp", 64 "$ROOT_DIR/quota/quota_manager.cpp", 65 "$ROOT_DIR/user/src/mount_manager.cpp", 66 "$ROOT_DIR/user/src/user_manager.cpp", 67 "$ROOT_DIR/utils/test/common/help_utils.cpp", 68 "$ROOT_DIR/volume/src/external_volume_info.cpp", 69 "$ROOT_DIR/volume/src/process.cpp", 70 "$ROOT_DIR/volume/src/volume_info.cpp", 71 "$ROOT_DIR/volume/src/volume_manager.cpp", 72 ] 73 74 deps = [ 75 "${storage_daemon_path}:storage_common_utils", 76 "//third_party/googletest:gtest_main", 77 ] 78 79 external_deps = [ 80 "ability_base:base", 81 "ability_base:want", 82 "ability_base:zuri", 83 "access_token:libaccesstoken_sdk", 84 "app_file_service:fileshare_native", 85 "app_file_service:fileuri_native", 86 "app_file_service:sandbox_helper_native", 87 "bundle_framework:appexecfwk_core", 88 "c_utils:utils", 89 "dfs_service:cloud_daemon_kit_inner", 90 "eventhandler:libeventhandler", 91 "hicollie:libhicollie", 92 "hilog:libhilog", 93 "hisysevent:libhisysevent", 94 "huks:libhukssdk", 95 "init:libbegetutil", 96 "ipc:ipc_single", 97 "ipc:libdbinder", 98 "safwk:system_ability_fwk", 99 "samgr:samgr_proxy", 100 ] 101 102 if (enable_user_auth_framework) { 103 defines += [ "USER_AUTH_FRAMEWORK" ] 104 external_deps += [ "user_auth_framework:userauth_client" ] 105 } 106 107 use_exceptions = true 108} 109 110ohos_unittest("storage_daemon_proxy_test") { 111 branch_protector_ret = "pac_ret" 112 sanitize = { 113 integer_overflow = true 114 cfi = true 115 cfi_cross_dso = true 116 debug = false 117 blocklist = "${storage_service_path}/cfi_blocklist.txt" 118 } 119 module_out_path = "storage_service/storage_daemon" 120 121 defines = [ 122 "STORAGE_LOG_TAG = \"StorageDaemon\"", 123 "LOG_DOMAIN = 0xD004301", 124 ] 125 126 include_dirs = [ 127 "$ROOT_DIR/include", 128 "${storage_service_common_path}/include", 129 "${storage_interface_path}/innerkits/storage_manager/native", 130 ] 131 132 sources = [ 133 "$ROOT_DIR/ipc/src/storage_daemon_proxy.cpp", 134 "$ROOT_DIR/ipc/test/storage_daemon_proxy_test.cpp", 135 ] 136 137 deps = [ 138 "//third_party/googletest:gmock_main", 139 "//third_party/googletest:gtest_main", 140 ] 141 142 external_deps = [ 143 "c_utils:utils", 144 "hilog:libhilog", 145 "ipc:ipc_single", 146 "ipc:libdbinder", 147 "safwk:system_ability_fwk", 148 "samgr:samgr_proxy", 149 ] 150} 151 152ohos_unittest("storage_daemon_stub_test") { 153 branch_protector_ret = "pac_ret" 154 sanitize = { 155 integer_overflow = true 156 cfi = true 157 cfi_cross_dso = true 158 debug = false 159 blocklist = "${storage_service_path}/cfi_blocklist.txt" 160 } 161 module_out_path = "storage_service/storage_daemon" 162 163 defines = [ 164 "STORAGE_LOG_TAG = \"StorageDaemon\"", 165 "LOG_DOMAIN = 0xD004301", 166 "private = public", 167 ] 168 169 if (storage_service_user_crypto_manager) { 170 defines += [ "USER_CRYPTO_MANAGER" ] 171 } 172 173 include_dirs = [ 174 "$ROOT_DIR/include", 175 "$ROOT_DIR/ipc/test/", 176 "${storage_service_common_path}/include", 177 "${storage_interface_path}/innerkits/storage_manager/native", 178 ] 179 180 sources = [ 181 "$ROOT_DIR/ipc/src/storage_daemon_proxy.cpp", 182 "$ROOT_DIR/ipc/src/storage_daemon_stub.cpp", 183 "$ROOT_DIR/ipc/test/storage_daemon_stub_test.cpp", 184 "$ROOT_DIR/user/src/user_manager.cpp", 185 "$ROOT_DIR/utils/mount_argument_utils.cpp", 186 ] 187 188 deps = [ 189 "${storage_daemon_path}:storage_common_utils", 190 "//third_party/googletest:gmock_main", 191 "//third_party/googletest:gtest_main", 192 ] 193 194 external_deps = [ 195 "access_token:libaccesstoken_sdk", 196 "bundle_framework:appexecfwk_core", 197 "c_utils:utils", 198 "hicollie:libhicollie", 199 "hilog:libhilog", 200 "huks:libhukssdk", 201 "init:libbegetutil", 202 "ipc:ipc_single", 203 "ipc:libdbinder", 204 "safwk:system_ability_fwk", 205 "samgr:samgr_proxy", 206 ] 207 208 if (enable_user_auth_framework) { 209 defines += [ "USER_AUTH_FRAMEWORK" ] 210 external_deps += [ "user_auth_framework:userauth_client" ] 211 } 212} 213 214ohos_unittest("storage_manager_clt_test") { 215 branch_protector_ret = "pac_ret" 216 sanitize = { 217 integer_overflow = true 218 cfi = true 219 cfi_cross_dso = true 220 debug = false 221 blocklist = "${storage_service_path}/cfi_blocklist.txt" 222 } 223 module_out_path = "storage_service/storage_daemon" 224 225 sources = [ 226 "${storage_daemon_path}/disk/src/disk_info.cpp", 227 "${storage_daemon_path}/ipc/src/storage_manager_client.cpp", 228 "${storage_daemon_path}/volume/src/external_volume_info.cpp", 229 "${storage_daemon_path}/volume/src/process.cpp", 230 "${storage_daemon_path}/volume/src/volume_info.cpp", 231 "${storage_manager_path}/innerkits_impl/src/disk.cpp", 232 "${storage_manager_path}/innerkits_impl/src/volume_core.cpp", 233 "${storage_manager_path}/innerkits_impl/src/volume_external.cpp", 234 "${storage_manager_path}/mock/storage_manager_proxy_mock.cpp", 235 "storage_manager_client_test.cpp", 236 ] 237 238 include_dirs = [ 239 "${storage_daemon_path}/include", 240 "${storage_interface_path}/innerkits/storage_manager/native", 241 "${storage_manager_path}/include", 242 "${storage_service_common_path}/include", 243 ] 244 245 defines = [ 246 "STORAGE_LOG_TAG = \"StorageDaemon\"", 247 "LOG_DOMAIN = 0xD004301", 248 "private = public", 249 ] 250 251 deps = [ 252 "${storage_daemon_path}:storage_common_utils", 253 "//third_party/googletest:gtest_main", 254 ] 255 256 external_deps = [ 257 "c_utils:utils", 258 "hilog:libhilog", 259 "init:libbegetutil", 260 "ipc:ipc_single", 261 "os_account:os_account_innerkits", 262 "safwk:system_ability_fwk", 263 "samgr:samgr_proxy", 264 ] 265} 266 267group("storage_daemon_ipc_test") { 268 testonly = true 269 deps = [ 270 ":storage_daemon_proxy_test", 271 ":storage_daemon_stub_test", 272 ":storage_daemon_test", 273 ":storage_manager_clt_test", 274 ] 275} 276