• 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/ets_frontend/es2panda/es2abc_config.gni")
15import("//arkcompiler/runtime_core/ark_config.gni")
16import("$ark_root/tests/test_helper.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  sdk_libc_secshared_config,
23]
24
25disasm_test_deps = [
26  "$ark_root/disassembler:arkdisassembler",
27  "$ark_root/libpandabase:libarkbase_static",
28  "$ark_root/libpandafile:libarkfile_static",
29]
30
31disasm_column_test_js_files = [
32  "column-number1",
33  "column-number2",
34  "column-number3",
35  "column-number4",
36  "column-number5",
37  "column-number6",
38  "line-number1",
39  "line-number2",
40  "line-number3",
41  "line-number4",
42  "line-number5",
43]
44
45disasm_line_release_test_ts_files = [ "line_number_release" ]
46
47disasm_test_js_files = [
48  "slot-number-annotation",
49  "script-string1",
50  "script-string2",
51]
52
53test_js_path = "//arkcompiler/runtime_core/disassembler/tests/js/"
54
55foreach(file, disasm_column_test_js_files) {
56  es2abc_gen_abc("gen_${file}_abc") {
57    test_js = "${test_js_path}${file}.js"
58    test_abc = "$target_out_dir/${file}.abc"
59    src_js = rebase_path(test_js)
60    dst_file = rebase_path(test_abc)
61    extra_args = [
62      "--debug",
63      "--module",
64    ]
65    in_puts = [ test_js ]
66    out_puts = [ test_abc ]
67  }
68}
69
70test_ts_path = "//arkcompiler/runtime_core/disassembler/tests/ts/"
71
72foreach(file, disasm_line_release_test_ts_files) {
73  es2abc_gen_abc("gen_${file}_abc") {
74    test_ts = "${test_ts_path}${file}.ts"
75    test_abc = "$target_out_dir/${file}.abc"
76    src_js = rebase_path(test_ts)
77    dst_file = rebase_path(test_abc)
78    extra_args = [ "--module" ]
79    in_puts = [ test_ts ]
80    out_puts = [ test_abc ]
81  }
82}
83
84disasm_module_test_js_files = [
85  "module-requests-annotation-import",
86  "module-regular-import",
87  "module-namespace-import",
88  "module-local-export",
89  "module-indirect-export",
90  "module-start-export",
91  "module-regular-import-local-export",
92]
93
94module_test_js_path = "//arkcompiler/runtime_core/disassembler/tests/module/"
95
96foreach(file, disasm_module_test_js_files) {
97  es2abc_gen_abc("gen_${file}_abc") {
98    test_js = "${module_test_js_path}${file}.js"
99    test_abc = "$target_out_dir/${file}.abc"
100    src_js = rebase_path(test_js)
101
102    dst_file = rebase_path(test_abc)
103    extra_args = [
104      "--module",
105      "--merge-abc",
106    ]
107    in_puts = [ test_js ]
108    out_puts = [ test_abc ]
109  }
110}
111
112foreach(file, disasm_test_js_files) {
113  es2abc_gen_abc("gen_${file}_abc") {
114    test_js = "${test_js_path}${file}.js"
115    test_abc = "$target_out_dir/${file}.abc"
116    src_js = rebase_path(test_js)
117
118    dst_file = rebase_path(test_abc)
119    in_puts = [ test_js ]
120    out_puts = [ test_abc ]
121  }
122}
123
124disasm_include_dirs = [
125  "$ark_root/disassembler",
126  "$ark_root/assembler",
127  "$target_gen_dir",
128  "$target_gen_dir/../",
129  "$target_gen_dir/../../assembler",
130]
131
132script_sources = [
133  "disassembler_annotations_test.cpp",
134  "disassembler_column_number_test.cpp",
135  "disassembler_get_file_name_test.cpp",
136  "disassembler_line_number_test.cpp",
137  "disassembler_string_test.cpp",
138]
139
140module_sources = [
141  "disassembler_annotations_test.cpp",
142  "disassembler_module_literal_test.cpp",
143]
144
145host_unittest_action("DisasmModuleTest") {
146  module_out_path = module_output_path
147  sources = module_sources
148  include_dirs = disasm_include_dirs
149  configs = disasm_test_configs
150  deps = disasm_test_deps
151  test_abc_dir = rebase_path(target_out_dir)
152  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
153
154  foreach(file, disasm_module_test_js_files) {
155    deps += [ ":gen_${file}_abc" ]
156  }
157}
158
159host_unittest_action("DisasmDebugTest") {
160  module_out_path = module_output_path
161  sources = script_sources
162  include_dirs = disasm_include_dirs
163  configs = disasm_test_configs
164  deps = disasm_test_deps
165  test_abc_dir = rebase_path(target_out_dir)
166  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
167
168  foreach(file, disasm_column_test_js_files) {
169    deps += [ ":gen_${file}_abc" ]
170  }
171}
172
173host_unittest_action("DisasmReleaseTest") {
174  module_out_path = module_output_path
175  sources = script_sources
176  include_dirs = disasm_include_dirs
177  configs = disasm_test_configs
178  deps = disasm_test_deps
179  test_abc_dir = rebase_path(target_out_dir)
180  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
181
182  foreach(file, disasm_line_release_test_ts_files) {
183    deps += [ ":gen_${file}_abc" ]
184  }
185}
186
187host_unittest_action("DisasmScriptTest") {
188  module_out_path = module_output_path
189  sources = script_sources
190  include_dirs = disasm_include_dirs
191  configs = disasm_test_configs
192  deps = disasm_test_deps
193  test_abc_dir = rebase_path(target_out_dir)
194  defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
195
196  foreach(file, disasm_test_js_files) {
197    deps += [ ":gen_${file}_abc" ]
198  }
199}
200
201host_unittest_action("DisasmImmTest") {
202  module_out_path = module_output_path
203  sources = [ "disassembler_imm_tests.cpp" ]
204  include_dirs = disasm_include_dirs
205  configs = disasm_test_configs
206  deps = disasm_test_deps
207}
208
209group("host_unittest") {
210  testonly = true
211  deps = [
212    ":DisasmDebugTestAction",
213    ":DisasmImmTestAction",
214    ":DisasmModuleTestAction",
215    ":DisasmReleaseTestAction",
216    ":DisasmScriptTestAction",
217  ]
218}
219