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/ability/ability_runtime/ability_runtime.gni") 16 17module_output_path = "ability_runtime/ability_runtime/abilitymgr" 18 19config("coverage_flags") { 20 cflags = [ "--coverage" ] 21 ldflags = [ "--coverage" ] 22} 23 24ohos_unittest("quickfix_callback_test") { 25 module_out_path = module_output_path 26 27 include_dirs = [ 28 "${ability_runtime_native_path}/runtime", 29 "${ability_runtime_native_path}/runtime/utils/include", 30 ] 31 32 sources = [ "js_quickfix_callback_test.cpp" ] 33 34 configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] 35 deps = [] 36 37 external_deps = [ 38 "ability_runtime:runtime", 39 "c_utils:utils", 40 ] 41} 42 43ohos_unittest("runtime_test") { 44 module_out_path = module_output_path 45 46 include_dirs = [ 47 "${ability_runtime_native_path}/runtime", 48 "${ability_runtime_native_path}/runtime/utils/include", 49 ] 50 51 sources = [ 52 # add mock file 53 "js_module_reader_test.cpp", 54 ] 55 56 configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] 57 deps = [] 58 59 external_deps = [ 60 "ability_base:extractortool", 61 "ability_runtime:runtime", 62 "c_utils:utils", 63 "zlib:libz", 64 "zlib:shared_libz", 65 ] 66} 67 68ohos_unittest("hybrid_js_module_reader_test") { 69 module_out_path = module_output_path 70 71 include_dirs = [ 72 "${ability_runtime_native_path}/runtime", 73 "${ability_runtime_native_path}/runtime/utils/include", 74 ] 75 76 sources = [ 77 # add mock file 78 "hybrid_js_module_reader_test.cpp", 79 ] 80 81 configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] 82 deps = [] 83 84 external_deps = [ 85 "ability_base:extractortool", 86 "ability_runtime:runtime", 87 "c_utils:utils", 88 "zlib:libz", 89 "zlib:shared_libz", 90 ] 91} 92 93ohos_unittest("js_runtime_test") { 94 module_out_path = module_output_path 95 sanitize = { 96 cfi = true 97 cfi_cross_dso = true 98 debug = false 99 blocklist = "../../cfi_blocklist.txt" 100 } 101 branch_protector_ret = "pac_ret" 102 103 include_dirs = [ 104 "${ability_runtime_native_path}/runtime", 105 "${ability_runtime_native_path}/runtime/utils/include", 106 ] 107 108 sources = [ 109 # add mock file 110 "js_runtime_test.cpp", 111 "mock_jsnapi.cpp", 112 ] 113 114 configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] 115 116 external_deps = [ 117 "ability_runtime:js_environment", 118 "ability_runtime:runtime", 119 "bundle_framework:appexecfwk_base", 120 "bundle_framework:appexecfwk_core", 121 "c_utils:utils", 122 "ets_runtime:libark_jsruntime", 123 "eventhandler:libeventhandler", 124 "ffrt:libffrt", 125 "googletest:gmock_main", 126 "googletest:gtest_main", 127 "hilog:libhilog", 128 "ipc:ipc_core", 129 "napi:ace_napi", 130 "zlib:libz", 131 "zlib:shared_libz", 132 ] 133} 134 135ohos_unittest("js_runtime_first_test") { 136 module_out_path = module_output_path 137 sanitize = { 138 cfi = true 139 cfi_cross_dso = true 140 debug = false 141 blocklist = "../../cfi_blocklist.txt" 142 } 143 branch_protector_ret = "pac_ret" 144 145 include_dirs = [ 146 "${ability_runtime_native_path}/runtime", 147 "${ability_runtime_native_path}/runtime/utils/include", 148 ] 149 150 sources = [ 151 # add mock file 152 "js_runtime_first_test.cpp", 153 "mock_jsnapi.cpp", 154 ] 155 156 configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] 157 158 external_deps = [ 159 "ability_runtime:js_environment", 160 "ability_runtime:runtime", 161 "bundle_framework:appexecfwk_base", 162 "bundle_framework:appexecfwk_core", 163 "c_utils:utils", 164 "ets_runtime:libark_jsruntime", 165 "eventhandler:libeventhandler", 166 "ffrt:libffrt", 167 "googletest:gmock_main", 168 "googletest:gtest_main", 169 "hilog:libhilog", 170 "ipc:ipc_core", 171 "napi:ace_napi", 172 "zlib:libz", 173 "zlib:shared_libz", 174 ] 175} 176 177ohos_unittest("hdc_register_test") { 178 module_out_path = module_output_path 179 180 include_dirs = [ 181 "${ability_runtime_native_path}/runtime", 182 "${ability_runtime_native_path}/runtime/utils/include", 183 ] 184 185 sources = [ 186 # add mock file 187 "${ability_runtime_native_path}/runtime/hdc_register.cpp", 188 "hdc_register_test.cpp", 189 ] 190 191 configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] 192 193 external_deps = [ 194 "bundle_framework:appexecfwk_core", 195 "c_utils:utils", 196 "googletest:gmock_main", 197 "googletest:gtest_main", 198 "hilog:libhilog", 199 "ipc:ipc_core", 200 "zlib:libz", 201 "zlib:shared_libz", 202 ] 203} 204 205ohos_unittest("ohos_js_environment_test") { 206 module_out_path = module_output_path 207 208 include_dirs = [ "${ability_runtime_native_path}/runtime" ] 209 210 sources = [ "ohos_js_environment_test.cpp" ] 211 212 configs = [] 213 214 external_deps = [ 215 "ability_runtime:js_environment", 216 "ability_runtime:runtime", 217 "c_utils:utils", 218 "ets_runtime:libark_jsruntime", 219 "eventhandler:libeventhandler", 220 "googletest:gmock_main", 221 "googletest:gtest_main", 222 "hilog:libhilog", 223 "napi:ace_napi", 224 ] 225} 226 227ohos_unittest("js_worker_test") { 228 module_out_path = module_output_path 229 230 include_dirs = [ 231 "${ability_runtime_native_path}/runtime", 232 "${ability_runtime_native_path}/runtime/utils/include", 233 ] 234 235 sources = [ 236 # add mock file 237 "js_worker_test.cpp", 238 ] 239 240 configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] 241 deps = [] 242 243 external_deps = [ 244 "ability_base:extractortool", 245 "ability_runtime:js_environment", 246 "ability_runtime:runtime", 247 "bundle_framework:appexecfwk_base", 248 "bundle_framework:appexecfwk_core", 249 "c_utils:utils", 250 "ets_runtime:libark_jsruntime", 251 "eventhandler:libeventhandler", 252 "hilog:libhilog", 253 "ipc:ipc_core", 254 "napi:ace_napi", 255 "zlib:libz", 256 "zlib:shared_libz", 257 ] 258} 259 260ohos_unittest("ets_runtime_test") { 261 module_out_path = module_output_path 262 sanitize = { 263 cfi = true 264 cfi_cross_dso = true 265 debug = false 266 blocklist = "../../cfi_blocklist.txt" 267 } 268 branch_protector_ret = "pac_ret" 269 270 include_dirs = [ 271 "${ability_runtime_innerkits_path}/runtime/include", 272 "${ability_runtime_path}/frameworks/ets/ani/ani_common/include", 273 "${ability_runtime_path}/interfaces/inner_api", 274 "${ability_runtime_path}/ets_environment/interfaces/inner_api", 275 "${ability_runtime_path}/ets_environment/frameworks/ets_environment/include", 276 "${ability_runtime_native_path}/runtime", 277 "${ability_runtime_native_path}/runtime/utils/include", 278 ] 279 280 sources = [ 281 "${ability_runtime_path}/ets_environment/frameworks/ets_environment/src/dynamic_loader.cpp", 282 "${ability_runtime_path}/ets_environment/frameworks/ets_environment/src/ets_environment.cpp", 283 "ets_runtime_test.cpp", 284 ] 285 286 configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] 287 deps = [] 288 289 external_deps = [ 290 "ability_runtime:runtime", 291 "bundle_framework:appexecfwk_core", 292 "c_utils:utils", 293 "eventhandler:libeventhandler", 294 "faultloggerd:libunwinder", 295 "ffrt:libffrt", 296 "googletest:gmock_main", 297 "googletest:gtest_main", 298 "hilog:libhilog", 299 "ipc:ipc_core", 300 "json:nlohmann_json_static", 301 "napi:ace_napi", 302 "runtime_core:ani", 303 "runtime_core:libarkruntime", 304 ] 305 306 if (ability_runtime_graphics) { 307 defines = [ "SUPPORT_GRAPHICS" ] 308 external_deps += [ "ace_engine:ace_uicontent" ] 309 } 310} 311 312group("unittest") { 313 testonly = true 314 315 deps = [ 316 ":hdc_register_test", 317 ":ets_runtime_test", 318 ":hybrid_js_module_reader_test", 319 ":js_runtime_first_test", 320 ":js_runtime_test", 321 ":js_worker_test", 322 ":ohos_js_environment_test", 323 ":runtime_test", 324 ] 325} 326