• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 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/runtime_core/ark_config.gni")
15import("$ark_root/tests/test_helper.gni")
16import("$build_root/config/components/ets_frontend/es2abc_config.gni")
17
18disasm_test_configs = [
19  "$ark_root:ark_config",
20  "$ark_root/libpandabase:arkbase_public_config",
21  "$ark_root/libpandafile:arkfile_public_config",
22]
23
24disasm_test_deps = [
25  "$ark_root/disassembler:arkdisassembler",
26  "$ark_root/libpandabase:libarkbase_static",
27  "$ark_root/libpandafile:libarkfile_static",
28]
29
30disasm_column_test_js_files = [
31  "column-number1",
32  "column-number2",
33  "column-number3",
34  "column-number4",
35  "column-number5",
36  "column-number6",
37  "line-number1",
38  "line-number2",
39  "line-number3",
40  "line-number4",
41  "line-number5",
42]
43
44disasm_line_release_test_ts_files = [ "line_number_release" ]
45
46disasm_ets_implements_test_ts_files = [ "etsImplements" ]
47
48disasm_test_js_files = [
49  "slot-number-annotation",
50  "script-string1",
51  "script-string2",
52]
53
54test_js_path = "//arkcompiler/runtime_core/disassembler/tests/js/"
55
56foreach(file, disasm_column_test_js_files) {
57  es2abc_gen_abc("gen_${file}_abc") {
58    test_js = "${test_js_path}${file}.js"
59    test_abc = "$target_out_dir/${file}.abc"
60    src_js = rebase_path(test_js)
61    dst_file = rebase_path(test_abc)
62    extra_args = [
63      "--debug",
64      "--module",
65    ]
66    in_puts = [ test_js ]
67    out_puts = [ test_abc ]
68  }
69}
70
71test_ts_path = "//arkcompiler/runtime_core/disassembler/tests/ts/"
72
73foreach(file, disasm_line_release_test_ts_files) {
74  es2abc_gen_abc("gen_${file}_abc") {
75    test_ts = "${test_ts_path}${file}.ts"
76    test_abc = "$target_out_dir/${file}.abc"
77    src_js = rebase_path(test_ts)
78    dst_file = rebase_path(test_abc)
79    extra_args = [ "--module" ]
80    in_puts = [ test_ts ]
81    out_puts = [ test_abc ]
82  }
83}
84
85foreach(file, disasm_ets_implements_test_ts_files) {
86  es2abc_gen_abc("gen_${file}_abc") {
87    test_ts = "${test_ts_path}${file}.ts"
88    test_abc = "$target_out_dir/${file}.abc"
89    src_js = rebase_path(test_ts)
90    dst_file = rebase_path(test_abc)
91    extra_args = [ "--module",
92                   "--enable-ets-implements",
93                 ]
94    in_puts = [ test_ts ]
95    out_puts = [ test_abc ]
96  }
97}
98
99disasm_annotation_test_files = [
100  "declaration-3d-array-boolean",
101  "declaration-3d-array-enum-number",
102  "declaration-3d-array-enum-string",
103  "declaration-3d-array-number",
104  "declaration-3d-array-string",
105  "declaration-array-boolean",
106  "declaration-array-enum-number",
107  "declaration-array-enum-string",
108  "declaration-array-number",
109  "declaration-array-string",
110  "declaration-boolean",
111  "declaration-combination",
112  "declaration-empty",
113  "declaration-enum-number",
114  "declaration-enum-string",
115  "declaration-number",
116  "declaration-string",
117  "declaration-usage-3d-array-boolean",
118  "declaration-usage-3d-array-enum-number",
119  "declaration-usage-3d-array-enum-string",
120  "declaration-usage-3d-array-number",
121  "declaration-usage-3d-array-string",
122  "declaration-usage-array-boolean",
123  "declaration-usage-array-enum-number",
124  "declaration-usage-array-enum-string",
125  "declaration-usage-array-number",
126  "declaration-usage-array-string",
127  "declaration-usage-boolean",
128  "declaration-usage-combination",
129  "declaration-usage-empty",
130  "declaration-usage-enum-number",
131  "declaration-usage-enum-string",
132  "declaration-usage-number",
133  "declaration-usage-string",
134  "export",
135  "import-qualified",
136  "import-unqualified",
137  "multiple-annotations",
138]
139
140test_annotation_path =
141    "//arkcompiler/runtime_core/disassembler/tests/annotations/"
142
143foreach(file, disasm_annotation_test_files) {
144  es2abc_gen_abc("gen_${file}_abc") {
145    test_ts = "${test_annotation_path}${file}.ts"
146    test_abc = "$target_out_dir/${file}.abc"
147    src_js = rebase_path(test_ts)
148    dst_file = rebase_path(test_abc)
149    extra_args = [
150      "--enable-annotations",
151      "--module",
152      "--merge-abc",
153    ]
154    in_puts = [ test_ts ]
155    out_puts = [ test_abc ]
156  }
157}
158
159disasm_module_test_js_files = [
160  "module-requests-annotation-import",
161  "module-regular-import",
162  "module-namespace-import",
163  "module-local-export",
164  "module-indirect-export",
165  "module-start-export",
166  "module-regular-import-local-export",
167]
168
169module_test_js_path = "//arkcompiler/runtime_core/disassembler/tests/module/"
170
171foreach(file, disasm_module_test_js_files) {
172  es2abc_gen_abc("gen_${file}_abc") {
173    test_js = "${module_test_js_path}${file}.js"
174    test_abc = "$target_out_dir/${file}.abc"
175    src_js = rebase_path(test_js)
176
177    dst_file = rebase_path(test_abc)
178    extra_args = [
179      "--module",
180      "--merge-abc",
181    ]
182    in_puts = [ test_js ]
183    out_puts = [ test_abc ]
184  }
185}
186
187foreach(file, disasm_test_js_files) {
188  es2abc_gen_abc("gen_${file}_abc") {
189    test_js = "${test_js_path}${file}.js"
190    test_abc = "$target_out_dir/${file}.abc"
191    src_js = rebase_path(test_js)
192
193    dst_file = rebase_path(test_abc)
194    in_puts = [ test_js ]
195    out_puts = [ test_abc ]
196  }
197}
198
199sourceLang_file = "sourceLang"
200action("gen_filesinfo_action") {
201  script = "handle_fileinfo.py"
202
203  inputs = [ "${sourceLang_file}/filesInfo.txt" ]
204  outputs = [ "${target_out_dir}/${sourceLang_file}/filesInfo.txt" ]
205  args = [
206    rebase_path("${sourceLang_file}/filesInfo.txt"),
207    rebase_path("${target_out_dir}/${sourceLang_file}/filesInfo.txt"),
208    rebase_path("./"),
209  ]
210}
211
212es2abc_gen_abc("gen_${sourceLang_file}_abc") {
213  test_abc = "$target_out_dir/${sourceLang_file}.abc"
214  fileinfo_path =
215      rebase_path("${target_out_dir}/${sourceLang_file}/filesInfo.txt")
216  src_js = "@${fileinfo_path}"
217  dst_file = rebase_path(test_abc)
218  extra_args = [
219    "--module",
220    "--merge-abc",
221    "--enable-annotations",
222  ]
223  out_puts = [ test_abc ]
224}
225
226disasm_include_dirs = [
227  "$ark_root/disassembler",
228  "$ark_root/assembler",
229  "$target_gen_dir",
230  "$target_gen_dir/../",
231  "$target_gen_dir/../../assembler",
232]
233
234script_sources = [
235  "disassembler_column_number_test.cpp",
236  "disassembler_get_file_name_test.cpp",
237  "disassembler_line_number_test.cpp",
238  "disassembler_source_lang_test.cpp",
239  "disassembler_string_test.cpp",
240  "disassembler_system_annotations_test.cpp",
241  "disassembler_etsImplements_literal_test.cpp"
242]
243
244module_sources = [
245  "disassembler_module_literal_test.cpp",
246  "disassembler_system_annotations_test.cpp",
247  "utils.cpp",
248]
249
250disasm_module_test_action_files = [
251  "module-requests-annotation-import",
252  "module-regular-import",
253  "module-namespace-import",
254  "module-local-export",
255  "module-indirect-export",
256  "module-start-export",
257  "module-regular-import-local-export",
258  "slot-number-annotation",
259]
260
261host_unittest_action("DisasmModuleTest") {
262  module_out_path = module_output_path
263  sources = module_sources
264  include_dirs = disasm_include_dirs
265  configs = disasm_test_configs
266  external_deps = [ sdk_libc_secshared_dep ]
267  deps = disasm_test_deps
268  test_abc_dir = rebase_path(target_out_dir)
269  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
270
271  foreach(file, disasm_module_test_action_files) {
272    deps += [ ":gen_${file}_abc" ]
273  }
274}
275
276disasm_debug_script_test_action_files = [
277  "column-number1",
278  "column-number2",
279  "column-number3",
280  "column-number4",
281  "column-number5",
282  "column-number6",
283  "line-number1",
284  "line-number2",
285  "line-number3",
286  "line-number4",
287  "line-number5",
288  "module-requests-annotation-import",
289  "script-string1",
290  "script-string2",
291  "slot-number-annotation",
292]
293
294host_unittest_action("DisasmDebugTest") {
295  module_out_path = module_output_path
296  sources = script_sources
297  include_dirs = disasm_include_dirs
298  configs = disasm_test_configs
299  external_deps = [ sdk_libc_secshared_dep ]
300  deps = disasm_test_deps
301  test_abc_dir = rebase_path(target_out_dir)
302  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
303
304  foreach(file, disasm_debug_script_test_action_files) {
305    deps += [ ":gen_${file}_abc" ]
306  }
307
308  foreach(file, disasm_ets_implements_test_ts_files) {
309    deps += [ ":gen_${file}_abc" ]
310  }
311}
312
313host_unittest_action("DisasmReleaseTest") {
314  module_out_path = module_output_path
315  sources = [ "disassembler_line_number_release_test.cpp" ]
316  include_dirs = disasm_include_dirs
317  configs = disasm_test_configs
318  external_deps = [ sdk_libc_secshared_dep ]
319  deps = disasm_test_deps
320  test_abc_dir = rebase_path(target_out_dir)
321  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
322
323  foreach(file, disasm_line_release_test_ts_files) {
324    deps += [ ":gen_${file}_abc" ]
325  }
326}
327
328annotations_sources = [ "disassembler_user_annotations_test.cpp" ]
329
330host_unittest_action("DisasmUserAnnotationsTest") {
331  module_out_path = module_output_path
332  sources = annotations_sources
333  include_dirs = disasm_include_dirs
334  configs = disasm_test_configs
335  external_deps = [ sdk_libc_secshared_dep ]
336  deps = disasm_test_deps
337  test_abc_dir = rebase_path(target_out_dir)
338  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
339
340  foreach(file, disasm_annotation_test_files) {
341    deps += [ ":gen_${file}_abc" ]
342  }
343}
344
345host_unittest_action("DisasmScriptTest") {
346  module_out_path = module_output_path
347  sources = script_sources
348  include_dirs = disasm_include_dirs
349  configs = disasm_test_configs
350  external_deps = [ sdk_libc_secshared_dep ]
351  deps = disasm_test_deps
352  test_abc_dir = rebase_path(target_out_dir)
353  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
354
355  foreach(file, disasm_debug_script_test_action_files) {
356    deps += [ ":gen_${file}_abc" ]
357  }
358
359  foreach(file, disasm_ets_implements_test_ts_files) {
360    deps += [ ":gen_${file}_abc" ]
361  }
362}
363
364host_unittest_action("DisasmImmTest") {
365  module_out_path = module_output_path
366  sources = [ "disassembler_imm_tests.cpp" ]
367  include_dirs = disasm_include_dirs
368  configs = disasm_test_configs
369  external_deps = [ sdk_libc_secshared_dep ]
370  deps = disasm_test_deps
371}
372
373host_unittest_action("DisasmSourceLangTest") {
374  module_out_path = module_output_path
375  sources = [ "disassembler_source_lang_test.cpp" ]
376  include_dirs = disasm_include_dirs
377  configs = disasm_test_configs
378  external_deps = [ sdk_libc_secshared_dep ]
379  deps = disasm_test_deps
380  test_abc_dir = rebase_path(target_out_dir)
381  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
382  deps += [
383    ":gen_${sourceLang_file}_abc",
384    ":gen_filesinfo_action",
385  ]
386}
387
388group("host_unittest") {
389  testonly = true
390  deps = [
391    ":DisasmDebugTestAction",
392    ":DisasmImmTestAction",
393    ":DisasmModuleTestAction",
394    ":DisasmReleaseTestAction",
395    ":DisasmScriptTestAction",
396    ":DisasmSourceLangTestAction",
397    ":DisasmUserAnnotationsTestAction",
398  ]
399}
400