• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/ets_runtime/js_runtime_config.gni")
16import("//arkcompiler/toolchain/test/test_helper.gni")
17import("//build/ohos.gni")
18import("//build/test.gni")
19
20module_output_path = "arkcompiler/toolchain"
21
22config("debug_api_test") {
23  visibility = [ ":*" ]
24
25  ldflags = [ "-Wl,-rpath=\$ORIGIN/" ]
26
27  configs = [ "//arkcompiler/toolchain:toolchain_test_config" ]
28
29  include_dirs = [
30    "//arkcompiler/ets_runtime",
31    "//arkcompiler/toolchain/tooling",
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]
48
49foreach(file, test_js_files) {
50  es2abc_gen_abc("gen_${file}_abc") {
51    test_js = "${test_js_path}${file}.js"
52    test_abc = "$target_out_dir/${file}.abc"
53
54    # Only targets in this file can depend on this.
55    extra_visibility = [ ":*" ]
56    src_js = rebase_path(test_js)
57    dst_file = rebase_path(test_abc)
58    extra_args = [ "--debug" ]
59
60    in_puts = [ test_js ]
61    out_puts = [ test_abc ]
62  }
63}
64
65source_set("debugger_entry_set") {
66  sources = [ "entry/test_debugger_entry.cpp" ]
67
68  public_configs = [ ":debug_api_test" ]
69
70  deps = [ ":jsdebugtest" ]
71
72  foreach(file, test_js_files) {
73    deps += [ ":gen_${file}_abc" ]
74  }
75}
76
77ohos_shared_library("debugger_entry") {
78  deps = [ ":debugger_entry_set" ]
79
80  install_enable = false
81
82  output_extension = "so"
83  subsystem_name = "test"
84}
85
86source_set("jsdebugtest_set") {
87  sources = [
88    "utils/test_entry.cpp",
89    "utils/test_extractor.cpp",
90    "utils/test_list.cpp",
91    "utils/test_util.cpp",
92  ]
93
94  public_configs = [
95    ":debug_api_test",
96    "//arkcompiler/toolchain/tooling:ark_ecma_debugger_config",
97  ]
98
99  test_abc_dir = "/data/test/"
100  target_label = get_label_info(":${target_name}", "label_with_toolchain")
101  target_toolchain = get_label_info(target_label, "toolchain")
102  if (target_toolchain == host_toolchain) {
103    test_abc_dir = rebase_path(target_out_dir)
104  }
105
106  defines = [ "DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"" ]
107
108  if (is_ohos && is_standard_system) {
109    if (enable_hilog) {
110      defines += [ "ENABLE_HILOG" ]
111      include_dirs =
112          [ "//base/hiviewdfx/hilog/interfaces/native/innerkits/include" ]
113    }
114  }
115
116  deps = [ "$ark_root/libpandafile:arkfile_header_deps" ]
117}
118
119ohos_shared_library("jsdebugtest") {
120  deps = [ ":jsdebugtest_set" ]
121
122  deps += [
123    "//arkcompiler/ets_runtime:libark_jsruntime_test",
124    "//arkcompiler/toolchain/tooling:libark_ecma_debugger_test",
125  ]
126
127  if (is_ohos && is_standard_system) {
128    if (enable_hilog) {
129      external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
130    }
131  }
132
133  install_enable = false
134
135  output_extension = "so"
136  subsystem_name = "test"
137}
138
139host_unittest_action("DebuggerEntryTest") {
140  module_out_path = module_output_path
141
142  sources = [
143    # test file
144    "debugger_entry_test.cpp",
145  ]
146
147  cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ]
148
149  defines = [ "DEBUGGER_TEST_LIBRARY=\"libdebugger_entry.so\"" ]
150
151  configs = [ ":debug_api_test" ]
152
153  deps = [
154    ":debugger_entry_resource",
155    ":jsdebugtest",
156    "//arkcompiler/ets_runtime:libark_jsruntime_test",
157    "//arkcompiler/toolchain/tooling:libark_ecma_debugger_test",
158  ]
159}
160
161host_unittest_action("DebuggerTest") {
162  module_out_path = module_output_path
163
164  sources = [
165    # test file
166    "debugger_commands_test.cpp",
167    "debugger_events_test.cpp",
168    "debugger_params_test.cpp",
169    "debugger_returns_test.cpp",
170    "debugger_script_test.cpp",
171    "debugger_types_test.cpp",
172    "heapprofiler_impl_test.cpp",
173    "js_pt_hooks_test.cpp",
174    "profiler_impl_test.cpp",
175    "pt_base64_test.cpp",
176    "pt_json_test.cpp",
177    "runtime_impl_test.cpp",
178    "tracing_impl_test.cpp",
179  ]
180
181  configs = [ "//arkcompiler/toolchain:toolchain_test_config" ]
182
183  deps = [
184    "//arkcompiler/ets_runtime:libark_jsruntime_test",
185    "//arkcompiler/toolchain/tooling:libark_ecma_debugger_test",
186    "//third_party/cJSON:cjson",
187    sdk_libc_secshared_dep,
188  ]
189}
190
191group("debugger_entry_resource") {
192  testonly = true
193
194  deps = [ ":debugger_entry" ]
195}
196
197group("unittest") {
198  testonly = true
199
200  # deps file
201  deps = [
202    ":DebuggerEntryTest",
203    ":DebuggerTest",
204  ]
205}
206
207group("host_unittest") {
208  testonly = true
209
210  # deps file
211  deps = [
212    ":DebuggerEntryTestAction",
213    ":DebuggerTestAction",
214  ]
215}
216