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 = "arkcompiler/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 "//third_party/libuv/include", 33 ] 34} 35 36test_js_path = "//arkcompiler/toolchain/tooling/test/testcases/js/" 37 38# When new js test file added, pls modify ohos_test.xml in test/resource accordingly. 39test_js_files = [ 40 "arrow_func", 41 "async_func", 42 "exception", 43 "range_error", 44 "sample", 45 "step", 46 "syntax_exception", 47 "throw_exception", 48 "variable_first", 49 "variable_second", 50 "export_variable_first", 51 "export_variable_second", 52 "module_variable", 53 "dropframe", 54 "local_variable_scope", 55 "container", 56 "closure_scope", 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 = false 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 = [] 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 = false 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 = [ 135 "//arkcompiler/ets_runtime:libark_jsruntime_test", 136 "//arkcompiler/toolchain/tooling:libark_ecma_debugger_test", 137 ] 138 139 # hiviewdfx libraries 140 external_deps = hiviewdfx_ext_deps 141 deps += hiviewdfx_deps 142 if (enable_hilog) { 143 external_deps += [ "hilog:libhilog" ] 144 } 145 146 external_deps += [ 147 "cJSON:cjson_static", 148 "ets_runtime:libark_jsruntime", 149 ] 150 install_enable = false 151 output_extension = "so" 152 subsystem_name = "test" 153} 154 155host_unittest_action("DebuggerEntryTest") { 156 module_out_path = module_output_path 157 158 sources = [ 159 # test file 160 "debugger_entry_test.cpp", 161 ] 162 163 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 164 165 defines = [ "DEBUGGER_TEST_LIBRARY=\"libdebugger_entry.so\"" ] 166 167 configs = [ ":debug_api_test" ] 168 169 deps = [ 170 ":debugger_entry_resource", 171 ":jsdebugtest", 172 "$js_root:libark_jsruntime_test", 173 "$toolchain_root/tooling:libark_ecma_debugger_test", 174 ] 175 176 # hiviewdfx libraries 177 external_deps = hiviewdfx_ext_deps 178 external_deps += [ 179 "cJSON:cjson_static", 180 "icu:shared_icui18n", 181 "icu:shared_icuuc", 182 ] 183 deps += hiviewdfx_deps 184} 185 186host_unittest_action("DebuggerTest") { 187 module_out_path = module_output_path 188 189 sources = [ 190 # test file 191 "debugger_commands_test.cpp", 192 "debugger_events_test.cpp", 193 "debugger_impl_test.cpp", 194 "debugger_params_test.cpp", 195 "debugger_returns_test.cpp", 196 "debugger_script_test.cpp", 197 "debugger_service_test.cpp", 198 "debugger_types_test.cpp", 199 "dispatcher_test.cpp", 200 "dom_impl_test.cpp", 201 "heapprofiler_impl_test.cpp", 202 "js_pt_hooks_test.cpp", 203 "overlay_impl_test.cpp", 204 "page_impl_test.cpp", 205 "profiler_impl_test.cpp", 206 "protocol_handler_test.cpp", 207 "pt_base64_test.cpp", 208 "pt_json_test.cpp", 209 "pt_params_test.cpp", 210 "pt_returns_test.cpp", 211 "pt_types_test.cpp", 212 "runtime_impl_test.cpp", 213 "target_impl_test.cpp", 214 "tracing_impl_test.cpp", 215 ] 216 217 configs = [ ":debug_api_test" ] 218 219 deps = [ 220 "$js_root:libark_jsruntime_test", 221 "$toolchain_root/tooling:libark_ecma_debugger_test", 222 ] 223 224 # hiviewdfx libraries 225 external_deps = hiviewdfx_ext_deps 226 external_deps += [ 227 "bounds_checking_function:libsec_shared", 228 "cJSON:cjson", 229 "icu:shared_icui18n", 230 "icu:shared_icuuc", 231 "runtime_core:libarkbase_static", 232 ] 233 deps += hiviewdfx_deps 234} 235 236host_unittest_action("DebuggerCInterpTest") { 237 module_out_path = module_output_path 238 239 sources = [ 240 # test file 241 "debugger_cinterp_test.cpp", 242 ] 243 244 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 245 246 defines = [ "DEBUGGER_TEST_LIBRARY=\"libdebugger_entry.so\"" ] 247 248 configs = [ ":debug_api_test" ] 249 250 deps = [ 251 ":debugger_entry_resource", 252 ":jsdebugtest", 253 "$js_root:libark_jsruntime_test", 254 "$toolchain_root/tooling:libark_ecma_debugger_test", 255 ] 256 257 # hiviewdfx libraries 258 external_deps = hiviewdfx_ext_deps 259 external_deps += [ 260 "cJSON:cjson_static", 261 "icu:shared_icui18n", 262 "icu:shared_icuuc", 263 ] 264 deps += hiviewdfx_deps 265} 266 267host_unittest_action("DebuggerClientTest") { 268 module_out_path = module_output_path 269 270 sources = [ 271 # test file 272 "client_utils/test_list.cpp", 273 "client_utils/test_util.cpp", 274 "debugger_client_test.cpp", 275 ] 276 277 test_abc_dir = "/data/test/" 278 test_label = get_label_info(":${target_name}", "label_with_toolchain") 279 test_toolchain = get_label_info(test_label, "toolchain") 280 if (test_toolchain == host_toolchain || ark_standalone_build) { 281 test_abc_dir = rebase_path(target_out_dir) 282 } 283 test_js_dir = rebase_path(test_js_path) 284 285 defines = [ 286 "DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"", 287 "DEBUGGER_JS_DIR=\"${test_js_dir}\"", 288 ] 289 290 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 291 292 configs = [ ":debug_api_test" ] 293 294 deps = [ 295 ":debugger_client_resource", 296 "$toolchain_root/tooling:libark_ecma_debugger", 297 "../client:libark_client", 298 ] 299 300 # hiviewdfx libraries 301 external_deps = hiviewdfx_ext_deps 302 external_deps += [ 303 "bounds_checking_function:libsec_shared", 304 "cJSON:cjson_static", 305 "icu:shared_icui18n", 306 "icu:shared_icuuc", 307 ] 308 deps += hiviewdfx_deps 309 310 external_deps += [ "ets_runtime:libark_jsruntime" ] 311} 312 313host_unittest_action("DebuggerCIntClientTest") { 314 module_out_path = module_output_path 315 316 sources = [ 317 # test file 318 "client_utils/test_list.cpp", 319 "client_utils/test_util.cpp", 320 "debugger_cint_client_test.cpp", 321 ] 322 323 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 324 325 test_abc_dir = "/data/test/" 326 test_label = get_label_info(":${target_name}", "label_with_toolchain") 327 test_toolchain = get_label_info(test_label, "toolchain") 328 if (test_toolchain == host_toolchain || ark_standalone_build) { 329 test_abc_dir = rebase_path(target_out_dir) 330 } 331 test_js_dir = rebase_path(test_js_path) 332 333 defines = [ 334 "DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"", 335 "DEBUGGER_JS_DIR=\"${test_js_dir}\"", 336 ] 337 338 configs = [ ":debug_api_test" ] 339 340 deps = [ 341 ":debugger_client_resource", 342 "$toolchain_root/tooling:libark_ecma_debugger", 343 "../client:libark_client", 344 ] 345 346 # hiviewdfx libraries 347 external_deps = hiviewdfx_ext_deps 348 external_deps += [ 349 "bounds_checking_function:libsec_shared", 350 "cJSON:cjson_static", 351 "icu:shared_icui18n", 352 "icu:shared_icuuc", 353 ] 354 deps += hiviewdfx_deps 355 356 external_deps += [ "ets_runtime:libark_jsruntime" ] 357} 358 359group("debugger_entry_resource") { 360 testonly = true 361 362 deps = [ ":debugger_entry" ] 363 foreach(file, test_js_files) { 364 deps += [ ":gen_${file}_abc" ] 365 } 366} 367 368group("debugger_client_resource") { 369 testonly = true 370 371 deps = [ "../../inspector:ark_debugger" ] 372 foreach(file, test_js_files) { 373 deps += [ ":gen_${file}_abc" ] 374 } 375} 376 377group("unittest") { 378 testonly = true 379 380 # deps file 381 deps = [ 382 ":DebuggerCIntClientTest", 383 ":DebuggerCInterpTest", 384 ":DebuggerClientTest", 385 ":DebuggerEntryTest", 386 ":DebuggerTest", 387 ] 388} 389 390group("host_unittest") { 391 testonly = true 392 393 # deps file 394 deps = [ 395 ":DebuggerCIntClientTestAction", 396 ":DebuggerCInterpTestAction", 397 ":DebuggerClientTestAction", 398 ":DebuggerEntryTestAction", 399 ":DebuggerTestAction", 400 ] 401} 402