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