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