1# Copyright (c) 2021 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("//arkcompiler/toolchain/test/test_helper.gni") 15import("$build_root/config/components/ets_frontend/es2abc_config.gni") 16 17module_output_path = "toolchain" 18 19config("debug_api_test") { 20 visibility = [ ":*" ] 21 22 if (!is_mac) { 23 ldflags = [ "-Wl,-rpath=\$ORIGIN/" ] 24 } 25 26 configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] 27 28 include_dirs = [ 29 "$toolchain_root/websocket", 30 "//arkcompiler/ets_runtime", 31 "../..", 32 ] 33} 34 35test_js_path = "//arkcompiler/toolchain/tooling/test/testcases/js/" 36 37# When new js test file added, pls modify ohos_test.xml in test/resource accordingly. 38test_js_files = [ 39 "arrow_func", 40 "async_func", 41 "exception", 42 "range_error", 43 "sample", 44 "step", 45 "syntax_exception", 46 "throw_exception", 47 "variable_first", 48 "variable_second", 49 "export_variable_first", 50 "export_variable_second", 51 "module_variable", 52 "dropframe", 53 "local_variable_scope", 54 "container", 55 "closure_scope", 56 "closure_variable", 57 "branch", 58 "common_func", 59 "watch_variable", 60 "smart_stepInto", 61] 62 63foreach(file, test_js_files) { 64 es2abc_gen_abc("gen_${file}_abc") { 65 test_js = "${test_js_path}${file}.js" 66 test_abc = "$target_out_dir/${file}.abc" 67 68 # Only targets in this file can depend on this. 69 extra_visibility = [ ":*" ] 70 src_js = rebase_path(test_js) 71 dst_file = rebase_path(test_abc) 72 extra_args = [ "--debug" ] 73 if (file == "module_variable" || file == "export_variable_first" || 74 file == "export_variable_second") { 75 extra_args += [ "--module" ] 76 extra_args += [ "--merge-abc" ] 77 } 78 79 in_puts = [ test_js ] 80 out_puts = [ test_abc ] 81 } 82} 83 84ohos_shared_library("debugger_entry") { 85 testonly = true 86 stack_protector_ret = true 87 sources = [ "entry/test_debugger_entry.cpp" ] 88 89 configs = [ ":debug_api_test" ] 90 91 deps = [ ":jsdebugtest" ] 92 93 foreach(file, test_js_files) { 94 deps += [ ":gen_${file}_abc" ] 95 } 96 external_deps = [ "libuv:uv" ] 97 if (enable_hilog) { 98 external_deps += [ "hilog:libhilog" ] 99 } 100 external_deps += [ "cJSON:cjson_static" ] 101 install_enable = false 102 output_extension = "so" 103 subsystem_name = "test" 104} 105 106ohos_shared_library("jsdebugtest") { 107 testonly = true 108 stack_protector_ret = true 109 sources = [ 110 "utils/test_entry.cpp", 111 "utils/test_extractor.cpp", 112 "utils/test_list.cpp", 113 "utils/test_util.cpp", 114 ] 115 116 configs = [ 117 ":debug_api_test", 118 "//arkcompiler/toolchain/tooling:ark_ecma_debugger_config", 119 ] 120 121 test_abc_dir = "/data/test/" 122 test_label = get_label_info(":${target_name}", "label_with_toolchain") 123 test_toolchain = get_label_info(test_label, "toolchain") 124 if (test_toolchain == host_toolchain || ark_standalone_build) { 125 test_abc_dir = rebase_path(target_out_dir) 126 } 127 test_js_dir = rebase_path(test_js_path) 128 129 defines = [ 130 "DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"", 131 "DEBUGGER_JS_DIR=\"${test_js_dir}\"", 132 ] 133 134 deps = [ "..:libark_ecma_debugger_test" ] 135 external_deps = [ 136 "ets_runtime:libark_jsruntime", 137 "icu:shared_icuuc", 138 "libuv:uv", 139 ] 140 141 # hiviewdfx libraries 142 external_deps += hiviewdfx_ext_deps 143 deps += hiviewdfx_deps 144 if (enable_hilog) { 145 external_deps += [ "hilog:libhilog" ] 146 } 147 148 external_deps += [ 149 "cJSON:cjson_static", 150 "ets_runtime:libark_jsruntime", 151 ] 152 install_enable = false 153 output_extension = "so" 154 subsystem_name = "test" 155} 156 157host_unittest_action("DebuggerEntryTest") { 158 module_out_path = module_output_path 159 160 sources = [ 161 # test file 162 "debugger_entry_test.cpp", 163 ] 164 165 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 166 167 defines = [ "DEBUGGER_TEST_LIBRARY=\"libdebugger_entry.so\"" ] 168 169 configs = [ ":debug_api_test" ] 170 171 deps = [ 172 ":debugger_entry_resource", 173 ":jsdebugtest", 174 "..:libark_ecma_debugger_test", 175 ] 176 177 # hiviewdfx libraries 178 external_deps = hiviewdfx_ext_deps 179 external_deps += [ 180 "cJSON:cjson_static", 181 "ets_runtime:libark_jsruntime", 182 "icu:shared_icui18n", 183 "icu:shared_icuuc", 184 "libuv:uv", 185 ] 186 deps += hiviewdfx_deps 187} 188 189host_unittest_action("DebuggerTest") { 190 module_out_path = module_output_path 191 192 sources = [ 193 # test file 194 "animation_impl_test.cpp", 195 "debugger_commands_test.cpp", 196 "debugger_events_test.cpp", 197 "debugger_impl_test.cpp", 198 "debugger_params_test.cpp", 199 "debugger_returns_test.cpp", 200 "debugger_script_test.cpp", 201 "debugger_service_test.cpp", 202 "debugger_types_test.cpp", 203 "dispatcher_test.cpp", 204 "dom_impl_test.cpp", 205 "heapprofiler_impl_test.cpp", 206 "js_pt_hooks_test.cpp", 207 "overlay_impl_test.cpp", 208 "page_impl_test.cpp", 209 "profiler_impl_test.cpp", 210 "protocol_handler_test.cpp", 211 "pt_base64_test.cpp", 212 "pt_json_test.cpp", 213 "pt_params_test.cpp", 214 "pt_returns_test.cpp", 215 "pt_types_test.cpp", 216 "runtime_impl_test.cpp", 217 "target_impl_test.cpp", 218 "tracing_impl_test.cpp", 219 ] 220 221 configs = [ ":debug_api_test" ] 222 223 deps = [ "..:libark_ecma_debugger_test" ] 224 225 # hiviewdfx libraries 226 external_deps = hiviewdfx_ext_deps 227 external_deps += [ 228 "bounds_checking_function:libsec_shared", 229 "cJSON:cjson", 230 "ets_runtime:libark_jsruntime", 231 "icu:shared_icui18n", 232 "icu:shared_icuuc", 233 "libuv:uv", 234 "runtime_core:libarkbase_static", 235 ] 236 deps += hiviewdfx_deps 237} 238 239host_unittest_action("DebuggerCInterpTest") { 240 module_out_path = module_output_path 241 242 sources = [ 243 # test file 244 "debugger_cinterp_test.cpp", 245 ] 246 247 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 248 249 defines = [ "DEBUGGER_TEST_LIBRARY=\"libdebugger_entry.so\"" ] 250 251 configs = [ ":debug_api_test" ] 252 253 deps = [ 254 ":debugger_entry_resource", 255 ":jsdebugtest", 256 "..:libark_ecma_debugger_test", 257 ] 258 259 # hiviewdfx libraries 260 external_deps = hiviewdfx_ext_deps 261 external_deps += [ 262 "cJSON:cjson_static", 263 "ets_runtime:libark_jsruntime", 264 "icu:shared_icui18n", 265 "icu:shared_icuuc", 266 "libuv:uv", 267 ] 268 deps += hiviewdfx_deps 269} 270 271host_unittest_action("DebuggerClientTest") { 272 module_out_path = module_output_path 273 274 sources = [ 275 # test file 276 "client_utils/test_list.cpp", 277 "client_utils/test_util.cpp", 278 "debugger_client_test.cpp", 279 ] 280 281 test_abc_dir = "/data/test/" 282 test_label = get_label_info(":${target_name}", "label_with_toolchain") 283 test_toolchain = get_label_info(test_label, "toolchain") 284 if (test_toolchain == host_toolchain || ark_standalone_build) { 285 test_abc_dir = rebase_path(target_out_dir) 286 } 287 test_js_dir = rebase_path(test_js_path) 288 289 defines = [ 290 "DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"", 291 "DEBUGGER_JS_DIR=\"${test_js_dir}\"", 292 ] 293 294 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 295 296 configs = [ ":debug_api_test" ] 297 298 deps = [ 299 ":debugger_client_resource", 300 "..:libark_ecma_debugger_test", 301 "../client:libark_client", 302 ] 303 304 # hiviewdfx libraries 305 external_deps = hiviewdfx_ext_deps 306 external_deps += [ 307 "bounds_checking_function:libsec_shared", 308 "cJSON:cjson_static", 309 "icu:shared_icui18n", 310 "icu:shared_icuuc", 311 "libuv:uv", 312 ] 313 deps += hiviewdfx_deps 314 315 external_deps += [ "ets_runtime:libark_jsruntime" ] 316} 317 318host_unittest_action("DebuggerCIntClientTest") { 319 module_out_path = module_output_path 320 321 sources = [ 322 # test file 323 "client_utils/test_list.cpp", 324 "client_utils/test_util.cpp", 325 "debugger_cint_client_test.cpp", 326 ] 327 328 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 329 330 test_abc_dir = "/data/test/" 331 test_label = get_label_info(":${target_name}", "label_with_toolchain") 332 test_toolchain = get_label_info(test_label, "toolchain") 333 if (test_toolchain == host_toolchain || ark_standalone_build) { 334 test_abc_dir = rebase_path(target_out_dir) 335 } 336 test_js_dir = rebase_path(test_js_path) 337 338 defines = [ 339 "DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"", 340 "DEBUGGER_JS_DIR=\"${test_js_dir}\"", 341 ] 342 343 configs = [ ":debug_api_test" ] 344 345 deps = [ 346 ":debugger_client_resource", 347 "..:libark_ecma_debugger_test", 348 "../client:libark_client", 349 ] 350 351 # hiviewdfx libraries 352 external_deps = hiviewdfx_ext_deps 353 external_deps += [ 354 "bounds_checking_function:libsec_shared", 355 "cJSON:cjson_static", 356 "icu:shared_icui18n", 357 "icu:shared_icuuc", 358 "libuv:uv", 359 ] 360 deps += hiviewdfx_deps 361 362 external_deps += [ "ets_runtime:libark_jsruntime" ] 363} 364 365group("debugger_entry_resource") { 366 testonly = true 367 368 deps = [ ":debugger_entry" ] 369 foreach(file, test_js_files) { 370 deps += [ ":gen_${file}_abc" ] 371 } 372} 373 374group("debugger_client_resource") { 375 testonly = true 376 377 deps = [ "../../inspector:ark_debugger" ] 378 foreach(file, test_js_files) { 379 deps += [ ":gen_${file}_abc" ] 380 } 381} 382 383group("unittest") { 384 testonly = true 385 386 # deps file 387 deps = [ 388 ":DebuggerCIntClientTest", 389 ":DebuggerCInterpTest", 390 ":DebuggerClientTest", 391 ":DebuggerEntryTest", 392 ":DebuggerTest", 393 ] 394} 395 396group("host_unittest") { 397 testonly = true 398 399 # deps file 400 deps = [ 401 ":DebuggerCIntClientTestAction", 402 ":DebuggerCInterpTestAction", 403 ":DebuggerClientTestAction", 404 ":DebuggerEntryTestAction", 405 ":DebuggerTestAction", 406 ] 407} 408